* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --paper:     #ecca8a;
  --ink:       #2a2419;
  --ink-soft:  #5a4f3d;
  --stamp-ink: #8a2e1f;
}

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'IM Fell English', Georgia, serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* layout ----------------------------------------------------- */

.stage {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 120px;
}

.card {
  position: relative;
  z-index: 2;
  max-width: 560px;
  width: 100%;
  text-align: center;
}

/* decorative collage scraps in the page corners --------------- */

/* scraps use PRE-BAKED *_torn.png files — torn edges + burn outline + drop-shadow
   are already in the source pixels. no runtime filter needed; fast to paint. */
.scrap {
  position: absolute;
  pointer-events: none;
  z-index: 1;
}
.scrap-trees      { top: 30px;     left: -30px;  width: 240px; transform: rotate(-4deg); opacity: 0.92; }
.scrap-moon-paper { top: 60px;     right: -30px; width: 160px; transform: rotate(6deg);  opacity: 0.9;  }
.scrap-forest     { bottom: 100px; left: -40px;  width: 200px; transform: rotate(3deg);  opacity: 0.88; }
.scrap-sea        { bottom: 140px; right: -30px; width: 210px; transform: rotate(-5deg); opacity: 0.9;  }

/* title + tagline -------------------------------------------- */

.title {
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1;
  margin-bottom: 18px;
}

.tagline {
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-bottom: 48px;
}

/* layered cabin scene ---------------------------------------- */

.cabin-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 440px;
  margin-bottom: 36px;
}

/* torn-edge filter is applied to the COMPOSITED scene so each layer's interior
   stays clean while the outer rectangle reads as ripped paper */
.cabin-scene {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 800 / 968;
  z-index: 1;
  filter: url(#torn-edge-burn) drop-shadow(3px 8px 16px rgba(40,25,10,0.4));
  /* the smoke + moss children animate continuously; without this hint, the parent's
     filter would be recomposited every animation frame. will-change isolates it
     into a GPU layer that only re-renders when the filter inputs change. */
  will-change: filter;
}

.layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.layer-base  { z-index: 1; }
.layer-smoke { z-index: 2; transform-origin: 53% 30%;  animation: smoke-rise 9s ease-out infinite; }
.layer-moss  { z-index: 3; transform-origin: 50% 100%; animation: moss-sway 13s ease-in-out infinite; }

@keyframes smoke-rise {
  0%   { transform: translateY(0)     scale(1, 1)       skewX(0deg);  opacity: 0;    }
  18%  {                                                              opacity: 0.95; }
  55%  { transform: translateY(-12px) scale(1.12, 1.25) skewX(4deg);  opacity: 0.7;  }
  100% { transform: translateY(-26px) scale(1.32, 1.6)  skewX(9deg);  opacity: 0;    }
}

@keyframes moss-sway {
  0%, 100% { transform: translateX(0)   rotate(0deg);    }
  50%      { transform: translateX(1px) rotate(0.15deg); }
}

/* stamp + platform marks ------------------------------------- */

/* rubber-stamp look — faded red ink, double border, uneven contact via SVG roughness */
.stamp {
  display: inline-block;
  font-style: normal;
  font-size: 0.85rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--stamp-ink);
  border: 2.5px solid var(--stamp-ink);
  padding: 9px 22px 7px 26px; /* extra left padding balances letter-spacing */
  box-shadow: 0 0 0 1px rgba(138,46,31,0.15);
  transform: rotate(-4deg);
  opacity: 0.82;
  filter: url(#stamp-rough);
}

.platforms {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  color: var(--stamp-ink);
  opacity: 0.55;
}
.platforms svg { display: block; }

/* footer + sound toggle -------------------------------------- */

.footer {
  position: absolute;
  bottom: 28px;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 36px;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-soft);
  z-index: 10;
}

.footer-divider {
  display: block;
  opacity: 0.5;
}

.credit { letter-spacing: 0.02em; }

.heart {
  display: inline-block;
  color: #b04a3c;
  font-style: normal;
  margin: 0 2px;
  transform: translateY(1px);
  /* same stamp-rough filter as the main stamp + sound toggle —
     gives the heart a hand-pressed ink-on-paper feel */
  filter: url(#stamp-rough);
}

.dad {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
}
.dad:hover { color: var(--ink-soft); border-bottom-color: var(--ink-soft); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* sound toggle — small stamp pinned to the top-right corner of the viewport.
   slash crosses through when sound is OFF. */
.sound-toggle {
  position: fixed;
  top: 28px;
  right: 28px;
  transform: rotate(-4deg);
  background: transparent;
  border: 1.5px solid var(--stamp-ink);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--stamp-ink);
  font-family: inherit;
  filter: url(#stamp-rough);
  opacity: 0.55;
  z-index: 20;
  transition: opacity 0.2s, transform 0.2s;
}
.sound-toggle:hover { opacity: 0.95; }
.sound-toggle[aria-pressed="true"] {
  opacity: 0.9;
  transform: rotate(-1deg);
}
.sound-toggle[aria-pressed="false"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 14%;
  right: 14%;
  height: 1.6px;
  background: currentColor;
  transform: rotate(-32deg);
  transform-origin: center;
  pointer-events: none;
}

/* responsive ------------------------------------------------- */

@media (max-width: 760px) {
  .scrap { display: none; }
  .stage { padding: 60px 16px 140px; }
  .footer { gap: 14px; padding: 0 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .layer-smoke, .layer-moss { animation: none !important; }
  .layer-smoke { opacity: 0.7; }
}

/* during active window resize, drop the expensive SVG filter on .cabin-scene and
   pause the smoke/moss animations so the browser doesn't recomposite + re-filter
   on every frame. JS toggles `.is-resizing` on <body>.
   (scraps don't need this — their effects are baked into the PNGs.) */
body.is-resizing .cabin-scene    { filter: none !important; }
body.is-resizing .layer-smoke,
body.is-resizing .layer-moss     { animation: none !important; }

/* night theme — JS adds .is-night to <body> + .cabin-scene
   based on local clock (19:00–06:00) or ?night URL override.
   warm amber/candle palette on a near-black paper. */

body.is-night {
  background: #07070d;
  color: #d8b878;
}
body.is-night .title    { color: #f0d18a; }
body.is-night .tagline  { color: #d8b878; }
body.is-night .stamp    { color: #d8b878; border-color: #d8b878; opacity: 0.78; }
body.is-night .platforms { color: #c4a376; opacity: 0.6; }
body.is-night .footer   { color: #d8b878; }
body.is-night .heart    { color: #d04a3c; }
body.is-night .dad      { color: #c4a376; border-bottom-color: #c4a376; }
body.is-night .dad:hover { color: #f0d18a; border-bottom-color: #f0d18a; }
body.is-night .sound-toggle { color: #d8b878; border-color: #d8b878; }
/* dim the corner scraps so they don't glare against the dark page —
   cheap brightness filter only; the torn edges are already baked into the PNGs */
body.is-night .scrap { filter: brightness(0.55); }

.cabin-scene.is-night {
  filter: url(#torn-edge-soft) drop-shadow(3px 8px 22px rgba(0,0,15,0.55));
}
.cabin-scene.is-night .layer-moss { display: none; }
