/* ==========================================================================
   AJK Dream House Ltd. — Interactive components
   Used by the four trade pages. Every component degrades to readable,
   complete static content without JS; js/interactive.js only adds behaviour.
   ========================================================================== */


/* ==========================================================================
   1. RAIL NAV — sticky in-page scroll-spy
   These pages run 6000–8000px. The rail keeps the section list and the
   reader's position visible without a jump-to-top round trip.
   ========================================================================== */
/* interactive.css only loads on pages that carry the rail, so this can be
   unconditional: anchor targets must clear the rail, not just the header. */
html { scroll-padding-top: calc(var(--header-h) + 58px + 20px); }

.railnav {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur-md);
  backdrop-filter: var(--blur-md);
  border-block: 1px solid var(--line);
}

.railnav__inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
}

.railnav__label {
  flex: none;
  color: var(--text-dim);
}
@media (max-width: 900px) { .railnav__label { display: none; } }

.railnav__track {
  position: relative;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
}
.railnav__track::-webkit-scrollbar { display: none; }

.railnav__link {
  position: relative;
  flex: none;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-family: var(--font-ui);
  color: var(--text-dim);
  white-space: nowrap;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.railnav__link:hover { color: var(--text); background: var(--layer-04); }
.railnav__link.is-active { color: var(--gold-ink); background: var(--gold-grad); font-weight: 600; }

/* Reading progress hairline along the bottom edge of the rail */
.railnav__progress {
  position: absolute;
  left: 0; bottom: -1px;
  height: 2px;
  width: 0%;
  background: var(--gold-grad);
  box-shadow: var(--glow-gold-soft);
  transition: width 120ms linear;
}


/* ==========================================================================
   2. BUILD-UP EXPLORER
   A cutaway that accumulates layers as the reader advances the stages.
   Replaces the generic four-step process strip: on a trade page the
   *order* is the argument, and the order is physical, not calendrical.
   ========================================================================== */
/* ---- left: the cutaway ---- */
.buildup__stage {
  position: relative;
  padding: clamp(20px, 2.4vw, 30px);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 80% at 50% 0%, var(--gold-06), transparent 60%),
    linear-gradient(180deg, var(--layer-06), var(--layer-02)),
    var(--bg-sunk);
  border: 1px solid var(--line);
  box-shadow: var(--edge), var(--shadow-md);
  overflow: hidden;
}

/* face preview — what the surface looks like at this stage */
.buildup__facewrap { position: relative; }

.buildup__face {
  position: relative;
  height: clamp(96px, 12vw, 136px);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--face, #3b352a);
  box-shadow: inset 0 2px 18px rgba(0,0,0,0.45);
  overflow: hidden;
  transition: background 700ms var(--ease-out);
}

/* Surface grain. Early stages are rough and uneven; --grain is driven down
   to 0 as the stages advance, so the sample visibly smooths out. */
.buildup__face::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    repeating-linear-gradient(58deg,  rgba(0,0,0,0.30) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-31deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(97deg,  rgba(255,255,255,0.10) 0 1px, transparent 1px 15px);
  opacity: var(--grain, 1);
  transition: opacity 700ms var(--ease-out);
}
/* a raking-light sheen that only appears once a finish coat exists */
.buildup__face::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 26%, rgba(255,255,255,0.22) 46%, transparent 64%),
    radial-gradient(120% 90% at 50% -20%, rgba(255,255,255,0.10), transparent 60%);
  opacity: var(--sheen, 0);
  transition: opacity 700ms var(--ease-out);
}
.buildup__face-tag {
  position: absolute;
  left: 12px; bottom: 10px;
  z-index: 2;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: rgba(11,9,6,0.72);
  -webkit-backdrop-filter: var(--blur-sm);
  backdrop-filter: var(--blur-sm);
  border: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* the stack — index 0 is the substrate, so it sits at the bottom */
.buildup__stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  margin-top: 18px;
}

