/* Theme drawn from the Red Book plates: aged parchment, night indigo, oxblood,
   gold ochre, muted teal, ink line work. Original palette and ornament, not
   reproduced artwork. */
:root {
  --parchment:   #f6efe0;
  --parchment-2: #ece2cd;
  --surface:     #fdfaf1;
  --ink:         #2b2620;
  --ink-soft:    #5f5548;
  --ink-faint:   #928572;
  --ink-line:    #4a4436;
  --line:        #ddd0b4;
  --line-soft:   #e9dfc8;

  --indigo:      #26406b;
  --indigo-deep: #1b2d4d;
  --indigo-tint: #e2e7f0;
  --oxblood:     #9c3324;
  --oxblood-deep:#7c2519;
  --oxblood-tint:#f6e3dd;
  --gold:        #c08a2e;
  --gold-tint:   #f8eed6;
  --teal:        #2f7573;
  --teal-tint:   #dfeceb;

  --accent:      var(--oxblood);
  --accent-deep: var(--oxblood-deep);
  --accent-tint: var(--oxblood-tint);
  --accent-ink:  var(--oxblood-deep);

  --note-bg:   var(--gold-tint);
  --note-line: #e0c68d;
  --note-ink:  #6f501a;

  --radius:   14px;
  --radius-s: 10px;
  --shadow:    0 1px 2px rgba(43, 38, 32, .06), 0 12px 30px -14px rgba(43, 38, 32, .28);
  --shadow-sm: 0 1px 2px rgba(43, 38, 32, .07);

  /* Psych Dive mark. Ink and gold sampled from the approved logo. */
  --pd-ink:  #4B545E;
  --pd-gold: #B39456;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --parchment:   #14161d;
    --parchment-2: #1c1f28;
    --surface:     #1a1d25;
    --ink:         #ece3d2;
    --ink-soft:    #b6ab97;
    --ink-faint:   #877c6b;
    --ink-line:    #8a7f68;
    --line:        #2e3340;
    --line-soft:   #262a35;

    --indigo:      #6d8fc4;
    --indigo-deep: #8aa8d8;
    --indigo-tint: #1e2739;
    --oxblood:     #cf5f45;
    --oxblood-deep:#e0785d;
    --oxblood-tint:#33201b;
    --gold:        #d8a94e;
    --gold-tint:   #302716;
    --teal:        #62a8a4;
    --teal-tint:   #17282a;

    --note-bg:   #302716;
    --note-line: #4d3f1f;
    --note-ink:  #e5c684;

    --shadow:    0 1px 2px rgba(0, 0, 0, .35), 0 12px 30px -14px rgba(0, 0, 0, .6);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);

    --pd-ink:  #DCD6CB;
    --pd-gold: #D2AD60;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--parchment);
  /* Fine diagonal hatching, the way the Red Book pen drawings are shaded,
     plus two soft washes. Inline SVG so there is no extra request. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Cpath d='M0 6L6 0' stroke='%234a4436' stroke-width='.35' opacity='.16'/%3E%3C/svg%3E"),
    radial-gradient(52rem 30rem at 88% -10%, color-mix(in srgb, var(--gold) 15%, transparent), transparent 70%),
    radial-gradient(46rem 28rem at -10% 2%, color-mix(in srgb, var(--indigo) 13%, transparent), transparent 70%);
  background-repeat: repeat, no-repeat, no-repeat;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  body {
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Cpath d='M0 6L6 0' stroke='%23c8bda4' stroke-width='.35' opacity='.07'/%3E%3C/svg%3E"),
      radial-gradient(52rem 30rem at 88% -10%, color-mix(in srgb, var(--gold) 12%, transparent), transparent 70%),
      radial-gradient(46rem 28rem at -10% 2%, color-mix(in srgb, var(--indigo) 16%, transparent), transparent 70%);
  }
}

.wrap { max-width: 44rem; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 1.75rem) 5rem; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
h1 { font-size: clamp(1.75rem, 5.5vw, 2.5rem); margin: 0 0 .65rem; }
h2 { font-size: clamp(1.2rem, 3.5vw, 1.45rem); margin: 2.6rem 0 .9rem; }
h3 { font-size: 1.06rem; margin: 0 0 .45rem; }
p { margin: 0 0 1.05rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent-ink); text-underline-offset: 2px; }

.lede { font-size: 1.08rem; color: var(--ink-soft); }
.muted { color: var(--ink-faint); font-size: .875rem; }
.center { text-align: center; }

/* Ornamental rule, echoing the ruled borders on the plates. */
.rule { display: flex; align-items: center; gap: .75rem; margin: 2.2rem 0 1.2rem; color: var(--ink-faint); }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
.rule .ico { width: 17px; height: 17px; }

