/* Weirdlings — styles */

:root {
  --bg: #121016;
  --bg-2: #1b1821;
  --surface: #221e29;
  --line: #34303c;
  --text: #ece8f1;
  --muted: #a39cae;
  --accent: #e8c547;
  --accent-ink: #1a1500;
  --accent-text: var(--accent);
  --link: #f0d672;
  --stage: #0b0a0d;
  --radius: 14px;
  --bar-h: 56px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Source Serif 4', Georgia, serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f3ee;
    --bg-2: #efeae2;
    --surface: #ffffff;
    --line: #ddd5c8;
    --text: #1e1a22;
    --muted: #6b6371;
    --link: #8a5a00;
    --accent-text: color-mix(in srgb, var(--accent) 50%, #000);
    --stage: #1a171d;
    color-scheme: light;
  }
}

/* Per-comic accents are set inline; re-derive the text tone wherever one is set. */
[style*="--accent"] { --accent-text: var(--accent); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) [style*="--accent"] { --accent-text: color-mix(in srgb, var(--accent) 50%, #000); }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }
.loading, .noscript { padding: 30vh 16px; text-align: center; color: var(--muted); font-family: var(--ui); }
.muted { color: var(--muted); }
.center { text-align: center; padding-block: 12vh; }

/* ---------- site chrome ---------- */

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1200px; margin: 0 auto; padding: 18px 24px;
}
.brand {
  font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text); text-decoration: none;
}
.brand::first-letter { color: var(--accent-text); }
.site-header nav { display: flex; gap: 22px; font-family: var(--ui); font-size: .95rem; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--text); }

.page { max-width: 1200px; margin: 0 auto; padding: 8px 24px 64px; }

.site-footer {
  max-width: 1200px; margin: 0 auto; padding: 28px 24px 40px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px;
  color: var(--muted); font: .85rem/1.5 var(--ui);
}
.site-footer p { margin: 0; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer a { color: var(--muted); }

/* ---------- buttons ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: 600 .95rem/1 var(--ui); text-decoration: none; cursor: pointer; transition: transform .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }

/* ---------- covers ---------- */

.cover { width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 10px; background: var(--surface); }
.gen-cover {
  display: flex; align-items: flex-end; padding: 18px;
  background:
    radial-gradient(120% 80% at 80% 0%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 30%, #15121a), #0f0d12 75%);
  color: #fff; overflow: hidden;
}
.gen-cover span {
  font: 800 clamp(1.3rem, 2.6vw, 2rem)/1 var(--display); text-transform: uppercase; letter-spacing: .02em;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .5); overflow-wrap: anywhere;
}

/* ---------- home ---------- */

.hero {
  display: grid; grid-template-columns: minmax(200px, 340px) 1fr; gap: clamp(24px, 5vw, 56px); align-items: center;
  padding: clamp(20px, 4vw, 44px); margin: 8px 0 56px; border-radius: 24px;
  background:
    radial-gradient(80% 120% at 100% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--line);
}
.hero-cover, .tile-cover { text-decoration: none; }
.hero-cover .cover { box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6); transition: transform .25s; }
.hero-cover:hover .cover { transform: rotate(-1deg) scale(1.02); }
.hero h1 { font-size: clamp(2.6rem, 7vw, 5rem); margin: 0; }
.hero h1 a { color: var(--text); text-decoration: none; }
.kicker { font: 700 .78rem/1 var(--ui); letter-spacing: .16em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 12px; }
.tagline { font-size: 1.2rem; font-style: italic; color: var(--muted); margin: .4em 0 0; }
.credits { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 14px 0 0; font: .92rem/1.5 var(--ui); }
.credits em, .page-credits em { font-style: normal; color: var(--muted); margin-right: 4px; }
.schedule { margin: 16px 0 0; font: .88rem var(--ui); color: var(--muted); }

.latest {
  display: flex; align-items: center; gap: 14px; margin-top: 22px; padding: 10px; max-width: 440px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none;
  transition: border-color .15s;
}
.latest:hover { border-color: var(--accent); }
.latest img { width: 96px; height: 64px; object-fit: cover; object-position: top; border-radius: 8px; }
.latest span { display: flex; flex-direction: column; font-family: var(--ui); }
.latest small { color: var(--muted); font-size: .8rem; }

