/* =========================================================================
   Cart Source 3D Cart Configurator — styles
   ========================================================================= */

:root {
  /* Cart Source brand */
  --cs-red:        #C0272D;
  --cs-red-dark:   #9E1F24;
  --cs-red-light:  #E8393F;

  /* Light theme tokens — page bg is light grey-with-blue per v3 brief */
  --cs-bg:            #f3f5f8;            /* light grey with a hint of blue */
  --color-bg:         var(--cs-bg);
  --color-surface:    #ffffff;             /* cards stay white for contrast */
  --color-surface-2:  #f8fafc;
  --color-border:     #e2e6ec;
  --color-border-strong: #c8cfd8;
  --color-text:       #1c1b19;
  --color-text-mute:  #5b606a;             /* ≥4.9:1 on bg per WCAG AA */
  --color-text-soft:  #5b606a;             /* tightened from #7d828c (3.85:1) to keep small-text contrast ≥4.5:1 */
  --color-accent:     var(--cs-red);

  /* Layout */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.02);
  --shadow:    0 4px 16px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);

  /* Font stacks — EB Garamond (open-source) replaces Cabinet Grotesk + Satoshi */
  --font-display: 'EB Garamond', Garamond, 'Times New Roman', serif;
  --font-body:    'EB Garamond', Garamond, 'Times New Roman', serif;
}

[data-theme="dark"] {
  --cs-bg:            #15171a;
  --color-bg:         var(--cs-bg);
  --color-surface:    #1f2226;
  --color-surface-2:  #262a30;
  --color-border:     #2a2e34;
  --color-border-strong: #3a3e44;
  --color-text:       #f3f2ee;
  --color-text-mute:  #b4b8c0;
  --color-text-soft:  #888c94;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* =========================================================================
   HEADER
   ========================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: saturate(1.1);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo-svg { height: 34px; width: auto; }
.header-nav {
  margin-left: auto;
  display: flex;
  gap: 26px;
  align-items: center;
  font-weight: 500;
  color: var(--color-text-mute);
}
.header-nav a:hover { color: var(--color-text); }
.btn-nav-cta {
  background: var(--cs-red);
  color: #fff !important;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background 0.15s ease;
}
.btn-nav-cta:hover { background: var(--cs-red-dark); }
.theme-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-mute);
  width: 38px; height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--color-text); border-color: var(--color-border-strong); }

/* =========================================================================
   HERO
   ========================================================================= */
.hero-banner {
  padding: 40px 28px 28px;
  max-width: 1440px;
  margin: 0 auto;
}
.hero-inner { max-width: 820px; }
.hero-eyebrow {
  color: var(--cs-red);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 11.5px;
  font-weight: 700;
  margin: 0 0 8px;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(32px, 4.4vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 12px;
}
.hero-sub {
  font-size: 17px;
  color: var(--color-text-mute);
  max-width: 640px;
  margin: 0;
}

/* =========================================================================
   CONFIGURATOR LAYOUT
   ========================================================================= */
.configurator-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 980px) {
  .configurator-layout {
    grid-template-columns: 1fr;
  }
}

/* =========================================================================
   PREVIEW PANEL
   ========================================================================= */
.preview-panel { position: sticky; top: 80px; }
@media (max-width: 980px) { .preview-panel { position: static; } }

.preview-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.preview-topbar {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}
.preview-badge {
  font-weight: 700;
  letter-spacing: 0.02em;
}
.preview-hint {
  color: var(--color-text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(ellipse at 50% 90%, rgba(0,0,0,0.06), transparent 60%),
    linear-gradient(180deg, #fafaf8 0%, #eeedea 100%);
  overflow: hidden;
}
[data-theme="dark"] .canvas-wrap {
  background:
    radial-gradient(ellipse at 50% 90%, rgba(0,0,0,0.5), transparent 60%),
    linear-gradient(180deg, #26241f 0%, #1c1b19 100%);
}
#three-canvas { width: 100%; height: 100%; display: block; }

.loader-overlay {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(4px);
  z-index: 3;
}
[data-theme="dark"] .loader-overlay { background: rgba(0,0,0,0.55); }
.loader-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--cs-red);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  color: var(--color-text-mute);
  font-size: 13px;
  margin: 0;
}

.error-overlay {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.92);
  z-index: 4;
  text-align: center;
  padding: 24px;
}
/* CRITICAL — class rule above would otherwise override the [hidden] attribute's
   UA display:none, causing the error overlay to show permanently on every
   successful load. This line is the actual fix. Do not remove. */
