/* Mana³ components: the m3- classes the app renders with (plain HTML + JS, no build step).
   Reads tokens.css (colours, spacing, radii, shadows, blur, opacity, type classes). */

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.m3-num, .figure-hero, .figure, .figure-sm { font-variant-numeric: tabular-nums; }
.m3-muted { color: var(--muted); }
.m3-ico { width: 24px; height: 24px; flex: none; stroke-width: 1.75; }
.m3-ico--sm { width: 18px; height: 18px; }

/* Area modifiers: colour = area, never state */
.m3-sleep    { --area: var(--area-sleep);    --area-tint: var(--sleep-tint); }
.m3-recovery { --area: var(--area-recovery); --area-tint: var(--recovery-tint); }
.m3-personal { --area: var(--area-personal); --area-tint: var(--personal-tint); }
.m3-load     { --area: var(--area-load);     --area-tint: var(--load-tint); }

/* ── App shell: fixed to the screen, only the screen scrolls (no 100vh) ── */
.m3-shell { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--ink); }
.m3-shell__hole { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: var(--hole-behind-data); }
.m3-shell__hole.is-hero { opacity: var(--hole-hero); }
.m3-screen {
  position: relative; z-index: 1; flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--sat, env(safe-area-inset-top, 0px)) + var(--space-5)) var(--space-5)
           calc(var(--space-nav) + var(--sab, env(safe-area-inset-bottom, 0px)));
  display: flex; flex-direction: column; gap: var(--space-3);
  scrollbar-width: none;
}
.m3-screen::-webkit-scrollbar { display: none; }
.m3-screen > * { flex-shrink: 0; } /* a card clips its content (overflow: hidden), so it must never shrink to fit the screen */

/* ── Card ── */
.m3-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg); padding: var(--space-6);
  background: radial-gradient(120% 90% at 100% 100%, var(--area-tint, transparent) 0%, transparent 60%), var(--surface-glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  -webkit-backdrop-filter: blur(var(--blur-glass)); backdrop-filter: blur(var(--blur-glass));
}

/* ── Area card ── */
.m3-area { display: grid; gap: var(--space-5); color: inherit; text-decoration: none; }
.m3-area__head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3); }
.m3-area__icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--area); background: rgba(255, 255, 255, 0.06); }
.m3-area__icon .m3-ico { width: 20px; height: 20px; }
.m3-area__name { margin: 0; }
.m3-area__state { margin: 2px 0 0; text-transform: uppercase; color: var(--area); }
.m3-area__chev { color: var(--muted); }
.m3-area__body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: var(--space-5); }
.m3-figure { margin: 0; display: flex; align-items: baseline; gap: var(--space-1); white-space: nowrap; }
.m3-figure .unit { color: var(--muted); }

