/* ============================================================
   DekFlip prototype — mobile-first, Castaway brand language
   ============================================================ */

@font-face {
  font-family: 'Cambria';
  src: url('Custom/fonts/Cambria.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ink: #0e1b26;
  --ink-2: #44525e;
  --ink-3: #8a949c;
  --bg: #f6f5f2;
  --card: #ffffff;
  --line: #e6e3dc;
  --accent: #0e7490;
  --accent-ink: #ffffff;
  --good: #157f3d;
  --radius: 14px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --shadow-1: 0 1px 2px rgba(14, 27, 38, 0.05), 0 4px 16px rgba(14, 27, 38, 0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Barlow', -apple-system, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: 96px; /* room for price bar */
}

/* ── header — dark navy like the live site (white logo art) ── */
.hd {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: #051826;
}
.hd-logo-img { height: 38px; width: auto; display: block; }
.hd-tag {
  font-size: 11px; letter-spacing: 1.8px; text-transform: uppercase;
  color: #7fb6c4; font-weight: 700;
}
.hd-admin { color: #7fb6c4 !important; }

/* ── product switcher ───────────────────────────────────── */
.switch {
  display: flex; gap: 6px; overflow-x: auto;
  background: #ecebe6; border-radius: 12px; padding: 4px;
  margin: 0 18px 4px;
  scrollbar-width: none;
}
.switch::-webkit-scrollbar { display: none; }
.switch button { flex: 0 0 auto; min-width: 150px; }
.switch button {
  appearance: none; border: 0; background: transparent;
  font: 600 14px/1 'Barlow', sans-serif; letter-spacing: 0.2px;
  color: var(--ink-2); border-radius: 9px; padding: 11px 8px;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}
.switch button:active { transform: scale(0.97); }
.switch button[aria-pressed="true"] {
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-1);
}
.switch button small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* ── preview ────────────────────────────────────────────── */
.stage {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--bg) 82%, rgba(246, 245, 242, 0));
  padding: 10px 18px 18px;
}
.stage-card {
  background:
    radial-gradient(130% 100% at 50% 8%, #ffffff 0%, #f4f2ee 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  height: min(46dvh, 380px);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.stage-card svg, .stage-card canvas {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;          /* never distort the cooler photo */
  touch-action: none;
}
.stage-card svg { padding: 10px; }
.stage-card canvas { padding: 6px; }
.stage-hint {
  position: absolute; bottom: 10px; left: 0; right: 0;
  text-align: center; font-size: 11px; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--ink-3); font-weight: 600;
  pointer-events: none;
  opacity: 1; transition: opacity 300ms ease;
}
.stage-hint.off { opacity: 0; }

/* ── control sections ───────────────────────────────────── */
.controls { padding: 4px 18px 12px; display: grid; gap: 14px; max-width: 560px; margin: 0 auto; }

.sec {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  opacity: 0; transform: translateY(8px);
  animation: secIn 360ms var(--ease-out) forwards;
}
.sec:nth-child(1) { animation-delay: 0ms; }
.sec:nth-child(2) { animation-delay: 40ms; }
.sec:nth-child(3) { animation-delay: 80ms; }
.sec:nth-child(4) { animation-delay: 120ms; }
.sec:nth-child(5) { animation-delay: 160ms; }
@keyframes secIn { to { opacity: 1; transform: translateY(0); } }

.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.sec-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
}
.sec-value { font-size: 13px; font-weight: 600; color: var(--accent); }