/* --- top bar -------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .5rem 0 1.1rem; margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: inline-flex; align-items: center; gap: .7rem;
  text-decoration: none; color: inherit;
}
/* The mark is line art on a transparent ground, so it sits directly on the
   page rather than in a tile. currentColor carries the ink into the symbol;
   the gold dot reads --pd-gold. Both swap in dark mode above. */
.brand-mark { display: block; flex: 0 0 auto; width: 3rem; color: var(--pd-ink); }
.brand-mark svg { display: block; width: 100%; height: auto; overflow: visible; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--serif); font-size: 1.06rem; font-weight: 600;
  letter-spacing: .005em; color: var(--ink);
}
.brand-sub { font-size: .74rem; color: var(--ink-faint); letter-spacing: .01em; }
.brand:hover .brand-name { color: var(--accent-ink); }
@media (max-width: 26rem) { .brand-sub { display: none; } }
.lang-switch {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .84rem; font-weight: 550; text-decoration: none;
  color: var(--ink-soft); background: var(--surface);
  border: 1px solid var(--line); border-radius: 99px;
  padding: .34rem .8rem; box-shadow: var(--shadow-sm);
}
.lang-switch:hover { border-color: var(--accent); color: var(--accent-ink); }

/* --- cards ---------------------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.15rem, 3.5vw, 1.7rem);
  box-shadow: var(--shadow);
}
/* Inner rule, like the double-ruled borders on the plates. */
.card::after {
  content: ""; position: absolute; inset: 5px;
  border: 1px solid var(--line-soft); border-radius: calc(var(--radius) - 4px);
  pointer-events: none;
}
.card > * { position: relative; z-index: 1; }
.card + .card { margin-top: 1rem; }
.card-quiet { background: var(--parchment-2); box-shadow: none; }
.card-quiet::after { display: none; }

.scroll-box { max-height: 22rem; overflow-y: auto; padding-right: .75rem; margin-bottom: 1.1rem; font-size: .95rem; color: var(--ink-soft); }
.scroll-box p { margin-bottom: .85rem; }

/* --- progress ------------------------------------------------------------- */
.progress-bar {
  position: sticky; top: 0; z-index: 10;
  margin: 0 -1rem 1.25rem; padding: .8rem 1rem;
  background: color-mix(in srgb, var(--parchment) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.progress-track { height: 7px; background: var(--parchment-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line-soft); }
.progress-fill { height: 100%; border-radius: 99px; width: 0%; background: linear-gradient(90deg, var(--gold), var(--oxblood)); transition: width .3s cubic-bezier(.4, 0, .2, 1); }
.progress-meta { display: flex; justify-content: space-between; gap: 1rem; margin-top: .45rem; font-size: .8rem; color: var(--ink-faint); }

/* --- question ------------------------------------------------------------- */
.section-tag {
  display: inline-block; font-size: .7rem; font-weight: 650;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--indigo); background: var(--indigo-tint);
  padding: .28rem .65rem; border-radius: 99px; margin-bottom: .95rem;
}
.question-text { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin: 0 0 1.3rem; line-height: 1.35; }

.options { display: flex; flex-direction: column; gap: .5rem; }
.option {
  display: flex; align-items: flex-start; gap: .8rem;
  padding: .9rem 1.05rem; background: var(--parchment-2);
  border: 1.5px solid transparent; border-radius: var(--radius-s);
  cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
  transition: border-color .13s, background .13s, transform .08s;
}
.option:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.option:active { transform: scale(.994); }
.option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); }
.option:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.option .dot { flex: 0 0 auto; width: 19px; height: 19px; margin-top: .22rem; border: 2px solid var(--ink-faint); border-radius: 50%; transition: .13s; }
.option[aria-pressed="true"] .dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3.5px var(--surface); }

