/* The demo borrows the landing page's light palette and type pairing rather than importing
   landing-light.css: that file is written against the marketing page's markup (#top, .hero, nav)
   and pulling it in here would drag half a landing page's rules over a product screen. The tokens
   below are the same values, so the two surfaces stay visually one product. */

:root {
  --awaira-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  --awaira-sans: "Familjen Grotesk", "Avenir Next", "Segoe UI", sans-serif;

  --accent: #a976ac;
  --accent-strong: #8b568d;
  --bg: #fcf8ed;
  --surface: #fffefe;
  --line: rgba(58, 47, 57, 0.12);
  --text: #34343d;
  --muted: #676571;
  --soft: #8f8792;

  /* The head map's three intensity bands, straight from TouchZonesCard.swift. */
  --zone-high: #fc8434;
  --zone-medium: #16c795;
  --zone-low: #0059e9;

  --radius: 14px;
}

* { box-sizing: border-box; }

/* The browser's own `[hidden] { display: none }` lives in the user-agent stylesheet, and *any*
   author rule beats it — so the moment a class here says `display: grid`, the element's `hidden`
   attribute stops doing anything. Half this page is toggled through `hidden` (the gate, the status
   strip, the cue), so it is declared once here, loudly, instead of being remembered at every
   `display` further down. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--awaira-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- header --- */

.demo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(252, 248, 237, 0.92);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-family: var(--awaira-display);
  font-weight: 650;
  font-size: 1.25rem;
  letter-spacing: -0.05em;
}
.brand img { border-radius: 9px; }

.header-right { display: flex; align-items: center; gap: 12px; }

/* The camera feed is never shown. It is hidden by clipping it to a pixel rather than with `hidden`
   or `display: none`, because a video element that is not rendered is allowed to stop decoding
   frames — and those frames are the only thing the detector reads. Out of flow, so it takes up no
   room in the header. */
