/* Imperial Millwork — Configurator styles */

/* ── Minimal header ───────────────────────────────────────────────────────── */
.cfg-header {
  background: var(--header-bg);
  padding-block: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.cfg-header-inner { display: flex; align-items: center; gap: var(--space-3); }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--header-ink); }
.logo-mark { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px;
             background: var(--brass); color: var(--paper-raised); font-family: var(--font-display);
             font-weight: 600; font-size: var(--text-base); border-radius: var(--radius-sm); }
.logo-text { font-family: var(--font-display); font-size: var(--text-xs); font-weight: 500;
             line-height: 1.2; color: var(--header-ink); }
.cfg-breadcrumb { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm);
                  color: var(--header-ink); opacity: .7; margin-left: auto; }
.cfg-breadcrumb a { color: inherit; text-decoration: none; }
.cfg-breadcrumb a:hover { text-decoration: underline; }
.cfg-breadcrumb span[aria-current] { opacity: 1; font-weight: 500; }

/* ── Step progress bar ────────────────────────────────────────────────────── */
.cfg-steps-bar {
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
  padding-block: 16px;
}
.cfg-steps-inner {
  display: flex;
  align-items: center;
  gap: 0;
  max-width: var(--max-content);
}
.step-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-faint);
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease);
  white-space: nowrap;
}
.step-tab:disabled { cursor: default; }
.step-tab.active   { color: var(--ink); }
.step-tab.done     { color: var(--brass); }
.step-tab .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-faint);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-body);
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.step-tab.active .step-num { background: var(--brass); color: var(--paper-raised); }
.step-tab.done   .step-num { background: var(--forest); color: #fff; }
.step-connector   { flex: 1; height: 1px; background: var(--line); min-width: 16px; transition: background var(--duration-base) var(--ease); }
.step-connector.done { background: var(--brass); }
@media (prefers-reduced-motion: reduce) { .step-connector { transition: none; } }

@media (max-width: 640px) {
  .step-tab span:last-child { display: none; }
  .step-connector { min-width: 8px; }
}

/* ── Main layout ──────────────────────────────────────────────────────────── */
.cfg-main { padding-block: var(--space-4); min-height: 70vh; }
.cfg-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 900px) {
  .cfg-body { grid-template-columns: 1fr; }
}

/* ── Step panels ──────────────────────────────────────────────────────────── */
.step-panel { display: none; }
.step-panel.active { display: block; animation: step-in .28s ease; }
.step-panel[hidden] { display: none; }
@keyframes step-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .step-panel.active { animation: none; } }
.step-panel h2 { font-size: var(--text-3xl); margin-bottom: var(--space-1); }
.step-desc { color: var(--ink-soft); margin-bottom: var(--space-4); }
.measure-link { color: var(--brass); font-weight: 500; }

/* ── Shape select grid ───────────────────────────────────────────────────── */
.shape-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.shape-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: var(--space-2);
  background: var(--paper-raised);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
  user-select: none;
}
.shape-option svg { width: 60px; height: 52px; color: var(--ink-soft); }
.shape-option:hover { border-color: var(--brass-soft); }
.shape-option:active { transform: scale(.96); }
.shape-option[aria-selected="true"] { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); color: var(--brass-ink); }
.shape-option[aria-selected="true"] svg { color: var(--brass); }

/* ── Field groups ─────────────────────────────────────────────────────────── */
.field-group { margin-bottom: var(--space-3); }
.field-group label {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 8px;
  color: var(--ink);
}
.input-wrap { position: relative; display: inline-flex; align-items: center; }
.input-wrap input, select, input[type="number"] {
  font-family: var(--font-body);
  font-size: var(--text-base);
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  width: 100%;
  max-width: 260px;
  transition: border-color var(--duration-fast) var(--ease);
}
.input-wrap input:focus, select:focus { border-color: var(--brass); outline: none; }
.input-unit { position: absolute; right: 12px; font-size: var(--text-sm); color: var(--ink-faint); pointer-events: none; }
.input-wrap--narrow input { max-width: 100px; }
.dim-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-2); }

