/* Leek Nook — warm ivory & charcoal, clay-orange accent, serif greetings. */
@font-face {
  font-family: 'Nook Serif';
  src: url(fonts/source-serif.woff2) format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --serif: 'Nook Serif', 'Iowan Old Style', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --bg: #faf9f5;
  --bg-2: #f2f0e8;
  --card: #ffffff;
  --line: rgba(31, 30, 29, .11);
  --line-2: rgba(31, 30, 29, .2);
  --ink: #141413;
  --ink-2: #3d3d3a;
  --ink-3: #73726c;
  --ink-4: #a3a19a;
  --accent: #d97757;
  --accent-2: #e9a184;
  --accent-ink: #c6613f;
  --accent-soft: rgba(217, 119, 87, .12);
  --on-accent: #ffffff;
  --up: #4f8a52;
  --down: #b9493d;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 6px 24px -8px rgba(20, 20, 19, .08);
  --glow: rgba(217, 119, 87, .08);

  /* the little leek */
  --leaf: #7d9a5c; --leaf-2: #93ad72; --leaf-3: #6a874c; --vein: rgba(52, 72, 33, .3);
  --stalk-top: #c5d6a2; --stalk-mid: #ebefdc; --stalk-low: #fdfbf4; --stalk-edge: rgba(90, 110, 60, .22);
  --scarf: #d97757; --scarf-stripe: #fbf1e8; --scarf-knot: #c6613f;
  --face: #2b2a27; --blush: #f2a08d; --globe: #b49ad0; --globe-dot: #d3c0e6; --root: #b7a58c;
}

:root[data-theme='dark'] {
  --bg: #262624;
  --bg-2: #1f1e1d;
  --card: #30302e;
  --line: rgba(222, 220, 209, .1);
  --line-2: rgba(222, 220, 209, .22);
  --ink: #faf9f5;
  --ink-2: #c9c7bd;
  --ink-3: #9c9a92;
  --ink-4: #6f6e69;
  --accent: #d97757;
  --accent-2: #b8614a;
  --accent-ink: #e8957a;
  --accent-soft: rgba(217, 119, 87, .16);
  --up: #8cbb7f;
  --down: #ec8a78;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 10px 30px -12px rgba(0, 0, 0, .45);
  --glow: rgba(217, 119, 87, .1);

  --leaf: #87a566; --leaf-2: #9db97c; --leaf-3: #718f53;
  --stalk-top: #b3c890; --stalk-mid: #e2e7d0; --stalk-low: #f4f1e6;
  --root: #8d7e69;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color .5s ease, color .5s ease;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
[hidden] { display: none !important; }

/* a soft lamp-warmth at the top of the room */
.glow {
  position: fixed; left: -30vw; right: -30vw; top: -25vh; height: 75vh; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 35%, var(--glow), transparent 62%);
}

.nook {
  position: relative; z-index: 1;
  width: 100%; max-width: 460px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 28px);
  display: flex; flex-direction: column; gap: 12px;
}