.likert { display: flex; flex-direction: row; gap: .4rem; flex-wrap: wrap; }
.likert .option { flex: 1 1 0; min-width: 2.6rem; justify-content: center; padding: .9rem .3rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.likert .option .dot { display: none; }
.scale-ends { display: flex; justify-content: space-between; gap: 1rem; margin-top: .65rem; font-size: .8rem; color: var(--ink-faint); }
.scale-ends span:last-child { text-align: right; }

/* --- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .82rem 1.6rem; border-radius: 99px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: filter .13s, transform .08s;
}
.btn-primary { background: var(--oxblood); color: #fdfaf1; box-shadow: 0 2px 10px -3px var(--oxblood); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--parchment-2); }
.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.nav-row-end { justify-content: flex-end; }

/* --- forms ---------------------------------------------------------------- */
.field { margin-bottom: 1.3rem; }
.field > label { display: block; font-weight: 600; margin-bottom: .2rem; }
.field .help { display: block; font-size: .87rem; color: var(--ink-faint); margin-bottom: .5rem; }
.field input[type="text"], .field input[type="number"], .field input[type="email"], .field textarea {
  width: 100%; padding: .72rem .9rem; font: inherit;
  background: var(--parchment-2); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--radius-s);
}
.field textarea { min-height: 6.5rem; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.choice-list { display: flex; flex-direction: column; gap: .45rem; }
.choice { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; background: var(--parchment-2); border: 1.5px solid transparent; border-radius: var(--radius-s); cursor: pointer; transition: .13s; }
.choice:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; flex: 0 0 auto; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }

.consent { display: flex; gap: .8rem; align-items: flex-start; padding: .9rem 1rem; background: var(--accent-tint); border: 1.5px solid var(--line); border-radius: var(--radius-s); }
.consent input { width: 21px; height: 21px; margin-top: .15rem; flex: 0 0 auto; accent-color: var(--accent); }
.consent label { font-size: .94rem; color: var(--ink); }

/* --- icons and mandala ---------------------------------------------------- */
.ico { width: 24px; height: 24px; display: inline-block; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.ico-lg { width: 34px; height: 34px; stroke-width: 1.9; }

.mandala { display: block; max-width: 100%; height: auto; }
.mandala-frame { display: grid; place-items: center; margin: 0 auto 1.2rem; }
.mandala-frame .caption { font-family: var(--serif); font-size: .84rem; color: var(--ink-faint); letter-spacing: .04em; margin-top: .3rem; }
.pick .mandala { width: 100%; height: auto; }

/* --- result --------------------------------------------------------------- */
.result-head { text-align: center; margin-bottom: 1.5rem; }
.profile-badge {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .72rem; font-weight: 650; letter-spacing: .13em;
  color: var(--indigo); background: var(--indigo-tint);
  padding: .3rem .8rem; border-radius: 99px; margin-bottom: .8rem;
}
.archetype-name { font-family: var(--serif); font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 600; margin: 0 0 .25rem; }
.archetype-tag { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: 1.08rem; margin: 0; }

.prose p + p { margin-top: .1rem; }
.trait-row { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 1.1rem 0 0; }
.trait {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .84rem; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 99px; padding: .32rem .85rem;
}
.trait .ico { width: 15px; height: 15px; color: var(--gold); }

/* --- picks ---------------------------------------------------------------- */
.picks { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.pick {
  display: grid; gap: 1rem; align-items: start;
  grid-template-columns: 5.5rem 1fr;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: var(--shadow-sm);
}
.pick-art {
  display: grid; place-items: center; width: 5.5rem; height: 5.5rem;
  border-radius: 50%; overflow: hidden;
  background: var(--gold-tint); color: var(--gold);
  border: 1px solid var(--line);
}
.pick:nth-child(3n+2) .pick-art { background: var(--teal-tint); color: var(--teal); }
.pick:nth-child(3n+3) .pick-art { background: var(--indigo-tint); color: var(--indigo); }
.pick-art img { width: 100%; height: 100%; object-fit: cover; }
.pick-art .ico { width: 38px; height: 38px; stroke-width: 1.7; }
.pick-label { display: block; font-size: .7rem; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .3rem; }
.pick-value { font-family: var(--serif); font-size: 1.22rem; font-weight: 600; line-height: 1.28; }
.pick-sub { font-size: .9rem; color: var(--ink-faint); margin-top: .1rem; }
.pick-reason { margin-top: .55rem; font-size: .95rem; color: var(--ink-soft); line-height: 1.55; }

/* --- plain-language meters ------------------------------------------------ */
.gauge { margin-bottom: 1.35rem; }
.gauge:last-child { margin-bottom: 0; }
.gauge-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .35rem; }
.gauge-label { font-weight: 600; }
.gauge-word { font-family: var(--serif); font-style: italic; color: var(--ink-soft); }
.gauge-track { height: 10px; background: var(--parchment-2); border: 1px solid var(--line-soft); border-radius: 99px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--oxblood)); }
.gauge-fill.is-teal { background: var(--teal); }
.gauge-fill.is-indigo { background: var(--indigo); }
.gauge-fill.is-quiet { background: var(--line); }
.gauge-note { font-size: .89rem; color: var(--ink-faint); margin-top: .3rem; }

