/*
 * Torfo website – Black & Yellow house style.
 * Colour and type tokens come from ../Torfo Brand/black-yellow/tokens.css (copied
 * here so the site has no build step). Keep them in sync if the brand changes.
 * Smallest text on the page: 12px.
 *
 * Sections: base · surface · layers · buried things · apps · core · UI (meter,
 * finds tray, toast) · animations · responsive · reduced motion / no-JS.
 */
:root {
  --yellow: #FFC21A;
  --yellow-300: #FFD84F;
  --yellow-500: #F0AD00;
  --ink: #181613;
  --night: #0E0D0B;
  --paper: #FAF8F3;
  --peat-200: #E8C9A0;
  --peat-400: #B9875A;
  --peat-600: #7D5434;
  --peat-700: #5C3B24;
  --peat-800: #4A3020;

  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --radius: 20px;
  --edge: clamp(36px, 5vw, 72px); /* height of the wavy layer edges */
  --ui-bg: rgba(14, 13, 11, .88);
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--night); color: var(--ink); font: 17px/1.6 var(--font-body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img, svg { display: block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; margin: 0 0 .4em; }
h2 { font-size: clamp(30px, 5vw, 48px); }
h3 { font-size: 24px; }
p { margin: 0 0 1em; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.wrap { position: relative; z-index: 2; max-width: 880px; margin: 0 auto; padding: 0 24px; }
.big { font-size: clamp(20px, 2.6vw, 26px); line-height: 1.45; }
.depth-tag { display: inline-block; font: 600 13px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; padding: 7px 12px; border-radius: 999px; margin-bottom: 18px; background: rgba(24, 22, 19, .1); }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-weight: 700; }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

/* ------------------------------------------------------------- surface */
.surface { position: relative; min-height: 100svh; background: var(--paper); display: flex; flex-direction: column; padding: 24px 24px 0; overflow: hidden; }
.brand { position: relative; z-index: 3; align-self: flex-start; }
.brand img { width: 176px; height: auto; }
.sun { position: absolute; width: min(70vw, 560px); aspect-ratio: 1; right: -12%; top: -18%; }
.sun::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--yellow); }
.sun .rays { position: absolute; inset: -13%; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 194, 26, .32) 0 3deg, transparent 3deg 12deg);
  -webkit-mask: radial-gradient(circle, transparent 60%, #000 62%, #000 66%, transparent 71%);
          mask: radial-gradient(circle, transparent 60%, #000 62%, #000 66%, transparent 71%);
  animation: spin 90s linear infinite; }
.hero { position: relative; z-index: 2; margin: auto 0; padding: 48px 0 160px; max-width: 880px; width: 100%; align-self: center; }
.hero h1 { font-size: clamp(46px, 9vw, 104px); font-weight: 700; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--yellow) 62% 92%, transparent 92%); padding: 0 .06em; }
.hero p { font-size: clamp(19px, 2.4vw, 24px); max-width: 520px; color: #3B3732; }
.hero .hint { font-size: 15px; color: #57514A; margin-top: 18px; max-width: 420px; }
.dig { display: inline-block; margin-top: 8px; font: 600 15px var(--font-display); text-decoration: none; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; transition: transform .2s; }
.dig:hover { transform: translateY(2px); }
.dig span { display: inline-block; animation: bob 1.8s ease-in-out infinite; }
.sprouts { position: absolute; left: 0; right: 0; bottom: calc(var(--edge) * .5); height: 0; z-index: 1; }
.sprouts .sprout { position: absolute; bottom: 0; width: calc(96px * var(--s)); height: auto; transform: translateX(-50%); overflow: visible; cursor: pointer; }

/* shared sprout drawing */
.stem { fill: none; stroke: var(--ink); stroke-width: 6; stroke-linecap: round; }
.leaf-a { fill: var(--yellow-500); }
.leaf-b { fill: var(--yellow); }
.grow { transform-box: fill-box; transform-origin: 50% 100%; animation: grow 1.1s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: var(--d, 0s); }
.sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 4.5s ease-in-out infinite; animation-delay: var(--sd, 0s); }
.sprout.wiggle .sway { animation: wiggle .8s ease-in-out; }

/* -------------------------------------------------------------- layers */
.layer { position: relative; padding: calc(var(--edge) + 56px) 0 calc(var(--edge) + 72px); background-color: var(--layer); }
.layer .edge { position: absolute; left: 0; top: calc(var(--edge) * -1 + 1px); width: 100%; height: var(--edge); }
.layer .edge path { fill: var(--layer); }
/* faint strata lines give each layer some grain */
.layer::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='60'%3E%3Cpath d='M0 30 C40 18 80 42 120 30 S200 18 240 30' fill='none' stroke='%23000' stroke-opacity='.07' stroke-width='2'/%3E%3C/svg%3E");
  background-size: 240px 60px; }

