/* ═══════════════════════════════════════════════
   Q Health — Shared Stylesheet  v1.0
   Link this before any screen-specific <style>.
   Screen-level overrides go in a <style> block
   below this link tag.
   ═══════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body ── */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #000;
  font-family: 'Inter', sans-serif;
}

/* ── Mobile frame (375 × 812) ── */
.mobile-screen {
  position: relative;
  width: 375px;
  height: 812px;
  border-radius: 40px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  opacity: 0;
  animation: fadeIn .8s ease-in-out .05s forwards;
  /* Prevent typing-caret / caret-browsing on static labels (tabs, copy, icons). */
  caret-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* Real fields still show a caret and allow selecting typed text. */
.mobile-screen input,
.mobile-screen textarea,
.mobile-screen select,
.mobile-screen [contenteditable="true"] {
  caret-color: auto;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
@keyframes fadeIn { to { opacity: 1; } }

/* ── Background layers ── */
.bg { position: absolute; inset: 0; background: #000; }

canvas { position: absolute; inset: 0; pointer-events: none; z-index: 1; }

/* SVG fractal-noise grain overlay */
.noise {
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .15;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 2;
}

/* ── Q corner logo — 62 px, default top used by ques_1-8 ── */
.logo-q {
  position: absolute;
  top: 100px; left: 30px;
  width: 62px; z-index: 4;
}

/* ── Content region ── */
.content {
  position: absolute;
  top: 185px; left: 30px; right: 30px;
  z-index: 3;
}

/* ── Merriweather heading (26 px default; screens override to 24 px) ── */
.heading {
  font-family: 'Merriweather', serif;
  font-size: 26px; font-weight: 700;
  color: #fff; line-height: 1.3;
}

/* ── Progress bar strip ── */
.progress-row {
  position: absolute;
  top: 48px; left: 28px; right: 28px;
  display: flex; align-items: center; gap: 14px;
  z-index: 4;
}
.back-btn {
  background: none; border: none;
  color: #fff; font-size: 24px;
  cursor: pointer; padding: 0;
  line-height: 1; opacity: .85; flex-shrink: 0;
}
.back-btn:hover { opacity: 1; }
.progress-track {
  flex: 1; height: 3px;
  background: rgba(255,255,255,.2);
  border-radius: 99px; overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 99px; }

/* ── Bottom action row (ques_1-8) ── */
.bottom-nav {
  position: absolute;
  bottom: 36px; left: 30px; right: 30px;
  display: flex; align-items: center;
  justify-content: space-between;
  z-index: 4;
}
.bottom-hint {
  font-size: 11px; color: rgba(255,255,255,.5);
  line-height: 1.5; max-width: 215px;
}

/* ── Blue next / forward button ── */
.next-btn {
  width: 50px; height: 50px;
  border-radius: 50%; background: #2563eb;
  border: none; color: #fff; font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .3s;
}
.next-btn:hover { background: #1d4ed8; }

/* ── Write / record input inner elements ── */
.write-input {
  flex: 1; background: none; border: none;
  color: rgba(255,255,255,.5);
  font-size: 14px; font-family: 'Inter', sans-serif;
}
.write-input::placeholder { color: rgba(255,255,255,.4); }
.write-input:focus { outline: none; color: #fff; }
.mic-btn {
  width: 38px; height: 38px;
  border-radius: 50%; background: rgba(255,255,255,.92);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Checkbox list (ques_8, ques_10) ── */
.check-list { display: flex; flex-direction: column; }
.check-item {
  display: flex; align-items: flex-start;
  gap: 16px; padding: 13px 0;
  cursor: pointer; user-select: none;
}
.check-item + .check-item { border-top: 1px solid rgba(255,255,255,.1); }
.checkbox {
  width: 20px; height: 20px; min-width: 20px;
  border: 1.5px solid rgba(255,255,255,.55);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  transition: background .2s, border-color .2s;
}
.checkbox.checked { background: #fff; border-color: #fff; }
.checkbox.checked::after {
  content: ''; display: block;
  width: 5px; height: 9px;
  border: 2px solid #000;
  border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
}
.check-label { font-size: 14px; font-weight: 400; color: #fff; line-height: 1.4; }

/* ── Custom select dropdown ── */
.select-wrap { position: relative; }
.custom-select {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  background: rgba(14,30,65,.8);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 50px;
  color: #fff; font-size: 14px; font-weight: 500;
  font-family: 'Inter', sans-serif;
  padding: 13px 40px 13px 20px;
  cursor: pointer;
}
.custom-select:focus { outline: none; border-color: rgba(255,255,255,.5); }
.custom-select option { background: #0a1428; color: #fff; }
.select-arrow {
  position: absolute; right: 16px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #fff; font-size: 11px; opacity: .75;
}

/* ── Word-by-word reveal (personalizing, completion) ── */
.w {
  display: inline-block;
  opacity: 0; transform: translateY(7px);
  transition: opacity .35s ease, transform .35s ease;
}
.w.show { opacity: 1; transform: translateY(0); }
.w + .w { margin-left: 6px; }

/* Punctuation-aware end energy on the final revealed word (speakReveal) */
.w-lift { transform: translateY(-2px) scale(1.05); }
.w-fall { opacity: .88; }

/* ══════════════════════════════════════════════
   SHARED COMPONENTS — post-onboarding screens
   ══════════════════════════════════════════════ */

/* ── Bottom tab bar ── */
.tab-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 68px;
  background: #0a0a0a;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; z-index: 5;
  view-transition-name: tab-bar; /* anchors tab bar during cross-doc transitions */
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; padding-bottom: 4px;
  -webkit-user-select: none; user-select: none;
  caret-color: transparent;
}
.tab-icon { width: 22px; height: 22px; pointer-events: none; }
.tab-label {
  font-size: 10px; font-weight: 500; letter-spacing: .01em;
  pointer-events: none;
}
.tab .tab-icon, .tab .tab-label { color: #2dd4bf; }
.tab.active .tab-icon, .tab.active .tab-label { color: #a855f7; }
.tab.active { pointer-events: none; cursor: default; }

/* ── Section label (deep_q, profile) ── */
.section-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 600;
  color: #2dd4bf; letter-spacing: .1em;
  text-transform: uppercase;
  margin: 18px 0 8px 2px;
}

/* ── Mic hold-to-record ── */
.ask-mic {
  transition: transform .22s cubic-bezier(.34,1.56,.64,1);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.ask-mic.recording {
  transform: scale(1.72);
  animation: micPulse 1s ease-out infinite;
}
@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0   rgba(255,255,255,.4),  0 0 0 0   rgba(255,255,255,.18); }
  70%  { box-shadow: 0 0 0 11px rgba(255,255,255,0),  0 0 0 20px rgba(255,255,255,0);  }
  100% { box-shadow: 0 0 0 0   rgba(255,255,255,0),   0 0 0 0   rgba(255,255,255,0);   }
}
/* Animate the waveform bars individually */
.ask-mic.recording svg rect {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: micBar .5s ease-in-out infinite alternate;
}
.ask-mic.recording svg rect:nth-child(1) { animation-delay: .00s; }
.ask-mic.recording svg rect:nth-child(2) { animation-delay: .09s; }
.ask-mic.recording svg rect:nth-child(3) { animation-delay: .18s; }
.ask-mic.recording svg rect:nth-child(4) { animation-delay: .09s; }
.ask-mic.recording svg rect:nth-child(5) { animation-delay: .00s; }
@keyframes micBar {
  from { transform: scaleY(.25); }
  to   { transform: scaleY(1);   }
}

/* ── View-transition keyframes ── */
@keyframes vt-out { to   { opacity: 0; } }
@keyframes vt-in  { from { opacity: 0; } }

/* ── Progress bar view transitions (question screens ques_1–8) ──
   Track is anchored (same bar); fill morphs width+color (liquid). */
.progress-row .back-btn { view-transition-name: question-back; }
.progress-track         { view-transition-name: progress-track; }

/* Back button stays pixel-perfect still; track cross-fades with fill inside */
::view-transition-old(question-back),
::view-transition-new(question-back) { animation: none; }

::view-transition-group(progress-track) {
  animation-duration: 220ms;
  animation-timing-function: ease;
}

/* Root crossfade used by all @view-transition screens
   (app screens re-declare these in local style with same values) */
::view-transition-old(root) { animation: 160ms ease-in  vt-out; }
::view-transition-new(root) { animation: 160ms ease-out vt-in;  }
