:root {
  --paper: #f3ead8;
  --paper-2: #ebdfc6;
  --card: #fbf6ea;
  --ink: #2b2420;
  --ink-soft: #5c5047;
  --line: #3a302a;
  --accent: #8a3b2a;
  --shadow: 4px 4px 0 var(--line);
  --hand: "Patrick Hand", "Comic Sans MS", system-ui, sans-serif;
  --marker: "Permanent Marker", "Patrick Hand", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1e1a17;
    --paper-2: #26211d;
    --card: #2b2521;
    --ink: #efe6d6;
    --ink-soft: #bfb2a0;
    --line: #0d0b0a;
    --accent: #e08a6d;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image: radial-gradient(var(--paper-2) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.2rem;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- header ---------- */
.site-header { text-align: center; padding: 2.5rem 16px 1rem; }
.brand { text-decoration: none; color: var(--ink); display: inline-block; }
.brand-name {
  font-family: var(--marker);
  font-size: clamp(2.2rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: 0.02em;
  display: inline-block;
  transform: rotate(-1.5deg);
}
.tagline {
  margin: 0.75rem 0 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  color: var(--ink-soft);
}
.tagline-q { display: block; color: var(--accent); font-family: var(--marker); letter-spacing: 0.06em; margin-top: 0.15rem; }
.site-nav { margin-top: 1rem; display: flex; gap: 1.25rem; justify-content: center; }
.site-nav a { color: var(--ink); text-decoration: none; border-bottom: 2px solid transparent; }
.site-nav a:hover { border-bottom-color: var(--accent); }

/* ---------- comic ---------- */
.comic { margin: 1rem auto 2rem; }
.comic-head { text-align: center; margin-bottom: 0.75rem; }
.comic-title { font-family: var(--marker); font-weight: 400; font-size: clamp(1.6rem, 4.5vw, 2.4rem); margin: 0; line-height: 1.15; }
.comic-date { color: var(--ink-soft); font-size: 1.1rem; }

.comic-figure {
  max-width: 820px;
  margin: 0 auto;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: clamp(6px, 1.5vw, 14px);
}
.comic-figure img { display: block; width: 100%; height: auto; border-radius: 2px; }

.comic-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.nav-btn {
  display: inline-block;
  font-family: var(--hand);
  font-size: 1.1rem;
  padding: 0.3rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 0.08s, box-shadow 0.08s;
}
a.nav-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
a.nav-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.nav-btn[aria-disabled="true"] { opacity: 0.35; box-shadow: none; }

/* ---------- share ---------- */
.share { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem; margin: 1.25rem 0; }
.share-label { font-size: 1.1rem; color: var(--ink-soft); margin-right: 0.25rem; }
.share-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 0.08s, box-shadow 0.08s, color 0.15s;
  padding: 0;
}
.share-btn:hover { transform: translate(-1px, -1px) rotate(-6deg); box-shadow: 3px 3px 0 var(--line); color: var(--accent); }
.share-btn.copied { color: var(--accent); }
.share-btn[hidden] { display: none; }

/* ---------- facts ---------- */
.comic-facts {
  max-width: 760px;
  margin: 1.5rem auto 0;
  padding: 1rem 1.25rem 1.1rem;
  background: var(--card);
  border: 2px dashed var(--ink-soft);
  border-radius: 6px;
}
.comic-facts h2 { font-family: var(--marker); font-weight: 400; font-size: 1.3rem; margin: 0 0 0.5rem; color: var(--accent); }
.comic-facts ul { list-style: none; margin: 0; padding: 0; }
.comic-facts li { padding: 0.6rem 0; border-top: 1px solid var(--paper-2); line-height: 1.4; }
.comic-facts li:first-child { border-top: 0; padding-top: 0.2rem; }
.fact-date {
  display: inline-block; font-size: 0.95rem; color: var(--ink); background: var(--paper-2);
  border-radius: 4px; padding: 0 0.4rem; margin-right: 0.35rem;
}
.fact-sources { display: block; font-size: 0.95rem; color: var(--ink-soft); margin-top: 0.15rem; }
.fact-sources::before { content: "Source: "; }
.fact-sources a { color: var(--accent); }
.facts-note { margin: 0.75rem 0 0; font-size: 1rem; color: var(--ink-soft); font-style: italic; }
.tags { text-align: center; color: var(--ink-soft); margin-top: 1rem; }
.tag { margin: 0 0.25rem; }

/* ---------- archive ---------- */
.archive h1, .notfound h1 { font-family: var(--marker); font-weight: 400; text-align: center; }
.archive h2 { font-family: var(--marker); font-weight: 400; border-bottom: 2px solid var(--line); }
.archive-grid {
  list-style: none; padding: 0; margin: 0 0 2rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem;
}
.archive-grid a {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--card); border: 2px solid var(--line); border-radius: 6px;
  box-shadow: 3px 3px 0 var(--line); padding: 8px;
  transition: transform 0.1s;
}
.archive-grid a:hover { transform: rotate(-1deg) translateY(-2px); }
.archive-grid img { width: 100%; height: auto; display: block; border-radius: 2px; }
.archive-title { display: block; font-size: 1.2rem; margin-top: 0.4rem; }
.archive-grid time { color: var(--ink-soft); font-size: 1rem; }

.notfound { text-align: center; padding: 3rem 0; }
.notfound h1 { font-size: 5rem; margin: 0; }
.empty { text-align: center; padding: 4rem 0; }

/* ---------- footer ---------- */
.site-footer { text-align: center; color: var(--ink-soft); font-size: 1rem; padding: 2rem 16px; }

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