/* ── Range bar: the usual range as a band, the value as a marker. Position = state. ── */
.m3-range { position: relative; height: 44px; min-width: 140px; }
.m3-range__track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: var(--radius-pill); background: var(--range-track); }
.m3-range__band { position: absolute; top: 12px; height: 4px; left: var(--lo); width: calc(var(--hi) - var(--lo)); border-radius: var(--radius-pill); background: var(--range-band); }
.m3-range__mark {
  position: absolute; top: 7px; left: var(--v); width: 14px; height: 14px; margin-left: -7px;
  border-radius: 50%; background: var(--bone); box-shadow: 0 0 0 3px var(--area), 0 0 12px var(--area);
  transition: left 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.m3-range__end { position: absolute; top: 24px; transform: translateX(-50%); color: var(--muted); white-space: nowrap; }
.m3-range--building .m3-range__track { background: none; border-top: 2px dashed var(--line-strong); height: 0; }
.m3-range--building .m3-range__note { position: absolute; top: 22px; left: 0; color: var(--muted); }

/* ── Trend line (7 nights) ── */
.m3-trend { display: block; width: 100%; height: auto; overflow: visible; }
.m3-trend__band { fill: var(--range-band); opacity: 0.5; }
.m3-trend__axis { stroke: var(--range-track); stroke-width: 1; }
.m3-trend__line { fill: none; stroke: var(--area); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.m3-trend__dot { fill: var(--surface); stroke: var(--area); stroke-width: 2; }
.m3-trend__dot.is-last { fill: var(--area); }
.m3-trend__tick { fill: var(--muted); font: 400 12px/16px var(--font-sans); }
.m3-trend.is-drawing .m3-trend__line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: m3-draw 700ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
@keyframes m3-draw { to { stroke-dashoffset: 0; } }

/* ── Today hero ── */
.m3-hero { position: relative; min-height: 560px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: var(--space-5); padding: var(--space-12) var(--space-5) var(--space-6); }
.m3-hero__hole { position: absolute; inset: 0; z-index: 0; opacity: var(--hole-hero); }
.m3-hero__hole canvas { width: 100% !important; height: 100% !important; display: block; }
.m3-hero > *:not(.m3-hero__hole) { position: relative; z-index: 1; }
.m3-hero__label { margin: 0; color: var(--muted); text-transform: uppercase; }
.m3-hero__main { display: grid; gap: var(--space-1); }
.m3-hero__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.m3-hero__stat { display: grid; gap: 2px; }
.m3-hero__stat .caption { color: var(--muted); }
.m3-pip { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--area); margin-right: 6px; vertical-align: middle; }
.m3-readiness { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--muted); width: fit-content; }

/* ── Open question: the way into the day ── */
.m3-question {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 56px;
  padding: 0 var(--space-4) 0 var(--space-5); border-radius: var(--radius-pill);
  background: var(--surface-glass); border: 1px solid var(--line-strong); color: var(--bone);
  -webkit-backdrop-filter: blur(var(--blur-glass)); backdrop-filter: blur(var(--blur-glass));
  font: 500 16px/22px var(--font-sans); text-align: left; cursor: pointer;
  transition: transform 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.m3-question__text { flex: 1; }
.m3-question .m3-pip { margin: 0; }

/* ── Buttons: neutral, colour is for areas ── */
.m3-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 0 var(--space-6); border-radius: var(--radius-pill);
  font: 500 16px/20px var(--font-sans); border: 1px solid transparent; cursor: pointer;
  transition: transform 120ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 120ms;
}
.m3-btn--primary { background: var(--action); color: var(--on-action); }
.m3-btn--glass { background: rgba(255, 255, 255, 0.08); color: var(--bone); border-color: var(--line-strong); }
.m3-btn--quiet { background: none; color: var(--bone); padding: 0 var(--space-3); text-decoration: underline; text-underline-offset: 4px; }
.m3-btn:active, .m3-question:active { transform: scale(0.97); }
.m3-btn:disabled { opacity: 0.4; cursor: default; }
.m3-btn:focus-visible, .m3-question:focus-visible, .m3-nav__item:focus-visible, .m3-mic:focus-visible, .m3-area:focus-visible {
  outline: 2px solid var(--focus-ring); outline-offset: 2px;
}

/* ── Chips: achievements on actions, never on the body ── */
.m3-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 var(--space-3); border-radius: var(--radius-pill); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--bone); font: 500 13px/18px var(--font-sans); }
.m3-chip .m3-ico { width: 16px; height: 16px; color: var(--area); }

