:root {
  color-scheme: light dark;
  --bg: light-dark(#ebe7de, #161616);
  --ink: light-dark(#161616, #ebe7de);
  --white: light-dark(#fff, #111);
  --primary: #93C572; /* green #93C572, blue #7293C5, red-purple #C57293 */
  --highlighter: #D4E157;
  --nav-bg: #161616;
  --nav-ink: #ebe7de;
  --nav-border: #fff;

  --mono: monospace;
  --serif: Georgia, serif;
  --sans: ui-sans; }

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; }

body { 
  background: var(--bg); 
  color: var(--ink); 
  font: 1rem/1.5 var(--mono); 
  padding-bottom: 5rem; }

a { 
  text-decoration: none; 
  color: inherit; }

h1 { 
  text-transform: uppercase; 
  margin-bottom: 1rem; 
  border-bottom: 4px solid var(--primary); 
  padding-bottom: .5rem; 
  display: inline-block; }

h3 { 
  text-transform: uppercase; 
  margin-bottom: 1rem; 
  margin-top: 1rem; 
  border-bottom: 4px solid var(--primary); 
  padding-bottom: .5rem; 
  display: inline-block; }

p { margin-bottom: 1.25rem; }

p a, li a {
  text-decoration: underline; 
  text-decoration-color: var(--primary);
  text-decoration-thickness: 0.2rem; }

  p a:hover, li a:hover {
  text-decoration-color: var(--primary);
  text-decoration-thickness: 0.3rem; }

ul, ol {
  padding-inline-start: 1.25rem;
  margin-bottom: 1.25rem; }

li {   margin-bottom: 0.25rem; }

img {
  display: block;
  max-width: 90%;
  height: auto;
  margin-left: auto;
  margin-right: auto; }

hr {
  border: 0;
  height: 4px;
  width: 50%;
  background: var(--primary);
  margin: 2.5rem auto; }

::selection {
  background: var(--primary);
  color: var(--ink); }

/* Naav */

nav { 
  background: var(--nav-bg);
  color: var(--nav-ink); 
  padding: 1rem 1.5rem; 
  display: flex; 
  justify-content: space-between; 
  flex-wrap: wrap; 
  gap: 1rem; 
  margin-bottom: 3rem; 
  border-bottom: 4px solid var(--nav-border); }

nav div { 
  display: flex; 
  gap: 1.5rem; 
  align-items: center; }

nav a { 
  font-size: 1.25rem; 
  font-weight: bold; 
  text-transform: uppercase; 
  border-bottom: 4px solid transparent;
  transition: border-color 0.2s ease;}

nav a:hover { 
  border-bottom: 4px solid var(--primary); }

/* Main page */

.wrap, .reader { 
  margin-inline: auto; 
  padding-inline: 1.5rem; }

.wrap { max-width: 800px; }

.reader { max-width: 65ch; }

/* The lists and cards */

.list { 
  display: grid; 
  gap: 1.5rem; 
  margin-top: 2rem; 
  margin-bottom: 2rem; }

.list h2 { 
  font-size: 1.25rem; 
  text-transform: uppercase; }

.card { 
  background: var(--white); 
  border: 3px solid; 
  box-shadow: 5px 5px 0 var(--primary); 
  padding: 1.25rem; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  flex-wrap: wrap; 
  gap: 1rem; }

.card:hover { box-shadow: 8px 8px 0 var(--primary); }

.tags { 
  display: flex; 
  gap: .5rem; 
  flex-wrap: wrap; 
  font-size: .85rem; 
  /*text-transform: uppercase; */
  margin-left: auto;
  justify-content: flex-end; }

.tags:not(.list .tags) { margin-bottom: 1rem; }

.tag {
  padding: .2rem .5rem; 
  border: 2px solid; 
  background: var(--bg); 
  color: var(--ink); }

/* Story pages */

.reader h1 { 
  font-family: var(--serif);
  font-size: 2.2rem; 
  text-transform: none;
  margin: .5rem 0 1rem; }

.story { 
  font: 1.2rem/1.8 var(--serif); 
  margin-top: 3rem; 
  text-wrap: pretty; 
  hyphens: auto; }

.note {
  display: block;
  background: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--primary);
  padding: 1.25rem;
  margin: 2rem 0; }

.story p { margin-bottom: 1.5rem; }

/* Reader colours */

body:has(.reader a[href*="x-"]) {
  --primary: #9E2A2B; }

body:has(.reader a[href*="x-"]) .card:hover {
  box-shadow: 8px 8px 0 var(--highlighter); }

body:has(.reader a[href*="x-"]) ::selection {
  background: var(--highlighter);
  color: var(--ink); }

body:has(.reader a[href*="auto-"]) {
  --primary: #7293C5; }

/* X-page */

body.x-page {
  color-scheme: light dark;
  --bg: light-dark(#D8C8B0, #161616);
  --ink: light-dark(#1A1A18, #ebe7de);
  --white: light-dark(#fff, #111);
  --primary: #9E2A2B; 
  --highlighter: #D4E157;
  --manila: light-dark(#b8a07c, #3b2d1f);
  --brown: light-dark(#3b2d1f, #b8a07c);
  background: var(--bg); 
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.15"/></svg>');
cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='72' height='72'><defs><radialGradient id='glow' cx='50%' cy='50%' r='50%'><stop offset='0%' stop-color='rgba(255,255,200,0.95)'/><stop offset='35%' stop-color='rgba(255,210,40,0.65)'/><stop offset='70%' stop-color='rgba(240,160,20,0.2)'/><stop offset='100%' stop-color='transparent'/></radialGradient></defs><circle cx='22' cy='50' r='24' fill='url(%23glow)'/><text x='28' y='42' font-size='26'>🔦</text></svg>") 22 46, auto;
}

body.x-page h1 { 
  color: var(--primary);
  text-transform: uppercase; 
  margin: 1rem; 
  border: 4px solid var(--primary); 
  border-radius: 4px;
  padding: .4rem .8rem .4rem .8rem ;
  transform: rotate(-2deg);
  display: inline-block; }

body.x-page ::selection {
  background: var(--highlighter);
  color: var(--ink); }

body.x-page .card:hover { box-shadow: 8px 8px 0 var(--highlighter); }

body.x-page .tags { 
  border-bottom: 4px solid var(--manila); }

body.x-page .tag {
  padding: .2rem .5rem; 
  border: 2px solid var(--manila); 
  background: var(--bg); 
  color: var(--brown); 
  border-radius: 5px 5px 0 0; 
  margin-bottom: -2px; }

.card.with-tab { /*class="card with-tab" data-tab="CHAPTERS"*/
  margin-top: 40px; 
  overflow: visible; 
  display: block;
  position: relative; }

.card.with-tab::before {
  content: attr(data-tab);
  position: absolute;
  bottom: 100%;
  left: 16px;  
  color: var(--brown);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  padding: 6px 14px;  
  border: 2px solid var(--manila);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  margin-bottom: 3px;
  z-index: 1; }

.redacted { 
  background: var(--ink); 
  color: var(--ink); 
  user-select: none; 
  padding: 0 .2rem; }

.redacted:has(:checked) { 
  background: transparent; 
  color: inherit; 
  user-select: text; }

/* Auto page */

body.auto-page {
  color-scheme: light dark;
  --ink: light-dark(#1A1A18, #ebe7de);
  --white: light-dark(#fff, #111);
  --primary: #7293C5; /* the blue */
  background-image: url('auto/paint-bg.jpg');
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  background-attachment: fixed; 
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='36' height='36'><text y='28' font-size='26'>🖌️</text></svg>") 4 28, auto;
}

body.auto-page .wrap {
  font-family: var(--serif);
  padding: 2.5rem 2rem;
  border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 var(--primary); 
  background: rgb(from var(--bg) r g b / 0.9); }

body.auto-page .wrap .prev-next, .to-top {
  font-family: var(--mono); }

/* Footer bits */

.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 4rem;
  border-top: 3px solid;
  padding-top: 2rem; }

.prev-next .prev {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem; }

.prev-next .next {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right; }

@media (max-width: 550px) {
  .prev-next {
    grid-template-columns: 1fr; }
    .prev-next .next {
    grid-column: 1; }
}

.prev-next small { 
  font-size: .75rem;
  font-weight: bold; 
  opacity: 0.7; }

.prev-next h3 { 
  font-size: .85rem; 
  text-transform: uppercase;
  margin-bottom: 0.1rem; 
  margin-top: 0.1rem; 
  border-bottom: 0; }

.to-top { 
  text-align: right; 
  margin-top: 2rem; 
  font-weight: bold; 
  font-size: .85rem; }

:is(.crumbs, .to-top) a:hover { 
  text-decoration: underline;
  text-decoration-color: var(--primary);
  text-decoration-thickness: 0.2rem; }

/* Printing */

@media print {
  nav, .prev-next, .to-top, .crumbs { display: none; }

  body { 
    background: #fff; 
    color: #000; 
    padding: 0; }

  .reader { 
    max-width: 100%; 
    margin: 0; 
    padding: 0; }

  .redacted { 
    background: transparent; 
    color: #000; 
    text-decoration: underline; }

  .tag { 
    border: 1px solid #000; 
    background: transparent; 
    color: #000; }

  .note {
    box-shadow: none;
    border: 1px solid #000;
    border-left: 5px solid #000; }
}