.buildup__layer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 0 12px 0 14px;
  min-height: var(--h, 34px);
  border-radius: var(--r-xs);
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  width: 100%;
  transition: background var(--dur-slow) var(--ease-out),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              transform var(--dur) var(--ease-back),
              box-shadow var(--dur) var(--ease);
}
/* applied */
.buildup__layer.is-on {
  border-style: solid;
  border-color: var(--line-strong);
  background:
    linear-gradient(90deg, var(--fill, var(--layer-10)), transparent 92%),
    var(--layer-04);
  color: var(--text);
}
/* the one being described */
.buildup__layer.is-current {
  transform: translateX(6px);
  border-color: var(--gold-60);
  box-shadow: var(--glow-gold-soft), inset 0 1px 0 rgba(255,255,255,0.12);
  color: #fff;
}
.buildup__layer:disabled { cursor: default; }

.buildup__layer-name {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.buildup__layer-gauge {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.buildup__layer.is-on .buildup__layer-gauge { opacity: 1; }
.buildup__layer.is-current .buildup__layer-gauge { color: var(--gold); }

/* a "not yet applied" hint on the pending slots */
.buildup__layer:not(.is-on) .buildup__layer-name::after {
  content: ' — pending';
  color: var(--text-dim);
  opacity: 0.55;
  font-size: 0.75rem;
}

/* ---- stage copy ---- */
.buildup__spec {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  list-style: none;
}
.buildup__spec li {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 14px;
  font-size: var(--fs-sm);
}
@media (max-width: 520px) { .buildup__spec li { grid-template-columns: 1fr; gap: 2px; } }
.buildup__spec dt, .buildup__spec b {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  padding-top: 2px;
}
.buildup__spec span { color: var(--text-muted); }

/* ---- scroll progress read-out (position only — scroll is the control) ---- */
.scrolly__track {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: clamp(16px, 2vw, 24px);
}
.scrolly__rail {
  position: relative;
  flex: 1;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--layer-10);
}
.scrolly__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: var(--gold-grad);
  transition: width 240ms var(--ease-out);
}
.scrolly__dots {
  position: absolute;
  inset: -9px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.scrolly__dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease-back),
              border-color var(--dur) var(--ease);
}
.scrolly__dot:hover { transform: scale(1.35); border-color: var(--gold-60); }
.scrolly__dot.is-done { background: var(--gold-deep); border-color: transparent; }
.scrolly__dot.is-active {
  background: var(--gold); border-color: transparent;
  transform: scale(1.45); box-shadow: var(--glow-gold-soft);
}
.scrolly__count {
  flex: none;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}


/* ==========================================================================
   2b. SCROLLYTELLING SHELL
   The visual pins; the stage copy scrolls past it. Scroll position is the
   only control, so there is no transport to learn and nothing auto-plays
   at the reader. Without JS every stage is simply a section of prose.
   ========================================================================== */
.scrolly__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(28px, 4vw, 64px);
  align-items: start;
}

.scrolly__viz {
  position: sticky;
  /* clears the fixed header and the sticky section rail */
  top: calc(var(--header-h) + 58px);
  /* Fill the viewport left over below the chrome and centre inside it, so the
     graphic sits on the same optical line as the stage copy — which is itself
     centred in the viewport by .scrolly__step. */
  height: calc(100vh - var(--header-h) - 58px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.scrolly__steps { display: grid; }

.scrolly__step {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 70vh;
  padding-block: clamp(24px, 4vw, 48px);
}
/* Dimming only applies once JS confirms it can drive the sequence —
   otherwise every stage must read at full strength. */
.js-scrolly .scrolly__step {
  opacity: 0.28;
  filter: blur(1.5px);
  transition: opacity var(--dur-slow) var(--ease-out), filter var(--dur-slow) var(--ease-out);
}
.js-scrolly .scrolly__step.is-active { opacity: 1; filter: none; }

.scrolly__step h3 { margin: 12px 0 12px; font-size: var(--fs-h3); }
.scrolly__step .buildup__body { color: var(--text-muted); }

@media (max-width: 940px) {
  .scrolly__grid { grid-template-columns: 1fr; gap: 0; }
  .scrolly__viz {
    top: calc(var(--header-h) + 52px);
    z-index: 5;
    height: auto;              /* pin the graphic alone; copy scrolls under it */
    margin-bottom: 8px;
    padding-bottom: 12px;
    /* Copy scrolls underneath, so this has to be genuinely opaque — matched
       to whichever band the alternator landed this section on. */
    background: var(--bg);
  }
  .section--alt .scrolly__viz { background: var(--bg-alt); }

  /* short fade so copy dissolves under the panel instead of cutting hard */
  .scrolly__viz::after {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 100%;
    height: 22px;
    background: linear-gradient(180deg, var(--bg), transparent);
    pointer-events: none;
  }
  .section--alt .scrolly__viz::after {
    background: linear-gradient(180deg, var(--bg-alt), transparent);
  }
  .scrolly__step { min-height: 58vh; }
  /* compact the pinned graphic so the copy still gets usable height */
  .scrolly__viz .buildup__face { height: 72px; }
  .scrolly__viz .buildup__layer { min-height: 30px !important; }
  .scrolly__viz .buildup__stack { gap: 4px; margin-top: 12px; }
  .scrolly__viz .buildup__stage { padding: 16px; }
}
/* Short viewports cannot pin a graphic and show copy at the same time. */
@media (max-height: 620px) {
  .scrolly__viz { position: static; height: auto; }
  .js-scrolly .scrolly__step { opacity: 1; filter: none; }
}


/* ==========================================================================
   3. MATRIX — expandable comparison table
   Product-fact comparison (moisture tolerance, refinishability, and so on),
   not opinion. Rows expand to the verdict sentence.
   ========================================================================== */
.matrix {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--layer-04), var(--layer-02)), var(--bg-raise);
  box-shadow: var(--edge), var(--shadow-sm);
  overflow: hidden;
}