.preview {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.preview video { width: 100%; height: 100%; display: block; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.84rem;
  color: var(--muted);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2f9e6f;
  box-shadow: 0 0 0 3px rgba(47, 158, 111, 0.16);
}
.status-pill.is-paused .status-dot { background: var(--soft); box-shadow: none; }
.status-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px;
  padding: 4px 12px;
  background: rgba(169, 118, 172, 0.12);
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 0.82rem;
}
.status-toggle-icon { width: 9px; height: 10px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.status-pill.is-paused .status-toggle-icon {
  border: 0;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.header-cta {
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--accent-strong);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
}

/* ------------------------------------------------------------------ gate --- */

.gate { display: grid; place-items: center; padding: clamp(28px, 7vw, 80px) 20px; }
.gate-card {
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 44px);
  box-shadow: 0 24px 60px rgba(58, 47, 57, 0.07);
}
.gate-card h1 {
  font-family: var(--awaira-display);
  font-weight: 600;
  letter-spacing: -0.045em;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1.05;
}
.gate-lede { margin-top: 12px; color: var(--muted); line-height: 1.55; }
.gate-points { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.gate-points li {
  padding-left: 22px;
  position: relative;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.94rem;
}
.gate-points li::before {
  content: "";
  position: absolute; left: 0; top: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}
.gate-points strong { color: var(--text); font-weight: 600; }
.gate-start {
  margin-top: 26px;
  width: 100%;
  padding: 14px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}
.gate-start:disabled { opacity: 0.6; cursor: progress; }
.gate-note { margin-top: 12px; text-align: center; color: var(--soft); font-size: 0.86rem; min-height: 1.2em; }
.gate-note.is-error { color: #b4462f; }

/* ------------------------------------------------------- detection check --- */

/* The four screens between the camera starting and the Today screen. Same card as the gate, so the
   two read as one flow; the preview tile is the app's dark rectangle, because a light frame around
   a webcam picture looks like a mistake. */

.check { display: grid; place-items: center; padding: clamp(20px, 5vw, 56px) 20px; }
.check-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(22px, 4vw, 34px);
  box-shadow: 0 24px 60px rgba(58, 47, 57, 0.07);
  text-align: center;
}
.check-counter {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
}
.check-card h1 {
  margin-top: 8px;
  font-family: var(--awaira-display);
  font-weight: 600;
  letter-spacing: -0.045em;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  line-height: 1.1;
}
.check-lede { margin-top: 10px; color: var(--muted); line-height: 1.55; font-size: 0.95rem; }

.check-preview {
  position: relative;
  margin-top: 18px;
  /* Replaced with the camera's real ratio once the metadata arrives, so the video fills the tile
     exactly — that is what lets the head box be positioned in plain normalized percentages. */
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: #12131a;
}
.check-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Selfie view. The pixels the detector reads are never mirrored — only this picture is — so every
     normalized x from the engine has to be flipped before it is drawn over it. */
  transform: scaleX(-1);
}
.check-box {
  position: absolute;
  border: 3px solid #4a84fa;
  border-radius: 10px;
  transition: border-color .12s ease-out;
  pointer-events: none;
}
.check-box.is-caught { border-color: #ff4d3d; }
.check-flag {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ff4d3d;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.check-status {
  position: absolute;
  top: 10px; left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.72rem;
  font-weight: 600;
}
.check-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.6); }
.check-dot.is-active { background: #3ccb7a; }
.check-dot.is-looking { background: #fab84d; }
.check-bubble {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  padding: 9px 15px;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.check-summary { margin: 18px 0 0; padding: 0; list-style: none; text-align: left; }
.check-summary li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 4px 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.check-summary li:last-child { border-bottom: 0; }
.check-summary strong { font-weight: 600; font-size: 0.95rem; }
.check-row-sub { grid-column: 2; color: var(--soft); font-size: 0.82rem; }
.check-mark {
  grid-row: span 2;
  align-self: start;
  width: 20px; height: 20px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--line);
}
/* A check that passed gets the tick; one that was skipped stays an empty ring and says so. */
.check-summary li.is-passed .check-mark {
  border-color: #16a05e;
  background: #16a05e url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/14px no-repeat;
}
.check-summary li:not(.is-passed) strong { color: var(--muted); }

.check-hint {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(169, 118, 172, 0.06);
}
.check-hint-icon {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: rgba(169, 118, 172, 0.16);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}
.check-hint strong { font-size: 0.95rem; font-weight: 600; }
.check-hint p { margin-top: 3px; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }

.check-hear {
  margin-top: 14px;
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(169, 118, 172, 0.16);
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 600;
}

.check-actions { display: flex; gap: 12px; margin-top: 22px; }
.check-back {
  padding: 13px 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.check-next {
  flex: 1;
  padding: 13px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}
.check-skip { margin-top: 14px; }

/* ------------------------------------------------------------------ main --- */

.demo-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 34px) clamp(16px, 4vw, 40px) 120px;
}

.greeting { margin-bottom: 20px; }
.greeting h1 {
  font-family: var(--awaira-display);
  font-weight: 600;
  letter-spacing: -0.045em;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
}
.greeting p { color: var(--soft); margin-top: 4px; font-size: 0.95rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head.stacked { display: block; }
.card-head h2 { font-size: 1.05rem; font-weight: 600; }
.card-sub { color: var(--soft); font-size: 0.86rem; margin-top: 3px; }

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

/* --------------------------------------------------------------- glance --- */

.glance { margin-bottom: 16px; }
.glance-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 14px; }
.glance-tile { padding-right: 24px; }
.glance-tile + .glance-tile { border-left: 1px solid var(--line); padding-left: 28px; padding-right: 0; }
.tile-label { font-size: 0.72rem; letter-spacing: 0.09em; font-weight: 600; color: var(--muted); }
.tile-value {
  font-family: var(--awaira-display);
  font-size: clamp(2.4rem, 6vw, 3.2rem);
  line-height: 1.05;
  color: var(--accent-strong);
  margin-top: 6px;
}
.tile-suffix { font-size: 0.42em; color: var(--accent); margin-left: 2px; }
.tile-delta { margin-top: 8px; font-size: 0.78rem; color: var(--soft); min-height: 1.1em; }
.tile-delta.is-down { color: #2f9e6f; }
.tile-delta.is-up { color: #b4462f; }

/* ----------------------------------------------------------------- grid --- */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 880px) { .grid { grid-template-columns: 1fr; } .glance-row { grid-template-columns: 1fr; } .glance-tile + .glance-tile { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 16px; margin-top: 16px; } }

/* ------------------------------------------------------------ head map --- */

.mirror-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
}
.mirror-toggle.is-on {
  color: var(--accent);
  background: rgba(169, 118, 172, 0.12);
  border-color: rgba(169, 118, 172, 0.62);
}

.zones-body { display: flex; align-items: center; gap: 18px; }
.head-map { position: relative; width: 150px; flex: 0 0 auto; }
.head-map img { width: 100%; display: block; filter: drop-shadow(0 4px 9px rgba(0, 0, 0, 0.34)); }
.head-pins { position: absolute; inset: 0; }
.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 3px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
}
.pin.is-high { background: color-mix(in srgb, var(--zone-high) 78%, transparent); }
.pin.is-medium { background: color-mix(in srgb, var(--zone-medium) 78%, transparent); }
.pin.is-low { background: color-mix(in srgb, var(--zone-low) 78%, transparent); }
.zones-key { font-size: 0.84rem; color: var(--soft); line-height: 1.5; min-width: 125px; }
.zones-key strong { color: var(--text); font-weight: 600; }
@media (max-width: 520px) { .zones-body { flex-direction: column; align-items: flex-start; } }

/* ---------------------------------------------------------------- chart --- */

