/* ============================================================
   Take Interest · Home configurator · configurator.css
   Self-contained prototype styling. Mirrors the deployed previews'
   discipline: theme-via-CSS, no inline style attributes in the HTML
   (dynamic values are set through the CSSOM .style property in JS,
   which CSP permits — it is inline style="" in markup that is blocked).
   Calm, dark "dusk" studio surface, one warm accent. Restraint over effects.
   ============================================================ */

:root {
  --bg:        #15171c;   /* studio dusk */
  --bg-2:      #1b1e25;
  --panel:     #1e222b;
  --panel-2:   #232833;
  --line:      #2c323d;
  --line-2:    #383f4c;
  --text:      #eef1f6;
  --text-dim:  #aab2c0;
  --text-mute: #79828f;
  --accent:    #c9a87a;   /* warm cedar — the single accent */
  --accent-2:  #e3c79b;
  --good:      #6fbf94;
  --radius:    14px;
  --radius-sm: 9px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --panel-w: 340px;
  --shadow: 0 18px 50px rgba(0,0,0,0.42);

  /* bridge: the shared page-tour CSS (ported from crestline) expects crestline's
     token names; map them to the configurator's cedar/dusk palette so the
     spotlight ring + card + launcher render correctly here. */
  --surface: var(--panel);
  --surface-2: var(--panel-2);
  --paper: var(--bg-2);
  --border: var(--line-2);
  --display: var(--sans);
  --gold: var(--accent-2);
  --ok: var(--good);
  --accent-bright: var(--accent-2);
  --accent-deep: var(--accent);
}

* { box-sizing: border-box; }

/* Restore the HTML `hidden` attribute. Several containers below use
   display:flex / display:grid, which would otherwise override `hidden` and
   leak a hidden overlay (the WebGL fallback, the off-mode view) on top of a
   working canvas. `hidden` must win. */
[hidden] { display: none !important; }

#ti-role {
  display: none !important;
}
.cfg-result-active .ti-dlt-launch-fixed {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;   /* the configurator owns the viewport; never let the page itself scroll */
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.cfg-mono { font-family: var(--mono); }

.cfg-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;   /* the app owns the viewport; the panel scrolls internally, the page never does */
}

/* ====================== HEADER ====================== */
.cfg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  flex: 0 0 auto;
}
.cfg-brand { display: flex; align-items: center; gap: 11px; }
.cfg-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: radial-gradient(120% 120% at 30% 25%, var(--accent-2), var(--accent) 55%, #8a6d44 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}
.cfg-brand-name { font-weight: 620; letter-spacing: 0.2px; font-size: 15.5px; }
.cfg-pill {
  font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--text-mute);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 3px 9px;
}

