/* REWIRE components. Depends on tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* Engineering grid paper */
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 100% 24px, 24px 100%;
  background-position: 0 0, 12px 0;
  background-blend-mode: normal;
}
body::before { /* fade grid so it stays a texture, never noise */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 80% at 50% 20%, rgba(243,241,236,.55), rgba(243,241,236,.9));
}
.app { position: relative; z-index: 1; padding: calc(var(--safe-top) + 12px) 18px calc(var(--safe-bottom) + 110px); }

/* ---------- Type ---------- */
.mono { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.mono.dim { color: var(--ink-3); }
.display { font-family: var(--f-display); font-weight: 400; letter-spacing: -.02em; line-height: .9; }
.display i, .display em { font-style: italic; }
.h2 { font-family: var(--f-display); font-size: 34px; line-height: 1; letter-spacing: -.015em; margin: 0; }
.h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.body-2 { font-size: 13.5px; color: var(--ink-2); }
.holo-text {
  background: var(--holo-linear); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: holo-slide 6s linear infinite;
}
@keyframes holo-slide { to { background-position: 200% 0; } }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 40px; }
.logo { font-family: var(--f-mono); font-weight: 500; font-size: 12px; letter-spacing: .32em; }
.logo b { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--holo); animation: holo-spin 4s linear infinite; margin-right: 8px; vertical-align: 1px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; background: transparent; }

/* ---------- Specimen card (hairline + registration corners) ---------- */
.spec {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px;
}
.spec::before, .spec::after {
  content: ''; position: absolute; width: 10px; height: 10px; border: 1px solid var(--ink); pointer-events: none;
}
.spec::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--r-md); }
.spec::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--r-md); }
.spec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }

/* Holo foil frame: only for wins/milestones */
.foil { position: relative; border-radius: var(--r-md); padding: 1.5px; background: var(--holo); animation: holo-spin 5s linear infinite; }
.foil > * { border-radius: calc(var(--r-md) - 1.5px); }

/* ---------- Hero counter ---------- */
.counter { display: flex; align-items: flex-end; gap: 10px; }
.counter .num { font-family: var(--f-display); font-style: italic; font-size: 112px; line-height: .78; letter-spacing: -.04em; }
.counter .unit { padding-bottom: 6px; }
.ticker { font-family: var(--f-mono); font-size: 13px; letter-spacing: .04em; }
.ticker span { color: var(--ink-3); }

/* ---------- Brain stage ---------- */
.stage { position: relative; height: 360px; margin: 6px -18px 0; }
.stage canvas { width: 100%; height: 100%; display: block; }
.stage .crosshair { position: absolute; inset: 18px; pointer-events: none; }
.stage .crosshair::before, .stage .crosshair::after { content: ''; position: absolute; background: var(--line-strong); }
.stage .crosshair::before { left: 50%; top: 0; bottom: 0; width: 1px; opacity: .35; }
.stage .crosshair::after { top: 46%; left: 0; right: 0; height: 1px; opacity: .35; }
.stage .readout { position: absolute; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .08em; color: var(--ink-3); text-transform: uppercase; }
.tag {
  position: absolute; display: flex; align-items: center; gap: 6px; padding: 5px 9px 5px 6px;
  background: rgba(251,250,247,.85); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.tag .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--holo); animation: holo-spin 3s linear infinite; }
.tag .pct { color: var(--ink-3); }

/* ---------- Upgrade bar ---------- */
.bar { height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--holo-linear); background-size: 300px 100%; }
.bar.ticks::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 9px, var(--card) 9px 10px); }

/* Region row */
.region { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px dashed var(--line-strong); }
.region:first-child { border-top: 0; }
.region .code { font-family: var(--f-mono); font-size: 10px; color: var(--ink-3); }
.region .name { font-weight: 600; font-size: 14.5px; }
.region .sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.region .val { font-family: var(--f-display); font-style: italic; font-size: 26px; }
.evidence { font-family: var(--f-mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--ink-2); }
.evidence.measured { border-color: transparent; background: var(--ink); color: var(--card); }

/* ---------- Buttons ---------- */
.btn { appearance: none; border: 0; font: 600 15px/1 var(--f-ui); border-radius: var(--r-pill); padding: 16px 20px; cursor: pointer; }
.btn-ink { background: var(--ink); color: var(--card); }
.btn-ghost { background: transparent; border: 1px solid var(--line-strong); color: var(--ink); }
.craving-btn {
  position: relative; display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: transparent; color: var(--card); border-radius: var(--r-pill); padding: 8px 8px 8px 22px; border: 0;
  font: 600 16px var(--f-ui); isolation: isolate;
}
.craving-btn::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--ink); z-index: -1; }
.craving-btn::before { /* holographic rim */
  content: ''; position: absolute; inset: -2px; border-radius: inherit; background: var(--holo); z-index: -2;
  animation: holo-spin 4s linear infinite; filter: saturate(1.2);
}
.craving-btn .go { width: 48px; height: 48px; border-radius: 50%; background: var(--signal); display: grid; place-items: center; }
.dock { position: fixed; left: 14px; right: 14px; bottom: calc(var(--safe-bottom) + 14px); z-index: 10; }

/* ---------- Chips ---------- */
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 8px 12px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); font-size: 13px; background: var(--card); }
.chip.on { background: var(--ink); color: var(--card); border-color: var(--ink); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: var(--line-strong); }
.timeline .progress-line { position: absolute; left: 6px; top: 6px; width: 3px; border-radius: 2px; background: var(--holo-linear); transform-origin: top; }
.tl-item { position: relative; padding: 0 0 26px; }
.tl-item::before { content: ''; position: absolute; left: -26px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
.tl-item.done::before { background: var(--holo); border-color: transparent; animation: holo-spin 4s linear infinite; }
.tl-item.now::before { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 0 6px rgba(255,77,26,.15); }

/* ---------- Sheets ---------- */
.sheet { background: var(--card); border-radius: 28px 28px 0 0; border-top: 1px solid var(--line-strong); padding: 10px 20px 28px; }
.grabber { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 14px; }

/* ---------- Ring ---------- */
.ring { --p: .5; width: 108px; height: 108px; border-radius: 50%; position: relative;
  background: conic-gradient(var(--h-cyan), var(--h-violet), var(--h-magenta), var(--h-mint) calc(var(--p) * 100%), var(--paper-2) 0); }
.ring::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--card); }
.ring > * { position: relative; z-index: 1; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
