/*
 * Design system transcribed from the brief's interactive prototype.
 *
 * The prototype defines its tokens twice: a first :root, then a "Modern
 * document system" block that overrides most of them. The later values are the
 * ones it actually renders with, and those are the ones used here.
 *
 * Each assessment carries its own palette. Pages set .theme-business or
 * .theme-life on <body>, which rebinds --theme and --theme-accent; components
 * below refer only to those two, so nothing needs a per-quiz rule.
 */

:root {
  --cream: #f6f4ef;
  --paper: #fffefa;
  --ink: #20242a;
  --muted: #646a70;
  --border: #dcdedb;

  --business: #122d4c;
  --business-accent: #b78942;
  --life: #2d4a3a;
  --life-accent: #5f4832;

  --danger: #9a382f;
  --success: #2f6348;
  --pending-bg: #f3ebdc;
  --pending-border: #d9c8a9;
  --pending-ink: #744b16;

  --shadow: 0 24px 70px rgba(18, 45, 76, 0.12);
  --card-shadow: 0 18px 45px rgba(31, 43, 55, 0.08);
  --radius: 8px;

  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --content: 1060px;
  --reading: 68ch;

  /* Default theme, overridden per assessment. */
  --theme: var(--business);
  --theme-accent: var(--business-accent);
}

.theme-business {
  --theme: var(--business);
  --theme-accent: var(--business-accent);
}

.theme-life {
  --theme: var(--life);
  --theme-accent: var(--life-accent);
}

/* ------------------------------------------------------------------ base */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #f1f2ef;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.65em;
  font-family: var(--serif);
  /* The mockup renders in Georgia, where 600 is synthesised to a heavy bold.
     Playfair Display at 600 is much lighter, so 700 is what matches what the
     client actually saw on screen. */
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

p {
  max-width: var(--reading);
  margin: 0 0 1rem;
}

a {
  color: var(--theme);
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: 3px solid var(--theme-accent);
  outline-offset: 3px;
}

/*
 * Headings and legends are given tabindex="-1" and focused after each screen
 * renders, so assistive tech announces the new question rather than leaving the
 * reading position at the top of the document.
 *
 * They are not interactive, so they must not show a focus ring. Without this
 * the question text sits inside a gold outline that reads as a border. Real
 * controls are unaffected: nothing interactive here uses tabindex="-1".
 */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
  outline: none;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-160%);
  color: #fff;
  background: var(--theme);
  padding: 0.65rem 1rem;
  border-radius: 6px;
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------- shell */

.screen {
  padding: clamp(1.5rem, 5vw, 4.5rem) clamp(1.15rem, 4vw, 2rem);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--content);
  margin: 0 auto 3.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #cfd3d5;
}

.site-brand {
  color: var(--theme);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-header nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--theme);
}

.site-footer {
  max-width: var(--content);
  margin: 4rem auto 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid #cfd3d5;
  color: var(--muted);
  font-size: 0.78rem;
}

/* --------------------------------------------------------------- buttons */

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  color: #fff;
  background: var(--theme);
}

.button-primary:hover:not(:disabled) {
  filter: brightness(0.88);
}

.button-paper {
  color: var(--ink);
  background: #fff;
  border-color: var(--border);
}

.button-paper:hover:not(:disabled) {
  background: #f7f7f5;
}

.button-gold {
  color: #24190a;
  background: #d2aa6d;
}

.button-gold:hover:not(:disabled) {
  background: #c49a5c;
}

.text-button {
  min-height: 44px;
  border: 0;
  color: var(--theme);
  background: transparent;
  padding: 0.55rem 0.25rem;
  cursor: pointer;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* ------------------------------------------------------------ pending box */

.pending {
  display: block;
  margin: 0.5rem 0;
  padding: 0.75rem 0.85rem;
  color: var(--pending-ink);
  background: var(--pending-bg);
  border: 1px solid var(--pending-border);
  border-radius: 4px;
  font-size: 0.86rem;
}

.pending-label {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.pending-text {
  color: var(--ink);
}

/* Privacy summary and terms under the consent box at intake. */
.intake-policies {
  margin: 0.25rem 0 1rem;
}

.intake-policies p {
  margin: 0.5rem 0;
}

.intake-policies .pending-link {
  margin-top: 0.4rem;
}

/* ------------------------------------------------------------------ home */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: clamp(2.5rem, 7vw, 7rem);
  align-items: center;
  max-width: var(--content);
  margin: 0 auto;
}

.home-copy h1 {
  max-width: 14ch;
  font-size: clamp(2.4rem, 4.5vw, 4rem);
  line-height: 1.05;
}

.home-copy > p {
  max-width: 34ch;
  color: var(--muted);
  font-size: 0.98rem;
}

.choice-stack {
  display: grid;
  gap: 1rem;
}

.choice-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 210px;
  padding: 1.5rem 1.5rem 1.35rem;
  border-radius: var(--radius);
  color: #fff;
}