.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.segmented button {
  border: 0; background: transparent; border-radius: 7px;
  padding: 5px 11px; font-size: 0.8rem; color: var(--muted);
}
.segmented button.is-on { background: var(--accent-strong); color: #fff; font-weight: 600; }

.chart-body { height: 190px; }
.chart-body svg { width: 100%; height: 100%; display: block; }
.chart-axis { fill: rgba(52, 52, 61, 0.62); font-size: 10px; }
/* The peak annotation carries the same amber as the bars it names. */
.chart-peak { fill: #fe6400; font-size: 12px; font-weight: 600; }

/* -------------------------------------------------------------- context --- */

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .chips { grid-template-columns: repeat(2, 1fr); } }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 9px 12px;
  color: var(--soft);
  font-size: 0.86rem;
  transition: color .12s, border-color .12s, background .12s;
}
.context.is-live .chip { color: var(--text); border-color: rgba(119, 82, 116, 0.28); }
.context.is-live .chip:hover { background: rgba(169, 118, 172, 0.09); border-color: var(--accent); }
.chip:disabled { cursor: default; }

/* Solid blue with a tick when chosen — the app's own selected state, colour included.
   Written with the same three classes as the `.context.is-live .chip` rule above, because that one
   sets the colour too and would otherwise win on specificity and leave dark text on blue. */
.chip.is-selected,
.context.is-live .chip.is-selected,
.context.is-live .chip.is-selected:hover {
  background: #0f4ece;
  border-color: #0f4ece;
  color: #fff;
  font-weight: 600;
}
.chip.is-selected::after { content: " ✓"; }

.save-trigger {
  margin-top: 14px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}
.save-trigger:disabled { color: rgba(52, 52, 61, 0.28); cursor: default; }

.note-row { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: var(--soft); font-size: 0.86rem; }
.context.is-live .note-row { color: var(--muted); cursor: pointer; }
.note-field { margin-top: 10px; }
.note-field input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 0.9rem;
}

/* ------------------------------------------------------------- happened --- */

.happened-body { display: grid; gap: 8px; min-height: 120px; align-content: start; }
.empty { color: var(--soft); font-size: 0.86rem; }
.happened-total { color: rgba(52, 52, 61, 0.66); font-size: 0.82rem; margin-bottom: 2px; }

/* The ranked breakdown from HappenedRingsView: rank, topic, a bar scaled against the largest row,
   and the share. Fixed rank and share columns so the bar is the only thing that flexes. */
.happened-row {
  display: grid;
  grid-template-columns: 16px 94px minmax(52px, 1fr) 38px;
  gap: 10px;
  align-items: center;
  font-size: 0.82rem;
  color: rgba(52, 52, 61, 0.84);
}
.happened-head { font-size: 0.7rem; color: rgba(52, 52, 61, 0.55); }
.col-topic { display: flex; align-items: center; gap: 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.col-topic i { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.col-bar { height: 8px; border-radius: 999px; background: rgba(52, 52, 61, 0.08); overflow: hidden; }
.col-bar b { display: block; height: 100%; border-radius: 999px; }
.col-share { text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- footnote --- */

.demo-footnote {
  margin-top: 22px;
  color: var(--soft);
  font-size: 0.84rem;
  line-height: 1.55;
}
.demo-footnote a, .linkish {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none; border: 0; padding: 0; font-size: inherit;
}

/* ---------------------------------------------------------- status strip --- */

.status-strip {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: clamp(20px, 6vw, 64px);
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(252, 248, 237, 0.94);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  z-index: 15;
}
.strip-stat { display: flex; flex-direction: column; gap: 2px; }
.strip-stat strong { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.strip-stat span { font-size: 0.78rem; color: var(--soft); }

/* ------------------------------------------------------------------- cue --- */

.cue {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  /* The cue is a nudge, not a modal: Pause has to stay clickable underneath it. */
  pointer-events: none;
  background: rgba(252, 248, 237, 0.55);
  backdrop-filter: blur(14px);
  animation: cue-in .22s ease-out;
}
/* The app's own treatment: the product sans at 30pt semibold, centred, dark on the light frost —
   not the editorial serif, and not wrapped into a narrow column. See ScreenBlurOverlay.addLabel. */
.cue p {
  font-family: var(--awaira-sans);
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  padding: 0 32px;
  line-height: 1.3;
}
@keyframes cue-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cue { animation: none; } }

.toast {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  box-shadow: 0 10px 30px rgba(58, 47, 57, 0.22);
}

/* --------------------------------------------------------------- desktop --- */

/* The detectors want a desktop CPU and the layout wants two columns; a phone gets the honest
   version — "open this on your computer" — instead of a cramped one that drains the battery. */
body.is-mobile .gate-points,
body.is-mobile .gate-start { display: none; }
body.is-mobile .gate-note { color: var(--muted); font-size: 0.95rem; text-align: left; line-height: 1.55; margin-top: 20px; }