/* ---------- header ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 2px 4px 10px; }
.brand { margin: 0 0 6px; display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; letter-spacing: .01em; color: var(--ink-3); }
.mark { display: block; }
h1 { margin: 0; font: 400 32px/1.1 var(--serif); letter-spacing: -.012em; color: var(--ink); font-variation-settings: 'opsz' 48; }
.lamp {
  flex: none; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; box-shadow: var(--shadow);
  transition: transform .15s ease, background-color .5s ease, border-color .5s ease;
}
.lamp:active { transform: scale(.94); }
.lamp svg { width: 24px; height: 29px; overflow: visible; }
.lamp-shade { fill: var(--ink-4); transition: fill .4s ease; }
.lamp-pole, .lamp-base { fill: var(--ink-3); }
.lamp-chain line { stroke: var(--ink-3); stroke-width: 1.3; }
.lamp-chain circle { fill: var(--ink-3); }
.lamp-chain { transform-origin: 29px 21px; }
.lamp.tug .lamp-chain { animation: tug .5s ease; }
@keyframes tug { 30% { transform: translateY(3px); } 60% { transform: translateY(-1px) rotate(4deg); } }
.lamp-halo { opacity: 0; transition: opacity .5s ease; }
[data-theme='dark'] .lamp-shade { fill: var(--accent); }
[data-theme='dark'] .lamp-halo { opacity: 1; }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
  transition: background-color .5s ease, border-color .5s ease;
}
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.eyebrow { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .01em; }
.fine { margin: 0; font-size: 13px; color: var(--ink-3); line-height: 1.45; }

/* ---------- the widget: market cap + bar ---------- */
.hero { padding: 16px 20px 20px; -webkit-user-select: none; user-select: none; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--up); position: relative; }
.live i::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; background: var(--up); opacity: 0; animation: breathe 2.6s ease-out infinite; }
.live.stale i, .live.stale i::after { background: var(--ink-4); }
.live.stale i::after { animation: none; }
@keyframes breathe { 0% { transform: scale(.4); opacity: .45; } 100% { transform: scale(1.5); opacity: 0; } }
.ago { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.hero .eyebrow { margin-top: 18px; }
.mc {
  margin: 6px 0 6px; font: 400 64px/1 var(--serif); letter-spacing: -.025em; color: var(--ink);
  font-variation-settings: 'opsz' 60; font-variant-numeric: lining-nums tabular-nums;
  transition: color 1.4s ease; white-space: nowrap;
}
.mc .cur { font-size: .5em; vertical-align: .72em; margin-right: 3px; color: var(--ink-3); letter-spacing: 0; }
.mc .unit { font-size: .5em; margin-left: 4px; color: var(--ink-3); letter-spacing: 0; }
.mc.flash-up { color: var(--up); transition: none; }
.mc.flash-down { color: var(--down); transition: none; }
.moves { margin: 0; font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.moves b { font-weight: 650; }
.moves .up { color: var(--up); } .moves .down { color: var(--down); }

.bar-wrap { position: relative; margin-top: 14px; padding-top: 72px; }
.buddy {
  position: absolute; top: 0; width: 50px; height: 75px;
  left: clamp(24px, calc(var(--p, 0) * 1%), calc(100% - 24px));
  transform: translateX(-50%);
  transition: left 1.4s cubic-bezier(.25, .9, .25, 1);
  z-index: 2; pointer-events: none;
}
.buddy svg { width: 100%; height: 100%; overflow: visible; display: block; }
.bar {
  position: relative; height: 16px; border-radius: 99px; background: var(--bg-2);
  box-shadow: inset 0 0 0 1px var(--line); overflow: hidden;
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0; width: max(16px, calc(var(--p, 0) * 1%)); border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 1.4s cubic-bezier(.25, .9, .25, 1); overflow: hidden;
}
.bar-fill::after {
  content: ''; position: absolute; inset: 0; width: 60px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  animation: shimmer 4.5s ease-in-out infinite; transform: translateX(-80px);
}
@keyframes shimmer { 60%, 100% { transform: translateX(110vw); } }
.tick { position: absolute; top: 5px; bottom: 5px; width: 1.5px; margin-left: -.75px; border-radius: 1px; background: var(--line-2); }
.bar-scale { position: relative; height: 18px; margin-top: 7px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bar-scale span { position: absolute; top: 0; white-space: nowrap; }
.bar-scale span:nth-child(1) { left: 0; }
.bar-scale span:nth-child(2) { left: 33.333%; transform: translateX(-50%); }
.bar-scale span:nth-child(3) { left: 66.667%; transform: translateX(-50%); }
.bar-scale .goal { right: 0; color: var(--accent-ink); font-weight: 700; }
.note { margin: 14px 0 2px; font-size: 14px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mood { margin: 0; font: italic 400 15px/1.35 var(--serif); color: var(--ink-3); }

/* the little leek riding the bar */
.leaf path:first-child { fill: var(--leaf); }
.leaf-l path { fill: var(--leaf-2); }
.leaf-r path { fill: var(--leaf-3); }
.vein { fill: none; stroke: var(--vein); stroke-width: .9; stroke-linecap: round; }
.leaf { transform-box: fill-box; animation: sway 6s ease-in-out infinite; }
.leaf-c { transform-origin: 40% 100%; }
.leaf-l { transform-origin: 100% 100%; animation-duration: 7s; animation-delay: -2s; }
.leaf-r { transform-origin: 0% 100%; animation-duration: 6.5s; animation-delay: -4s; }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.stalk { stroke: var(--stalk-edge); stroke-width: .8; }
.roots { stroke: var(--root); stroke-width: 1.4; stroke-linecap: round; fill: none; }
.scarf-band, .scarf-tail { fill: var(--scarf); }
.scarf-stripes rect { fill: var(--scarf-stripe); opacity: .85; }
.scarf-knot { fill: var(--scarf-knot); }
.scarf-fringe { stroke: var(--scarf); stroke-width: 1.1; stroke-linecap: round; fill: none; }
.face { fill: var(--face); }
.blush { fill: var(--blush); opacity: .85; }
.shine { fill: #fff; }
.eyes-happy path, .eyes-sleepy path, .mouth { fill: none; stroke: var(--face); stroke-width: 1.5; stroke-linecap: round; }
.eyes-happy, .eyes-sleepy { display: none; }
.buddy.happy .eyes-calm, .buddy.sleepy .eyes-calm, .buddy.bloom .eyes-calm { display: none; }
.buddy.happy .eyes-happy, .buddy.bloom .eyes-happy { display: inline; }
.buddy.sleepy .eyes-sleepy { display: inline; }
.buddy svg > g:not(.zzz):not(.sparkles), .buddy .stalk, .buddy .roots { animation: bob 3.2s ease-in-out infinite; }
.buddy.sleepy svg > g:not(.zzz):not(.sparkles), .buddy.sleepy .stalk, .buddy.sleepy .roots { animation-duration: 5s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.2px); } }
.zzz text { font: italic 600 10px var(--serif); fill: var(--ink-3); opacity: 0; }
.buddy.sleepy .zzz text { animation: zzz 3.6s ease-in-out infinite; }
.buddy.sleepy .zzz text + text { animation-delay: 1.8s; }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 5px); } 30% { opacity: .9; } 100% { opacity: 0; transform: translate(5px, -7px); } }
.scape { fill: none; stroke: var(--leaf); stroke-width: 1.8; stroke-linecap: round; transform-box: fill-box; transform-origin: 50% 100%; transform: scaleY(0); transition: transform .9s cubic-bezier(.3, 1.3, .5, 1); }
.globe { transform-box: fill-box; transform-origin: 50% 80%; transform: scale(0); transition: transform .8s .5s cubic-bezier(.3, 1.6, .5, 1); }
.globe circle { fill: var(--globe-dot); }
.globe .globe-base { fill: var(--globe); }
.buddy.bloom .scape { transform: scaleY(1); }
.buddy.bloom .globe { transform: scale(1); }
.sparkles path { fill: var(--accent); opacity: 0; transform-box: fill-box; transform-origin: center; }
.buddy.bloom .sparkles path { animation: twinkle 2.4s ease-in-out infinite; }
.buddy.bloom .sparkles path:nth-child(2) { animation-delay: .8s; }
.buddy.bloom .sparkles path:nth-child(3) { animation-delay: 1.6s; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(20deg); } }

