/* Number Nest — the Nest hub.
   Warm, cozy "home for your creatures" feel. Tuned for iPad landscape
   (~1194×834) but fluid. One reusable .bar component is used for every
   "bar that fills" — the egg/nest bar AND each game's daily portion. */

/* Make the native `hidden` attribute authoritative. The #fanfare overlay is
   toggled from JS via `.hidden = true/false`, but its own rule sets
   `display: grid` — and an author `display` declaration overrides the UA
   `[hidden] { display:none }` rule, so without this `hidden` is a no-op and the
   overlay renders over the whole hub and swallows every click. */
[hidden] { display: none !important; }

:root {
  --ink: #2c2417;
  --ink-soft: #6f6149;
  --cream: #fff8ec;
  --panel: #fffdf8;
  --line: #ece0c9;
  --moss: #7ea24b;
  --moss-deep: #5f7e34;
  --amber: #f2a93b;
  --amber-deep: #e0902a;
  --warmth: linear-gradient(90deg, #ffcf6b, #f59331);
  --portion: linear-gradient(90deg, #9fd07a, #6f9e3e);
  --shadow: 0 8px 24px rgba(90, 70, 30, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Fredoka', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #fef3d8 0%, #f7e8c9 45%, #ecdcb6 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 22px; }
.brand-mark { font-size: 26px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.free-play-link {
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 15px;
  opacity: 0.8;
}
.free-play-link:hover { opacity: 1; }

/* ── Layout ─────────────────────────────────────────────── */
.nest { max-width: 1120px; margin: 0 auto; padding: 8px 22px 64px; }
.block { margin-top: 30px; }
.block-title {
  font-size: 20px; font-weight: 700; margin: 0 0 14px;
  display: flex; align-items: baseline; gap: 10px;
}
.block-note { font-size: 14px; font-weight: 600; color: var(--ink-soft); }

/* ── Egg hero ───────────────────────────────────────────── */
.egg-hero {
  display: flex; align-items: center; gap: 28px;
  background: linear-gradient(135deg, #fffdf8, #fbf2dc);
  border: 1.5px solid var(--line); border-radius: 28px;
  padding: 26px 30px; margin-top: 10px; box-shadow: var(--shadow);
}
.egg-stage { position: relative; flex: 0 0 auto; width: 150px; height: 150px;
  display: grid; place-items: center; }
.egg-glow {
  position: absolute; inset: 8px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,193,92,0.55), rgba(255,193,92,0) 68%);
  filter: blur(4px); animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(0.92); opacity: 0.7; } 50% { transform: scale(1.06); opacity: 1; } }
.egg-art { position: relative; width: 120px; height: 120px; z-index: 1;
  background-size: contain; background-repeat: no-repeat; background-position: center;
  font-size: 86px; display: grid; place-items: center;
  animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
.egg-info { flex: 1; min-width: 0; }
.egg-title { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.egg-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 15px; }

/* ── The reusable bar ───────────────────────────────────── */
.bar {
  position: relative; height: 20px; border-radius: 999px;
  background: #efe3cb; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}
.bar > .bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  border-radius: 999px; transition: width 600ms cubic-bezier(.2,.8,.2,1);
}
.bar--warmth { height: 26px; }
.bar--warmth > .bar-fill { background: var(--warmth); }
.bar--portion > .bar-fill { background: var(--portion); }
.bar > .bar-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; color: var(--ink);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}
.bar.is-done > .bar-fill { background: linear-gradient(90deg, #8fd07a, #4e9e3e); }

/* ── Game tiles ─────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 16px; }
.tile {
  position: relative; text-align: left; cursor: pointer;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 20px;
  padding: 16px 16px 18px; box-shadow: var(--shadow);
  transition: transform 140ms ease, box-shadow 140ms ease; color: inherit;
  font-family: inherit;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(90,70,30,0.18); }
.tile:active { transform: translateY(-1px); }
.tile-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tile-emoji { font-size: 30px; }
.tile-name { font-weight: 700; font-size: 18px; }
.tile-blurb { font-size: 13px; color: var(--ink-soft); margin: -8px 0 12px; }
.tile.is-done { border-color: #bfe0a0; background: linear-gradient(180deg,#fbfff5,#f1f9e8); }
.tile-check { position: absolute; top: 12px; right: 14px; font-size: 18px; color: var(--moss-deep); opacity: 0; }
.tile.is-done .tile-check { opacity: 1; }
.tile.is-locked { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.4); }
.tile.is-locked:hover { transform: none; box-shadow: var(--shadow); }
.tile-lock { position: absolute; top: 10px; right: 12px; font-size: 20px; }
.treasure-badge {
  position: absolute; top: -10px; right: -8px;
  background: var(--warmth); color: #5a3a05; font-weight: 800; font-size: 12px;
  padding: 5px 11px; border-radius: 999px; box-shadow: 0 4px 12px rgba(240,170,60,0.5);
  transform: rotate(6deg); white-space: nowrap;
}

/* ── Menagerie ──────────────────────────────────────────── */
.menagerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
.creature {
  position: relative; background: var(--panel);
  border: 1.5px solid var(--line); border-radius: 18px; padding: 14px 8px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: var(--shadow); color: inherit;
}
.creature-art {
  width: 84px; height: 84px; background-size: contain; background-repeat: no-repeat;
  background-position: center bottom; font-size: 56px; display: grid; place-items: center;
  transition: transform 300ms ease, filter 300ms ease;
}
.creature-name { font-weight: 700; font-size: 14px; }
.creature-stage { font-size: 11px; color: var(--ink-soft); }
.menagerie-empty { color: var(--ink-soft); font-size: 15px; }

/* ── Fanfare ────────────────────────────────────────────── */
.fanfare {
  position: fixed; inset: 0; background: rgba(30,22,8,0.6);
  display: grid; place-items: center; z-index: 60; backdrop-filter: blur(3px);
}
.fanfare-card {
  background: var(--cream); border-radius: 28px; padding: 36px 44px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35); animation: pop 320ms cubic-bezier(.2,1.3,.4,1);
  max-width: 380px;
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.fanfare-banner { font-size: 15px; font-weight: 800; letter-spacing: 1px; color: var(--amber-deep); }
.fanfare-art { width: 160px; height: 160px; margin: 8px auto 6px; background-size: contain;
  background-repeat: no-repeat; background-position: center; font-size: 110px; display: grid; place-items: center;
  animation: bob 3s ease-in-out infinite; }
/* Sprite-sheet hatch: a square sheet --hatch-frames wide, stepped across with
   steps(N-1). Mirrors NEST's own hatch technique (nest.css). */
.fanfare-art.is-hatching {
  --hs: 160px;
  background: var(--hatch-bg) no-repeat 0 0;
  background-size: calc(var(--hs) * var(--hatch-frames, 6)) var(--hs);
  animation: nest-hatch-play var(--hatch-duration, 1.7s) steps(var(--hatch-steps, 5)) forwards;
}
.fanfare-art.is-settled { animation: pop 360ms cubic-bezier(.2,1.3,.4,1), bob 3s ease-in-out 360ms infinite; }
@keyframes nest-hatch-play {
  from { background-position-x: 0; }
  to   { background-position-x: calc(var(--hs) * var(--hatch-offset, -5)); }
}
.fanfare-rare .fanfare-art { filter: drop-shadow(0 0 18px rgba(255,210,90,0.85)); }
.fanfare-rave-burst { font-size: 22px; letter-spacing: 3px; }
@media (prefers-reduced-motion: reduce) {
  .fanfare-art, .fanfare-art.is-hatching, .fanfare-art.is-settled { animation: none; }
}

/* Confetti — bits fall from the top of the fanfare overlay. */
.fanfare-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.fanfare-confetti > i {
  position: absolute; top: -16px; width: 9px; height: 14px; border-radius: 2px;
  animation: nn-confetti linear forwards;
}
@keyframes nn-confetti {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0.9; }
}

/* Honor reduced-motion across the whole hub: kill the egg bob/glow, the
   fanfare-card pop, and confetti (also skipped in JS). */
@media (prefers-reduced-motion: reduce) {
  .egg-glow, .egg-art, .fanfare-card, .fanfare-confetti > i { animation: none !important; }
}
.fanfare-title { font-size: 30px; font-weight: 800; margin: 4px 0 2px; }
.fanfare-flavor { font-size: 15px; color: var(--ink-soft); margin: 0 0 22px; }
.fanfare-btn {
  background: var(--warmth); border: none; color: #5a3a05; font-weight: 800; font-size: 18px;
  padding: 12px 34px; border-radius: 999px; cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 16px rgba(240,170,60,0.45);
}
.fanfare-btn:active { transform: translateY(1px); }

@media (max-width: 640px) {
  .egg-hero { flex-direction: column; text-align: center; }
  .egg-info { width: 100%; }
}

/* ── Onboarding tutorial overlay (Pokémon-style) ── */
.nt-root {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 20px; padding: 0 0 4vh; cursor: pointer;
  background: radial-gradient(1100px 680px at 50% 32%, rgba(60,44,16,0.50), rgba(22,15,6,0.85));
  backdrop-filter: blur(3px);
  animation: nt-in 260ms ease;
}
.nt-root.nt-out { animation: nt-out 260ms ease forwards; }
@keyframes nt-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nt-out { to { opacity: 0; } }

.nt-stage { flex: 1; display: grid; place-items: center; width: 100%; min-height: 0; }
.nt-emoji { font-size: 120px; line-height: 1; filter: drop-shadow(0 12px 22px rgba(0,0,0,0.45)); }
.nt-baby { width: 210px; height: 210px; background-size: contain; background-repeat: no-repeat;
  background-position: center; filter: drop-shadow(0 12px 22px rgba(0,0,0,0.45)); }
.nt-bar { width: 260px; height: 18px; margin: 18px auto 0; border-radius: 999px;
  background: rgba(255,255,255,0.28); overflow: hidden; }
.nt-bar-fill { height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #f2c14e, #e8973a); }
.nt-moons { font-size: 42px; letter-spacing: 6px; margin-top: 14px; min-height: 50px; }
.nt-pop { animation: nt-pop 0.5s cubic-bezier(.2,1.3,.4,1); }
@keyframes nt-pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.nt-wiggle { animation: nt-wiggle 0.7s ease-in-out infinite; }
@keyframes nt-wiggle { 0%,100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }

.nt-box { display: flex; align-items: flex-end; gap: 14px; width: min(680px, 92vw); }
.nt-prof { font-size: 80px; flex: 0 0 auto; line-height: 1; filter: drop-shadow(0 6px 12px rgba(0,0,0,0.45)); }
.nt-bubble { flex: 1; background: var(--cream, #fff8ec); border-radius: 20px;
  padding: 14px 20px 12px; box-shadow: 0 16px 44px rgba(0,0,0,0.4); }
.nt-name { font-size: 13px; font-weight: 800; letter-spacing: 0.5px; color: var(--amber-deep, #b5781f); margin-bottom: 4px; }
.nt-text { font-size: 22px; font-weight: 600; color: var(--ink, #2c2417); line-height: 1.35; min-height: 2.6em; }
.nt-next { font-size: 13px; font-weight: 700; color: var(--ink-soft, #6f6149); text-align: right; margin-top: 6px;
  animation: nt-blink 1.2s ease-in-out infinite; }
@keyframes nt-blink { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .nt-bar-fill, .nt-wiggle, .nt-pop, .nt-next, .nt-root { animation: none !important; transition: none !important; }
}

/* "+N straw added to your nest" — pops on the egg-hero subtitle on return. */
.egg-sub--gain {
  color: var(--moss-deep, #5f7e34);
  font-weight: 700;
  animation: straw-pop 0.55s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes straw-pop { from { transform: scale(0.92); opacity: 0.3; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .egg-sub--gain { animation: none; } }
