/* ═══════════════════════════════════════════════════════════════
   Perfamix Quiz — design system

   Brand-matched to perfamix.com: deep green, gold accents, ivory
   grounds, flat surfaces. Presence comes from the green band, the
   gold rules and the type scale — not from elevation. There are no
   drop shadows and no hover lift anywhere in this file.

   Deliberately single-theme. This is a brand surface that always
   renders light, so every colour is painted explicitly rather than
   inherited from the host.
   ═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* ── Palette ── */
  --green:      #264E36;  /* brand */
  --green-deep: #1B3E29;  /* masthead ground, CTA hover */
  --green-dim:  #143020;  /* progress track on the green band */
  --ivory:      #FAF8F4;  /* page ground */
  --paper:      #FFFFFF;  /* cards, packshot tiles */
  --ink:        #1B2A20;  /* primary text — near-black, biased green */
  --muted:      #5F6B61;  /* secondary text — 5.0:1 on ivory, AA */
  --rule:       #D8D2C6;  /* hairlines */
  --rule-firm:  #B9B1A1;  /* card borders */

  /* Gold measures 2.29:1 on ivory — it fails even the 3:1 large-text
     threshold, so it is never text on the ivory ground. On the green
     band it measures 4.94:1 and passes AA. --gold-ink (4.57:1 on
     ivory) exists for the places that want gold *type* off the band. */
  --gold:       #C8A05A;
  --gold-ink:   #8F6B2E;

  /* ── Type ── */
  --font-display: 'El Messiri', 'Segoe UI', Tahoma, Arial, sans-serif;
  --font-body:    'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
  --font-lat:     'Jost', 'Segoe UI', system-ui, sans-serif;

  /* ── Metrics ── */
  --measure: 42rem;        /* quiz column */
  --measure-wide: 68rem;   /* results column */
  --radius: 4px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.75;          /* Arabic wants more air than Latin */
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, figure {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
}

img {
  max-width: 100%;
  display: block;
}

[hidden] {
  display: none !important;
}

/* Keyboard focus — the pre-redesign build set outline:none with no
   replacement, which made the whole quiz unusable by keyboard. */
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 1px;
}







/* ═══════════════════════════════════════════
   QUIZ
   ═══════════════════════════════════════════ */

.quiz {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 20px;
  padding-block: clamp(40px, 7vw, 68px) 64px;
}

.quiz-step {
  display: none;
}

.quiz-step.is-active {
  display: block;
  animation: fade-in 180ms var(--ease);
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.question {
  margin-block-end: clamp(28px, 4vw, 40px);
}

.question-title {
  font-family: var(--font-display);
  font-size: clamp(1.875rem, 1.4rem + 2.4vw, 2.75rem);
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  text-wrap: balance;
}

/* Focus target when a step advances — never draws a ring on click,
   only when focus was moved programmatically for keyboard users. */
.question-title:focus {
  outline: none;
}

/* The rule closes the question block, so it hangs off .question
   rather than the title — otherwise it lands between the heading and
   its note on the steps that carry one. */
.question::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  margin-block-start: 18px;
  background: var(--gold);
}

.question-note {
  margin-block-start: 12px;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ── Option grids ── */

.options {
  display: grid;
  gap: 12px;
}

.options--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.options--two   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.options--four  { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── Option card ── */

.option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 20px 18px;
  text-align: start;
  background: var(--paper);
  border: 1.5px solid var(--rule-firm);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color 160ms var(--ease),
    background-color 160ms var(--ease),
    color 160ms var(--ease);
}

/* Compact variant for the self-explanatory steps (gender, season,
   dislikes) — centred, name only, no descriptor to carry. */
.option--compact {
  align-items: center;
  text-align: center;
  padding: 24px 12px;
}

.option:hover {
  border-color: var(--green);
}

.option-name {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  transition: color 160ms var(--ease);
}

.option-note {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
  transition: color 160ms var(--ease);
}

/* Selection inverts the card. No checkmark badge needed — the
   inversion is unambiguous, and it drops a bouncing animation. */
.option[aria-checked="true"],
.option[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
}

.option[aria-checked="true"] .option-name,
.option[aria-pressed="true"] .option-name {
  color: var(--ivory);
}

.option[aria-checked="true"] .option-note,
.option[aria-pressed="true"] .option-note {
  color: rgba(250, 248, 244, 0.78);
}

/* "مفيش، بحب كل حاجة" — spans the row, reads as an opt-out rather
   than another sibling choice. */
.option--optout {
  grid-column: 1 / -1;
  align-items: center;
  text-align: center;
  padding: 16px;
  background: transparent;
  border-style: dashed;
  border-color: var(--rule-firm);
}

.option--optout .option-name {
  font-weight: 500;
  color: var(--muted);
}

.option--optout[aria-pressed="true"] {
  background: var(--green);
  border-style: solid;
}

.option--optout[aria-pressed="true"] .option-name {
  font-weight: 700;
  color: var(--ivory);
}

/* ── Step actions ── */

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-block-start: 32px;
}

.actions--end {
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 15px 30px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 160ms var(--ease),
    border-color 160ms var(--ease),
    color 160ms var(--ease);
}

.btn--primary {
  background: var(--green);
  color: var(--ivory);
  border: 1.5px solid var(--green);
}

.btn--primary:hover:not(:disabled) {
  background: var(--green-deep);
  border-color: var(--green-deep);
}

.btn--primary:disabled {
  background: transparent;
  color: var(--muted);
  border-color: var(--rule-firm);
  cursor: not-allowed;
}

.btn--quiet {
  padding-inline: 6px;
  font-weight: 500;
  color: var(--muted);
  border: none;
}

.btn--quiet:hover {
  color: var(--green);
}