/* ---------- install ---------- */
.install { display: flex; align-items: center; gap: 14px; background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.install-text { flex: 1; }
.install-title { margin: 0 0 2px; font-weight: 650; color: var(--ink); font-size: 14.5px; }

/* ---------- bell ---------- */
.bell-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.bell-head h2 { margin: 0; font: 400 23px/1.15 var(--serif); font-variation-settings: 'opsz' 32; }
.bell-ico { width: 44px; height: 44px; flex: none; border-radius: 13px; background: var(--accent-soft); padding: 7px; overflow: visible; }
.bell-body { fill: var(--accent); }
.bell-hook { stroke: var(--accent-ink); stroke-width: 2.6; stroke-linecap: round; }
.bell-shine { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 2; stroke-linecap: round; }
.bell-clapper { fill: var(--accent-ink); }
.bell-swing { transform-origin: 24px 6px; }
.bell-ico.ring .bell-swing { animation: ring 1.1s ease-in-out; }
.bell-ico.hung:not(.ring) .bell-swing { animation: idle 5s ease-in-out infinite; }
@keyframes ring { 15% { transform: rotate(16deg); } 35% { transform: rotate(-13deg); } 55% { transform: rotate(8deg); } 75% { transform: rotate(-4deg); } }
@keyframes idle { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }

.targets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.targets button {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 0; font-size: 14.5px; font-weight: 650; color: var(--ink-2);
  transition: border-color .2s ease, background-color .2s ease, color .2s ease, transform .12s ease; font-variant-numeric: tabular-nums;
}
.targets button:active { transform: scale(.96); }
.targets button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.custom { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 6px 6px 14px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--bg-2); }
.custom span { font: 400 20px var(--serif); color: var(--ink-3); }
.custom input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font: 400 22px var(--serif); color: var(--ink); padding: 2px 0; }
.status { display: flex; align-items: flex-start; gap: 9px; margin: 14px 0; font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.status i { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--ink-4); }
.status.wait i { background: var(--accent); animation: blink 1.6s ease-in-out infinite; }
.status.ok i { background: var(--up); }
.status.bad i { background: var(--down); }
@keyframes blink { 50% { opacity: .3; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid transparent; border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 650;
  transition: transform .12s ease, background-color .2s ease, opacity .2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); flex: 1; }
.btn.soft { background: var(--bg-2); border-color: var(--line); color: var(--ink-2); flex: 1; }
.btn.small { padding: 9px 14px; font-size: 14px; flex: none; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.btn .spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.watch { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
#watchSeen { color: var(--ink-2); }

/* ---------- footer, toast, petals ---------- */
.foot { text-align: center; padding: 8px 12px 0; font-size: 13px; color: var(--ink-3); }
.foot p { margin: 0 0 4px; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px); z-index: 10;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); transition: opacity .25s ease, transform .3s cubic-bezier(.2, .9, .3, 1);
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
.petals i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 10px 0 10px 0; background: var(--accent); animation: fall linear forwards; }
.petals i:nth-child(3n) { background: var(--leaf-2); }
.petals i:nth-child(4n) { background: var(--globe); }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }

@media (hover: hover) {
  .targets button:hover { border-color: var(--line-2); }
  .btn.primary:hover { background: var(--accent-ink); }
  [data-theme='dark'] .btn.primary:hover { background: #c6613f; }
}
@media (min-width: 560px) { .nook { padding-top: 56px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