/* ── Pills ────────────────────────────────────────────────────────────────── */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 8px 16px;
  border: 1.5px solid var(--line);
  border-radius: 100px;
  background: var(--paper-raised);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.pill:hover { border-color: var(--brass-soft); color: var(--ink); }
.pill:active { transform: scale(.95); }
.pill.selected { border-color: var(--brass); color: var(--brass-ink); background: var(--brass-soft); }

/* ── Swatch grid ──────────────────────────────────────────────────────────── */
.swatch-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper-raised); cursor: pointer; font-family: var(--font-body);
  text-align: left; transition: border-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.swatch-btn:hover { border-color: var(--brass-soft); }
.swatch-btn:active { transform: scale(.96); }
.swatch-btn.selected { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass-soft); }
.swatch-color { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,.1); }
.swatch-name { font-size: var(--text-sm); font-weight: 600; color: var(--ink); }
.swatch-note { font-size: var(--text-xs); color: var(--brass); }

/* ── Field hints ─────────────────────────────────────────────────────────── */
.field-hint { display: block; font-size: var(--text-xs); color: var(--ink-faint); margin-top: 6px; }
.field-hint a { color: var(--brass); }

/* ── Customize more ───────────────────────────────────────────────────────── */
.customize-more {
  margin-block: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}
.customize-more summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--brass);
  list-style: none;
  user-select: none;
}
.customize-more summary::after { content: ' ↓'; font-weight: 400; }
.customize-more[open] summary::after { content: ' ↑'; }
.customize-fields { padding-top: var(--space-2); }

/* ── Step footer ──────────────────────────────────────────────────────────── */
.step-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
  margin-top: var(--space-4);
}
.step-footer-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }

/* ── Combined "Configure" step sub-sections ─────────────────────────────── */
.cfg-subhead {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--ink);
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
}
.step-panel > .cfg-subhead:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

/* ── Preview panel ────────────────────────────────────────────────────────── */
.cfg-preview {
  position: sticky;
  top: calc(60px + 60px + var(--space-2)); /* header + steps bar + gap */
}
.preview-inner {
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
}
.preview-heading {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--ink);
}
.preview-schematic {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
  text-align: center;
}
#preview-svg { width: 100%; max-width: 160px; margin: auto; }

/* ── Preview spec DL ─────────────────────────────────────────────────────── */
.preview-spec { margin-bottom: var(--space-2); }
.spec-row { display: flex; justify-content: space-between; gap: var(--space-2); padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.spec-row:last-child { border-bottom: none; }
.spec-row dt { font-size: var(--text-xs); color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }
.spec-row dd { font-size: var(--text-sm); font-weight: 500; color: var(--ink); text-align: right; }
/* Values shown before the user has actually reached that field's step —
   these are real defaults (they'll apply as-is if the user doesn't change
   them), so keep them visible, just visually distinct from a confirmed
   choice. Removed via JS the moment the user actually picks a value. */
.spec-row dd.spec-default { color: var(--ink-faint); font-weight: 400; font-style: italic; }
.spec-row dd.spec-default::after { content: " (default)"; font-style: normal; }

/* ── Price display ────────────────────────────────────────────────────────── */
.preview-price-wrap { background: var(--paper); border-radius: var(--radius-sm); padding: var(--space-2); margin-bottom: var(--space-2); }
.preview-price-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); margin-bottom: 4px; }
.preview-price { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 600; color: var(--brass); font-variant-numeric: tabular-nums; }
.price-value { display: inline-block; }
.price-value.bump { animation: price-bump .22s ease; }
@keyframes price-bump { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .price-value.bump { animation: none; } }
.price-loading { font-size: var(--text-base); color: var(--ink-faint); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }
.preview-shipping { font-size: var(--text-xs); color: var(--ink-faint); margin-top: 4px; }
.preview-note { font-size: var(--text-xs); color: var(--ink-faint); }

/* ── Freight warning ─────────────────────────────────────────────────────── */
.freight-warn {
  background: #fff3cd;
  border: 1px solid #f0c040;
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font-size: var(--text-xs);
  color: #7a5c00;
}
:root[data-theme="dark"] .freight-warn,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .freight-warn {
  background: #3a2d00; border-color: #7a5c00; color: #e8c94e;
}}