/* ── Nav: a floating pill of three tabs and the round mic ── */
.m3-navbar { position: fixed; left: 0; right: 0; bottom: calc(var(--sab, env(safe-area-inset-bottom, 0px)) + var(--space-3)); z-index: 10; display: flex; justify-content: center; align-items: center; gap: var(--space-3); padding: 0 var(--space-5); pointer-events: none; }
.m3-navbar > * { pointer-events: auto; }
.m3-nav { display: flex; gap: 2px; padding: 6px; border-radius: var(--radius-pill); background: rgba(28, 28, 31, 0.88); border: 1px solid var(--line-strong); box-shadow: var(--shadow-nav); -webkit-backdrop-filter: blur(var(--blur-glass)); backdrop-filter: blur(var(--blur-glass)); }
.m3-nav__item { display: grid; justify-items: center; gap: 2px; width: 76px; padding: 8px 0 6px; border: 0; border-radius: var(--radius-pill); background: none; color: var(--muted); font: 500 11px/14px var(--font-sans); cursor: pointer; transition: color 240ms, background 240ms; }
.m3-nav__item .m3-ico { width: 22px; height: 22px; }
.m3-nav__item.is-active { color: var(--bone); background: rgba(255, 255, 255, 0.08); }
.m3-mic { position: relative; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); background: rgba(28, 28, 31, 0.88); color: var(--bone); box-shadow: var(--shadow-nav); cursor: pointer; -webkit-backdrop-filter: blur(var(--blur-glass)); backdrop-filter: blur(var(--blur-glass)); transition: background 240ms, color 240ms; }
.m3-mic.is-recording { background: var(--recording); color: var(--on-yellow); border-color: transparent; }
.m3-mic.is-recording::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--recording); animation: m3-ring 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) infinite; }
@keyframes m3-ring { from { transform: scale(1); opacity: 0.8; } to { transform: scale(1.45); opacity: 0; } }

/* ── Check-in slider (1 to 7, no starting value) ── */
.m3-slider { display: grid; gap: var(--space-2); --area: var(--area-personal); }
.m3-slider__q { margin: 0; }
.m3-slider__input { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; margin: 0; background: transparent; cursor: pointer; }
.m3-slider__input::-webkit-slider-runnable-track { height: 4px; border-radius: var(--radius-pill); background: var(--range-track); }
.m3-slider__input::-moz-range-track { height: 4px; border-radius: var(--radius-pill); background: var(--range-track); }
.m3-slider__input::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%; background: var(--area); border: 3px solid var(--ink); box-shadow: 0 0 0 1px var(--area); }
.m3-slider__input::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--area); border: 3px solid var(--ink); }
.m3-slider.is-unset .m3-slider__input::-webkit-slider-thumb { opacity: 0; }
.m3-slider.is-unset .m3-slider__input::-moz-range-thumb { opacity: 0; }
.m3-slider__ends { display: flex; justify-content: space-between; color: var(--muted); }

/* ── Notice: grey, never red ── */
.m3-notice { display: flex; align-items: flex-start; gap: 10px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--notice-fill); color: var(--notice-ink); }
.m3-notice .m3-ico { width: 20px; height: 20px; margin-top: 1px; }
.m3-notice p { margin: 0; }

/* ── Opener: once a day, Geneva from the lake ── */
.m3-opener { position: relative; min-height: 600px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: var(--space-12) var(--space-5) calc(var(--space-8) + var(--sab, env(safe-area-inset-bottom, 0px))); background: var(--surface); }
.m3-opener__media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.m3-opener__scrim { position: absolute; inset: 0; background: linear-gradient(to top, var(--ink) 0%, rgba(10, 10, 10, 0.55) 35%, rgba(10, 10, 10, 0) 65%); }
.m3-opener > *:not(.m3-opener__media):not(.m3-opener__scrim) { position: relative; z-index: 1; }
.m3-opener__greeting { margin: 0; }
.m3-opener__date { margin: var(--space-2) 0 0; color: var(--muted); }
.m3-opener__hint { margin-top: var(--space-12); display: flex; align-items: center; justify-content: center; gap: var(--space-2); color: var(--muted); }
.m3-opener__greeting, .m3-opener__date { animation: m3-rise 600ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.m3-opener__date { animation-delay: 120ms; }

/* ── Entrance: cards rise in order ── */
.m3-enter > * { animation: m3-rise 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.m3-enter > *:nth-child(2) { animation-delay: 60ms; }
.m3-enter > *:nth-child(3) { animation-delay: 120ms; }
.m3-enter > *:nth-child(4) { animation-delay: 180ms; }
.m3-enter > *:nth-child(5) { animation-delay: 240ms; }
@keyframes m3-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .m3-mic.is-recording::after { display: none; }
}