/* dimension steppers */
.dims { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dim label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px;
}
.stepper {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: stretch;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fbfaf8;
}
.stepper button {
  appearance: none; border: 0; background: transparent; font-size: 22px; font-weight: 500;
  color: var(--ink-2); cursor: pointer; padding: 10px 0;
  transition: transform 120ms var(--ease-out), background 150ms ease;
}
.stepper button:active { transform: scale(0.9); background: #f0eee8; }
.stepper input {
  border: 0; background: transparent; text-align: center;
  font: 600 19px 'Barlow', sans-serif; color: var(--ink);
  width: 100%; min-width: 0;
}
.stepper input:focus { outline: none; }
.frac {
  margin-top: 6px; width: 100%;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfaf8;
  font: 500 13px 'Barlow', sans-serif; color: var(--ink-2); padding: 7px 8px;
}

/* swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw {
  appearance: none; border: 0; padding: 0; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  background-size: cover; background-position: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
  position: relative;
  transition: transform 140ms var(--ease-out), box-shadow 180ms ease;
}
.sw:active { transform: scale(0.92); }
.sw[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
@media (hover: hover) and (pointer: fine) {
  .sw:hover { transform: scale(1.07); }
  .sw[aria-pressed="true"]:hover { transform: none; }
}

/* pattern cards */
.patterns { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.pat {
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfaf8;
  padding: 8px; display: grid; gap: 6px;
  transition: transform 140ms var(--ease-out), border-color 180ms ease, box-shadow 180ms ease;
}
.pat:active { transform: scale(0.96); }
.pat[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #fff; }
.pat svg { width: 100%; height: 44px; border-radius: 6px; background: #e9e7e0; display: block; }
.pat-name { font-size: 12px; font-weight: 600; color: var(--ink); }
.pat-price { font-size: 11px; font-weight: 600; color: var(--ink-3); }
.pat[aria-pressed="true"] .pat-price { color: var(--accent); }

/* personalize */
.pers-row { display: grid; gap: 10px; }
.pers-row input[type="text"], .pers-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfaf8; padding: 12px 14px;
  font: 500 15px 'Barlow', sans-serif; color: var(--ink);
  resize: vertical;
}
.pers-row input[type="text"]:focus, .pers-row textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.text-warn {
  font-size: 12.5px; font-weight: 600; color: #a33;
  background: #fbeaea; border: 1px solid #efc9c9; border-radius: 8px; padding: 8px 12px;
}
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toggle-label { font-size: 14px; font-weight: 600; }
.toggle-label small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.tg {
  appearance: none; width: 50px; height: 30px; border-radius: 30px; cursor: pointer;
  background: #ddd9d0; position: relative; transition: background 200ms ease; flex: none;
}
.tg::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 200ms var(--ease-out);
}
.tg:checked { background: var(--accent); }
.tg:checked::after { transform: translateX(20px); }

.buffer { display: grid; gap: 6px; }
.buffer-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.buffer input[type="range"] { width: 100%; accent-color: var(--accent); }
.buffer-note { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }

/* ── price bar ──────────────────────────────────────────── */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
}
.bar-inner { display: flex; align-items: center; gap: 14px; max-width: 560px; margin: 0 auto; }
.bar-price { flex: 1; min-width: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bar-total {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 26px; font-weight: 700; letter-spacing: 0.5px;
  transition: opacity 150ms ease;
}
.bar-total.tick { opacity: 0.35; }
.bar-sub { font-size: 11px; color: var(--ink-3); font-weight: 600; letter-spacing: 0.4px; }
.bar-cta {
  appearance: none; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font: 700 14px 'Barlow', sans-serif; letter-spacing: 1.2px; text-transform: uppercase;
  border-radius: 11px; padding: 14px 20px;
  transition: transform 140ms var(--ease-out), filter 180ms ease;
}
.bar-cta:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .bar-cta:hover { filter: brightness(1.08); } }

/* ── spec sheet (bottom sheet) ───────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 40; display: none;
}
.sheet.open { display: block; }
.sheet-bg { position: absolute; inset: 0; background: rgba(10, 20, 30, 0.4); opacity: 0; transition: opacity 240ms ease; }
.sheet.open .sheet-bg { opacity: 1; }
.sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-radius: 18px 18px 0 0;
  max-height: 78dvh; overflow: auto;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet.open .sheet-card { transform: translateY(0); }
.sheet-grab { width: 36px; height: 4px; border-radius: 4px; background: #d8d4cb; margin: 0 auto 14px; }
.sheet h3 {
  font-family: 'Barlow Condensed', sans-serif; font-size: 18px;
  letter-spacing: 1.4px; text-transform: uppercase; margin-bottom: 4px;
}
.sheet .sheet-sub { font-size: 12.5px; color: var(--ink-3); margin-bottom: 14px; }
.spec-lines { display: grid; gap: 0; margin-bottom: 14px; }
.spec-line {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.spec-line b { font-weight: 600; }
.spec-line.total { border-bottom: 0; font-size: 16px; }
.spec-line.total b { font-family: 'Barlow Condensed', sans-serif; font-size: 20px; letter-spacing: 0.5px; }
.sheet pre {
  background: #0e1b26; color: #9fd6e2; border-radius: 10px;
  font-size: 11.5px; line-height: 1.55; padding: 14px; overflow: auto;
}

/* ── panel (controls column) ────────────────────────────── */
.panel-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px; font-weight: 700; letter-spacing: 0.6px;
  padding: 10px 18px 2px;
  max-width: 560px; margin: 0 auto;
}
.hd-admin {
  margin-left: auto; font-size: 12px; font-weight: 600; letter-spacing: 0.6px;
  color: var(--accent); text-decoration: none;
}

/* logo picker */
.logo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px; margin-top: 12px; max-height: 320px; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fbfaf8;
}
.logo-card {
  appearance: none; border: 1px solid transparent; border-radius: 8px; background: #fff;
  cursor: pointer; padding: 6px 4px; display: grid; gap: 4px; justify-items: center;
  transition: transform 140ms var(--ease-out), border-color 160ms ease, box-shadow 160ms ease;
}
.logo-card:active { transform: scale(0.94); }
.logo-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.logo-card img { width: 100%; height: 52px; object-fit: contain; }
.logo-card span {
  font-size: 10px; font-weight: 600; color: var(--ink-2); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.logo-empty { grid-column: 1/-1; font-size: 12px; color: var(--ink-3); padding: 10px; }

/* model + thickness selects */
.model-select { font-size: 14.5px; padding: 11px 12px; color: var(--ink); width: 100%; margin-top: 0; }

/* shape toggle */
.shape-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shape-btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; background: #fbfaf8;
  font: 600 14px 'Barlow', sans-serif; color: var(--ink-2); padding: 11px;
  transition: transform 140ms var(--ease-out), border-color 160ms ease, box-shadow 160ms ease;
}
.shape-btn:active { transform: scale(0.96); }
.shape-btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #fff; color: var(--ink); }

