/* Snoopy — the neighbourhood. Flat colour, one ink line, hand lettering. */
:root {
  --ink: #111;
  --paper: #fbf6e9;
  --cream: #fff8e8;
  --paper-2: #f3ecd9;

  /* the sky and the yard — swapped by body.night */
  --sky: #a9d8ef;
  --sun: #ffd23f;
  --grass: #7fbf5e;
  --leaf: #5aa34b;
  --path: #e6e0cf;
  --road: #5d6169;
  --fence: #ffffff;
  --dog-red: #d7262c;
  --roof-red: #b71c22;
  --window: #cfe9f3;
  --stars: 0;
  --sunv: 1;
  --title: #111;

  --wood: #4a3524;
  --step: .36s;

  --font: 'Patrick Hand', 'Comic Sans MS', cursive;
  --font-caps: 'Patrick Hand SC', 'Patrick Hand', cursive;
}
body.night {
  --sky: #17223f;
  --grass: #3d6a41;
  --leaf: #2f5c36;
  --path: #9a968b;
  --road: #2b2e36;
  --fence: #d9d9d9;
  --dog-red: #a51d22;
  --roof-red: #7e151a;
  --window: #ffe08a;
  --stars: 1;
  --sunv: 0;
  --title: #fbf6e9;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-caps); font-weight: 400; letter-spacing: .02em; margin: 0; }
em { font-style: normal; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---------- hero: the neighbourhood ---------- */
.hero {
  position: relative;
  height: clamp(460px, 45vw, 86vh);
  overflow: hidden;
  background: var(--sky);
  transition: background .6s;
  border-bottom: 3px solid var(--ink);
}
.scene, .scene svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene svg { display: block; }

.title { position: absolute; left: clamp(16px, 3vw, 48px); top: clamp(12px, 2.2vw, 34px); pointer-events: none; }
.title h1 { font-size: clamp(46px, 6vw, 86px); line-height: .95; color: var(--title); transition: color .6s; }
.title p { margin: .25em 0 0 .15em; font-size: clamp(15px, 1.4vw, 21px); color: var(--title); opacity: .82; transition: color .6s; }

.hero-nav { position: absolute; right: clamp(12px, 2vw, 32px); top: clamp(12px, 2vw, 28px); display: flex; gap: 8px; align-items: center; }
.hero-nav a, .toggle, .hint, .close, .up {
  font-family: var(--font-caps);
  font-size: 18px;
  color: var(--ink);
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
}
.hero-nav a:hover, .toggle:hover, .close:hover, .up:hover { background: #fff; }
.x-link { display: inline-flex; align-items: center; gap: 7px; }
.x-link svg { width: 16px; height: 16px; flex: none; }
.foot .x-link { margin: 0 0 22px; }
.toggle { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; }
.toggle svg { width: 22px; height: 22px; }
.toggle .moon { display: none; }
body.night .toggle .moon { display: block; }
body.night .toggle .sun { display: none; }

.hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; font-size: 16px; padding: 2px 12px; opacity: .92; pointer-events: none; }
.hint.gone { display: none; }

/* scene pieces */
.sun { opacity: var(--sunv); transition: opacity .6s; }
.moon, .stars { opacity: var(--stars); transition: opacity .6s; }
.stars .tw { animation: twinkle 2.6s steps(1) infinite; }
.stars .tw:nth-child(3n) { animation-delay: -.9s; }
.stars .tw:nth-child(3n+1) { animation-delay: -1.7s; }
@keyframes twinkle { 0% { opacity: 1; } 50% { opacity: .35; } 100% { opacity: 1; } }

.cloud { animation: drift var(--dur, 140s) linear infinite; animation-delay: var(--delay, 0s); }
@keyframes drift { from { transform: translateX(-420px); } to { transform: translateX(1720px); } }

.kite { transform-box: fill-box; transform-origin: 50% 0; animation: sway 1.6s steps(1) infinite; }
@keyframes sway { 0% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } 100% { transform: rotate(-4deg); } }

/* two-frame cycles: .fa / .fb are swapped, never blended */
.fb { opacity: 0; }
.cycle .fa { animation: fa var(--step) steps(1) infinite; }
.cycle .fb { animation: fb var(--step) steps(1) infinite; }
@keyframes fa { 0% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes fb { 0% { opacity: 0; } 50%, 100% { opacity: 1; } }

.walker .bob { animation: bob var(--step) steps(1) infinite; }
@keyframes bob { 0% { transform: translateY(0); } 50%, 100% { transform: translateY(-6px); } }
.walker .dust { animation: dust .3s steps(1) infinite; }
@keyframes dust { 0% { transform: translate(0, 0); } 50%, 100% { transform: translate(4px, -3px); } }
.walker.paused .fa, .walker.paused .fb, .walker.paused .bob, .walker.paused .dust { animation-play-state: paused; }

#roof-snoopy { cursor: pointer; }
#roof-snoopy > g { display: none; }
#roof-snoopy > g.on { display: block; }
.zzz { animation: zzz 1.8s steps(3) infinite; }
@keyframes zzz { from { opacity: .2; } to { opacity: 1; } }

/* ---------- lore strip ---------- */
.lore { padding: clamp(40px, 6vw, 80px) clamp(16px, 4vw, 48px); background: var(--paper); }
.lore h2, .gallery h2 { font-size: clamp(30px, 3.4vw, 44px); text-align: center; }
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; max-width: 1240px; margin: 28px auto 0; }
.panel { background: var(--cream); border: 3px solid var(--ink); padding: 14px 14px 0; display: flex; flex-direction: column; gap: 26px; min-height: 400px; }
.bubble { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 26px; padding: 12px 16px; font-size: 18.5px; line-height: 1.3; }
.bubble::before, .bubble::after { content: ""; position: absolute; background: #fff; border: 3px solid var(--ink); border-radius: 50%; }
.bubble::before { width: 16px; height: 16px; left: 44px; bottom: -19px; }
.bubble::after { width: 9px; height: 9px; left: 34px; bottom: -33px; }
.panel .art { margin-top: auto; }
.panel .art svg { width: 100%; display: block; height: 210px; }
.byline { max-width: 900px; margin: 30px auto 0; text-align: center; font-size: 18px; opacity: .85; }

/* ---------- gallery: inside the doghouse ---------- */
.gallery {
  background: var(--wood);
  background-image: repeating-linear-gradient(90deg, transparent 0 150px, rgba(0, 0, 0, .16) 150px 154px);
  color: var(--paper);
  padding: clamp(40px, 6vw, 80px) clamp(16px, 4vw, 48px) clamp(56px, 7vw, 96px);
  border-top: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
}
.gallery .sub { text-align: center; margin: 6px 0 0; opacity: .8; }
.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 40px 28px; max-width: 1240px; margin: 48px auto 0; }
.frame {
  position: relative;
  border: 0; padding: 0; background: none;
  cursor: pointer; font: inherit; color: inherit; text-align: left;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .18s ease-out;
}
.frame:hover, .frame:focus-visible { transform: rotate(0deg) translateY(-4px) scale(1.02); outline: none; }
.frame::before { content: ""; position: absolute; left: 50%; top: -22px; width: 9px; height: 9px; background: #1a1a1a; border-radius: 50%; transform: translateX(-50%); }
.frame::after { content: ""; position: absolute; left: 18%; right: 18%; top: -18px; height: 26px; border: 2px solid #d8c9a3; border-bottom: 0; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.mat { display: block; background: var(--cream); border: 9px solid #2a1d13; outline: 3px solid #b28b52; padding: 10px; box-shadow: 0 12px 22px rgba(0, 0, 0, .45); }
.slot { display: grid; place-content: center; gap: 4px; text-align: center; aspect-ratio: 16 / 15; background: var(--paper-2); border: 3px dashed #b28b52; color: #6b5738; font-family: var(--font-caps); font-size: 16px; padding: 12px; }
.slot code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: #fff; padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.lb-art .slot { aspect-ratio: auto; min-height: 240px; }
.mat svg, .mat img { display: block; width: 100%; aspect-ratio: 16 / 15; object-fit: cover; background: var(--paper-2); }
.cap { display: block; margin: 12px 4px 0; font-family: var(--font-caps); font-size: 19px; line-height: 1.2; }

/* ---------- lightbox ---------- */
dialog { border: 3px solid var(--ink); border-radius: 10px; background: var(--cream); color: var(--ink); padding: 0; max-width: min(92vw, 820px); width: 100%; }
dialog::backdrop { background: rgba(10, 8, 6, .72); }
.lb-art svg, .lb-art img { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: var(--paper-2); }
.lb-cap { margin: 0; padding: 14px 18px; font-family: var(--font-caps); font-size: 24px; border-top: 3px solid var(--ink); }
.close { position: absolute; right: 10px; top: 10px; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 26px; }

/* ---------- footer ---------- */
.foot { padding: clamp(40px, 6vw, 72px) 24px; text-align: center; }
.quote { font-family: var(--font-caps); font-size: clamp(26px, 3vw, 36px); margin: 0; }
.small { font-size: 16px; opacity: .7; margin: 10px auto 22px; max-width: 640px; }
.up { display: inline-block; font-size: 16px; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  body { font-size: 18px; }
  .hero { height: clamp(440px, 120vw, 560px); }
  .hero-nav a { display: none; }
  .panel { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cloud, .kite, .stars .tw, .cycle .fa, .cycle .fb, .walker .bob, .walker .dust, .zzz { animation: none; }
  .fb { opacity: 0; }
  .frame { transition: none; }
}