.matrix__head,
.matrix__row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) repeat(var(--cols, 3), minmax(0, 1fr)) 44px;
  align-items: center;
  gap: clamp(10px, 1.4vw, 22px);
  padding: 14px clamp(16px, 1.8vw, 24px);
  text-align: left;
  width: 100%;
}

.matrix__head {
  border-bottom: 1px solid var(--line);
  background: var(--layer-04);
}
.matrix__head span {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.matrix__row {
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  transition: background-color var(--dur) var(--ease);
}
.matrix__row:first-of-type { border-top: 0; }
.matrix__row:hover { background: var(--layer-04); }
.matrix__row[aria-expanded='true'] { background: var(--gold-06); }

.matrix__name {
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
}

.matrix__cell { display: grid; gap: 7px; }
.matrix__val {
  font-size: 0.75rem;
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.meter {
  position: relative;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--layer-10);
  overflow: hidden;
}
.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: var(--gold-grad);
  transition: width 900ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.matrix__row.is-in .meter i { width: calc(var(--v) * 100%); }
/* low scores read as a warning rather than a small win */
.meter i.is-low { background: linear-gradient(135deg, #8e8471, #5f5849); }

.matrix__toggle {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  justify-self: end;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--text-dim);
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.matrix__row[aria-expanded='true'] .matrix__toggle {
  transform: rotate(45deg);
  color: var(--gold);
  border-color: var(--gold-35);
}

.matrix__more {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-slow) var(--ease-out);
  background: var(--bg-sunk);
}
.matrix__more.is-open { grid-template-rows: 1fr; }
.matrix__more > div { overflow: hidden; }
.matrix__more p {
  padding: 4px clamp(16px, 1.8vw, 24px) 20px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  max-width: 78ch;
}

/* stacked layout — the grid collapses to labelled rows */
@media (max-width: 860px) {
  .matrix__head { display: none; }
  .matrix__row {
    grid-template-columns: minmax(0, 1fr) 44px;
    row-gap: 14px;
    padding-block: 18px;
  }
  .matrix__name { grid-column: 1; }
  .matrix__toggle { grid-column: 2; grid-row: 1; }
  .matrix__cell { grid-column: 1 / -1; }
  .matrix__cell::before {
    content: attr(data-label);
    font-family: var(--font-ui);
    font-size: 0.625rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
}


/* ==========================================================================
   4. CONFIGURATOR — build your scope, then send it
   Deliberately outputs a *scope*, never a price. The written quote is the
   only place a number belongs, and that is the whole promise of the brand.
   ========================================================================== */
.config {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(24px, 3vw, 48px);
  align-items: start;
}
@media (max-width: 940px) { .config { grid-template-columns: 1fr; } }

.config__q { border: 0; margin: 0 0 26px; padding: 0; }
.config__q:last-child { margin-bottom: 0; }
.config__q legend {
  padding: 0;
  margin-bottom: 14px;
  font-family: var(--font-ui);
  font-size: var(--fs-h4);
  font-weight: 600;
  color: var(--text);
}
.config__opts { display: flex; flex-wrap: wrap; gap: 10px; }

.config__opt { position: relative; cursor: pointer; }
.config__opt input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.config__opt span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 17px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--layer-02);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background-color var(--dur) var(--ease), transform var(--dur) var(--ease-back);
}
.config__opt:hover span { color: var(--text); border-color: var(--line-strong); }
.config__opt input:checked + span {
  color: var(--gold-ink);
  background: var(--gold-grad);
  border-color: transparent;
  font-weight: 600;
  transform: translateY(-1px);
  box-shadow: var(--glow-gold-soft);
}
.config__opt input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* output panel */
.config__out {
  position: sticky;
  top: calc(var(--header-h) + 76px);
  padding: clamp(22px, 2.4vw, 32px);
  border-radius: var(--r-lg);
}
@media (max-width: 940px) { .config__out { position: static; } }

.config__out h3 { margin: 12px 0 4px; font-size: var(--fs-h3); }
.config__lede { font-size: var(--fs-sm); color: var(--text-dim); }

.config__list {
  display: grid;
  gap: 12px;
  margin: 22px 0;
  list-style: none;
  min-height: 120px;
}
.config__list li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  animation: cfg-in 380ms var(--ease-out) both;
}
@keyframes cfg-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: none; }
}
.config__list svg { flex: none; margin-top: 3px; color: var(--gold); }
.config__list li.is-empty { color: var(--text-dim); font-style: italic; }
.config__list li.is-empty svg { color: var(--text-dim); opacity: 0.5; }