.error-overlay[hidden] { display: none !important; }
[data-theme="dark"] .error-overlay { background: rgba(28,27,25,0.92); }
.error-overlay .error-msg { color: #a02c2c; margin: 0 0 12px; }
.retry-btn {
  background: var(--cs-red);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}

.view-controls {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-mute);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.12s ease;
}
.view-btn:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.view-btn.active {
  background: var(--cs-red);
  color: #fff;
  border-color: var(--cs-red);
}

/* Camera preset tabs */
.camera-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.cam-tab {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-mute);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.12s ease;
}
.cam-tab:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.cam-tab.active {
  background: var(--color-text);
  color: var(--color-surface);
  border-color: var(--color-text);
}

/* Exposure slider */
.exposure-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--color-border);
}
.exposure-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-soft);
}
#exposure-slider {
  flex: 1;
  accent-color: var(--cs-red);
}
.exposure-value {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--color-text-mute);
  min-width: 36px;
  text-align: right;
}

/* file:// protocol banner */
.protocol-banner {
  background: #fef3c7;
  border-bottom: 2px solid #d97706;
  color: #78350f;
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.6;
}
.protocol-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.protocol-banner h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: #92400e;
}
.protocol-banner p { margin: 4px 0; }
.protocol-banner code {
  background: #fde68a;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.color-readout {
  padding: 14px 18px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  font-size: 13px;
}
.readout-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.readout-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
}
.readout-meta {
  margin-left: auto;
  color: var(--color-text-soft);
  font-size: 12px;
  font-variant-numeric: lining-nums tabular-nums;
}
.readout-meta.spec-line {
  margin-left: 0;
  flex: 1 1 100%;
  padding-top: 6px;
  border-top: 1px dashed var(--color-border);
  color: var(--color-text);
  font-size: 13px;
  letter-spacing: 0.01em;
  font-variant-numeric: lining-nums tabular-nums;
}

