:root {
  --bg:       #fbfbfa;
  --ink:      #16161a;
  --ink-soft: #63636b;
  --line:     #e4e4e0;
  --accent:   #f0501e;

  /* The comic art is drawn for white. It sits on this surface in both themes
     so the panels never pick up a tint from the page behind them. */
  --art:      #ffffff;
  --raise:    0 1px 2px rgba(16, 16, 18, 0.04), 0 8px 24px rgba(16, 16, 18, 0.06);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;

  --step-0: 1.0625rem;
  --step-1: clamp(1.125rem, 1.02rem + 0.5vw, 1.375rem);
  --step-2: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem);
  --step-3: clamp(2.4rem, 1.4rem + 4.2vw, 4.5rem);

  /* page shell vs reading measure — the shell is wide, prose stays readable */
  --wrap:    1120px;
  --measure: 62ch;
  --feed:    40rem;   /* the comic column: wide enough to read a 4-panel strip */
  --pad:     clamp(1.25rem, 4vw, 3rem);
  --radius:  12px;
}

@media (prefers-color-scheme: dark) {
  :root { --bg:#101012; --ink:#f2f2f0; --ink-soft:#9a9aa2; --line:#2a2a2f;
          --raise: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.35); }
}
:root[data-theme="dark"]  { --bg:#101012; --ink:#f2f2f0; --ink-soft:#9a9aa2; --line:#2a2a2f;
                            --raise: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.35); }
:root[data-theme="light"] { --bg:#fbfbfa; --ink:#16161a; --ink-soft:#63636b; --line:#e4e4e0;
                            --raise: 0 1px 2px rgba(16,16,18,0.04), 0 8px 24px rgba(16,16,18,0.06); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-block: 1.75rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  margin-right: auto;
}
.brand img { width: 34px; height: 34px; }
.brand b { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; }

.nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
}
.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }

.toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.toggle:hover { color: var(--ink); border-color: var(--ink-soft); }
/* Auto / Light / Dark all differ in width; a fixed measure stops the header
   shifting as the label cycles. */
.toggle-label { display: inline-block; min-width: 3.1em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- type ---------- */
main { flex: 1; padding-block: clamp(2.5rem, 6vw, 5rem) clamp(3rem, 7vw, 6rem); }

h1 {
  font-size: var(--step-3);
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 800;
  margin: 0 0 1rem;
  max-width: 16ch;
}
.lede {
  font-size: var(--step-1);
  color: var(--ink-soft);
  margin: 0;
  max-width: 46ch;
}
.lede a { color: var(--accent); }

.label {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  margin: 0 0 0.6rem;
}

/* ---------- meta line ---------- */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8125rem;
}
.meta .sep { opacity: 0.5; }
.meta .num { font-variant-numeric: tabular-nums; }

/* ---------- home: the comic column ---------- */
.cards {
  list-style: none;
  margin: clamp(2.5rem, 6vw, 4rem) auto 0;
  padding: 0;
  max-width: var(--feed);
  display: grid;
  gap: clamp(2rem, 5vw, 3.5rem);
}

.card article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.card article:hover {
  border-color: var(--ink-soft);
  box-shadow: var(--raise);
  transform: translateY(-2px);
}
@media (prefers-reduced-motion: reduce) {
  .card article, .card article:hover { transition: none; transform: none; }
}

.card-link { display: block; color: inherit; text-decoration: none; }

/* The art always sits on white — it is drawn for white. */
.art {
  position: relative;
  background: var(--art);
  border-bottom: 1px solid var(--line);
}
.art img { width: 100%; }

.badge {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: rgba(16, 16, 18, 0.72);
  color: #fff;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
}

.card-body { padding: 1.1rem 1.25rem 1.25rem; }
.card-title {
  font-size: var(--step-1);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.4rem;
}
.card-link:hover .card-title { color: var(--accent); }
.card-caption { margin: 0 0 0.7rem; color: var(--ink-soft); }

/* ---------- load more ---------- */
.more-wrap { max-width: var(--feed); margin: clamp(2.5rem, 6vw, 3.5rem) auto 0; text-align: center; }
.load-more {
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
}
.load-more:hover:not(:disabled) { border-color: var(--ink-soft); }
.load-more:disabled { opacity: 0.5; cursor: default; }
.load-more .count { color: var(--ink-soft); font-weight: 400; }