.library h2 { margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 32px 24px; }
.tile-cover { position: relative; display: block; border-radius: 10px; }
.tile-cover .cover { transition: transform .2s, box-shadow .2s; box-shadow: 0 10px 30px -14px rgba(0, 0, 0, .7); }
.tile-cover:hover .cover { transform: translateY(-4px); box-shadow: 0 22px 40px -16px rgba(0, 0, 0, .8); }
.badge {
  position: absolute; top: 10px; left: 10px; padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .7); color: #fff; font: 600 .72rem/1.4 var(--ui); letter-spacing: .04em;
}
.tile-body { padding-top: 12px; }
.tile-body h3 { margin: 0; }
.tile-body h3 a { color: var(--text); text-decoration: none; }
.artist { margin: 2px 0 0; color: var(--muted); font: .88rem/1.4 var(--ui); }
.tile-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; font: .85rem var(--ui); }
.tile-links .resume { color: var(--accent-text); font-weight: 600; }

/* ---------- comic landing / about / cast ---------- */

.comic-head { display: grid; grid-template-columns: minmax(180px, 300px) 1fr; gap: clamp(24px, 5vw, 48px); align-items: start; margin: 16px 0 40px; }
.facts { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 20px 0 0; font-family: var(--ui); }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }

.prose-wrap { max-width: 720px; margin: 0 0 40px; }
.prose-wrap.center { margin-inline: auto; }
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0 0 1em; }
.prose blockquote { border-left: 3px solid var(--accent); padding-left: 16px; color: var(--muted); font-style: italic; }
.prose code { font-size: .9em; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.prose > :last-child { margin-bottom: 0; }

.chapters { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 18px; }
.chapters a { display: flex; flex-direction: column; gap: 4px; color: var(--text); text-decoration: none; }
.chapters .cover { margin-bottom: 8px; transition: transform .2s; box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .7); }
.chapters .gen-cover { padding: 12px; }
.chapters .gen-cover span { font-size: .95rem; overflow-wrap: normal; hyphens: auto; }
.chapters a:hover .cover { transform: translateY(-3px); }
.chapters a > span { font: 700 1.05rem/1.2 var(--display); }
.chapters small { color: var(--muted); font: .78rem var(--ui); }

.about { margin: 24px 0; }
.author-photo { width: 160px; height: 160px; object-fit: cover; border-radius: 50%; margin-bottom: 24px; }

.cast-head { margin: 16px 0 36px; }
.crumbs { font: .88rem var(--ui); color: var(--muted); margin: 0 0 10px; }
.crumbs a { color: var(--muted); }
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); gap: 24px; }
.cast-card {
  display: grid; grid-template-columns: 150px 1fr; gap: 22px; padding: 20px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2);
}
.portrait { width: 150px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; background: var(--surface); }
.portrait.placeholder {
  display: grid; place-items: center; font: 800 2.4rem var(--display); color: var(--accent-text);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface));
}
.cast-body h2 { margin: 0; font-size: 1.5rem; }
.aka { margin: 0; color: var(--muted); font-style: italic; }
.role { margin: 6px 0 12px; font: 700 .75rem/1 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); }
.cast-body h3 { margin: 16px 0 6px; font-size: .8rem; font-family: var(--ui); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.rels { margin: 0; padding-left: 18px; }
.first { margin: 14px 0 0; font: 600 .9rem var(--ui); }

/* ---------- reader ---------- */

.reader { min-height: 100svh; background: var(--stage); color: #ece8f1; --link: #f0d672; }
.reader-bar {
  position: sticky; top: 0; z-index: 20; height: var(--bar-h);
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: rgba(14, 12, 17, .88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, .08); font-family: var(--ui);
}
.reader-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #fff; text-decoration: none; font: 700 1.05rem var(--display); letter-spacing: .02em;
}
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px; border-radius: 10px;
  border: 0; background: transparent; color: #d9d3e2; text-decoration: none; font: 500 .88rem var(--ui); cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.icon-btn[aria-disabled="true"] { opacity: .3; pointer-events: none; }
.page-select select {
  height: 38px; max-width: 42vw; padding: 0 30px 0 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .14); background: #1c1922; color: #fff; font-size: .88rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bbb' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px;
}

