/* ============================================================
   Claude Opus Diagnostic — style.css
   Design language: a precision instrument, not a chat app.
   Think: the calm dark panel of a diagnostic scanner. One warm
   signal color (amber) for the "reading," everything else quiet.
   All colors/spacing derive from these tokens — don't hardcode new ones.
   ============================================================ */
:root {
  /* palette */
  --ink:        #0B0B0F;   /* near-black base */
  --panel:      #14141B;   /* raised surface */
  --panel-2:    #1D1D27;   /* input / secondary surface */
  --hairline:   #2A2A36;   /* dividers, borders */
  --text:       #ECECF1;   /* primary text */
  --text-dim:   #9A9AA8;   /* secondary text */
  --signal:     #F5A623;   /* amber — the diagnostic "reading" accent, used sparingly */
  --signal-dim: #7A5A1E;
  --danger:     #E5484D;   /* severe-finding red, used only inside results */
  --ok:         #3DD68C;

  /* type */
  --font-display: "Space Grotesk", system-ui, sans-serif;  /* set via @font-face or CDN in build */
  --font-body:    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    ui-monospace, "SF Mono", "Roboto Mono", monospace;

  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --radius: 16px;
  --radius-sm: 10px;

  /* safe areas for notched phones */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  overscroll-behavior: none;
}

/* ambient background image from Gemini, dimmed so UI stays readable */
.bg-layer {
  position: fixed; inset: 0;
  /* Scanner-floor hero with a LIGHT dark-scrim on top (the art is already UI-safe).
     Anchored to the bottom so the amber light-well sits low, behind the action area. */
  background-image:
    radial-gradient(120% 95% at 50% 100%, rgba(11,11,15,.20) 0%, rgba(11,11,15,.40) 78%),
    url('/assets/bg.jpg');
  background-size: cover, cover;
  background-position: center, center bottom;
  background-repeat: no-repeat, no-repeat;
  background-color: var(--ink);
  z-index: -1;
}

/* ---------- one-shot intro overlay ---------- */
.intro-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink) url('/assets/intro.jpg') center / cover no-repeat;
  opacity: 1; transition: opacity .6s ease;
}
.intro-overlay::before {                 /* readability scrim over the busy bubble art */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(85% 55% at 50% 48%, rgba(11,11,15,.5) 0%, rgba(11,11,15,.86) 100%);
}
.intro-overlay.intro-hide { opacity: 0; pointer-events: none; }
.intro-inner { position: relative; text-align: center; padding: var(--s5); }
.intro-wordmark { font-family: var(--font-display); line-height: 1.02; }
.intro-name { display: block; font-size: 44px; letter-spacing: .5px; }
.intro-name .wm-strong { font-weight: 700; color: var(--text); }
.intro-name .wm-light  { font-weight: 300; color: var(--text-dim); }
.intro-tag {
  display: block; margin-top: var(--s2);
  font-size: 13px; letter-spacing: 6px; text-transform: uppercase; color: var(--signal);
}
.intro-tagline {
  margin-top: var(--s5); font-family: var(--font-display);
  font-size: 17px; letter-spacing: .3px; color: var(--text-dim); font-weight: 500;
}
.intro-tagline .intro-amber { color: var(--signal); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .intro-overlay { transition: none; }
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + var(--s4)) var(--s5) var(--s3);
}
.wordmark { font-family: var(--font-display); font-size: 18px; letter-spacing: .3px; }
.wordmark-strong { font-weight: 700; }
.wordmark-light  { font-weight: 300; color: var(--text-dim); }
.wordmark-tag {
  display: block; font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--signal); margin-top: 2px;
}
.lang-toggle {
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--hairline);
  border-radius: 999px; padding: var(--s2) var(--s3); font-size: 12px; font-weight: 600;
}

/* ---------- main stage ---------- */
.stage {
  display: flex; flex-direction: column; gap: var(--s4);
  /* Bottom room defaults to a generous strip so the Diagnose button + result card
     always clear the pinned install banner. It COLLAPSES to normal spacing only when
     no banner is showing (JS adds body.no-banner-room). Default-on = no detection race. */
  padding: var(--s3) var(--s5) calc(var(--safe-bottom) + 160px);
  max-width: 520px; margin: 0 auto; width: 100%;
}
body.no-banner-room .stage { padding-bottom: calc(var(--safe-bottom) + var(--s6)); }
/* Physical scroll spacer — real 160px height by DEFAULT so the Diagnose button clears
   the pinned banner with a little breathing room; collapses to 0 once it's dismissed. */
.scroll-spacer { flex: 0 0 auto; height: 160px; }
body.no-banner-room .scroll-spacer { height: 0; }

/* camera viewport — the hero */
.viewport-wrap {
  position: relative; aspect-ratio: 3 / 4; width: 100%;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
#cameraFeed, #capturedFrame {
  width: 100%; height: 100%; object-fit: cover;
}
.viewport-hint {
  position: absolute; inset: auto 0 0 0; padding: var(--s4);
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  text-align: center;
}
.viewport-hint p { font-size: 14px; color: var(--text-dim); }