/* ---------- one comic ---------- */
.comic .back { margin-bottom: 1.5rem; }

.viewer {
  position: relative;
  max-width: 48rem;
  margin-inline: auto;
}
.track {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--art);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.track.is-single .slide { width: 100%; }

/* A real scroll container: swipe and scrollbar drag work with no JS at all. */
.viewer.is-carousel .track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.viewer.is-carousel .track::-webkit-scrollbar { display: none; }
.viewer.is-carousel .slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
}
.slide img { width: 100%; }

.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--raise);
}
.arrow.prev { left: -0.75rem; }
.arrow.next { right: -0.75rem; }
.arrow:hover:not(:disabled) { border-color: var(--ink-soft); }
.arrow:disabled { opacity: 0.3; cursor: default; }

.viewer-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.9rem;
}
.dots { display: flex; gap: 0.4rem; }
.dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line);
  cursor: pointer;
}
.dot.is-current { background: var(--accent); }
.counter { margin: 0; color: var(--ink-soft); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }

.comic-head { max-width: var(--measure); margin: clamp(2rem, 5vw, 3rem) auto 0; }
.comic-head h1 { font-size: var(--step-2); max-width: none; margin-bottom: 0.6rem; }
.comic-head .meta { margin-bottom: 0.9rem; }

.prose { max-width: var(--measure); margin: 2rem auto 0; }
.prose h2 {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  margin: 2rem 0 0.6rem;
}
.prose p { margin: 0 0 1rem; }
.prose ol, .prose ul { margin: 0 0 1rem; padding-left: 1.4rem; }
.prose li { margin-bottom: 0.35rem; }
.prose li strong { font-weight: 600; }
.prose a { color: var(--accent); }

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  list-style: none;
  max-width: var(--measure);
  margin: 1.75rem auto 0;
  padding: 0;
}
.topics li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ---------- share ---------- */
.share {
  max-width: var(--measure);
  margin: clamp(2rem, 5vw, 3rem) auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.share-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: none;
  cursor: pointer;
}
.chip:hover { border-color: var(--ink-soft); }
.chip.is-done { color: var(--accent); border-color: var(--accent); }

/* ---------- pager ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding-block: 1.5rem;
}
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 0;
}
.pager-link:hover { border-color: var(--line); }
.pager-link.is-older { text-align: right; align-items: flex-end; }
.pager-link.is-empty { border: 0; }
.pager-dir { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }
.pager-title {
  font-weight: 600;
  letter-spacing: -0.01em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pager-link:hover .pager-title { color: var(--accent); }

/* ---------- links ---------- */
.back {
  display: inline-block;
  margin-bottom: 1.25rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
}
.back:hover { color: var(--accent); }

/* ---------- cast sheets — always on white, the art is drawn for white ---------- */
figure {
  margin: 0;
  background: var(--art);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
figcaption {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 0.8rem;
}
.sheets {
  display: grid;
  gap: 1.25rem;
  margin-top: 2rem;
}

.roster {
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem 2.5rem;
  /* Wide enough for "Ines Marchetti — the designer · finds them" to sit on one
     line; at 16rem the grid made four columns and broke every name in half. */
  grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
  font-size: 0.95rem;
}
.roster li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.swatch {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex: none;
  transform: translateY(-1px);
}
.roster .who { min-width: 0; }
.roster b { font-weight: 600; white-space: nowrap; }
.roster .role { color: var(--ink-soft); }

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--line);
  padding-block: 1.75rem 3rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  margin-right: auto;
}
.links a { color: var(--ink); text-decoration: none; font-weight: 600; }
.links a:hover { color: var(--accent); }
.fine { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.fine a { color: inherit; }
.fine a:hover { color: var(--accent); }
.fine .sep { opacity: 0.5; }

@media (max-width: 480px) {
  .nav { gap: 1rem; }
  .nav a { font-size: 0.85rem; }
  footer { flex-direction: column; align-items: flex-start; }
  .pager { grid-template-columns: 1fr; }
  .pager-link.is-empty { display: none; }
  .arrow.prev { left: 0.4rem; }
  .arrow.next { right: 0.4rem; }
}
