/* Wavely — site.css (DESIGN.md v2, D-080)
   Shared components: layout, type helpers, buttons, inputs, cards, stage panel, device frame,
   nav (frosted), footer, wave card, glass (dark), chips, tier badge, flame, waveform, quota ring,
   toast, skeleton, status capsule. BEM-lite. Tokens only — no raw colors or radii here. */

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--max-w); margin-inline: auto; padding-inline: var(--gutter); }
.wrap--stage { max-width: var(--max-w-stage); }
.skip-link {
  position: absolute; left: var(--s-16); top: -100px; z-index: 100;
  padding: var(--s-8) var(--s-12); background: var(--surface-2); border-radius: var(--r-8);
  font-weight: 500;
}
.skip-link:focus-visible { top: var(--s-16); }

/* ---------- Type helpers (§4) ---------- */
.display { font-family: var(--font-display); font-weight: 600; text-wrap: pretty; hyphens: none; }
.d1 { font-size: var(--fs-d1); line-height: var(--lh-d1); letter-spacing: var(--ls-d1); text-wrap: initial; }
.d2 { font-size: var(--fs-d2); line-height: var(--lh-d2); letter-spacing: var(--ls-d2); max-width: 20ch; }
.d3 { font-size: var(--fs-d3); line-height: var(--lh-d3); letter-spacing: var(--ls-d3); max-width: 16ch; }
.d4 { font-size: var(--fs-d4); line-height: var(--lh-d4); letter-spacing: 0; }
.d5 { font-size: var(--fs-d5); line-height: var(--lh-d5); letter-spacing: 0; }
.statement { font-size: var(--fs-statement); line-height: 1.3; font-weight: 500; letter-spacing: -0.005em; max-width: 40ch; color: var(--text); text-wrap: pretty; }
.lede { font-size: var(--fs-lede); line-height: 1.5; color: var(--text-muted); max-width: 56ch; text-wrap: pretty; }
.muted { color: var(--text-muted); }
.meta { font-size: var(--fs-meta); font-variant-numeric: tabular-nums; color: var(--text-muted); line-height: 1.4; }
.meta--lg { font-size: var(--fs-lede); font-weight: 500; color: var(--text); }
.eyebrow { font-size: var(--fs-meta); font-weight: 500; color: var(--text-muted); line-height: 1.4; }
.eyebrow--index { display: inline-flex; align-items: center; gap: var(--s-12); font-variant-numeric: tabular-nums; }
.eyebrow__n { color: var(--ember); font-weight: 600; }
.eyebrow__n::after { content: ""; display: inline-block; width: 20px; height: 1px; background: var(--ember-a-45); margin-left: var(--s-12); vertical-align: middle; }
.small { font-size: var(--fs-micro); letter-spacing: 0.01em; }
p { text-wrap: pretty; }

/* ---------- Buttons (§8) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-8);
  min-height: 48px; padding: 0 var(--s-24);
  border-radius: var(--r-8); border: 1px solid transparent;
  font-weight: 500; font-size: var(--fs-body); line-height: 1.4; white-space: nowrap;
  transition: background-color var(--t-micro) var(--ease), border-color var(--t-micro) var(--ease),
              color var(--t-micro) var(--ease), box-shadow var(--t-std) var(--ease), transform var(--t-micro) var(--ease);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--ember); color: var(--bg); box-shadow: var(--btn-highlight); }
.btn--secondary { background: var(--overlay-1); border-color: var(--border-control); color: var(--text); box-shadow: var(--btn-highlight); }
.btn--ghost { background: transparent; color: var(--text-muted); padding-inline: var(--s-12); text-decoration: none; }
.btn--sm { min-height: 40px; font-size: var(--fs-meta); padding-inline: var(--s-16); }
.btn[disabled], .btn[aria-disabled="true"] { cursor: default; opacity: .55; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover:not([disabled]) { background: var(--ember-hi); box-shadow: var(--btn-highlight), var(--glow-cta); transform: translateY(-1px); }
  .btn--secondary:hover:not([disabled]) { border-color: var(--text-muted); background: var(--overlay-2); transform: translateY(-1px); }
  .btn--ghost:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
}

/* Status capsule — never a button (§8) */
.capsule { display: inline-flex; align-items: center; gap: var(--s-8); min-height: 32px; padding: 0 var(--s-12); border-radius: var(--r-full); background: var(--surface-2); font-size: var(--fs-meta); font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.capsule__dot { width: 6px; height: 6px; border-radius: var(--r-full); background: var(--success); flex: none; }

/* ---------- Inputs ---------- */
.field { display: grid; gap: var(--s-8); }
.field__label { font-size: var(--fs-meta); font-weight: 500; color: var(--text-muted); }
.input {
  width: 100%; min-height: 48px; padding: 0 var(--s-12);
  background: var(--surface-2); border: 1px solid var(--border-control); border-radius: var(--r-8);
  color: var(--text); transition: border-color var(--t-micro) var(--ease);
}
.input::placeholder { color: var(--text-muted); }
.input:focus-visible { outline-offset: 0; border-color: var(--ember); }
.check { display: flex; align-items: center; gap: var(--s-12); min-height: 44px; font-size: var(--fs-meta); }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ember); }

