/* Base layout tokens and chrome (FR-011, FR-012, FR-013, FR-033).
   Art direction takes its palette from the RPC over IT/Pro cover: ink navy,
   warm gold, cream "paper". The reduced-motion guard at the bottom of this file
   layers on top of everything above it. */

:root {
  /* <=2 typefaces across the whole site (FR-012). System stacks only — no
     network font fetch, so this costs nothing against the perf budget. */
  --font-heading: "Segoe UI Semibold", "Segoe UI", Inter, system-ui, sans-serif;
  --font-body: Georgia, "Iowan Old Style", "Times New Roman", serif;

  /* WCAG 2.1 AA contrast tokens: 4.5:1 normal text, 3:1 large text/non-text UI (FR-033). */
  --color-ink: #10203a;
  --color-bg: #f3efe6;
  --color-surface: #fdfbf6;
  --color-text: #16181d;
  --color-text-muted: #4a4f5a;
  --color-link: #0d4a86;
  --color-link-visited: #56338c;
  --color-focus: #b30000;
  --color-border: #6f6959;
  --color-rule: #ddd5c4;
  --color-accent: #e0a52b;
  --color-accent-deep: #8a5a00;

  --comic-max-width: 1300px;
  /* Cover art is deliberately narrower than a reading page so the title, status,
     and "Start Reading" CTA (FR-008) all land above the fold on a laptop. */
  --cover-max-width: 620px;
  --page-gutter: clamp(1rem, 4vw, 2.5rem);
  --radius: 6px;
  --shadow-card: 0 1px 2px rgba(16, 32, 58, 0.16), 0 6px 18px rgba(16, 32, 58, 0.1);
  --shadow-card-raised: 0 2px 4px rgba(16, 32, 58, 0.2), 0 14px 32px rgba(16, 32, 58, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg);
  /* Faint halftone dot field, echoing the comic's own shading. */
  background-image: radial-gradient(var(--color-rule) 1px, transparent 1px);
  background-size: 22px 22px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-ink);
  line-height: 1.15;
  letter-spacing: -0.015em;
}

a {
  color: var(--color-link);
}

a:visited {
  color: var(--color-link-visited);
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Site chrome ---------- */

.site-header {
  padding: 0.75rem var(--page-gutter);
  border-color: var(--color-border);
  background: var(--color-ink);
  border-bottom: 3px solid var(--color-accent);
}

/* FR-032/SC-009 target-size: 24x24px minimum touch target. */
.site-header__brand {
  display: inline-block;
  padding: 0.5rem 0;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-surface);
  text-decoration: none;
}

/* The capital "IT" is the wordplay — never uppercase the whole wordmark. */
.brand-mark__it {
  color: var(--color-accent);
}

.site-header__brand:visited {
  color: var(--color-surface);
}

.site-header__brand:hover {
  color: var(--color-accent);
}

.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--comic-max-width);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) var(--page-gutter);
}

.site-footer {
  padding: 1.5rem var(--page-gutter);
  border-color: var(--color-border);
  border-top: 1px solid var(--color-rule);
  background: var(--color-ink);
  color: #d6dae2;
  font-size: 0.9375rem;
}

.site-footer p {
  max-width: var(--comic-max-width);
  margin: 0 auto;
}

/* ---------- Comic art ---------- */

/* FR-011: comic image has a fixed max-width, centered, never stretched to fill the viewport.
   Descendant selectors (not a class on the shortcode's own <img>) so this applies regardless
   of what comicImage's generated <img> attributes look like — same pattern as the thumbnail
   selectors below. Fixes the image-size-responsive Lighthouse failure: the img's native
   width="1300" attribute was rendering unconstrained on narrow viewports with no CSS applied. */
.comic-page__figure img,
.comic-cover__figure img {
  display: block;
  width: 100%;
  max-width: var(--comic-max-width);
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.comic-page__figure,
.comic-cover__figure {
  margin: 0;
}

.comic-cover__figure img {
  max-width: var(--cover-max-width);
}

.comic-page__long-description {
  max-width: 68ch;
  margin: 1.5rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-rule);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* ---------- Reading navigation ---------- */

/* nav-cluster: first/previous/random/next/latest, identical order/labels/position on every comic page (FR-005). */
.nav-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  max-width: var(--comic-max-width);
  margin: 1.5rem auto;
}

/* FR-032/SC-009 target-size: 24x24px minimum touch target with adequate spacing. */
.nav-cluster__control {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-ink);
  border-radius: 999px;
  background: var(--color-surface);
  box-shadow: 0 1px 0 var(--color-ink);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  color: var(--color-ink);
  text-decoration: none;
}

.nav-cluster__control:visited {
  color: var(--color-ink);
}

.nav-cluster__control:hover {
  background: var(--color-accent);
  color: var(--color-ink);
}

.nav-cluster__control[aria-disabled="true"] {
  color: var(--color-text-muted);
  pointer-events: none;
  border-color: var(--color-rule);
  background: transparent;
  box-shadow: none;
}