.cfg-modeswitch {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.cfg-mode {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.cfg-mode:hover { color: var(--text); }
.cfg-mode.is-active {
  background: var(--accent);
  color: #20170c;
}

/* ====================== BODY (design) ====================== */
.cfg-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  grid-template-rows: minmax(0, 1fr);   /* bound the row so the cells can scroll, not grow the page */
  min-height: 0;
}

/* ---------- control panel ---------- */
.cfg-panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  min-height: 0;          /* grid item must allow shrink so overflow-y actually scrolls */
  padding: 6px 18px 28px;
}
.cfg-group { padding: 18px 0; border-bottom: 1px solid var(--line); }
.cfg-group:last-child { border-bottom: 0; }
.cfg-group-title {
  margin: 0 0 4px;
  font-size: 12.5px;
  font-weight: 660;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.cfg-group-hint { margin: 0 0 13px; font-size: 12.5px; line-height: 1.45; color: var(--text-mute); }

/* templates */
.cfg-templates { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.cfg-template {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}
.cfg-template:hover { transform: translateY(-1px); border-color: var(--line-2); background: #262c38; }
.cfg-template.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cfg-template-name { display: block; font-size: 13px; font-weight: 600; }
.cfg-template-desc { display: block; font-size: 11px; color: var(--text-mute); margin-top: 2px; }

/* swatches */
.cfg-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.cfg-swatch {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 7px 7px 9px;
  cursor: pointer;
  width: 84px;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.cfg-swatch:hover { transform: translateY(-1px); }
.cfg-swatch.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cfg-swatch-strip { display: flex; height: 26px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(0,0,0,0.35); }
.cfg-swatch-strip > i { flex: 1 1 auto; display: block; }
.cfg-swatch-name { display: block; font-size: 11px; color: var(--text-dim); margin-top: 6px; text-align: center; }

/* segmented controls */
.cfg-field { margin-bottom: 14px; }
.cfg-field:last-child { margin-bottom: 0; }
.cfg-field-label { display: block; font-size: 12px; color: var(--text-mute); margin-bottom: 7px; }
.cfg-segs { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.cfg-seg {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text-dim);
  font: inherit; font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.cfg-seg:hover { color: var(--text); }
.cfg-seg.is-active { background: var(--accent); color: #20170c; border-color: var(--accent); }
.cfg-segs-wrap { display: flex; }

/* "Surprise me" — full-width ghost button under the template grid */
.cfg-surprise { width: 100%; margin-top: 10px; }

/* custom colour pickers — four swatches in a row */
.cfg-colors { display: flex; gap: 10px; }
.cfg-color { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1 1 0; }
.cfg-color span { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.cfg-color input[type="color"] {
  width: 100%; height: 30px; padding: 0; margin: 0;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: none; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.cfg-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.cfg-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.cfg-color input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }

/* toggles */
.cfg-toggle { display: flex; align-items: center; gap: 11px; cursor: pointer; padding: 8px 0; }
.cfg-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cfg-toggle-track {
  position: relative;
  width: 40px; height: 23px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  transition: background 0.16s ease, border-color 0.16s ease;
  flex: 0 0 auto;
}
.cfg-toggle-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.16s ease, background 0.16s ease;
}
.cfg-toggle input:checked + .cfg-toggle-track { background: var(--accent); border-color: var(--accent); }
.cfg-toggle input:checked + .cfg-toggle-track::after { transform: translateX(17px); background: #20170c; }
.cfg-toggle input:focus-visible + .cfg-toggle-track { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.cfg-toggle-label { font-size: 13.5px; }

/* actions */
.cfg-group-actions { display: flex; flex-direction: column; gap: 9px; }
.cfg-btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 560;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.cfg-btn:hover { transform: translateY(-1px); background: #262c38; }
.cfg-btn:active { transform: translateY(0); }
.cfg-btn-primary { background: var(--accent); color: #20170c; border-color: var(--accent); }
.cfg-btn-primary:hover { background: var(--accent-2); }
.cfg-btn-ghost { background: transparent; }
.cfg-action-note { margin: 4px 0 0; min-height: 16px; font-size: 12px; color: var(--good); }

/* ---------- the 3D stage ---------- */
.cfg-stage {
  position: relative;
  min-width: 0;
  background:
    radial-gradient(120% 90% at 50% 8%, #232a36 0%, #181b22 55%, #121419 100%);
  overflow: hidden;
}
.cfg-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.cfg-stage.is-grabbing canvas { cursor: grabbing; }

.cfg-stage-readout {
  position: absolute; left: 16px; bottom: 14px;
  font-size: 12px; color: var(--text-dim);
  background: rgba(18,20,25,0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.cfg-loading, .cfg-result-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mute); font-size: 14px;
  background: var(--bg);
  transition: opacity 0.4s ease;
}
.cfg-loading.is-gone, .cfg-result-loading.is-gone { opacity: 0; pointer-events: none; }

.cfg-fallback, .cfg-result-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 40px; text-align: center;
  color: var(--text-dim);
}
.cfg-fallback p, .cfg-result-fallback p { max-width: 460px; line-height: 1.55; }
.cfg-fallback-spec { width: 100%; max-width: 420px; }

/* ====================== RESULT view ====================== */
.cfg-result {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: 0;
}
.cfg-result-stage {
  position: relative;
  min-width: 0;
  background: radial-gradient(120% 90% at 50% 10%, #262d3a 0%, #181b22 58%, #111317 100%);
  overflow: hidden;
}
.cfg-result-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }

.cfg-turntable-row {
  position: absolute; left: 18px; right: auto; bottom: 16px;
  display: flex; align-items: center; justify-content: flex-start;
  gap: 8px; flex-wrap: wrap;
  pointer-events: none;
  max-width: calc(100% - 36px);
}
.cfg-turntable-row > * { pointer-events: auto; }
.cfg-views { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.cfg-chip {
  appearance: none;
  border: 1px solid var(--line-2);
  background: rgba(20,23,29,0.82);
  color: var(--text-dim);
  font: inherit; font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.cfg-chip:hover { color: var(--text); }
.cfg-chip.is-active { background: var(--accent); color: #20170c; border-color: var(--accent); }

/* spec sheet */
.cfg-spec {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 26px 24px 32px;
}
.cfg-spec-head { margin-bottom: 20px; }
.cfg-spec-name { margin: 0 0 6px; font-size: 22px; font-weight: 640; letter-spacing: 0.2px; }
.cfg-spec-tag {
  font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--text-mute);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 9px;
}
.cfg-spec-rows { margin: 0 0 22px; display: grid; grid-template-columns: auto 1fr; gap: 0; }
.cfg-spec-row-k {
  padding: 11px 0; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-mute); padding-right: 18px;
}
.cfg-spec-row-v {
  padding: 11px 0; border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--text); text-align: right; font-weight: 540;
}
.cfg-spec-palette { margin-bottom: 18px; }
.cfg-spec-palette-label {
  display: block; font-size: 12px; color: var(--text-mute); margin-bottom: 9px;
  letter-spacing: 0.4px; text-transform: uppercase;
}
.cfg-spec-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.cfg-spec-chip { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 60px; }
.cfg-spec-chip i {
  width: 100%; height: 30px; border-radius: 7px;
  border: 1px solid rgba(0,0,0,0.4);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.cfg-spec-chip span { font-size: 10.5px; color: var(--text-mute); }
.cfg-spec-foot { font-size: 12px; line-height: 1.5; color: var(--text-mute); margin: 0; }

/* ---- result: eyebrow + "send to client" action ---- */
.cfg-spec-eyebrow {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}
.cfg-spec-send { margin: 4px 0 16px; }
.cfg-spec-send .cfg-btn { width: 100%; }
.cfg-spec-send-note { margin: 8px 0 0; font-size: 11.5px; color: var(--text-mute); }

/* (the first-run tour moved to the shared page-tour.js engine + datalayer-tour.css) */

/* ====================== responsive ====================== */
@media (max-width: 880px) {
  .cfg-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .cfg-panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: 44vh; }
  .cfg-result { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .cfg-spec { border-left: 0; border-top: 1px solid var(--line); max-height: 46vh; }
  .cfg-turntable-row { bottom: 76px; }
}

/* ====================== reduced motion ====================== */
/* JS reads this too (to stop the auto-orbit turntable); here we drop UI
   transitions so nothing animates for people who asked it not to. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