/* ---------- Cards / surfaces (§5, §8) ---------- */
.card { background: var(--surface); border-radius: var(--r-12); }
.card--on-stage, .card--light { background: var(--surface-2); border-radius: var(--r-16); box-shadow: var(--edge-top); }
.card--warm { background: var(--surface-warm); }
.stage .card { box-shadow: var(--edge-top); }
/* Object light: a wrapper that puts an ember glow behind an object and a rim on its lit edge */
.lit { position: relative; }
.lit::before { content: ""; position: absolute; inset: -12% -22% -12%; background: var(--glow-object); z-index: -1; pointer-events: none; }
.lit > .frame, .lit > .wave-card { box-shadow: inset 0 0 0 1px var(--overlay-edge), inset -1px 0 0 var(--rim-ember), inset 0 1px 0 var(--overlay-edge); }
.hr { border: 0; border-top: 1px solid var(--hairline); margin: 0; }
.stage { position: relative; background: var(--surface); padding: var(--stage-pad) var(--gutter); overflow: hidden; isolation: isolate; }
.stage--warm { background: var(--surface-warm); }
.stage::before { content: ""; position: absolute; inset: 0; background: var(--glow-ember); pointer-events: none; z-index: -1; }
.stage::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; background: var(--veil-ember); pointer-events: none; z-index: -1; }
@media (min-width: 1024px) { .stage { border-radius: var(--r-24); } }

/* Device frame (§8): the real screenshot in a screen-only crop, ≥ 1× export pixels on screen */
.frame { position: relative; aspect-ratio: 402 / 874; border-radius: var(--r-40); overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--overlay-edge); }
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Nav (frosted, 72px) ---------- */
body:not(.landing) { padding-top: 72px; }
/* Fixed (not sticky): the landing hero sits under it and Pin A pins at the true viewport top;
   every other page offsets its body by the nav height. */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: background-color var(--t-max) var(--ease), border-color var(--t-max) var(--ease);
}
.nav { border-bottom-color: var(--edge-soft); }
.nav.is-scrolled { background: var(--nav-bg-scrolled); }
@supports not (backdrop-filter: blur(1px)) { .nav, .nav.is-scrolled { background: var(--nav-bg-scrolled); } }
.nav__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-16); min-height: 72px; }
.nav__links { display: flex; align-items: center; gap: var(--s-8); }
.nav__link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-12); font-weight: 500; font-size: 0.9375rem; color: var(--text); opacity: .82; border-radius: var(--r-8); white-space: nowrap; transition: opacity var(--t-micro) var(--ease); }
.nav__link[aria-current="page"] { color: var(--text); }
@media (hover: hover) and (pointer: fine) { .nav__link:hover { opacity: 1; } }
.nav__link[aria-current="page"] { opacity: 1; }
/* One ember-filled control per viewport: the nav CTA is a ghost while a section's own ember CTA is on screen. */
.nav__cta { margin-left: var(--s-8); min-height: 44px; padding-inline: var(--s-24); background: var(--overlay-1); border-color: var(--border-control); color: var(--text); }
.nav.is-ember .nav__cta { background: var(--ember); border-color: transparent; color: var(--bg); }
@media (max-width: 639px) {
  .nav__link:not(.nav__link--keep) { display: none; }
  .nav__cta { padding-inline: var(--s-12); margin-left: 0; }
}
/* Narrow phones: the lockup and the one action; the hub link lives in the hub section. */
@media (max-width: 479px) {
  .nav__link { display: none; }
  .lockup__word { font-size: var(--fs-24); }
  .lockup__mark { width: 24px; height: 24px; }
}