/* Narrow viewports: reflow without overlap or clipping (FR-011). */
@media (max-width: 480px) {
  .nav-cluster {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-cluster__control {
    text-align: center;
  }
}

/* Ultra-wide viewports: stay aligned to the fixed-width column, never stretch full-width (FR-011). */
@media (min-width: 1600px) {
  .site-main,
  .nav-cluster {
    margin-left: auto;
    margin-right: auto;
  }
}

/* ---------- Hub landing ---------- */

/* Hub landing page (FR-009): comic cards in a responsive grid, cover thumbnail
   above title/tagline/status. */
.hub-landing__title {
  margin: 0 0 0.25rem;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  letter-spacing: -0.02em;
}

.hub-landing__tagline {
  margin: 0.6rem 0 0;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  color: var(--color-text-muted);
}

.hub-landing__title::after {
  content: "";
  display: block;
  width: 5rem;
  height: 5px;
  margin-top: 0.75rem;
  background: var(--color-accent);
  border-radius: 2px;
}

.hub-landing__title .brand-mark__it {
  color: var(--color-accent-deep);
}

.hub-landing__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
}

.comic-card {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.75rem 1rem;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.comic-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-raised);
}

.comic-card__link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.comic-card__link img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--color-rule);
}

.comic-card__title {
  margin: 0.85rem 0 0.35rem;
  font-size: 1.3rem;
}

.comic-card__link:hover .comic-card__title {
  color: var(--color-link);
}

.comic-card__tagline {
  margin: 0 0 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

.comic-card__status {
  margin: auto 0 0;
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ---------- Comic cover ---------- */

/* Comic cover page (FR-008): title/tagline/status plus a "Start Reading" CTA. */
.comic-cover {
  max-width: var(--comic-max-width);
  margin: 0 auto;
  text-align: center;
}

.comic-cover__title {
  margin: 0 0 0.35rem;
  font-size: clamp(2rem, 5vw, 3rem);
  text-transform: uppercase;
}

.comic-cover__tagline {
  margin: 0 0 0.5rem;
  color: var(--color-text-muted);
  font-size: 1.125rem;
}

.comic-cover__status {
  margin: 0 0 1.75rem;
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.comic-cover__cta,
.comic-cover__archive-link {
  display: inline-block;
  margin: 1.75rem 0.4rem 0;
  padding: 0.7rem 1.75rem;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-weight: 700;
  text-decoration: none;
}

.comic-cover__cta {
  border: 1px solid var(--color-ink);
  background: var(--color-accent);
  color: var(--color-ink);
  box-shadow: 0 2px 0 var(--color-ink);
}

.comic-cover__cta:visited {
  color: var(--color-ink);
}

.comic-cover__cta:hover {
  background: var(--color-ink);
  color: var(--color-surface);
}

.comic-cover__archive-link {
  border: 1px solid var(--color-ink);
  background: var(--color-surface);
  color: var(--color-ink);
}

.comic-cover__archive-link:visited {
  color: var(--color-ink);
}

.comic-cover__archive-link:hover {
  background: var(--color-ink);
  color: var(--color-surface);
}

.comic-cover__cta--disabled {
  color: var(--color-text-muted);
  pointer-events: none;
  background: transparent;
  border-color: var(--color-rule);
  box-shadow: none;
}

/* Zero-cover / zero-page placeholder (FR-009, Edge Cases): a static box, never a
   broken/missing image reference. */
.comic-card__placeholder,
.comic-cover__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background-color: var(--color-border);
  color: var(--color-bg);
  border-radius: calc(var(--radius) - 2px);
  font-family: var(--font-heading);
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--color-ink);
  color: var(--color-surface);
  text-transform: capitalize;
  font-weight: bold;
  letter-spacing: 0.03em;
}

.status-badge--ongoing {
  background: var(--color-accent-deep);
}

.status-badge--hiatus {
  background: var(--color-text-muted);
}

.hub-landing__empty {
  color: var(--color-text-muted);
}

/* ---------- Archive ---------- */

/* Comic archive/gallery (FR-010): thumbnails in ascending pageNumber order, scoped
   to one comic. Same responsive-grid pattern as .hub-landing__grid. */
.comic-archive {
  max-width: var(--comic-max-width);
  margin: 0 auto;
}

.comic-archive__title {
  margin: 0 0 1.5rem;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  text-transform: uppercase;
}

.comic-archive__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
}

.comic-archive__link {
  display: block;
  padding: 0.5rem;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.comic-archive__link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-raised);
}

.comic-archive__link img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 2px);
  /* Uniform tiles keep the gallery grid on a single baseline despite pages
     having different natural aspect ratios; top-anchored so the crop keeps
     each page's opening panel visible. */
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top center;
}

.comic-archive__page-number {
  display: block;
  margin-top: 0.5rem;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.comic-archive__empty {
  color: var(--color-text-muted);
}

/* FR-021: honor the reader's reduced-motion preference — disables/shortens any
   page-transition, parallax, or auto-reveal animation. Layered on top of the base
   layout rules above (T013); does not remove or replace any existing rule. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .comic-card:hover,
  .comic-archive__link:hover {
    transform: none;
  }
}
