/* Secret Santa: Kraft & ribbon v2. Tokens + the shared pieces every slice reuses.
   Slices own their own slice.css for anything specific to their screen. */

:root {
  color-scheme: only light; /* no forced dark mode: see index.html */
  /* paper & ink */
  --paper: oklch(0.95 0.015 75);
  --ink: oklch(0.26 0.02 50);
  --soft: oklch(0.42 0.02 50);
  --line: oklch(0.85 0.02 70);
  /* kraft */
  --kraft: oklch(0.74 0.07 65);
  --kraft-dark: oklch(0.67 0.07 65);
  --kraft-deep: oklch(0.36 0.05 55);
  /* red / pine / gold */
  --red: oklch(0.48 0.17 27);
  --red-dark: oklch(0.36 0.15 27);
  --pine: oklch(0.36 0.08 155);
  --green: oklch(0.45 0.1 155);
  --gold: oklch(0.82 0.14 85);
  --tag: #fffaf0;

  --serif: "Young Serif", Georgia, serif;
  --hand: "Caveat", "Segoe Script", cursive;
  --body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --col: 390px; /* the phone column, centred on desktop */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.15; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 22px; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
.hand { font-family: var(--hand); font-weight: 600; }
.serif { font-family: var(--serif); }
.mono { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* ---- the screen column ---------------------------------------------- */

#screen {
  position: relative;
  width: 100%;
  max-width: var(--col);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 64px 20px 72px; /* clears the garland, and the corner pills */
}

/* The bow screen is the pine one: the whole page goes green, not just the column. */
body[data-screen="bow"] { background-color: var(--pine); color: #fff; }

/* ---- static speckle (the snow itself is weather.js) ---------------------------------------------------- */

.snow, body {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle, oklch(0.82 0.03 70 / 0.4) 1.6px, transparent 2.2px),
    radial-gradient(circle, oklch(0.82 0.03 70 / 0.28) 1.2px, transparent 1.8px);
  background-size: 44px 44px, 71px 71px;
  background-position: 0 0, 22px 31px;
}

body[data-screen="bow"],
.snow--pine {
  background-color: var(--pine);
  background-image:
    radial-gradient(circle, oklch(1 0 0 / 0.22) 1.6px, transparent 2.2px),
    radial-gradient(circle, oklch(1 0 0 / 0.12) 1.2px, transparent 1.8px);
  background-size: 44px 44px, 71px 71px;
  background-position: 0 0, 22px 31px;
}

/* ---- fairy-light garland --------------------------------------------- */
/* One tile of sagging wire with four bulbs, repeated across the top.
   Fixed so it stays put while a long screen scrolls under it. */

.garland {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  z-index: 5;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='130' height='60' viewBox='0 0 130 60'%3E%3Cpath d='M0 6 Q65 62 130 6' fill='none' stroke='rgb(60,45,35)' stroke-width='1.6'/%3E%3Cg%3E%3Crect x='14' y='17' width='4' height='4' rx='1' fill='rgb(60,45,35)'/%3E%3Cellipse cx='16' cy='25' rx='4.5' ry='6' fill='rgb(206,74,74)'/%3E%3Crect x='47' y='31' width='4' height='4' rx='1' fill='rgb(60,45,35)'/%3E%3Cellipse cx='49' cy='39' rx='4.5' ry='6' fill='rgb(235,184,60)'/%3E%3Crect x='79' y='31' width='4' height='4' rx='1' fill='rgb(60,45,35)'/%3E%3Cellipse cx='81' cy='39' rx='4.5' ry='6' fill='rgb(70,170,110)'/%3E%3Crect x='112' y='17' width='4' height='4' rx='1' fill='rgb(60,45,35)'/%3E%3Cellipse cx='114' cy='25' rx='4.5' ry='6' fill='rgb(235,184,60)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 130px 60px;
  background-repeat: repeat-x;
  background-position: -20px 0;
}
/* The twinkle: a brighter copy of the lights fades in and out on top. Only its opacity animates,
   which the compositor does without repainting; animating filter on the strip itself repainted
   the full-width garland every frame on every screen (game included). */
.garland::after {
  content: ""; position: absolute; inset: 0;
  background: inherit;
  filter: brightness(1.18) saturate(1.1);
  opacity: 0; will-change: opacity;
  animation: garland-twinkle 2.8s ease-in-out infinite;
}

/* Soft paper strip behind the fixed garland, home button and weather chip, so content
   scrolling up never collides with them. Above #screen (z 1), below the garland (5). */
body::before {
  content: "";
  position: fixed; top: 0; left: 0; right: 0; z-index: 4; pointer-events: none;
  height: calc(76px + env(safe-area-inset-top, 0px));
  background: linear-gradient(to bottom, var(--paper) 0, var(--paper) 55%, oklch(0.95 0.015 75 / 0) 100%);
}
/* The strip only fades in once the page scrolls (body.is-scrolled, set by lib/screens.js), so it
   never dims the tartan header (My Santa) or the top of a screen at scroll top. Pure JS toggle:
   works in browsers without scroll-driven animations. The tree game never shows it. */
body::before { opacity: 0; transition: opacity 0.18s ease; }
body.is-scrolled::before { opacity: 1; }
body[data-screen="tree"]::before, body[data-screen="bakery"]::before { display: none; }
body[data-screen="bow"]::before {
  background: linear-gradient(to bottom, var(--pine) 0, var(--pine) 55%, oklch(0.36 0.08 155 / 0) 100%);
}

@keyframes garland-twinkle {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* ---- tartan ----------------------------------------------------------- */

.tartan {
  background-color: var(--red);
  background-image:
    repeating-linear-gradient(90deg,
      transparent 0 20px, oklch(0.3 0.06 155 / 0.8) 20px 36px,
      transparent 36px 62px, oklch(0.18 0.02 40 / 0.85) 62px 68px,
      transparent 68px 90px, oklch(0.82 0.14 85 / 0.7) 90px 92px, transparent 92px 100px),
    repeating-linear-gradient(0deg,
      transparent 0 20px, oklch(0.3 0.06 155 / 0.8) 20px 36px,
      transparent 36px 62px, oklch(0.18 0.02 40 / 0.85) 62px 68px,
      transparent 68px 90px, oklch(0.82 0.14 85 / 0.7) 90px 92px, transparent 92px 100px);
}

/* ---- gift tag ---------------------------------------------------------- */
/* clip-path would also clip a shadow, so the shadow lives on .tag-wrap.
     <div class="tag-wrap"><div class="twine"></div><div class="tag">…</div><i class="tag-hole"></i></div> */

.tag-wrap {
  position: relative;
  filter: drop-shadow(0 8px 8px oklch(0.3 0.03 50 / 0.22));
  transform: rotate(-3deg);
}

.tag {
  background: var(--tag);
  clip-path: polygon(38px 0, 100% 0, 100% 100%, 38px 100%, 0 50%);
  padding: 22px 22px 22px 60px;
}

.tag-hole {
  position: absolute;
  left: 15px; top: 50%;
  width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 3px var(--kraft-dark), inset 0 1px 2px oklch(0.3 0.03 50 / 0.4);
}

.twine {
  position: absolute;
  left: 22px; top: 50%;
  width: 96px; height: 2px;
  background: oklch(0.55 0.07 55);
  transform-origin: 0 50%;
  transform: rotate(205deg);
}

/* ---- kraft box with ribbon ---------------------------------------------- */

.kraft-box {
  position: relative;
  width: 180px;
  height: 130px;
  margin: 0 auto;
  background: var(--kraft);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 10px 14px -10px oklch(0.3 0.03 50 / 0.5);
}

.kraft-box::before { /* the lid rim */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 14px;
  background: var(--kraft-deep);
}

.ribbon {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 26px;
  margin-left: -13px;
  background:
    repeating-linear-gradient(0deg, var(--red) 0 10px, oklch(0.3 0.05 40) 10px 14px);
  box-shadow: inset 3px 0 0 oklch(0.3 0.05 40), inset -3px 0 0 oklch(0.3 0.05 40);
}

/* ---- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--red-dark), 0 12px 14px -8px oklch(0.3 0.1 27 / 0.55);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  touch-action: manipulation;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--red-dark), 0 6px 10px -8px oklch(0.3 0.1 27 / 0.55);
}

.btn:disabled { opacity: 0.5; cursor: default; }
.btn--block { display: flex; width: 100%; }
.btn--light {
  background: var(--tag);
  color: var(--pine);
  box-shadow: 0 5px 0 oklch(0.8 0.03 75), 0 12px 14px -8px oklch(0.1 0.05 155 / 0.6);
}
.btn--light:active:not(:disabled) { box-shadow: 0 2px 0 oklch(0.8 0.03 75); }

/* ---- chips & labels ------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--tag);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.chip::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--pine);
}

.chip--waiting { color: var(--soft); }
.chip--waiting::before { background: oklch(0.8 0.01 70); }

.over { /* red overline label */
  display: block;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* text field in the same family as the buttons */
.field {
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--tag);
  color: var(--ink);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
}
.field::placeholder { color: var(--soft); opacity: 0.8; }

/* ---- stub screens (Foundation only) --------------------------------------- */

.stub { padding-top: 120px; text-align: center; font-family: var(--hand); font-size: 28px; color: var(--soft); }

/* ---- motion ----------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* the secret tree game's score on a chip */
.tree-n { font-size: 0.85em; font-weight: 600; color: var(--pine); white-space: nowrap; }
.bakery-n { font-size: 0.85em; font-weight: 600; color: oklch(0.45 0.1 55); white-space: nowrap; }