.config__note {
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: var(--gold-06);
  border: 1px solid var(--gold-20);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: 20px;
}
.config__out .btn { width: 100%; justify-content: center; }


/* ==========================================================================
   5. CHECKER — feasibility checklist with a live verdict dial
   ========================================================================== */
.checker {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: clamp(24px, 3vw, 48px);
  align-items: start;
}
@media (max-width: 940px) { .checker { grid-template-columns: 1fr; } }

.checker__list { display: grid; gap: 10px; list-style: none; }

.checker__item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--layer-02);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.checker__item:hover { border-color: var(--line-strong); background: var(--layer-04); }
.checker__item input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.checker__box {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  margin-top: 1px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  color: transparent;
  transition: background var(--dur) var(--ease-back), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease-back);
}
.checker__item input:checked ~ .checker__box {
  background: var(--gold-grad);
  border-color: transparent;
  color: var(--gold-ink);
  transform: scale(1.08);
}
.checker__item input:focus-visible ~ .checker__box { outline: 2px solid var(--gold); outline-offset: 3px; }
.checker__item input:checked ~ .checker__text b { color: var(--text); }

.checker__text b {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--dur) var(--ease);
}
.checker__text small {
  display: block;
  margin-top: 5px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  line-height: 1.55;
}

/* verdict */
.checker__verdict {
  position: sticky;
  top: calc(var(--header-h) + 76px);
  padding: clamp(24px, 2.6vw, 34px);
  border-radius: var(--r-lg);
  text-align: center;
}
@media (max-width: 940px) { .checker__verdict { position: static; } }

.dial { position: relative; width: 148px; margin: 0 auto 18px; }
.dial svg { display: block; width: 100%; height: auto; transform: rotate(-90deg); }
.dial__bg { stroke: var(--layer-10); }
.dial__fg {
  stroke: url(#dialGrad);
  stroke-linecap: round;
  transition: stroke-dashoffset 700ms var(--ease-out);
}
.dial__num {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.dial__num small {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 2px;
}

.checker__state {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.checker__msg { font-size: var(--fs-sm); color: var(--text-muted); min-height: 4.5em; }
.checker__verdict .btn { width: 100%; justify-content: center; margin-top: 18px; }


/* ==========================================================================
   Shared: reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .buildup__layer,
  .buildup__face,
  .buildup__face::before,
  .buildup__face::after,
  .scrolly__fill,
  .meter i,
  .dial__fg,
  .matrix__more { transition-duration: 1ms !important; }
  .config__list li { animation: none !important; }
  /* no pinning, no dimming — the stages read as plain sequential prose */
  .scrolly__viz { position: static !important; }
  .scrolly__step { min-height: 0 !important; }
  .js-scrolly .scrolly__step { opacity: 1 !important; filter: none !important; }
  .railnav__track { scroll-behavior: auto; }
}