/* --- notes ---------------------------------------------------------------- */
.note { display: flex; gap: .9rem; align-items: flex-start; background: var(--note-bg); border: 1px solid var(--note-line); color: var(--note-ink); border-radius: var(--radius); padding: 1.15rem 1.3rem; margin: 1.4rem 0; }
.note .ico { flex: 0 0 auto; margin-top: .1rem; }
.note strong { display: block; margin-bottom: .28rem; font-family: var(--serif); font-size: 1.02rem; }
.note p { margin: 0 0 .6rem; font-size: .95rem; }
.note p:last-child { margin-bottom: 0; }

.disclaimer { border-top: 1px solid var(--line); margin-top: 2.75rem; padding-top: 1.3rem; color: var(--ink-faint); font-size: .88rem; }

/* --- admin ---------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .58rem .6rem; border-bottom: 1px solid var(--line-soft); }
th { font-weight: 650; color: var(--ink-faint); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); margin-bottom: 1.6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .95rem 1.1rem; }
.stat .stat-value { font-family: var(--serif); font-size: 1.75rem; font-weight: 600; line-height: 1.1; }
.stat .stat-label { font-size: .8rem; color: var(--ink-faint); }

.hidden { display: none !important; }

@media (min-width: 34rem) {
  .picks { grid-template-columns: 1fr; }
}
@media (max-width: 30rem) {
  body { font-size: 16px; }
  .likert .option { min-width: 2.1rem; padding: .78rem .2rem; font-size: .95rem; }
  .pick { grid-template-columns: 3.6rem 1fr; gap: .85rem; padding: 1rem; }
  .pick-art { width: 3.6rem; height: 3.6rem; }
  .pick-art .ico { width: 26px; height: 26px; }
  .pick-value { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* --- result: areas, defences, inline disclaimer --------------------------- */
.area { padding-bottom: 1.1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--line-soft); }
.area:last-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
.area h3 { font-size: .78rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
           font-family: var(--sans); color: var(--ink-faint); margin-bottom: .4rem; }
.area p { margin: 0; }

.disclaimer-inline {
  font-size: .87rem; line-height: 1.55; color: var(--ink-faint);
  background: var(--parchment-2); border: 1px dashed var(--line);
  border-radius: var(--radius-s); padding: .9rem 1.05rem; margin: 1rem 0 0;
}

.defence { padding-bottom: 1.1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--line-soft); }
.defence-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .45rem; }
.defence-rank {
  flex: 0 0 auto; display: grid; place-items: center; width: 1.9rem; height: 1.9rem;
  border-radius: 50%; background: var(--oxblood); color: #fdfaf1;
  font-family: var(--serif); font-size: 1rem; font-weight: 600;
}
.defence-name { font-family: var(--serif); font-size: 1.16rem; font-weight: 600; line-height: 1.2; }
.defence-style { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.defence-text { margin: 0; color: var(--ink-soft); font-size: .96rem; }

.pick-art img[src$=".svg"] { object-fit: contain; padding: .55rem; }

.site-foot { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--line-soft);
             font-size: .82rem; color: var(--ink-faint); text-align: center; }
.site-foot a { color: inherit; }

/* Country dropdown, matching the text inputs. */
.field select {
  width: 100%; padding: .72rem .9rem; font: inherit;
  background: var(--parchment-2); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--radius-s);
}
.field select:focus { outline: none; border-color: var(--accent); background: var(--surface); }

/* Generated star card art fills its circle like a photograph would. */
.pick-art .starfield { width: 100%; height: 100%; }
