/* ============================================================
   Webcomic site — paper, ink, and woodland warmth
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght,SOFT,WONK@9..144,300..900,0..100,0..1&family=Cormorant+Garamond:ital,wght@0,300..700;1,300..700&display=swap');

:root {
  /* Paper and ink palette — warm, slightly aged, a little sun-faded */
  --paper:        #f4ead8;
  --paper-deep:   #ebdfc6;
  --paper-shadow: #d9c9a8;
  --ink:          #2a241c;
  --ink-soft:     #4a3f30;
  --ink-faded:    #7a6c54;
  --accent:       #b8442b;   /* faded vermilion — old comic ink */
  --moss:         #5d6b3e;   /* signage green */

  /* Typography */
  --display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --body:    'Cormorant Garamond', Georgia, 'Times New Roman', serif;

  /* Layout */
  --strip-max-width: 1100px;
  --content-max:     720px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset & base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle paper texture using layered noise + warm vignette */
body {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at top, rgba(255,255,255,0.4) 0%, transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(217,201,168,0.5) 0%, transparent 50%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.14  0 0 0 0 0.11  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-attachment: fixed, fixed, fixed;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

a:hover {
  border-bottom-color: var(--accent);
}

/* ---------- Header / Masthead ---------- */

.masthead {
  max-width: var(--strip-max-width);
  margin: 0 auto;
  padding: 3rem 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--paper-shadow);
  position: relative;
}

.masthead::before,
.masthead::after {
  content: "";
  position: absolute;
  bottom: -1px;
  width: 40%;
  height: 1px;
  background: var(--ink);
}
.masthead::before { left: 30%; }
.masthead::after  { right: 30%; height: 3px; bottom: -4px; opacity: 0.4; }

.masthead h1 {
  font-family: var(--display);
  font-weight: 600;
  font-style: normal;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-variation-settings: "SOFT" 50, "WONK" 1, "opsz" 100;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
  color: var(--ink);
  line-height: 1.05;
}

.masthead .tagline {
  font-style: italic;
  color: var(--ink-faded);
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.02em;
}

.masthead nav {
  margin-top: 1.75rem;
  display: flex;
  gap: 2rem;
  justify-content: center;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.masthead nav a {
  color: var(--ink-soft);
  border: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.masthead nav a:hover,
.masthead nav a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

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

main {
  max-width: var(--strip-max-width);
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.strip-meta {
  text-align: center;
  margin-bottom: 0.5rem;
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faded);
}

.strip-meta .sep {
  display: inline-block;
  margin: 0 0.6rem;
  opacity: 0.5;
}

/* The strip itself — panels arranged like a printed comic.
   Desktop: horizontal row, recreating the strip layout.
   Mobile: stacked vertically, each panel fills width. */
.strip-frame {
  position: relative;
  margin: 1.5rem auto;
  max-width: 100%;
  background: #fffbf2;
  padding: 0.85rem;
  box-shadow:
    0 1px 0 var(--paper-shadow),
    0 2px 0 rgba(0,0,0,0.04),
    0 8px 24px -8px rgba(60, 40, 20, 0.18),
    0 20px 50px -20px rgba(60, 40, 20, 0.15);
  border: 1px solid var(--paper-shadow);
}

.panels {
  display: grid;
  grid-template-columns: repeat(var(--panel-count, 4), 1fr);
  gap: 0.4rem;
}

.panel {
  background: #fff;
  border: 1px solid rgba(42, 36, 28, 0.55);
  overflow: hidden;
  aspect-ratio: 3 / 4;
}

.panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* Stack vertically on phones — single column, panels keep their natural shape */
@media (max-width: 700px) {
  .panels {
    grid-template-columns: 1fr !important;
    gap: 0.5rem;
  }
  .panel {
    aspect-ratio: 3 / 4;
  }
}

.strip-caption {
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
  margin: 1.25rem auto 0;
  max-width: var(--content-max);
  font-size: 1.05rem;
}

/* ---------- Reader navigation ---------- */

.reader-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin: 2rem auto 0;
  max-width: var(--strip-max-width);
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.reader-nav button,
.reader-nav a {
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink-soft);
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border-bottom: 1px solid var(--ink-soft);
}

.reader-nav button:hover:not(:disabled),
.reader-nav a:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.reader-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.reader-nav .center-buttons {
  display: flex;
  gap: 0.5rem;
}

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

.archive-intro {
  max-width: var(--content-max);
  margin: 0 auto 2.5rem;
  text-align: center;
}

.archive-intro p {
  color: var(--ink-soft);
  font-size: 1.1rem;
  font-style: italic;
}

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

.archive-grid li {
  display: flex;
  flex-direction: column;
}

.archive-grid a {
  display: block;
  color: var(--ink);
  border: none;
}

.archive-grid .thumb {
  background: #fffbf2;
  border: 1px solid var(--paper-shadow);
  padding: 0.4rem;
  margin-bottom: 0.75rem;
  box-shadow:
    0 4px 12px -4px rgba(60, 40, 20, 0.15),
    0 1px 0 var(--paper-shadow);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  overflow: hidden;
}

.archive-grid .thumb-panels {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
  aspect-ratio: 4 / 1.3;
}

.archive-grid .thumb-panels .panel {
  flex: 1 1 0;
  min-width: 0;
  background: #fff;
  border: 1px solid rgba(42, 36, 28, 0.5);
  overflow: hidden;
}

.archive-grid .thumb-panels .panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.archive-grid a:hover .thumb {
  transform: translateY(-3px) rotate(-0.4deg);
  box-shadow:
    0 10px 24px -6px rgba(60, 40, 20, 0.22),
    0 1px 0 var(--paper-shadow);
}

.archive-grid .meta {
  padding: 0 0.25rem;
}

.archive-grid .num {
  font-family: var(--display);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faded);
}

.archive-grid .title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0.15rem 0 0.1rem;
  line-height: 1.2;
}

.archive-grid .date {
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
}

/* ---------- About page ---------- */

.prose {
  max-width: var(--content-max);
  margin: 0 auto;
  font-size: 1.1rem;
  line-height: 1.7;
}

.prose h2 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.6rem;
  margin: 2.5rem 0 0.75rem;
  color: var(--ink);
}

.prose p { margin: 0 0 1.1rem; }

.prose .drop-cap::first-letter {
  font-family: var(--display);
  float: left;
  font-size: 4.2rem;
  line-height: 0.85;
  padding: 0.45rem 0.6rem 0 0;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Footer ---------- */

footer {
  max-width: var(--strip-max-width);
  margin: 4rem auto 0;
  padding: 2rem;
  border-top: 1px solid var(--paper-shadow);
  text-align: center;
  color: var(--ink-faded);
  font-size: 0.9rem;
  font-style: italic;
}

footer a { color: var(--ink-soft); }

footer .colophon {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

/* ---------- Page transitions / load animation ---------- */

.fade-in {
  animation: fadeIn 0.5s var(--ease) both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive tuning ---------- */

@media (max-width: 640px) {
  body { font-size: 17px; }
  .masthead { padding: 2rem 1.25rem 1rem; }
  .masthead nav { gap: 1.25rem; flex-wrap: wrap; }
  main { padding: 1.5rem 1rem 2.5rem; }
  .strip-frame { padding: 0.5rem; }
  .strip-frame::before { inset: 0.3rem; }
  .reader-nav {
    flex-direction: column;
    gap: 0.75rem;
  }
  .reader-nav .center-buttons { order: -1; }
  .reader-nav button,
  .reader-nav a { width: 100%; text-align: center; }
}