/* pockets */
.pockets { display: grid; gap: 8px; }
.pocket-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 9px; background: #fbfaf8; padding: 8px 10px;
}
.pocket-label { font-size: 13px; font-weight: 600; flex: 1; }
.pocket-row label { font-size: 11px; font-weight: 700; color: var(--ink-3); display: flex; align-items: center; gap: 4px; }
.pocket-row input { width: 52px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 6px; font: 600 13px 'Barlow', sans-serif; text-align: center; }
.pocket-del {
  appearance: none; border: 0; background: transparent; color: var(--ink-3);
  font-size: 14px; cursor: pointer; padding: 4px 6px;
}
.pocket-add {
  appearance: none; cursor: pointer;
  border: 1px dashed var(--line); border-radius: 9px; background: transparent;
  font: 600 13px 'Barlow', sans-serif; color: var(--accent); padding: 10px;
  transition: transform 140ms var(--ease-out), border-color 160ms ease;
}
.pocket-add:active { transform: scale(0.97); }

/* font chips */
.fonts { display: flex; flex-wrap: wrap; gap: 8px; }
.font-chip {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; background: #fbfaf8;
  font-size: 14px; color: var(--ink); padding: 8px 12px;
  transition: transform 140ms var(--ease-out), border-color 160ms ease, box-shadow 160ms ease;
}
.font-chip:active { transform: scale(0.95); }
.font-chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #fff; }

/* cart */
.cart-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px; margin-left: 8px;
  background: #fff; color: var(--accent); border-radius: 20px;
  font-size: 12px; font-weight: 800;
}
.cart-items { display: grid; gap: 8px; margin-bottom: 14px; }
.cart-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fbfaf8;
}
.cart-item img { width: 72px; height: 48px; object-fit: contain; border-radius: 6px; background: #efede7; }
.cart-thumb-empty { width: 72px; height: 48px; border-radius: 6px; background: #efede7; flex: none; }
.cart-item-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.cart-item-info b { font-size: 13.5px; }
.cart-item-info span { font-size: 11.5px; color: var(--ink-3); }
.cart-item-price { font-size: 14px; }
.cart-empty { font-size: 13px; color: var(--ink-3); padding: 14px 0; }
.cart-checkout { width: 100%; position: static; transform: none; display: block; opacity: 0.55; cursor: not-allowed; }
.cart-checkout:active { transform: scale(0.99); }
.cart-note { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; margin-top: 10px; }

/* desktop price + CTA live in the stage (Kickflip orientation) */
.stage-price {
  display: none;
  position: absolute; top: 22px; right: 40px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 34px; font-weight: 700; letter-spacing: 0.5px; color: var(--ink-2);
  cursor: pointer; z-index: 6;
  transition: opacity 150ms ease;
}
.stage-price.tick { opacity: 0.35; }
.stage-cta {
  display: none;
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  appearance: none; border: 0; cursor: pointer; z-index: 6;
  background: var(--accent); color: var(--accent-ink);
  font: 700 15px 'Barlow', sans-serif; letter-spacing: 1.2px; text-transform: uppercase;
  border-radius: 11px; padding: 15px 34px;
  box-shadow: 0 6px 20px rgba(14, 116, 144, 0.35);
  transition: transform 140ms var(--ease-out), filter 180ms ease;
}
.stage-cta:active { transform: translateX(-50%) scale(0.97); }

/* ── mobile order: preview first ────────────────────────── */
.layout { display: flex; flex-direction: column; }
.stage { order: 0; }
.panel { order: 1; }

/* ── desktop: Kickflip orientation — controls LEFT, preview RIGHT ── */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .layout {
    display: grid; grid-template-columns: 470px 1fr; gap: 0;
    max-width: 1400px; margin: 0 auto;
    height: calc(100dvh - 110px);
  }
  .panel {
    order: 0; overflow-y: auto; height: 100%;
    border-right: 1px solid var(--line);
  }
  .panel-title { font-size: 26px; padding: 14px 18px 4px; margin: 0; max-width: none; }
  .controls { max-width: none; }
  .stage {
    order: 1; position: relative; padding: 18px 26px;
    height: 100%; display: flex; flex-direction: column;
  }
  .stage-card { height: 100%; flex: 1; }
  .stage-price, .stage-cta { display: block; }
  .bar { display: none; }
  .stage-hint { bottom: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  .sec { animation-duration: 1ms; }
  .sheet-card { transition-duration: 1ms; }
  .switch button, .sw, .pat, .stepper button, .bar-cta { transition-duration: 1ms; }
}
