/* =========================================================================
   The Drive Force Diagnostic - Claude Design handoff implementation.
   Tokens: ink #1A1A2E / deep #14142A / panel #232338 / accent #C0392B /
   accent-hi #E74C3C / paper #F7F5F0 / muted #8A8AA0 / curve #4A4A5E
   Type: Archivo Black display · Archivo UI · Georgia body · IBM Plex Mono labels
   ========================================================================= */

:root {
  --ink: #1A1A2E;
  --deep: #14142A;
  --panel: #232338;
  --border: #34344c;
  --track: #2a2a42;
  --accent: #C0392B;
  --accent-hi: #E74C3C;
  --paper: #F7F5F0;
  --body-dim: #b8b8c8;
  --muted: #8a8aa0;
  --faint: #6b6b84;
  --curve: #4A4A5E;
  --den-dim: #7a3d4a;
  --display: 'Archivo Black', 'Arial Black', Arial, sans-serif;
  --ui: Archivo, Arial, Helvetica, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--deep);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

main {
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  background: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 520px) {
  main {
    box-shadow: 0 6px 32px rgba(0, 0, 0, 0.5);
  }
}

.screen { animation: rise 0.4s ease both; flex: 1; display: flex; flex-direction: column; }
.pad { padding: 28px 28px 30px; display: flex; flex-direction: column; flex: 1; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Shared type utilities ---------- */

.mono, .mono-label, .mono-micro { font-family: var(--mono); }

.mono-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
}

.mono-micro {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  line-height: 1.7;
}

.mono-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.red { color: var(--accent); }
.center { text-align: center; }

/* ---------- Screen 1: Goal ---------- */

.topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 4px;
}

.m-mark {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 800;
  color: var(--accent-hi);
}

.parabola {
  width: 100%;
  height: 88px;
  margin: 26px 0 8px;
}

h1 {
  font-family: var(--display);
  font-weight: normal;
  font-size: 27px;
  line-height: 1.08;
  color: var(--paper);
  margin-top: 10px;
}

h1 .red { color: var(--accent); }

.lede {
  font-size: 15px;
  line-height: 1.55;
  color: var(--body-dim);
  margin-top: 16px;
}

#goal-form { display: flex; flex-direction: column; margin-top: 44px; }

.field-label {
  font-family: var(--ui);
  font-size: 16px;
  font-weight: 700;
  color: var(--paper);
  margin-top: 8px;
  line-height: 1.35;
}

input[type="text"], input[type="email"] {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--paper);
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  padding: 15px 16px;
  margin-top: 14px;
  caret-color: var(--accent);
}

input::placeholder { color: var(--faint); }

input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-error { color: var(--accent-hi); font-size: 13px; font-family: var(--serif); margin-top: 8px; }

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--ui);
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 14px;
  color: var(--paper);
  border: none;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s ease;
  text-transform: uppercase;
}

.btn-primary { background: var(--accent); margin-top: 14px; }
.btn-primary:hover { background: var(--accent-hi); }
.btn-arrow::after { content: " \2192"; }

.btn-square {
  flex: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 14px 18px;
  margin-top: 14px;
}
.btn-square:hover { border-color: var(--muted); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 11px 6px;
  border-radius: 6px;
}
.btn-ghost:hover { border-color: var(--muted); }

.btn-send { margin-top: 0; padding: 11px 16px; font-size: 12px; letter-spacing: 0.08em; border-radius: 6px; }

.btn-text {
  background: none;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-decoration: underline;
  padding: 8px;
  margin-top: 10px;
}
.btn-text:hover { color: var(--paper); }

.btn:focus-visible, .switch:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
}

.rule-foot {
  border-top: 1px solid var(--track);
  margin-top: 34px;
  padding-top: 14px;
  display: flex;
  justify-content: center;
  text-align: center;
}

.center-col { flex-direction: column; align-items: center; gap: 6px; }

.mono-buy {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-decoration: none;
}
.mono-buy::after { content: " \2192"; }
.mono-buy:hover { color: var(--accent-hi); }

/* ---------- Goal header bar (screens 2-4) ---------- */

.goal-bar {
  background: var(--deep);
  border-bottom: 1px solid var(--track);
  padding: 12px 26px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.goal-bar-row { display: flex; justify-content: space-between; align-items: baseline; }

.goal-bar-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--paper);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segments { display: flex; gap: 3px; margin-top: 2px; }
.segments span { flex: 1; height: 3px; background: var(--track); transition: background 0.3s ease; }
.segments span.done { background: var(--accent); }

/* ---------- Equation hero (scoring) ---------- */