/* =========================================================================
   CONTROLS PANEL
   ========================================================================= */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.control-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  flex-wrap: wrap;
}
.step-number {
  background: var(--cs-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.heading-sub {
  color: var(--color-text-soft);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  margin-left: 2px;
}
.control-hint {
  font-size: 12px;
  color: var(--color-text-soft);
  margin: 10px 0 0;
  line-height: 1.45;
}

/* Model sections (Retail / Back of House / Handbaskets) */
.model-section {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
}
.model-section:last-child { margin-bottom: 0; }
.model-section > legend {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-mute);
  padding: 0 0 8px;
  margin: 0;
}

/* Model cards */
.model-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 1280px) {
  .model-grid { grid-template-columns: repeat(2, 1fr); }
}
.model-card {
  display: flex;
  flex-direction: column;
  padding: 11px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--color-surface-2);
  min-height: 76px;
}
.model-card-placeholder {
  cursor: not-allowed;
  opacity: 0.6;
  border-style: dashed;
}
.model-card-placeholder:hover { transform: none; border-color: var(--color-border); }
.model-card:hover {
  border-color: var(--cs-red);
  transform: translateY(-1px);
}
.model-card.selected {
  border-color: var(--cs-red);
  background: color-mix(in srgb, var(--cs-red) 6%, var(--color-surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-red) 15%, transparent);
}
.model-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.model-desc {
  font-size: 13px;
  color: var(--color-text-mute);
  margin-top: 2px;
}
.model-cap {
  font-size: 11px;
  color: var(--color-text-soft);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* Finish picker */
.finish-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.finish-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  transition: all 0.15s ease;
}
.finish-btn:hover {
  border-color: var(--cs-red);
  transform: translateY(-1px);
}
.finish-btn.active {
  border-color: var(--cs-red);
  background: color-mix(in srgb, var(--cs-red) 6%, var(--color-surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-red) 15%, transparent);
}
.finish-preview {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.finish-preview-powder   { background: linear-gradient(135deg, #C0272D, #8B1D22); }
.finish-preview-zinc     { background: linear-gradient(135deg, #D0D0CE 0%, #9FA1A0 50%, #CECECE 100%); }
.finish-preview-chrome   { background: radial-gradient(circle at 30% 25%, #ffffff 0%, #C8CCCE 40%, #6B7075 100%); }
.finish-preview-stainless{ background: repeating-linear-gradient(90deg, #B8BBBE 0px, #CACDD0 2px, #A8ABAE 4px); }

/* Link toggle */
.link-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--color-text-mute);
  margin-bottom: 12px;
  cursor: pointer;
  user-select: none;
}
.link-toggle input { accent-color: var(--cs-red); }
#plastic-section.is-linked .swatch-grid,
#plastic-section.is-linked .custom-color-row { opacity: 0.55; pointer-events: none; }

/* Swatches */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.swatch-btn {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}
.swatch-btn:hover { transform: scale(1.15); z-index: 2; }
.swatch-btn.active {
  border-color: var(--color-text);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2), 0 0 0 2px var(--color-surface);
}
.swatch-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 3;
}
.swatch-btn:hover .swatch-tooltip { opacity: 1; }

/* Custom color row */
.custom-color-row {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  background: var(--color-surface-2);
}
.custom-color-label { color: var(--color-text-mute); }
.color-wheel {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.custom-hex {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--color-text-mute);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* Pantone + Hex customizer row */
.pantone-row {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: auto 1fr auto 100px;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  background: var(--color-surface-2);
}
.pantone-label {
  color: var(--color-text-mute);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.pantone-label-hex { margin-left: 4px; }
.pantone-input,
.pantone-hex-input {
  appearance: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 6px 8px;
  font: inherit;
  font-size: 12.5px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.02em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}
.pantone-input { font-family: var(--font-body); }
.pantone-input:focus,
.pantone-hex-input:focus {
  outline: none;
  border-color: var(--cs-red);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-red) 20%, transparent);
}
.pantone-input.invalid,
.pantone-hex-input.invalid {
  border-color: #d33;
  background: color-mix(in srgb, #d33 6%, var(--color-surface));
}
.pantone-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--color-text-soft);
  line-height: 1.4;
}
@media (max-width: 480px) {
  .pantone-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .pantone-label-hex { margin-left: 0; }
}

/* Quantity */
.qty-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.qty-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  font-size: 18px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.12s;
}
.qty-btn:hover { border-color: var(--cs-red); color: var(--cs-red); }
.qty-input {
  width: 90px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--color-surface);
  color: var(--color-text);
}
.qty-input:focus { outline: 2px solid var(--cs-red); outline-offset: 1px; }
.qty-tier {
  font-size: 12px;
  color: #2a7d3d;
  font-weight: 500;
  margin-left: 4px;
}
.qty-tier.warn { color: #c0272d; }

/* Summary */
.summary-card {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--cs-red) 8%, var(--color-surface)) 0%,
    var(--color-surface) 100%
  );
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.summary-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  margin: 0 0 14px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 13.5px;
}
.summary-row:last-of-type { border-bottom: none; }
.summary-row > span:first-child { color: var(--color-text-mute); }
.sum-color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sum-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
}
.summary-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
  flex: 1 1 auto;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}
.btn-primary {
  background: var(--cs-red);
  color: #fff;
}
.btn-primary:hover {
  background: var(--cs-red-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
}
.btn-secondary:hover { border-color: var(--cs-red); color: var(--cs-red); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--color-text-mute);
  line-height: 1;
  padding: 4px 10px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--color-surface-2); color: var(--color-text); }
.modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  margin: 0 0 8px;
}
.modal-body {
  color: var(--color-text-mute);
  margin: 0 0 18px;
  font-size: 14px;
}
.modal-config-summary {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.modal-config-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}
.modal-config-row > span { color: var(--color-text-mute); }
.modal-btn { display: block; text-align: center; text-decoration: none; }

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toast-in 0.3s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in {
  from { transform: translateX(-50%) translateY(10px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 24px 28px;
  color: var(--color-text-soft);
  font-size: 12.5px;
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

/* Utilities */
.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;
}

/* ─────────────────────────────────────────────────────────────────────────
   DIMENSION OVERLAY (RIMOWA-style callouts on the 3D canvas)
   Drawn via SVG inside .canvas-wrap. JS updates polyline points + text
   positions every frame when active. Hidden by default.
   ───────────────────────────────────────────────────────────────────────── */

.dim-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease-out;
}
.dim-overlay.active { opacity: 1; }
.dim-overlay .dim-line {
  fill: none;
  stroke: var(--color-text, #111);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.78;
  /* RIMOWA-style draw-in: bracket "extends" from offscreen when the overlay
     activates. pathLength is set to "1" in the SVG so a single dasharray
     covers the whole polyline regardless of pixel length. */
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              stroke-width 0.15s ease-out,
              opacity 0.15s ease-out;
}
.dim-overlay.active .dim-line { stroke-dashoffset: 0; }
.dim-overlay .dim-label {
  /* Labels fade in just after the bracket draws — subtle, not jumpy. */
  opacity: 0;
  transition: opacity 0.35s ease-out 0.25s;
}
.dim-overlay.active .dim-label { opacity: 1; }
.dim-overlay .dim-group:hover .dim-line {
  stroke-width: 1.6;
  opacity: 1;
}
[data-theme="dark"] .dim-overlay .dim-line { stroke: #e8e8e8; }
.dim-overlay .dim-label {
  fill: var(--color-text, #111);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.01em;
  font-variant-numeric: lining-nums tabular-nums;
  paint-order: stroke fill;
  stroke: var(--cs-bg, #fff);
  stroke-width: 3px;
  stroke-linejoin: round;
}
[data-theme="dark"] .dim-overlay .dim-label {
  fill: #f5f5f5;
  stroke: #1a1a1a;
}

.dim-unit-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-body);
  pointer-events: auto;
  z-index: 4;
}
.dim-unit-toggle[hidden] { display: none; }
.dim-unit-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text, #111);
  letter-spacing: 0.01em;
}
.dim-unit-buttons {
  display: inline-flex;
  background: var(--cs-bg, #fff);
  border: 1px solid var(--color-border, #d8d8d8);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.dim-unit-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted, #666);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.dim-unit-btn:hover { color: var(--color-text, #111); }
.dim-unit-btn.active {
  background: var(--color-text, #111);
  color: var(--cs-bg, #fff);
}
[data-theme="dark"] .dim-unit-buttons { background: #2a2a2a; border-color: #3a3a3a; }
[data-theme="dark"] .dim-unit-btn.active { background: #f5f5f5; color: #111; }

/* =========================================================================
   MOBILE RESPONSIVENESS — added in v3, RIMOWA-style polish
   ========================================================================= */
@media (max-width: 900px) {
  .header-inner    { padding: 12px 16px; gap: 12px; }
  .hero-banner     { padding: 24px 16px 16px; }
  .configurator-layout {
    grid-template-columns: 1fr;
    padding: 16px 16px 40px;
    gap: 20px;
  }
  .preview-panel, .controls-panel { width: 100%; }
  .preview-panel  { position: static; }
  .preview-card   { border-radius: 12px; }
  .canvas-wrap    { aspect-ratio: 4 / 3; max-height: 60vh; }
  .view-controls  { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .view-btn       { font-size: 13px; padding: 10px 12px; min-height: 44px; }
  .model-grid     { grid-template-columns: repeat(2, 1fr); }
  .swatch-grid    { grid-template-columns: repeat(4, 1fr); }
  .pantone-row    { grid-template-columns: 1fr; }
  .pantone-label-hex { margin-left: 0; }
  .swatch-btn     { min-height: 44px; }
  .qty-btn        { min-width: 44px; min-height: 44px; }
}

@media (max-width: 600px) {
  .header-nav     { display: none; }
  .hero-title     { font-size: clamp(28px, 7vw, 40px); }
  .hero-sub       { font-size: 15px; }
  .logo-svg       { height: 28px; }
  .model-grid     { grid-template-columns: 1fr; }
  .swatch-grid    { grid-template-columns: repeat(3, 1fr); }
  .preview-topbar { padding: 10px 12px; font-size: 12px; }
  .preview-badge  { font-size: 13px; }
  .preview-hint   { display: none; }
  .canvas-wrap    { aspect-ratio: 1 / 1; max-height: 70vh; }
  .dim-overlay .dim-label { font-size: 13px; }
  .dim-unit-toggle { top: 8px; left: 8px; }
}

/* =========================================================================
   FOCUS RINGS — accessibility (A11y) polish for v3 controls
   ========================================================================= */
.swatch-btn:focus-visible,
.model-card:focus-within,
.dim-unit-btn:focus-visible,
.qty-btn:focus-visible,
.view-btn:focus-visible,
.finish-btn:focus-visible,
.cam-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-red) 35%, transparent);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--cs-red);
  outline-offset: 2px;
}

/* =========================================================================
   PRINT SPEC SHEET — @media print
   ─────────────────────────────────────────────────────────────────────────
   The #print-sheet div is hidden on screen and only revealed when the user
   triggers window.print() via the "Download Spec Sheet" button. Everything
   else collapses so the PDF output is one clean A4/Letter page of spec data,
   no canvas, no swatches, no nav. updatePrintSheet() in app.js writes the
   field values before printing.
   ========================================================================= */

.print-sheet { display: none; }

@media print {
  /* Page setup */
  @page { size: Letter portrait; margin: 14mm 16mm; }
  html, body { background: #fff !important; color: #111 !important; font-family: 'EB Garamond', Georgia, serif !important; }

  /* Hide everything except the print sheet */
  .site-header, .hero-banner, .protocol-banner, .canvas-wrap, .preview-topbar,
  .control-panel, .summary-card, .modal-overlay, .toast, .site-footer,
  .three-canvas, .dim-overlay, .dim-unit-toggle, .preview-stack > .canvas-wrap,
  .summary-actions, .qty-row, .swatch-grid, .pantone-row, .model-section,
  .control-group, .preview-stack, .checkbox-row, .finish-grid, .cam-tabs,
  .legend { display: none !important; }

  .layout, .layout > * { display: block !important; padding: 0 !important; margin: 0 !important; }

  /* Reveal and style the print sheet */
  .print-sheet {
    display: block !important;
    color: #111;
    background: #fff;
    font-size: 11.5pt;
    line-height: 1.45;
  }
  .print-sheet * { color: inherit; background: transparent; }

  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1.5pt solid #C0272D;
    padding-bottom: 8pt;
    margin-bottom: 12pt;
  }
  .print-brand {
    display: flex;
    align-items: center;
    gap: 10pt;
  }
  .print-wordmark { display: flex; flex-direction: column; }
  .print-wordmark strong { font-size: 14pt; letter-spacing: 0.3pt; font-weight: 700; }
  .print-wordmark span   { font-size: 9.5pt; color: #555; }
  .print-meta { text-align: right; font-size: 9.5pt; line-height: 1.6; }

  .print-title {
    font-size: 22pt;
    font-weight: 600;
    margin: 4pt 0 14pt;
    color: #1A1A1A;
    page-break-after: avoid;
  }
  .print-section {
    margin-bottom: 16pt;
    page-break-inside: avoid;
  }
  .print-section h2 {
    font-size: 11pt;
    text-transform: uppercase;
    letter-spacing: 1pt;
    color: #555;
    border-bottom: 0.5pt solid #ddd;
    padding-bottom: 3pt;
    margin: 0 0 6pt;
    font-weight: 600;
  }
  .print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11pt;
  }
  .print-table th, .print-table td {
    padding: 4pt 8pt 4pt 0;
    text-align: left;
    vertical-align: top;
    border-bottom: 0.25pt solid #eee;
  }
  .print-table th {
    width: 130pt;
    font-weight: 500;
    color: #444;
  }
  .print-table td { color: #111; }
  .print-share {
    font-size: 9.5pt;
    word-break: break-all;
    background: #f5f5f5;
    padding: 6pt 8pt;
    border-radius: 3pt;
    margin-bottom: 8pt;
  }
  .print-footer {
    margin-top: 18pt;
    padding-top: 6pt;
    border-top: 0.5pt solid #ddd;
    display: flex;
    justify-content: space-between;
    font-size: 9pt;
    color: #777;
  }
}