.l1 { --layer: var(--peat-200); }
.l2 { --layer: var(--peat-400); }
.l3 { --layer: var(--peat-700); color: var(--paper); }
.l3 .depth-tag { background: rgba(250, 248, 243, .12); }
.core { --layer: var(--night); color: var(--paper); padding-bottom: 0; text-align: center; }
.core .depth-tag { background: rgba(255, 194, 26, .16); color: var(--yellow); }
.core::before { opacity: .25; filter: invert(1); }

/* roots hanging from the surface sprouts; main.js sets --grow (0..1) while scrolling */
.roots { position: absolute; left: 0; right: 0; top: calc(var(--edge) * -.5); height: 0; pointer-events: none; }
.roots svg { position: absolute; top: 0; width: 120px; transform: translateX(-50%); }
.roots path { fill: none; stroke: var(--peat-600); stroke-width: 3; stroke-linecap: round; opacity: .55;
  stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--grow, 1)); }

/* ------------------------------------------------------- buried things */
.pebble { position: absolute; border-radius: 50%; pointer-events: none; }
.p1 { width: 42px; height: 26px; background: var(--peat-400); left: 8%; bottom: 22%; transform: rotate(-12deg); }
.p2 { width: 22px; height: 15px; background: #D9B488; right: 12%; top: 46%; }
.p3 { width: 54px; height: 32px; background: var(--peat-600); left: 38%; bottom: 26px; transform: rotate(8deg); }
.p4 { width: 18px; height: 13px; background: #CDA073; left: 14%; top: 34%; }
.p5 { width: 36px; height: 22px; background: var(--peat-800); left: 6%; top: 18%; }
.worm { position: absolute; width: 96px; left: 6%; bottom: 22px; pointer-events: none; }
.worm path { fill: none; stroke: #D68F87; stroke-width: 7; stroke-linecap: round; }
.worm circle { fill: var(--ink); }

/* Treasures: buttons hidden in the soil. A glint now and then hints at them. */
.treasure { position: absolute; z-index: 3; border: 0; background: none; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.treasure svg { width: 100%; height: auto; overflow: visible; }
.treasure::after { content: ''; position: absolute; top: -6px; right: -6px; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 20%, rgba(255, 255, 255, .6) 30%, transparent 70%); opacity: 0; pointer-events: none;
  animation: glint 6s ease-in-out infinite; animation-delay: var(--gd, 0s); }
.treasure.found::after { display: none; }
.treasure.found svg { filter: drop-shadow(0 0 6px rgba(255, 194, 26, .85)); }
.treasure:focus-visible { border-radius: 12px; }

.t-star { width: 40px; right: 12%; bottom: 22px; --gd: .5s; transform: rotate(-18deg); }
.t-star path { fill: #E0A514; stroke: var(--peat-600); stroke-width: 2; stroke-linejoin: round; }
.t-star.pop svg { animation: twirl .9s cubic-bezier(.3, 1.4, .5, 1); }

.t-ammonite { width: 46px; right: 12%; top: calc(var(--edge) + 6px); --gd: 2.1s; transform: rotate(12deg); }
.t-ammonite .shell { fill: #DDB98C; stroke: var(--peat-600); stroke-width: 2; }
.t-ammonite .spiral { fill: none; stroke: var(--peat-600); stroke-width: 2.4; stroke-linecap: round; }
.t-ammonite.pop svg { animation: wiggle .7s ease-in-out; }

.mole { position: absolute; z-index: 3; right: 15%; bottom: calc(var(--edge) * .7); width: 92px; height: 82px; border: 0; background: none; padding: 0; cursor: pointer; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.mole svg { position: absolute; left: 1px; bottom: 6px; width: 90px; transform: translateY(78%); }
.l2.in-view .mole svg { animation: peek 7s ease-in-out infinite 1s; }
.mole.boop svg { animation: boop .9s ease-in-out !important; }
.mole-hole { position: absolute; left: 4px; right: 4px; bottom: 0; height: 14px; border-radius: 50%; background: var(--peat-800); }
.mole .fur { fill: #3B3732; } .mole .belly { fill: #57514A; } .mole .eye { fill: var(--paper); }
.mole .nose { fill: #E58C86; } .mole .hat { fill: var(--yellow); } .mole .claw { stroke: #E9D9C0; stroke-width: 3; stroke-linecap: round; }

/* ---------------------------------------------------------------- apps */
.apps { list-style: none; margin: 96px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 72px 24px; }
.app { position: relative; background: rgba(14, 13, 11, .32); border-radius: var(--radius); padding: 28px 24px 24px; transition: transform .3s, background .3s; }
.app:hover { transform: translateY(-3px); background: rgba(14, 13, 11, .42); }
.app p { font-size: 16px; color: #E9E3D6; }
.app .links { margin: 0; }
.app a { color: var(--yellow); font-weight: 800; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.app-sprout { position: absolute; width: 84px; height: 76px; top: -62px; left: 20px; transform-origin: 50% 100%; transform: scaleY(0); transition: transform .9s cubic-bezier(.3, 1.4, .5, 1) .2s; }
.app.in .app-sprout { transform: none; }
.app .stem { stroke: var(--yellow-300); }
.app-seed { background: transparent; border: 2px dashed rgba(250, 248, 243, .25); }
.app-seed:hover { background: rgba(14, 13, 11, .18); }

.buried { right: 18px; bottom: -18px; width: 36px; transform: rotate(-14deg); transition: transform .4s; }
.app:hover .buried { transform: rotate(6deg) translateY(-4px); }
.t-die { --gd: 1.2s; }
.t-die rect { fill: var(--paper); } .t-die circle { fill: var(--ink); }
.t-die.pop svg { animation: roll .8s cubic-bezier(.3, 1.2, .5, 1); }
.t-egg { --gd: 3.3s; width: 38px; bottom: -22px; }
.t-egg .shell { fill: #F1EEE6; } .t-egg .spot { fill: var(--peat-400); }
.t-egg .top { transform-box: view-box; transform-origin: 24px 32px; transition: transform .6s cubic-bezier(.3, 1.4, .5, 1); }
.t-egg .hatchling { transform-box: view-box; transform-origin: 24px 40px; transform: translateY(10px) scale(.6); opacity: 0; transition: transform .6s cubic-bezier(.3, 1.4, .5, 1) .15s, opacity .3s .15s; }
.t-egg .lizard { fill: var(--yellow-500); } .t-egg .eye { fill: var(--ink); } .t-egg .smile { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.t-egg.hatched .top { transform: translate(-6px, -14px) rotate(-24deg); }
.t-egg.hatched .hatchling { transform: translateY(-6px); opacity: 1; }
.t-reel { --gd: 4.4s; }
.t-reel circle { fill: #8A8276; } .t-reel .hole { fill: var(--peat-700); }
.t-reel .reel-disc { transform-box: fill-box; transform-origin: center; }
.t-reel.pop .reel-disc { animation: spin 1.2s cubic-bezier(.2, .8, .3, 1); }

.t-seed { width: 84px; top: -40px; left: 20px; --gd: 5.2s; }
.t-seed svg { transform-origin: 50% 80%; animation: wobble 3.2s ease-in-out infinite; }
.t-seed .husk { fill: #C9965F; }
.t-seed .crack { fill: none; stroke: var(--peat-800); stroke-width: 2.5; stroke-linecap: round; }
.t-seed .stem { stroke: var(--yellow-300); stroke-width: 4; }
.t-seed .seed-leaves { transform-box: fill-box; transform-origin: 50% 100%; transform: scale(0); }
.t-seed.pop .seed-leaves { animation: try-sprout 2.6s ease-in-out; }
.t-seed::after { top: 4px; right: 18px; }

/* ---------------------------------------------------------------- core */
.core .wrap { padding-bottom: 72px; }
.core h2 { color: var(--yellow); }
.glow-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.glow { position: absolute; left: 50%; bottom: -40%; width: min(140vw, 1100px); aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 194, 26, .38) 0%, rgba(255, 194, 26, .12) 38%, transparent 66%); animation: breathe 6s ease-in-out infinite; transition: filter .8s; }
.core.complete .glow { filter: brightness(1.6) saturate(1.2); }
.embers { position: absolute; inset: 0; opacity: .7;
  background-image:
    radial-gradient(circle at 12% 30%, rgba(255, 216, 79, .9) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 38% 70%, rgba(255, 194, 26, .8) 0 1px, transparent 2px),
    radial-gradient(circle at 63% 20%, rgba(255, 216, 79, .9) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 81% 55%, rgba(255, 194, 26, .8) 0 1px, transparent 2px),
    radial-gradient(circle at 92% 88%, rgba(255, 216, 79, .7) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 25% 95%, rgba(255, 194, 26, .7) 0 1px, transparent 2px);
  background-size: 100% 320px; animation: rise 14s linear infinite; }
.button { display: inline-block; margin-top: 12px; background: var(--yellow); color: var(--night); font: 700 18px var(--font-display); text-decoration: none; padding: 16px 28px; border-radius: 999px; box-shadow: 0 8px 30px rgba(255, 194, 26, .3); transition: transform .2s, background .2s; }
.button:hover { background: var(--yellow-300); transform: translateY(-2px); }
.foot { position: relative; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 20px; padding: 24px 24px 96px; border-top: 1px solid rgba(250, 248, 243, .1); font-size: 13px; color: #A39B8B; }
.foot a { color: #C9C2B3; }

/* leaf confetti for finding everything (spawned by main.js) */
.leaf-burst { position: fixed; left: 50%; top: 50%; width: 18px; height: 11px; border-radius: 0 100%; background: var(--yellow); z-index: 60; pointer-events: none;
  animation: burst 1.8s cubic-bezier(.2, .7, .4, 1) forwards; }
.leaf-burst:nth-child(even) { background: var(--yellow-500); }

/* ------------------------------------------------------------------ UI */
.meter { position: fixed; z-index: 40; right: 16px; top: 50%; transform: translate(130%, -50%); width: 96px; padding: 12px 10px 14px; border-radius: 18px;
  background: var(--ui-bg); color: var(--paper); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: transform .5s cubic-bezier(.3, 1.3, .5, 1); }
.meter.show { transform: translate(0, -50%); }
.meter-label { font: 600 12px var(--font-display); letter-spacing: .08em; text-transform: uppercase; color: #A39B8B; }
.meter-depth { font: 700 24px/1.1 var(--font-display); color: var(--yellow); white-space: nowrap; }
.meter-layer { font-size: 12px; line-height: 1.3; color: #E9E3D6; min-height: 32px; }
.meter-track { position: relative; width: 4px; height: 96px; margin-top: 6px; border-radius: 4px;
  background: linear-gradient(var(--paper), var(--peat-200) 25%, var(--peat-400) 50%, var(--peat-700) 75%, #2A2420); }
.meter-dot { position: absolute; left: 50%; top: var(--p, 0%); width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 3px var(--ink); }

.finds { position: fixed; z-index: 40; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px; background: var(--ui-bg); color: var(--paper); font-size: 14px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transform: translateY(160%); transition: transform .5s cubic-bezier(.3, 1.3, .5, 1); }
.finds.show { transform: none; }
.finds.bump { animation: bump .5s ease; }
.finds-icon { width: 18px; height: 18px; fill: none; stroke: var(--yellow); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.finds-text b { color: var(--yellow); font-family: var(--font-display); font-size: 16px; }
.finds-dots { display: flex; gap: 5px; }
.finds-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(250, 248, 243, .22); transition: background .3s, transform .3s; }
.finds-dots i.lit { background: var(--yellow); transform: scale(1.15); }
.finds-reset { border: 0; background: none; padding: 0; font-size: 13px; color: #C9C2B3; text-decoration: underline; cursor: pointer; }

.toast { position: fixed; z-index: 55; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); max-width: min(90vw, 440px); padding: 12px 18px; border-radius: 16px;
  background: var(--ink); color: var(--paper); border: 2px solid var(--yellow); font: 600 16px/1.4 var(--font-body); text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); opacity: 0; transform: translate(-50%, 12px); transition: opacity .25s, transform .3s cubic-bezier(.3, 1.3, .5, 1); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------- reveals */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s ease, transform .8s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------------------------------------------------------- animations */
@keyframes grow { from { transform: scale(.2, 0); } to { transform: none; } }
@keyframes sway { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 45% { transform: rotate(11deg); } 70% { transform: rotate(-6deg); } }
@keyframes bob { 50% { transform: translateY(4px); } }
@keyframes wobble { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes twirl { 0% { transform: scale(1) rotate(0); } 50% { transform: scale(1.5) rotate(200deg); } 100% { transform: scale(1) rotate(360deg); } }
@keyframes roll { 0% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-26px) rotate(400deg); } 100% { transform: translateY(0) rotate(720deg); } }
@keyframes glint { 0%, 88%, 100% { opacity: 0; transform: scale(.4); } 93% { opacity: 1; transform: scale(1.1); } }
@keyframes peek { 0%, 55%, 100% { transform: translateY(78%); } 64%, 88% { transform: translateY(8%); } 72% { transform: translateY(8%) rotate(-5deg); } 80% { transform: translateY(8%) rotate(5deg); } }
@keyframes boop { 0% { transform: translateY(8%); } 30% { transform: translateY(0%) scale(1.06); } 100% { transform: translateY(78%); } }
@keyframes try-sprout { 0% { transform: scale(0); } 25%, 70% { transform: scale(1); } 100% { transform: scale(0); } }
@keyframes breathe { 50% { transform: translateX(-50%) scale(1.06); } }
@keyframes rise { to { background-position: 0 -320px; } }
@keyframes bump { 40% { transform: scale(1.08); } }
@keyframes burst {
  0% { transform: translate(-50%, -50%) rotate(0) scale(.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)) scale(1); opacity: 0; } }

/* ---------------------------------------------------------- responsive */
@media (max-width: 700px) {
  body { font-size: 16px; }
  .brand img { width: 140px; }
  .hero { padding-bottom: 180px; }
  .sun { width: 90vw; right: -40%; top: -10%; }
  .apps { gap: 80px; }
  /* compact depth pill in the top-right corner */
  .meter { top: 12px; right: 12px; width: auto; flex-direction: row; align-items: baseline; gap: 8px; padding: 8px 14px; border-radius: 999px; transform: translateY(-160%); }
  .meter.show { transform: none; }
  .meter-label, .meter-track { display: none; }
  .meter-depth { font-size: 18px; }
  .meter-layer { min-height: 0; }
  .finds { font-size: 13px; padding: 9px 14px; gap: 8px; }
  .finds-dots, .finds-word { display: none; }
  .mole { right: 4%; }
}

/* ------------------------------------------- reduced motion and no-JS */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  .app-sprout { transform: none; }
  .mole svg { transform: translateY(8%); }
}
.no-js .reveal { opacity: 1; transform: none; }
.no-js .app-sprout { transform: none; }
.no-js .meter, .no-js .finds, .no-js .hero .hint { display: none; }
.no-js .treasure::after { display: none; }