.eq {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--body-dim);
  padding: 14px 0 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.eq-m { font-size: 22px; color: var(--paper); }

.frac { display: inline-flex; flex-direction: column; align-items: center; }
.frac .num { font-size: 15px; padding: 0 8px 3px; }
.frac .den { border-top: 1.5px solid var(--curve); font-size: 15px; padding: 3px 8px 0; }

.av-frac .num, .av-frac .den { font-size: 13px; padding-left: 6px; padding-right: 6px; }
.av-frac sub, .frac sub { font-size: 9px; font-style: normal; }

.eq .plus { font-size: 15px; color: #565670; font-style: normal; }
.eq .x { color: #565670; }

.eq [data-avpart] { opacity: 0.35; transition: opacity 0.3s ease; }
.eq.av-live [data-avpart] { opacity: 1; }
.eq.av-off [data-avpart] { display: none; }

.eq .var { transition: color 0.2s ease, font-size 0.2s ease; }

.eq .var.active {
  color: var(--accent);
  font-weight: 900;
  font-style: normal;
  font-family: var(--display);
  font-size: 1.55em;
}

/* ---------- Variable block ---------- */

.var-block { display: flex; flex-direction: column; }

.var-head { display: flex; align-items: baseline; gap: 12px; margin-top: 36px; }

.var-name {
  font-family: var(--display);
  font-size: 24px;
  color: var(--paper);
  line-height: 1.05;
}

.var-symbol { font-size: 12px; color: var(--accent); }

.role-flag { display: flex; align-items: center; gap: 7px; margin-top: 10px; }
.role-dot { width: 6px; height: 6px; background: var(--paper); flex: none; }
.role-flag.den .role-dot { background: var(--accent); }
.role-flag.den .mono-micro { color: var(--accent-hi); }

.var-question {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--body-dim);
  margin-top: 12px;
}

/* ---------- Readout + slider ---------- */

.readout { display: flex; align-items: baseline; gap: 6px; margin-top: 22px; }

.readout-value {
  font-family: var(--display);
  font-size: 44px;
  color: var(--paper);
  line-height: 1;
}

.den-mode .readout-value { color: var(--accent-hi); }

.readout-max { font-size: 13px; color: var(--muted); }

.slider-wrap { position: relative; height: 36px; margin-top: 8px; display: flex; align-items: center; }

input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--track);
  outline: none;
  margin: 0;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 10px rgba(192, 57, 43, 0.5);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 10px rgba(192, 57, 43, 0.5);
  cursor: pointer;
}

input[type="range"]:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 4px; }

.slider-scale { display: flex; justify-content: space-between; margin-top: 2px; }

/* ---------- Anchors ---------- */

.anchors { display: flex; flex-direction: column; gap: 11px; margin-top: 26px; }

.anchor {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  opacity: 0.38;
  transition: opacity 0.2s ease, background 0.2s ease;
  padding: 0;
}

.anchor .range { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.anchor .label { font-family: var(--serif); font-size: 13px; color: var(--body-dim); }

.anchor.active { opacity: 1; }
.anchor.active .range { color: var(--accent); font-weight: 600; }
.anchor.active .label { color: var(--paper); font-size: 14px; }

.den-mode .anchor.active {
  background: rgba(192, 57, 43, 0.08);
  padding: 9px 10px;
  margin: -9px -10px;
}

/* ---------- N/A toggle ---------- */

.na-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px 14px;
  margin-top: 16px;
  gap: 12px;
}

.na-text { font-family: var(--serif); font-size: 13px; color: var(--paper); line-height: 1.4; }

.switch {
  width: 44px;
  height: 26px;
  background: var(--track);
  border: none;
  border-radius: 13px;
  flex: none;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  background: var(--paper);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.slider-zone.dimmed { opacity: 0.3; pointer-events: none; }

.na-off { margin-top: 14px; }

.na-divider { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.na-divider .line { flex: 1; height: 1px; background: var(--border); }
.na-divider .mono-micro { letter-spacing: 0.16em; color: var(--muted); }

.na-note {
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.5;
}

.score-nav { display: flex; gap: 10px; margin-top: 32px; }
.score-nav .btn-primary { flex: 1; font-size: 13px; }

/* ---------- Screen 3: Diagnosis ---------- */

.shared-note {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.eq-result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--paper);
  padding: 22px 0 6px;
  white-space: nowrap;
  flex-wrap: wrap;
}

.eq-result .m-eq { font-size: 24px; }
.eq-result .frac .num { font-size: 19px; padding: 0 10px 4px; }
.eq-result .frac .den { font-size: 19px; padding: 4px 10px 0; }
.eq-result .plus { font-size: 19px; color: #565670; font-style: normal; }

.eq-result .hot {
  color: var(--accent-hi);
  font-weight: 900;
  font-style: normal;
  font-family: var(--display);
  border-bottom: 2px solid var(--accent);
}

/* ---------- Score profile bars ---------- */

.profile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 26px;
  border-top: 1px solid var(--track);
  padding-top: 22px;
}

.prow {
  display: grid;
  grid-template-columns: 34px 1fr 26px;
  gap: 10px;
  align-items: center;
}

.prow .sym { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.prow .num { font-family: var(--mono); font-size: 11px; color: var(--body-dim); text-align: right; }

.prow .bar { height: 10px; background: var(--track); position: relative; }
.prow .bar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--paper); }