/* framing reticle — inline SVG over the LIVE camera to help aim; non-interactive. */
.reticle-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: .7;
  z-index: 2;
}

/* front/rear camera toggle, subtle glass button in the viewport corner */
.flip-btn {
  position: absolute; top: var(--s3); right: var(--s3); z-index: 3;
  width: 40px; height: 40px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(11,11,15,.55); color: var(--text);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.flip-btn:active { border-color: var(--signal); }

/* mirror the preview (and its freeze) when using the front camera — natural selfie view */
.viewport-wrap.cam-front #cameraFeed,
.viewport-wrap.cam-front #capturedFrame { transform: scaleX(-1); }

/* once a frame is captured, the aiming reticle and flip control are irrelevant */
.viewport-wrap:has(#capturedFrame:not([hidden])) .reticle-overlay,
.viewport-wrap:has(#capturedFrame:not([hidden])) .flip-btn { display: none; }

/* note row */
.note-row { display: flex; gap: var(--s2); align-items: center; }
.mic-btn {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--hairline); font-size: 20px;
}
.mic-btn.listening { border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-dim); }
.note-field {
  flex: 1; height: 52px; padding: 0 var(--s4); border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--hairline);
  color: var(--text); font-size: 15px;
}
.note-field::placeholder { color: var(--text-dim); }

/* the primary action */
.snap-btn {
  height: 64px; border-radius: var(--radius); border: none;
  background: var(--signal); color: #1A1205;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center; gap: var(--s3);
  transition: transform .08s ease;
}
.snap-btn:active { transform: scale(.985); }
.snap-btn:disabled { background: var(--panel-2); color: var(--text-dim); }
.snap-count { font-family: var(--font-mono); font-size: 12px; opacity: .7; font-weight: 500; }

/* result card */
.result-card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: var(--s5);
}
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display); font-size: 13px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--signal); margin-bottom: var(--s4);
}
.reset-btn {
  background: none; border: 1px solid var(--hairline); color: var(--text-dim);
  border-radius: 999px; padding: var(--s1) var(--s3); font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase;
}
.result-body { font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.result-body strong { color: var(--signal); }
.result-disclaimer {
  margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--hairline);
  font-size: 12px; color: var(--text-dim);
}

/* paywall / feedback */
.paywall-card {
  background: var(--panel); border: 1px solid var(--signal-dim);
  border-radius: var(--radius); padding: var(--s5); text-align: center;
}
.paywall-card h2 { font-family: var(--font-display); font-size: 20px; margin-bottom: var(--s3); }
.paywall-card p { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin-bottom: var(--s4); }
.pw-question label { display: block; font-size: 13px; color: var(--text); margin-bottom: var(--s3); }
.pw-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.pw-options button {
  padding: var(--s3) 0; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--hairline);
  color: var(--text); font-weight: 600; font-size: 14px;
}
.pw-options button:active { border-color: var(--signal); }
.pw-thanks { color: var(--ok); margin-top: var(--s4); font-size: 14px; }

/* install banner */
/* The rules below set `display:flex`, which would otherwise override the UA
   `[hidden]{display:none}` rule and paint the banner even when hidden. This reset
   (higher specificity: class + attribute) makes the `hidden` attribute authoritative,
   so JS toggling `.hidden` truly shows/hides the banner. */
.install-banner[hidden], .ios-hint[hidden] { display: none; }
.install-banner {
  position: fixed; left: var(--s4); right: var(--s4);
  bottom: calc(var(--safe-bottom) + var(--s4));
  background: var(--panel-2); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: var(--s3) var(--s4);
  display: flex; align-items: center; gap: var(--s3);
  font-size: 13px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.install-banner button {
  border: none; border-radius: var(--radius-sm); padding: var(--s2) var(--s4);
  font-weight: 600; font-size: 13px;
}
#installBtn { background: var(--signal); color: #1A1205; }
#installClose { background: none; color: var(--text-dim); padding: var(--s2); }

.ios-hint {
  position: fixed; left: var(--s4); right: var(--s4);
  bottom: calc(var(--safe-bottom) + var(--s4));
  background: var(--panel-2); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: var(--s4); text-align: center; font-size: 13px;
}
.ios-hint button {
  margin-top: var(--s3); background: var(--signal); color: #1A1205;
  border: none; border-radius: var(--radius-sm); padding: var(--s2) var(--s5); font-weight: 600;
}

/* loading shimmer on the snap button while analyzing */
.snap-btn.loading { position: relative; overflow: hidden; }
.snap-btn.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  animation: sweep 1.1s infinite;
}
@keyframes sweep { from { transform: translateX(-100%);} to { transform: translateX(100%);} }

@media (prefers-reduced-motion: reduce) {
  .snap-btn.loading::after { animation: none; }
  .snap-btn:active { transform: none; }
}