.choice-card h2 {
  margin: 0 0 0.35rem;
  color: #fff;
  font-size: 1.65rem;
}

.choice-card p {
  margin: 0;
  max-width: 28ch;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.84rem;
  line-height: 1.45;
}

.choice-card .assessment-meta {
  margin: 0.65rem 0 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.choice-card .button {
  align-self: flex-start;
  margin-top: auto;
  min-width: 11rem;
}

.choice-business {
  background: var(--business);
}

.choice-life {
  background: var(--life);
}

/* ----------------------------------------------------------------- forms */

.form-head {
  max-width: 680px;
  margin: 0 auto 2.5rem;
  text-align: center;
}

.form-head h1 {
  font-size: clamp(2rem, 4.4vw, 3.3rem);
}

.form-head p {
  margin-inline: auto;
  color: var(--muted);
}

/* Assessment landing page: title, Heather's introduction, and the way in. */
.assessment-landing {
  max-width: 680px;
  margin: clamp(1rem, 6vw, 4rem) auto;
  text-align: center;
}

.assessment-landing h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
}

.assessment-intro-text {
  margin-inline: auto;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.6;
}

.assessment-meta {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* The row itself is .form-actions, shared with the intake. Only the gap above
   it differs, because here it follows the introduction, not a form. */
.assessment-landing-actions {
  margin-top: 2.5rem;
}

.form {
  max-width: 730px;
  margin: 0 auto;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.38rem;
  font-weight: 750;
}

.field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #bdb3a8;
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  padding: 0.7rem 0.8rem;
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.field-hint {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.field-error {
  display: block;
  min-height: 1.1em;
  margin-top: 0.3rem;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 650;
}

.consent {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.consent input {
  width: 20px;
  height: 20px;
  margin-top: 0.15rem;
  /* The only toggle target: the statement beside it is not a label. */
  cursor: pointer;
}

.consent strong {
  display: block;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

.two-col .text-button {
  text-align: center;
}

.turnstile-slot {
  margin: 1rem 0;
  min-height: 70px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.form-status {
  min-height: 1.4em;
  margin: 0.5rem 0 0;
  color: var(--danger);
  font-weight: 650;
  font-size: 0.86rem;
}

.legal-links {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ------------------------------------------------------------- questions */

.questions {
  max-width: 820px;
  margin: 1rem auto 0;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  background: #ded6cc;
  border-radius: 5px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--theme-accent);
  transition: width 0.3s ease;
}

.question {
  margin: 1.75rem 0 0;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  background: var(--paper);
  border: 1px solid #cfd3d5;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.question legend {
  float: left;
  max-width: 28ch;
  margin-bottom: 2rem;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 600;
  line-height: 1.2;
}

.question-number {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rating-scale {
  clear: both;
  display: grid;
  grid-template-columns: repeat(10, 48px);
  justify-content: space-between;
  gap: 0.5rem;
}

.rating-scale input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rating-scale label {
  width: 48px;
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid #d8dcde;
  border-radius: 50%;
  color: #31363b;
  background: #fafaf8;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 650;
}

.rating-scale label:hover {
  border-color: var(--theme);
  background: #f0f3f5;
}

.rating-scale input:focus-visible + label {
  outline: 3px solid var(--theme-accent);
  outline-offset: 2px;
}

.rating-scale input:checked + label {
  color: #fff;
  background: var(--theme);
  border-color: var(--theme);
  box-shadow: 0 5px 14px rgba(31, 43, 55, 0.18);
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.auto-advance-hint {
  display: block;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.question-error {
  display: block;
  min-height: 1.1em;
  margin-top: 0.8rem;
  color: var(--danger);
  font-size: 0.8rem;
}

.question-actions {
  max-width: 820px;
  margin-inline: auto;
}

.completion-copy {
  margin-top: 1rem;
  padding: 1rem;
  background: #eef5f0;
  border: 1px solid #cadccf;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- review */

.review-list {
  list-style: none;
  margin: 1.25rem 0;
  padding: 0;
}

.review-list li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 54px;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.review-score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/*
 * The mockup defines .panel twice. The base gives it a paper card, then the
 * "Modern document system" block strips that back to a single dark rule above
 * transparent content. The later one is what renders.
 */
.panel {
  border: 0;
  border-top: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  padding: 1.35rem 0 0;
}

.panel strong {
  display: block;
}

.panel .muted {
  color: var(--muted);
}

.note {
  margin: 1.5rem 0;
  padding: clamp(1.15rem, 2.5vw, 1.8rem);
  background: #fffaf1;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.note strong {
  color: #77501b;
}

.note p {
  margin: 0;
}

/* --------------------------------------------------------------- results */

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(250px, 0.6fr);
  gap: 0;
  max-width: 980px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #cfd3d5;
  border-radius: var(--radius);
}

.score-panel {
  color: #fff;
  background: var(--theme);
  padding: clamp(2rem, 4vw, 3rem);
}

.score-panel h1 {
  margin-top: 1.4rem;
  color: #fff;
}

.score-number {
  display: block;
  font-family: var(--serif);
  font-size: clamp(4rem, 10vw, 7rem);
  /*
   * The tight line height is from the prototype and is what makes the number
   * read as a single dense mark. It also squashes the line box below the
   * height of the digits, so they hang past the bottom of it and the band
   * sentence underneath rides up into them.
   *
   * The margin is in em so it tracks the clamped font size rather than being
   * right at one width and wrong at the others.
   */
  line-height: 0.9;
  margin-bottom: 0.2em;
}

.score-number small {
  font-family: var(--sans);
  font-size: 0.18em;
}

.score-panel p {
  color: rgba(255, 255, 255, 0.86);
}

.score-panel .pending {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #f3e3c8;
}

.score-panel .pending-text {
  color: rgba(255, 255, 255, 0.92);
}

.bars {
  margin-top: 2rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 2fr 2rem;
  gap: 0.75rem;
  align-items: center;
  margin: 0.65rem 0;
  font-size: 0.78rem;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
}

.bar-value {
  height: 100%;
  background: var(--theme-accent);
  border-radius: 5px;
}

/*
 * Bar widths are classes rather than inline style attributes. A style
 * attribute in server-rendered markup needs 'unsafe-inline' in the Content
 * Security Policy, and the scale only has ten steps, so ten classes costs
 * nothing and keeps the policy strict. Widths set from JavaScript via
 * element.style are CSSOM writes, which CSP does not restrict.
 */
.bar-value--1 { width: 10%; }
.bar-value--2 { width: 20%; }
.bar-value--3 { width: 30%; }
.bar-value--4 { width: 40%; }
.bar-value--5 { width: 50%; }
.bar-value--6 { width: 60%; }
.bar-value--7 { width: 70%; }
.bar-value--8 { width: 80%; }
.bar-value--9 { width: 90%; }
.bar-value--10 { width: 100%; }

.theme-business .bar-value {
  background: #d2aa6d;
}

.theme-life .bar-value {
  background: #d8c4ad;
}

.result-cards {
  display: grid;
  gap: 0;
  background: var(--paper);
  align-content: start;
}

.result-card {
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 1.5rem;
}

.result-card:last-child {
  border-bottom: 0;
}

.result-card h2 {
  margin-top: 0;
  color: var(--theme);
  font-size: 1.1rem;
}

.result-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.result-notice {
  padding: 0.75rem;
  color: #214a35;
  background: #e7f3eb;
  border-radius: 4px;
  font-size: 0.85rem;
}

.uniform-note {
  margin: 0 auto 1.5rem;
  max-width: 980px;
}

/* ------------------------------------------------------------- noscript */

.noscript {
  max-width: 730px;
  margin: 0 auto 1.5rem;
  padding: 1rem;
  background: #fbefed;
  border: 1px solid #e4c5c0;
  border-radius: 4px;
  color: #81352f;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .home {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .rating-scale {
    grid-template-columns: repeat(5, 48px);
    justify-content: center;
    gap: 0.75rem 1rem;
  }
}

@media (max-width: 680px) {
  .field-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .site-header {
    align-items: flex-start;
    margin-bottom: 2rem;
  }

  .site-header nav {
    gap: 0.75rem;
  }

  .home-copy h1 {
    font-size: clamp(2.35rem, 12vw, 3.5rem);
  }

  .choice-card .button {
    width: 100%;
  }

  .rating-scale {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
    gap: 0.65rem;
  }

  .rating-scale label {
    width: 100%;
    min-height: 46px;
  }

  .question {
    padding: 1.35rem;
  }

  .question legend {
    font-size: 1.45rem;
  }

  .form-actions .button {
    flex: 1 1 180px;
  }

  .bar-row {
    grid-template-columns: 1fr 2rem;
    gap: 0.45rem;
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

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