.prow.den .bar span { background: var(--den-dim); }
.prow.target .sym, .prow.target .num { color: var(--accent-hi); font-weight: 600; }
.prow.target .bar span { background: var(--accent); }
.prow.na { opacity: 0.35; }
.prow.na .bar {
  background: repeating-linear-gradient(45deg, var(--track), var(--track) 8px, var(--panel) 8px, var(--panel) 16px);
}

/* ---------- Break card + cascade ---------- */

.break-card {
  margin-top: 32px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
}

.break-head { background: var(--accent); padding: 8px 16px; }
.break-head .mono-micro { color: var(--paper); letter-spacing: 0.22em; font-size: 10px; }

.break-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; }

.break-name {
  font-family: var(--display);
  font-size: 28px;
  color: var(--paper);
  line-height: 1;
}

.break-quote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--paper);
  line-height: 1.45;
}

.diag-body {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.55;
  color: var(--body-dim);
  margin-top: 14px;
}

.cascade {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cascade .mono-micro { letter-spacing: 0.18em; color: var(--muted); }
.cascade .mono-micro.red { color: var(--accent-hi); }

.cascade p {
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.55;
  color: var(--body-dim);
}

#btn-to-rx { margin-top: 20px; font-size: 13px; }

/* ---------- Screen 4: Prescription ---------- */

.rx-card {
  background: var(--paper);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  color: var(--ink);
}

.rx-topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--ui);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.rx-rule { height: 1px; background: var(--ink); margin: 7px 0 12px; }

.rx-protocol {
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.32em;
  color: var(--accent);
}

.rx-name {
  font-family: var(--display);
  font-size: 21px;
  color: var(--ink);
  margin-top: 5px;
  line-height: 1.05;
}

.rx-eqbox {
  border: 1px solid var(--ink);
  display: flex;
  align-items: stretch;
  margin: 14px 0 12px;
}

.rx-eq {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 6px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
}

.rx-eq .m-eq { font-size: 18px; }
.rx-eq .frac .num { font-size: 14px; padding: 0 8px 3px; }
.rx-eq .frac .den { border-top: 1.25px solid var(--ink); font-size: 14px; padding: 3px 8px 0; }
.rx-eq .plus { font-size: 14px; font-style: normal; color: var(--ink); }
.rx-eq sub { font-size: 9px; font-style: normal; }

.rx-eq .hot {
  color: var(--accent);
  font-weight: 900;
  font-style: normal;
  font-size: 1.2em;
  border-bottom: 2px solid var(--ink);
}

.rx-target {
  width: 128px;
  border-left: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 10px;
  gap: 3px;
}

.rx-target-label {
  font-family: var(--ui);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.rx-target-note {
  font-family: var(--serif);
  font-style: italic;
  font-size: 9.5px;
  line-height: 1.4;
}

.rx-today-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0 12px;
  border-top: 1px solid var(--ink);
  padding: 9px 0 10px;
}

.rx-today-lead {
  font-family: var(--ui);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1.7;
}

.rx-today {
  font-family: var(--serif);
  font-size: 12.5px;
  line-height: 1.5;
}

.rx-mantra {
  border-top: 1px solid var(--ink);
  text-align: center;
  padding: 10px 0 4px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
}

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

.email-gate {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 18px;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.email-heading {
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 700;
  color: var(--paper);
  line-height: 1.4;
}

.email-row { display: flex; gap: 8px; }
.email-row input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  background: var(--ink);
  border-radius: 6px;
  padding: 11px 12px;
  font-size: 13px;
}

.email-msg { font-family: var(--serif); font-size: 13px; margin-top: 10px; }
.email-msg.ok { color: #7fbf8e; }
.email-msg.err { color: var(--accent-hi); }

/* ---------- Share block ---------- */

.share-block {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#share-preview {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
}

.share-btns { display: flex; gap: 8px; }
.share-btns .btn { flex: 1; }

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}