.btn--outline {
  background: transparent;
  color: var(--green);
  border: 1.5px solid var(--green);
}

.btn--outline:hover {
  background: var(--green);
  color: var(--ivory);
}

/* Chevrons are drawn, not typed. Arrow glyphs are bidi-neutral —
   they reposition in RTL but never mirror, so "التالي ←" is a coin
   flip across browsers. */
.chev {
  width: 14px;
  height: 14px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
}

/* ═══════════════════════════════════════════
   RESULTS
   ═══════════════════════════════════════════ */

.results {
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding-inline: 20px;
  padding-block: clamp(40px, 7vw, 68px) 80px;
}

.results-head {
  margin-block-end: clamp(32px, 5vw, 48px);
  padding-block-end: 24px;
  border-block-end: 2px solid var(--rule);
}

.eyebrow {
  display: block;
  font-family: var(--font-lat);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-ink);
  margin-block-end: 14px;
}

.results-title {
  font-family: var(--font-display);
  font-size: clamp(1.875rem, 1.4rem + 2.4vw, 2.75rem);
  font-weight: 600;
  line-height: 1.4;
  text-wrap: balance;
}

.results-title:focus {
  outline: none;
}

.results-note {
  margin-block-start: 12px;
  font-size: 0.9375rem;
  color: var(--muted);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
}

/* ── Perfume card ── */
.perfume {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.perfume-figure {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

/* position:relative puts the packshot in the same painting layer as
   the fallback below it, where tree order decides — and the img comes
   second, so it lands on top. Without this the absolutely-positioned
   fallback covers every packshot unconditionally. */
.perfume-figure img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Typographic tile behind the packshot. app.js hides the img on a
   load error, which reveals this — the real production fallback, so
   it gets designed rather than hidden. */
.perfume-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--paper);
}

.perfume-fallback::after {
  content: '';
  width: 32px;
  height: 2px;
  background: var(--gold);
}

.perfume-fallback span {
  font-family: var(--font-lat);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.5;
}

.perfume-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
  padding-block-start: 18px;
}

/* Ranking eyebrow. Sits in the body rather than over the packshot —
   these are product shots on near-white grounds, so a numeral on the
   image would drop out. */
.perfume-rank {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--gold-ink);
  font-variant-numeric: tabular-nums;
}

.perfume-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.45;
}

.perfume-notes {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.perfume-desc {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Pairs with the 6px body gap for a 16px minimum above the CTA,
     which the auto margin below can only ever grow. */
  margin-block-end: 10px;
}

/* Full-width bar rather than a quiet link — this is the one action
   the whole quiz exists to produce. The auto margin pins it to the
   bottom so CTAs line up across a row of uneven descriptions. */
.perfume-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-block-start: auto;
  padding: 14px 16px;
  background: var(--green);
  color: var(--ivory);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 160ms var(--ease);
}

.perfume-cta:hover {
  background: var(--green-deep);
}

.perfume-cta:hover .cta-arrow {
  transform: translate(-2px, -2px);
}

.cta-arrow {
  width: 12px;
  height: 12px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  transition: transform 160ms var(--ease);
}

/* ── Rationale ──
   Deliberately not a fourth card. Three white bordered cards sit
   directly above this, so the same treatment would read as a broken
   product tile. The green slab makes it a different kind of object —
   an editorial aside — and bookends the page against the masthead,
   which is the same green. It also lets gold be *type* here: 4.94:1
   on --green-deep, against 2.29:1 on the ivory ground. */

.rationale {
  margin-block-start: clamp(48px, 7vw, 72px);
  padding: clamp(28px, 5vw, 44px);
  background: var(--green-deep);
  border-radius: var(--radius);
}

.rationale-title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.625rem);
  font-weight: 600;
  line-height: 1.45;
  color: var(--ivory);
}

/* Same 40px gold rule that closes .question and .empty-title. */
.rationale-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  margin-block-start: 16px;
  background: var(--gold);
}

/* max-content puts the label column at the start edge — the right, in
   RTL — which is the reading order these pairs want. */
.rationale-choices {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 20px;
  margin-block: 24px 0;
}

.rationale-choices dt {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.75;
  color: var(--gold);
}

/* Browsers indent dd by 40px by default. */
.rationale-choices dd {
  margin: 0;
  font-weight: 500;
  color: var(--ivory);
}

.rationale-text {
  max-width: 60ch;
  margin-block-start: 26px;
  font-size: 0.9375rem;
  line-height: 1.85;
  color: rgba(250, 248, 244, 0.8);   /* ≈7.2:1 on the green */
}

.results-footer {
  display: flex;
  justify-content: center;
  margin-block-start: clamp(40px, 6vw, 60px);
}

/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */

.empty {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 20px;
  padding-block: clamp(56px, 12vw, 120px) 80px;
}

.empty-title {
  font-family: var(--font-display);
  font-size: clamp(1.625rem, 1.3rem + 1.6vw, 2.25rem);
  font-weight: 600;
  line-height: 1.4;
}

.empty-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  margin-block-start: 18px;
  background: var(--gold);
}

.empty-text {
  margin-block-start: 16px;
  font-size: 0.9375rem;
  color: var(--muted);
}

.empty-actions {
  margin-block-start: 32px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 860px) {
  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
  }
}

@media (max-width: 600px) {
  /* Descriptor lines need the full width to stay on two lines. */
  .options--two {
    grid-template-columns: minmax(0, 1fr);
  }

  .options--four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option {
    padding: 18px 16px;
  }

  .option--compact {
    padding: 20px 12px;
  }

  .results-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
    max-width: 23rem;
    margin-inline: auto;
  }
}

@media (max-width: 380px) {
  .options--three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .btn {
    padding-inline: 20px;
  }
}

/* ═══════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════ */

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