/* SPORE — clean-room styles. Storybook flat illustration, hand-built. */
:root {
  --sky1: #6fc3e8;
  --sky2: #f6ead2;
  --sun: #ffd94d;
  --ink: #2b1d16;
  --soil: #3a2a20;
  --soil-deep: #221610;
  --leaf: #7bc043;
  --leaf-dark: #4e9a2f;
  --trunk: #8b5e34;
  --cream: #f8efdd;
  --paper: #fffdf6;
  --dim: #8a7a68;
  --stroke: #2b1d16;
  --radius: 22px;
  --font-d: "Fredoka", "Trebuchet MS", sans-serif;
  --font-h: "Caveat", cursive;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-d);
  color: var(--ink);
  background: var(--sky2);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: min(1120px, 92%); margin: 0 auto; }
img { max-width: 100%; display: block; }
a { color: inherit; }

/* ---------- nav ---------- */
.nav {
  position: absolute; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 16px min(4vw, 32px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--stroke); object-fit: cover; background: var(--soil); }
.brand b { font-size: 24px; letter-spacing: 0.06em; }
.nav .sp { flex: 1; }
.pillbtn {
  font-family: var(--font-d); font-weight: 700; font-size: 14px;
  background: var(--paper); color: var(--ink); border: 3px solid var(--stroke);
  border-radius: 999px; padding: 8px 18px; cursor: pointer; text-decoration: none;
  box-shadow: 3px 3px 0 var(--stroke);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.pillbtn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--stroke); }
.pillbtn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--stroke); }

/* ---------- hero sky ---------- */
.hero {
  position: relative; min-height: 100svh; overflow: hidden;
  background: linear-gradient(180deg, var(--sky1) 0%, #a8d8ee 42%, var(--sky2) 78%, #f3e3c2 100%);
  display: flex; flex-direction: column;
}
.sun {
  position: absolute; top: 9%; right: 12%; width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle, #ffe98a 0%, var(--sun) 55%, rgba(255,217,77,0) 72%);
  filter: drop-shadow(0 0 34px rgba(255, 217, 77, 0.85));
  animation: sunpulse 6s ease-in-out infinite;
  z-index: 1;
}
@keyframes sunpulse { 50% { transform: scale(1.06); } }
.cloud { position: absolute; z-index: 1; opacity: 0.95; animation: drift linear infinite; }
.cloud svg { display: block; width: 100%; height: auto; }
@keyframes drift { from { transform: translateX(-30vw); } to { transform: translateX(115vw); } }
.hero-copy { position: relative; z-index: 5; text-align: center; padding: 110px 5% 0; }
.hero-copy > * { animation: rise 0.8s ease both; }
.hero-copy > *:nth-child(2) { animation-delay: 0.12s; }
.hero-copy > *:nth-child(3) { animation-delay: 0.24s; }
.hero-copy > *:nth-child(4) { animation-delay: 0.36s; }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }

/* scroll reveals (class .rv added by JS) */
.rv { opacity: 0; transform: translateY(28px); transition: opacity 0.7s ease, transform 0.7s ease; }
.rv.in { opacity: 1; transform: none; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--paper); border: 3px solid var(--stroke); border-radius: 999px;
  padding: 7px 16px; font-size: 13px; font-weight: 700; letter-spacing: 0.14em;
  box-shadow: 3px 3px 0 var(--stroke); margin-bottom: 18px;
}
.eyebrow .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--leaf); border: 2px solid var(--stroke); }
h1 {
  font-size: clamp(44px, 8vw, 96px); font-weight: 700; line-height: 1.02;
  letter-spacing: 0.01em; text-wrap: balance;
}
h1 .green { color: var(--leaf-dark); }
.lede {
  max-width: 56ch; margin: 16px auto 0; font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 500; color: #4a3a2c;
}
.hint { font-family: var(--font-h); font-size: 22px; color: #5a4a38; margin-top: 14px; }

/* ---------- tree stage (ORI-style: trunk + branches draw on, buds at tips) ---------- */
.stage { position: relative; z-index: 4; width: min(700px, 96vw); margin: -10px auto 0; }
.stage svg { width: 100%; height: auto; display: block; overflow: visible; }
.hill { fill: #69a84f; stroke: var(--ink); stroke-width: 6; }
.trunk { fill: var(--trunk); stroke: var(--ink); stroke-width: 5; transform-box: fill-box; transform-origin: 50% 100%; animation: growUp 1.3s cubic-bezier(.3, 1.2, .5, 1) both; }
.trunk-shade { fill: #5e3d22; transform-box: fill-box; transform-origin: 50% 100%; animation: growUp 1.3s cubic-bezier(.3, 1.2, .5, 1) both; }
@keyframes growUp { from { transform: scaleY(0); } }
.branch, .ext { fill: none; stroke: var(--trunk); stroke-linecap: round; stroke-dasharray: 1 2; stroke-dashoffset: 1.01; }
.ext { stroke-dashoffset: 1.01; }
.branch { animation: draw 0.9s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.deco { transform-box: fill-box; transform-origin: 0% 50%; animation: pop 0.5s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes pop { from { transform: scale(0); } }
.bud { cursor: pointer; outline: none; }
.bud-shape { transform-box: fill-box; transform-origin: 50% 100%; animation: pop 0.6s cubic-bezier(.3, 1.8, .5, 1) both, pulse 2.2s ease-in-out infinite; stroke: var(--ink); stroke-width: 3; }
.bud:hover .bud-shape, .bud:focus-visible .bud-shape { filter: brightness(1.08); }
.bud:hover .bud-ring, .bud:focus-visible .bud-ring { opacity: 1; }
.bud-ring { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-dasharray: 5 6; opacity: 0; transition: opacity 0.25s; }
@keyframes pulse { 50% { transform: scale(1.1) rotate(4deg); } }
.bud-label { font-family: var(--font-h); font-weight: 700; font-size: 30px; fill: var(--ink); opacity: 0; animation: fadeIn 0.6s ease forwards; pointer-events: none; }
@keyframes fadeIn { to { opacity: 1; } }
.bud.open .bud-shape { opacity: 0; transform: scale(0); transition: opacity 0.25s, transform 0.25s; animation: none; }
@media (prefers-reduced-motion: reduce) {
  .trunk, .trunk-shade, .branch, .deco, .bud-shape, .bud-label { animation: none !important; }
  .branch { stroke-dashoffset: 0; }
  .bud-label { opacity: 1; }
}

/* spores + leaves particles */
.fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; }
.mote {
  position: absolute; top: -30px; border-radius: 50%;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(112vh) translateX(6vw) rotate(340deg); }
}

/* ---------- leaf panel (dialog) ---------- */
.leafwrap {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(34, 22, 16, 0.45); backdrop-filter: blur(3px);
}
.leafwrap.open { display: flex; }
.leaf {
  position: relative; width: min(460px, 94vw); max-height: 86svh; overflow: auto;
  background: var(--paper); border: 4px solid var(--stroke);
  border-radius: 72px 16px 72px 16px;
  padding: 56px 76px 52px 64px;
  box-shadow: 8px 8px 0 rgba(43,29,22,0.35);
  animation: leafpop 0.28s ease;
}
@keyframes leafpop { from { transform: scale(0.85) rotate(-2deg); opacity: 0; } }
.leaf::before {
  content: ""; position: absolute; left: 50%; top: 14px; bottom: 14px; width: 3px;
  background: rgba(78,154,47,0.25); border-radius: 3px; transform: translateX(-50%) rotate(8deg);
  pointer-events: none; z-index: 0;
}
.leaf-body { position: relative; z-index: 1; }
.leaf h3 { font-size: 30px; margin-bottom: 4px; padding-right: 40px; }
.leaf .kicker { font-family: var(--font-h); font-size: 21px; color: var(--leaf-dark); margin-bottom: 12px; }
.leaf p, .leaf li { font-size: 15.5px; line-height: 1.65; font-weight: 500; color: #4a3a2c; }
.leaf ul { margin: 10px 0 0 20px; display: grid; gap: 8px; }
.leaf .cta-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.stamp {
  display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: 0.1em;
  color: #b3372f; border: 3px solid #b3372f; border-radius: 8px;
  padding: 4px 10px; transform: rotate(-4deg); margin-bottom: 12px;
  text-transform: uppercase;
}
.leaf .x {
  position: absolute; top: 14px; right: 18px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--stroke); background: var(--paper);
  font-size: 19px; font-weight: 800; cursor: pointer; line-height: 1;
}
.leaf .x:hover { background: var(--sun); }

/* ---------- footer soil ---------- */
.soil {
  position: relative; background: linear-gradient(180deg, var(--soil) 0%, var(--soil-deep) 100%);
  color: var(--cream); overflow: hidden; margin-top: -2px;
}
.soil .roots { position: absolute; top: -4px; left: 0; right: 0; height: 120px; opacity: 0.5; }
.soil-inner { position: relative; z-index: 2; text-align: center; padding: 110px 5% 34px; }
.soil-inner h2 { font-size: clamp(38px, 6vw, 72px); color: var(--cream); }
.soil-inner h2 .green { color: var(--leaf); }
.soil-inner p { max-width: 52ch; margin: 14px auto 26px; color: #d8c6ab; font-size: 16.5px; font-weight: 500; }
.linkpills { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 30px; }
.linkpills .pillbtn { background: var(--cream); }
.linkpills .pillbtn.soon { opacity: 0.55; cursor: default; }
.linkpills .pillbtn.soon:hover { transform: none; box-shadow: 3px 3px 0 var(--stroke); }
.disclaimer { font-size: 13px; color: #a68e6f; max-width: 62ch; margin: 0 auto; }
.footbase {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px 5% 26px; font-size: 13.5px; color: #a68e6f; flex-wrap: wrap;
}
.footbase img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #a68e6f; object-fit: cover; }

/* ---------- inner pages ---------- */
.page { background: var(--sky2); min-height: 100svh; }
.page .nav { position: sticky; background: rgba(246,234,210,0.9); backdrop-filter: blur(6px); border-bottom: 3px solid var(--stroke); }
.page-head { text-align: center; padding: 56px 5% 10px; }
.page-head h1 { font-size: clamp(40px, 7vw, 76px); }
.page-head .sub { font-family: var(--font-h); font-size: 24px; color: #5a4a38; margin-top: 6px; }
.card {
  background: var(--paper); border: 4px solid var(--stroke); border-radius: var(--radius);
  box-shadow: 7px 7px 0 rgba(43,29,22,0.9); padding: 28px;
}
.section { padding: 34px 0; }
.section h2 { font-size: clamp(30px, 4.5vw, 46px); margin-bottom: 6px; }
.section .sub { color: #5a4a38; font-weight: 500; margin-bottom: 20px; max-width: 64ch; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 22px; }
.progress { background: #e8d9bd; border: 3px solid var(--stroke); border-radius: 999px; height: 30px; overflow: hidden; }
.progress > div { height: 100%; width: 0%; background: repeating-linear-gradient(-45deg, var(--leaf) 0 14px, var(--leaf-dark) 14px 28px); transition: width 1.2s ease; }
.bigpct { font-size: 54px; font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 2px dashed #e0d0ae; font-size: 15px; font-weight: 500; }
.kv:last-child { border-bottom: none; }
.tier-pot { text-align: center; }
.tier-pot svg { width: 130px; height: auto; margin: 0 auto 10px; }
.tier-pot img {
  width: 130px; height: 130px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 10px; border: 4px solid var(--stroke); display: block; background: var(--soil);
}
.lane { display: flex; gap: 16px; overflow-x: auto; padding: 6px 2px 18px; scroll-snap-type: x mandatory; }
.seed { flex: 0 0 150px; scroll-snap-align: start; text-align: center; }
.seed .pot {
  background: var(--paper); border: 4px solid var(--stroke); border-radius: 18px;
  box-shadow: 5px 5px 0 rgba(43,29,22,0.9); padding: 12px 8px;
}
.seed img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 0 auto 8px; border: 3px solid var(--stroke); background: var(--soil); }
.seed .qn { font-family: var(--font-h); font-size: 24px; font-weight: 700; }
.seed .sname { font-family: var(--font-h); font-size: 21px; font-weight: 700; color: var(--leaf-dark); }
.seed .pot.mystery { background: var(--soil); border-color: var(--stroke); }
.seed .qmark {
  width: 96px; height: 96px; margin: 0 auto 8px; border-radius: 50%;
  border: 3px dashed #c9b190; color: #c9b190;
  font-family: var(--font-h); font-size: 54px; font-weight: 700; line-height: 90px;
}
.seed .pot.mystery .qn { color: #c9b190; }
.seed.locked { opacity: 0.75; }
.locktag { margin-left: auto; font-size: 13px; font-weight: 800; letter-spacing: 0.08em; color: #8a7a68; border: 2px solid #8a7a68; border-radius: 8px; padding: 3px 9px; }

/* docs */
.docs-layout { display: grid; grid-template-columns: 250px 1fr; gap: 34px; align-items: start; }
.toc {
  position: sticky; top: 100px; background: var(--paper); border: 4px solid var(--stroke);
  border-radius: var(--radius); box-shadow: 6px 6px 0 rgba(43,29,22,0.9); padding: 20px;
}
.toc h4 { font-size: 13px; letter-spacing: 0.12em; margin-bottom: 10px; color: var(--dim); }
.toc a { display: block; font-size: 14.5px; font-weight: 600; padding: 6px 0; text-decoration: none; color: #4a3a2c; border-bottom: 1px dashed #e8d9bd; }
.toc a:last-child { border: none; }
.toc a:hover { color: var(--leaf-dark); }
.doc h2 { font-size: 32px; margin: 34px 0 10px; scroll-margin-top: 110px; }
.doc h2:first-child { margin-top: 0; }
.doc p, .doc li { font-size: 16px; line-height: 1.7; color: #4a3a2c; font-weight: 500; }
.doc p { margin-bottom: 14px; }
.doc ul, .doc ol { margin: 0 0 16px 22px; display: grid; gap: 8px; }
.doc table { width: 100%; border-collapse: collapse; margin: 14px 0 20px; font-size: 15px; }
.doc th, .doc td { border: 3px solid var(--stroke); padding: 10px 12px; text-align: left; }
.doc th { background: var(--sun); }
.doc tr:nth-child(even) td { background: #faf3e2; }
.warn {
  background: #fdeeda; border: 3px solid #b3702a; border-radius: 14px;
  padding: 16px 18px; font-size: 15px; margin: 16px 0;
}

@media (max-width: 860px) {
  .bud-label { font-size: 34px; }

  .docs-layout { grid-template-columns: 1fr; }
  .toc { position: static; }
  .leaf { border-radius: 56px 14px 56px 14px; padding: 44px 68px 44px 52px; }
  .sun { width: 90px; height: 90px; }
}
@media (max-width: 480px) {
  .nav { flex-wrap: wrap; row-gap: 8px; }
  .hero-copy { padding-top: 148px; }
  .pillbtn { padding: 6px 12px; font-size: 12.5px; }
  .brand b { font-size: 20px; }
  .brand img { width: 38px; height: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- night mode ---------- */
.themebtn { padding: 8px 13px; }
.moon {
  position: absolute; top: 9%; right: 12%; width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fdf6e3 0%, #ece0c2 55%, #cfc09a 100%);
  box-shadow: 0 0 0 8px rgba(253,246,227,0.07), 0 0 46px rgba(253,246,227,0.35);
  display: none; z-index: 1;
  animation: sunpulse 6s ease-in-out infinite;
}
.moon::before, .moon::after { content: ""; position: absolute; border-radius: 50%; background: rgba(150,130,95,0.35); }
.moon::before { width: 26px; height: 26px; top: 28%; left: 22%; }
.moon::after { width: 15px; height: 15px; top: 58%; left: 58%; }
.stars { position: absolute; inset: 0; z-index: 0; display: none; pointer-events: none; }
.stars i { position: absolute; background: #fff; border-radius: 50%; animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.2; } }

body.night .hero { background: linear-gradient(180deg, #0a0f24 0%, #131b3a 45%, #1d2a55 75%, #2b3d68 100%); }
body.night .sun { display: none; }
body.night .moon { display: block; top: 6%; right: 6%; }
body.night .stars { display: block; }
body.night .cloud { opacity: 0.22; filter: brightness(0.5) saturate(0.7); }
body.night .hero-copy h1 { color: var(--cream); }
body.night .hero-copy h1 .green { color: #9be15d; }
body.night .lede { color: #d3c6ac; }
body.night .hint { color: #ab9c7f; }
body.night .bud-label { fill: #f3ead8; }
body.night .mote { box-shadow: 0 0 9px 2px rgba(190,255,120,0.75); }
body.night .brand b { color: var(--cream); }
body.night .eyebrow { color: #2b1d16; }

/* inner pages */
body.night { background: #0d1322; color: var(--cream); }
body.night.page { background: #0d1322; }
body.night.page .nav { background: rgba(13,19,34,0.92); }
body.night .page-head h1 { color: var(--cream); }
body.night .page-head .sub, body.night .section .sub { color: #b3a488; }
body.night .section h2 { color: var(--cream); }
body.night .card h2 { color: #2b1d16; }
body.night .card, body.night .toc, body.night .seed .pot { color: #2b1d16; }
body.night .doc h2 { color: var(--cream); }
body.night .doc p, body.night .doc li { color: #d9cdb4; }
body.night .doc tr:nth-child(even) td { background: #1b2440; }
body.night .warn { color: #4a3a2c; }
body.night .leaf h3, body.night .leaf .x { color: #2b1d16; }
body.night .bigpct { color: #2b1d16; }

@media (max-width: 860px) {
  .moon { width: 90px; height: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  .stars i, .moon { animation: none !important; }
}

.ca-row { display: flex; align-items: center; gap: 10px; background: #f3e9d2; border: 3px solid var(--stroke); border-radius: 14px; padding: 12px 14px; }
.ca-row code { font-size: 13px; word-break: break-all; flex: 1 1 200px; }
.ca-row .pillbtn { padding: 6px 14px; font-size: 13px; flex: none; }
body.night .ca-row { color: #2b1d16; }