/* Wordmark / lockup (§6b) */
.lockup { display: inline-flex; align-items: center; gap: 0.35em; min-height: 44px; }
.lockup__mark { width: 32px; height: 32px; flex: none; color: var(--ember); }
.lockup__word { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-32); letter-spacing: -0.02em; line-height: 1; color: var(--text); }
.lockup--lg .lockup__mark { width: 40px; height: 40px; }
.lockup--lg .lockup__word { font-size: 2.5rem; }
.mark-hero { width: 120px; height: 120px; color: var(--ember); filter: drop-shadow(0 0 32px var(--ember-a-45)); }

/* ---------- Footer ---------- */
.footer { background: transparent; padding-block: var(--s-48) var(--s-64); }
.footer__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-24); }
.footer__links { display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-16); font-size: var(--fs-meta); color: var(--text-muted); }
.footer__links a { display: inline-flex; align-items: center; min-height: 44px; }
.footer__legal { margin-top: var(--s-24); font-size: var(--fs-micro); letter-spacing: 0.01em; color: var(--text-muted); max-width: 70ch; }

/* ---------- Wave card (§6) ---------- */
.wave-card { background: var(--surface); border-radius: var(--r-12); overflow: hidden; container-type: inline-size; }
.wave-card__art { position: relative; aspect-ratio: 9 / 16; overflow: hidden; background: var(--surface-2); }
.wave-card__blur { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(24px); transform: scale(1.15); pointer-events: none; }
.wave-card__cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.wave-card__cover--fill { object-fit: cover; }
.wave-card__body { display: grid; gap: var(--s-8); padding: var(--s-16); }
.wave-card__title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-d5); line-height: var(--lh-d5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wave-card__handle { font-size: var(--fs-meta); color: var(--text-muted); }
.wave-card__actions { display: flex; align-items: center; gap: var(--s-8); margin-top: var(--s-4); }
@container (min-width: 380px) { .wave-card__body { padding: var(--s-24); gap: var(--s-12); } }

/* Glass — dark on the web, only over imagery (§6) */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: inset 0 0 0 1px var(--overlay-edge);
}
@supports not (backdrop-filter: blur(1px)) { .glass { background: var(--glass-fallback); } }
.glass-circle { width: 44px; height: 44px; border-radius: var(--r-full); display: inline-grid; place-items: center; border: 0; color: var(--text); }
.glass-capsule { display: inline-flex; align-items: center; gap: 0.35em; min-height: 29px; padding: 0 var(--s-12); border-radius: var(--r-full); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; color: var(--text); }
.rank { font-weight: 600; }
.rank__pts { font-weight: 400; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-8); }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s-12); border-radius: var(--r-full); background: var(--surface-2); font-size: var(--fs-micro); letter-spacing: 0.01em; text-transform: lowercase; color: var(--text); }
.chip--on { background: var(--ember); color: var(--bg); }
.chip--glass { background: var(--glass); color: var(--text); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); box-shadow: inset 0 0 0 1px var(--overlay-edge); }
/* Hashtag rail: chips that read as culture, not a form's tag picker */
.rail { display: flex; flex-wrap: wrap; gap: var(--s-8) var(--s-12); padding: var(--s-16) 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.rail .chip { min-height: 36px; font-size: var(--fs-meta); padding-inline: var(--s-16); }

/* Tier badge — the sanctioned uppercase exception */
.tier { display: inline-flex; align-items: center; min-height: 20px; padding: 0 var(--s-8); border-radius: var(--r-full); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; color: var(--tier-color, var(--tier-basic)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tier-color, var(--tier-basic)) 60%, transparent); }
.tier--basic { --tier-color: var(--tier-basic); }
.tier--gold { --tier-color: var(--tier-gold); }
.tier--platinum { --tier-color: var(--tier-platinum); }
.tier--opal { --tier-color: var(--tier-opal); }
.tier--obsidian { --tier-color: var(--tier-obsidian); }