.stage { display: flex; flex-direction: column; align-items: center; padding: 16px 12px 48px; }
.frame { position: relative; line-height: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.frame img { height: auto; background: #1a171d; }
.frame.is-loading img { opacity: .35; }
.frame img { transition: opacity .15s; }

/* Full pages: fit the whole page on screen (default) or fill the width. */
.reader[data-layout="page"][data-fit="screen"] .frame img {
  width: auto; max-width: min(100%, 1100px); max-height: calc(100svh - var(--bar-h) - 32px);
}
.reader[data-layout="page"][data-fit="width"] .frame img { width: min(100vw - 24px, 1100px); }
/* Vertical strips: comfortable column width, scroll down to read. */
.reader[data-layout="strip"] .frame img { width: min(100vw - 24px, 800px); }

.zone {
  position: absolute; top: 0; bottom: 0; width: 50%; padding: 0; border: 0; background: transparent;
  cursor: pointer; color: #fff; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start;
}
.zone.prev { left: 0; cursor: w-resize; }
.zone.next { right: 0; cursor: e-resize; align-items: flex-end; }
.zone:disabled { cursor: default; }
.zone span {
  position: sticky; top: calc(50vh - 28px); display: inline-grid; place-items: center;
  width: 56px; height: 56px; margin: 0 14px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .2s;
}
.reader[data-layout="page"] .zone span { position: absolute; top: calc(50% - 28px); }
.zone.prev span { left: 0; }
.zone.next span { right: 0; }
.zone span svg { width: 28px; height: 28px; }
.zone:not(:disabled):hover span, .zone:not(:disabled):focus-visible span { opacity: .75; }
.zone:focus-visible { outline: none; }
.zone:disabled span { display: none; }
@media (hover: none) { .zone span { display: none; } }

.pager { display: flex; align-items: center; gap: 4px; margin-top: 16px; font-family: var(--ui); }
.pager .count { min-width: 9em; text-align: center; font-size: .88rem; color: #b8b0c4; padding: 0 8px; }
.page-credits { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 16px; margin: 6px 0 0; font: .82rem var(--ui); color: #d9d3e2; }
.page-credits em { color: #9a92a6; }

.caught-up {
  display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 24px; padding: 18px 24px;
  border: 1px dashed rgba(255, 255, 255, .2); border-radius: var(--radius); font: .92rem/1.5 var(--ui); text-align: center; color: #b8b0c4;
}
.caught-up strong { color: #fff; font: 700 1.1rem var(--display); }

.commentary {
  width: min(100%, 720px); margin-top: 28px; border-radius: var(--radius);
  background: #17151b; border: 1px solid rgba(255, 255, 255, .09); color: #e4dfea;
}
.commentary summary {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none;
  font: 700 .82rem/1 var(--ui); letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
}
.commentary summary::-webkit-details-marker { display: none; }
.commentary summary::after { content: '+'; margin-left: auto; font-size: 1.2rem; color: #9a92a6; }
.commentary[open] summary::after { content: '–'; }
.commentary-body { padding: 0 20px 20px; font-size: 1.02rem; }
.commentary-meta { margin: 0 0 10px; font: .85rem var(--ui); color: #9a92a6; }
.commentary-meta strong { color: #fff; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .site-header, .page, .site-footer { padding-inline: 16px; }
  .hero, .comic-head { grid-template-columns: 1fr; }
  .hero-cover, .comic-cover { max-width: 240px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; }
  .cast-card { grid-template-columns: 96px 1fr; gap: 16px; padding: 16px; }
  .portrait { width: 96px; }
  .reader-bar { gap: 2px; padding: 0 6px; }
  .reader-bar .icon-btn span { display: none; }
  .reader-title { font-size: .95rem; }
  .stage { padding-inline: 0; }
  .reader[data-layout="strip"] .frame img,
  .reader[data-layout="page"][data-fit="width"] .frame img { width: 100vw; }
  .reader[data-layout="page"][data-fit="screen"] .frame img { max-width: 100vw; }
  .commentary { border-radius: 0; border-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