/* ── Mounting-type diagrams ──────────────────────────────────────────────── */
.mount-diagram-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-bottom: var(--space-2); }
.mount-diagram { margin: 0; border: 1.5px solid var(--line); border-radius: var(--radius-md); overflow: hidden; background: transparent; }
.mount-diagram img { display: block; width: 100%; height: auto; }
.mount-diagram figcaption { padding: 6px var(--space-1); font-size: var(--text-xs); color: var(--ink-soft); text-align: center; background: var(--paper); }
@media (max-width: 480px) { .mount-diagram-grid { grid-template-columns: 1fr; } }
.sill-reference { max-width: 360px; margin-bottom: var(--space-2); }

/* ── Cart panel ──────────────────────────────────────────────────────────── */
.cart-panel { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--line); }
.cart-list { list-style: none; padding: 0; margin: 0 0 var(--space-1); }
#cart-count.bump { display: inline-block; animation: price-bump .3s cubic-bezier(.22,1,.36,1); }
.cart-item { animation: cart-item-in .3s ease; }
@keyframes cart-item-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { #cart-count.bump, .cart-item { animation: none; } }
.cart-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--space-1); padding: 6px 0; border-bottom: 1px solid var(--line-soft);
  font-size: var(--text-xs);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name { color: var(--ink); font-weight: 500; }
.cart-item-spec { color: var(--ink-faint); display: block; }
.cart-item-price { color: var(--brass); font-weight: 600; white-space: nowrap; }
.cart-item-remove {
  background: none; border: none; color: var(--ink-faint); cursor: pointer;
  font-size: var(--text-sm); line-height: 1; padding: 0 0 0 6px;
}
.cart-item-remove:hover { color: var(--wood); }
.cart-total-row { display: flex; justify-content: space-between; font-weight: 600; color: var(--ink); font-size: var(--text-sm); padding-top: 4px; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.cfg-footer { border-top: 1px solid var(--line); padding-block: var(--space-3); }
.cfg-footer-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.cfg-footer p { font-size: var(--text-sm); color: var(--ink-soft); }
.cfg-footer p a { color: var(--brass); }
.footer-home-link { font-size: var(--text-sm); color: var(--ink-soft); text-decoration: none; }
.footer-home-link:hover { color: var(--brass); }

/* ── Mobile overrides (placed last on purpose) ──────────────────────────────
   These override earlier unconditional rules (.cfg-header, .cfg-preview) at
   equal specificity — a media query alone doesn't win a cascade tie, only
   source order does. An earlier attempt to disable .cfg-preview's sticky
   behavior on mobile silently never applied because it was placed BEFORE
   the base `.cfg-preview { position: sticky; ... }` rule further down this
   file — every "fix" since then was real cleanup, but the actual sticky
   preview panel this targets was never actually turned off until now. */
@media (max-width: 900px) {
  /* position: sticky + grid order together is a known Chromium bug source —
     scroll can appear to "stick" while the page continues moving underneath.
     Not needed here anyway: on a single column the panel already leads. */
  .cfg-preview { order: -1; position: static; top: auto; }

  /* App shell: static top chrome (header + step tabs), one scrollable
     region below containing everything else (preview + step panels +
     footer). Real fixed-viewport flex layout instead of position:sticky —
     avoids that bug class entirely rather than tuning around it again. */
  .cfg-shell {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .cfg-static-top { flex: none; }
  .cfg-header { position: static; }
  .cfg-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* How-to video */
.howto-link { background: none; border: 0; padding: 0; font: inherit; color: var(--brass-ink); text-decoration: underline; cursor: pointer; }
.howto-dialog { margin: auto; border: 0; border-radius: var(--radius-md); padding: 0; width: min(960px, 94vw); background: var(--ink); }
.howto-dialog::backdrop { background: rgba(20, 16, 12, .75); }
.howto-dialog video { display: block; width: 100%; height: auto; }
.howto-dialog form { display: flex; justify-content: flex-end; padding: .75rem; }

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