/* Flame (inactive = text outline 1.8, active = ember gradient fill) */
.flame { width: 24px; height: 24px; display: block; }
.flame__path { fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linejoin: round; transition: fill var(--t-micro) var(--ease), stroke var(--t-micro) var(--ease); }
.is-flamed .flame__path { fill: url(#emberGrad); stroke: var(--ember); }
.icon-btn { display: inline-flex; align-items: center; gap: var(--s-8); min-height: 44px; min-width: 44px; padding: 0 var(--s-12); border-radius: var(--r-8); background: transparent; border: 0; color: var(--text); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; transition: background-color var(--t-micro) var(--ease), transform var(--t-micro) var(--ease); }
.icon-btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--surface-2); } }
.icon-btn__glyph { width: 22px; height: 22px; }
.spark { position: absolute; width: 2px; height: 2px; border-radius: 1px; background: var(--ember); pointer-events: none; left: 50%; top: 50%; opacity: 0; }

/* Waveform — two stacked layers revealed by clip-path (§6) */
.wave { position: relative; height: 56px; --played: 0%; --tick: 66%; }
.wave--sm { height: 40px; }
.wave svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave__muted rect { fill: var(--wave-unplayed); }
.wave__muted .is-dim { fill: var(--wave-dim); }
.wave--room .wave__muted rect { fill: var(--surface-2); }
.wave__ember { clip-path: inset(0 calc(100% - var(--played)) 0 0); will-change: clip-path; }
.wave__ember rect { fill: var(--ember); }
.wave__tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ember-hi); left: var(--tick); pointer-events: none; }
.wave--scrub { cursor: pointer; touch-action: pan-y; }
.wave--scrub:focus-visible { outline-offset: 4px; border-radius: var(--r-4); }
@media (forced-colors: active) {
  .wave { forced-color-adjust: none; }
  .wave__muted rect, .wave--room .wave__muted rect { fill: CanvasText; }
  .wave__ember rect { fill: Highlight; }
}

/* Quota ring (13px; ember arc grows clockwise from 12 o'clock) */
.quota { display: inline-flex; align-items: center; gap: var(--s-8); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-muted); }
.ring { width: 13px; height: 13px; flex: none; transform: rotate(-90deg); }
.ring__track { fill: none; stroke: var(--surface-2); stroke-width: 2.5; }
.ring__arc { fill: none; stroke: var(--ember); stroke-width: 2.5; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--used, 0)); transition: stroke-dashoffset var(--t-std) var(--ease); }
@media (forced-colors: active) { .ring { forced-color-adjust: none; } .ring__track { stroke: CanvasText; } .ring__arc { stroke: Highlight; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: var(--s-24); z-index: 60;
  transform: translate(-50%, calc(100% + var(--s-24)));
  display: flex; align-items: center; gap: var(--s-12);
  max-width: min(480px, calc(100vw - 2 * var(--gutter)));
  padding: var(--s-12) var(--s-12) var(--s-12) var(--s-16);
  background: var(--surface-2); border-radius: var(--r-12);
  font-size: var(--fs-meta); opacity: 0;
  transition: transform var(--t-std) var(--ease), opacity var(--t-std) var(--ease);
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.toast__close { min-width: 44px; min-height: 44px; margin: -10px -8px -10px 0; background: transparent; border: 0; color: var(--text-muted); border-radius: var(--r-8); }

/* Skeleton — the one allowed loop */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-8); }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--edge-soft), transparent); animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* Spinner (download in flight) */
.spin { width: 16px; height: 16px; border-radius: var(--r-full); border: 2px solid var(--wave-unplayed); border-top-color: var(--ember); animation: spin 600ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Phone (legacy alias of .frame, kept for the hub/share pages) */
.phone { position: relative; aspect-ratio: 402 / 874; width: 100%; border-radius: var(--r-40); overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--overlay-edge); }
.phone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Status line */
.status { min-height: 1.5em; font-size: var(--fs-meta); color: var(--text-muted); }
.status--error { color: var(--danger); }
.status[aria-live] { font-variant-numeric: tabular-nums; }
