/* Print shop — ultra-minimal dark spatial UI */

:root {
  --void: #050507;
  --void-2: #0a0b10;
  --glow: rgba(91, 124, 255, 0.18);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --ink: #f2f2f4;
  --muted: #8b8d96;
  --royal: #5b7cff;
  --royal-hover: #7a94ff;
  --ok: #3dd68c;
  --warn: #ff6b6b;
  --radius: 16px;
  --radius-sm: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --topbar-h: 3.25rem;
  /* Collapsed sheet: handle + tabs only — product keeps the stage */
  --sheet-peek: 4.75rem;
  /* Open sheet: keep ≥58% free stage for product photography */
  --sheet-open-max: min(34vh, 300px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body.print-stage {
  font: 14px/1.45 var(--font);
  background: var(--void);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a {
  color: var(--royal);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ---------- Stage (full viewport 3D) ---------- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  /* Key light falloff sits upper-center — product photography, not full-frame CAD */
  background:
    radial-gradient(ellipse 68% 48% at 50% 36%, var(--glow) 0%, transparent 58%),
    radial-gradient(ellipse 100% 70% at 50% 100%, rgba(12, 14, 22, 0.95) 0%, transparent 48%),
    var(--void);
  overflow: hidden;
}

.stage-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.035) 0%, transparent 40%);
}

#viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

.dim-badge {
  position: absolute;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-b));
  transform: translateX(-50%);
  z-index: 2;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
}

.hint-toast {
  position: absolute;
  left: 50%;
  top: calc(var(--topbar-h) + 1rem + var(--safe-t));
  transform: translateX(-50%);
  z-index: 3;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 0.78rem;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
.hint-toast.show {
  opacity: 1;
}

.upload-orb {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: min(42vw, 220px);
  height: min(42vw, 220px);
  display: grid;
  place-items: center;
  pointer-events: none;
  text-align: center;
}
.upload-orb p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  z-index: 1;
}
.upload-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px dashed var(--border-strong);
  background: radial-gradient(circle, rgba(91, 124, 255, 0.08), transparent 70%);
  animation: pulse-ring 3s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.04);
    opacity: 1;
  }
}

/* ---------- HUD layer ---------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  perspective: 1200px;
  transform-style: preserve-3d;
}

.hud > * {
  pointer-events: auto;
}

/* Glass surface */
.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Top bar */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) calc(1rem + var(--safe-r)) 0 calc(1rem + var(--safe-l));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 30;
  background: linear-gradient(to bottom, rgba(5, 5, 7, 0.75), transparent);
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}
.brand span {
  color: var(--royal);
}
.brand:hover {
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 0.65rem;
  margin-left: auto;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.15rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.topbar nav a:hover {
  color: var(--ink);
}

.mode-tabs {
  display: flex;
  gap: 0;
  margin: 0 auto;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.mode-tabs button {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  min-height: 36px;
  min-width: 72px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.mode-tabs button.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  font-weight: 600;
}
.mode-tabs button:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
}

/* ---------- Desktop docks ---------- */

.dock {
  position: absolute;
  z-index: 20;
  padding: 0.85rem 0.95rem;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
  will-change: transform;
}

.dock h2 {
  margin: 0 0 0.65rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.dock h2.mt {
  margin-top: 0.85rem;
}

.dock-left {
  top: calc(var(--topbar-h) + var(--safe-t) + 0.75rem);
  left: calc(1rem + var(--safe-l));
  width: min(200px, 22vw);
}

.dock-right {
  top: calc(var(--topbar-h) + var(--safe-t) + 0.75rem);
  right: calc(1rem + var(--safe-r));
  width: min(260px, 26vw);
}

.dock-color {
  bottom: calc(1.25rem + var(--safe-b));
  left: calc(1rem + var(--safe-l));
  width: min(280px, 32vw);
  max-height: 160px;
}

.dock-order {
  bottom: calc(1.25rem + var(--safe-b));
  right: calc(1rem + var(--safe-r));
  width: min(300px, 34vw);
  max-height: min(52vh, 480px);
}

/* Mobile: hide desktop docks, show sheet */
.sheet {
  display: none;
}

/* ---------- Fields & controls ---------- */

.field {
  display: grid;
  gap: 0.28rem;
  margin-bottom: 0.7rem;
}
.field label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.field input[type="number"],
.field input[type="text"],
.field input[type="email"],
.field input[type="file"],
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  min-height: 40px;
  font: inherit;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--royal);
  box-shadow: 0 0 0 2px rgba(91, 124, 255, 0.25);
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--royal);
  height: 28px;
}
.field .hint,
.hint {
  font-size: 0.75rem;
  color: var(--muted);
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: end;
}

.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}
.style-grid button {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.35rem;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}
.style-grid button:hover {
  border-color: var(--border-strong);
}
.style-grid button.active {
  border-color: var(--royal);
  background: rgba(91, 124, 255, 0.15);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 20px rgba(91, 124, 255, 0.2);
}
.style-grid button:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-height: 88px;
  overflow: auto;
  scrollbar-width: thin;
}
.swatch {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.swatch:hover {
  transform: scale(1.08);
}
.swatch.active {
  box-shadow:
    0 0 0 2px var(--void),
    0 0 0 4px var(--royal),
    0 0 16px rgba(91, 124, 255, 0.45);
}
.swatch-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  min-height: 44px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.1);
}
.btn.primary {
  background: var(--royal);
  border-color: var(--royal);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--royal-hover);
  border-color: var(--royal-hover);
}
.btn.ghost {
  background: transparent;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  margin-top: 0.25rem;
}
.btn-row .primary {
  width: 100%;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  min-height: 40px;
  margin-bottom: 0.5rem;
}
.check-row input {
  accent-color: var(--royal);
  width: 18px;
  height: 18px;
}

.hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
}

.status {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.1em;
}
.status.ok {
  color: var(--ok);
}
.status.err {
  color: var(--warn);
}

.quote-box {
  margin-top: 0.65rem;
}
.quote-price {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ok);
  line-height: 1.1;
}
.quote-meta {
  margin: 0.65rem 0 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
}
.quote-meta div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.35rem;
}
.quote-meta dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.quote-meta dd {
  margin: 0;
  word-break: break-word;
}
.breaks {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.55rem;
  font-size: 0.78rem;
}
.breaks th,
.breaks td {
  text-align: left;
  padding: 0.3rem 0.25rem;
  border-bottom: 1px solid var(--border);
}
.breaks th {
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ship-form {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.note {
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---------- Mobile sheet ---------- */

@media (max-width: 900px) {
  /* Stage key light higher — product sits in free upper zone */
  .stage {
    background:
      radial-gradient(ellipse 78% 42% at 50% 28%, var(--glow) 0%, transparent 55%),
      radial-gradient(ellipse 100% 55% at 50% 100%, rgba(10, 12, 18, 0.98) 0%, transparent 45%),
      var(--void);
  }
  .stage-glow {
    background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.04) 0%, transparent 38%);
  }

  .dock-left,
  .dock-right,
  .dock-color,
  .dock-order {
    /* still in DOM for JS; visually hidden — content mirrored into sheet */
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    max-height: none;
  }

  .dim-badge {
    /* Sit mid-free-stage under the product, always above sheet */
    bottom: auto;
    top: auto;
    left: 50%;
    /* JS can refine; CSS fallback: above collapsed peek */
    transform: translateX(-50%);
    bottom: calc(var(--sheet-peek) + 0.85rem + var(--safe-b));
  }
  .sheet.is-open ~ .dim-badge,
  body:has(.sheet.is-open) .dim-badge {
    bottom: calc(min(34vh, 300px) + 0.75rem + var(--safe-b));
  }

  .sheet {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    /* Default: peek only (handle + tabs) — hero product owns the frame */
    height: calc(var(--sheet-peek) + var(--safe-b));
    max-height: calc(var(--sheet-peek) + var(--safe-b));
    background: rgba(12, 13, 18, 0.94);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    backdrop-filter: blur(22px) saturate(1.15);
    -webkit-backdrop-filter: blur(22px) saturate(1.15);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    padding-bottom: var(--safe-b);
    transition: height 0.35s var(--ease), max-height 0.35s var(--ease);
    overflow: hidden;
  }
  .sheet.is-open,
  .sheet[data-open="true"] {
    /* Open sheet: fixed ~1/3 viewport so ≥58% free stage for the product.
       Avoid min() here — some WebViews drop the whole declaration. */
    height: 32vh !important;
    max-height: 300px !important;
  }
  .sheet:not(.is-open):not([data-open="true"]) .sheet-body,
  .sheet[data-open="false"] .sheet-body {
    display: none;
  }

  .sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    margin: 0.45rem auto 0.25rem;
    flex-shrink: 0;
  }

  .sheet-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.2rem 0.65rem 0.45rem;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sheet-tabs::-webkit-scrollbar {
    display: none;
  }
  .sheet-tab {
    flex: 1 0 auto;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    min-height: 44px;
    font: inherit;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    color: var(--muted);
    cursor: pointer;
  }
  .sheet-tab.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border);
    color: var(--ink);
    font-weight: 600;
  }
  .sheet-tab:focus-visible {
    outline: 2px solid var(--royal);
    outline-offset: 2px;
  }

  .sheet-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.25rem 1rem 1rem;
    -webkit-overflow-scrolling: touch;
  }

  /* When JS moves panel into sheet, expand grids */
  .sheet-body .style-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .sheet-body .swatches {
    max-height: none;
  }
  .sheet-body .dock,
  .sheet-body .dock-left,
  .sheet-body .dock-right,
  .sheet-body .dock-color,
  .sheet-body .dock-order {
    position: static !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    background: none;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
    overflow: visible;
    transform: none !important;
  }

  .mode-tabs {
    margin: 0;
  }
  .topbar nav {
    display: none;
  }
}

/* Narrow phones: 2-col style in sheet is fine */
@media (max-width: 380px) {
  .sheet-body .style-grid {
    grid-template-columns: 1fr 1fr;
  }
  .mode-tabs button {
    min-width: 64px;
    padding: 0.4rem 0.7rem;
  }
}

/* Landscape phones: ultra-thin sheet, product stays on stage */
@media (max-height: 480px) and (orientation: landscape) {
  :root {
    --sheet-peek: 3.4rem;
    --sheet-open-max: min(52vh, 280px);
  }
  .stage {
    background:
      radial-gradient(ellipse 55% 70% at 42% 45%, var(--glow) 0%, transparent 55%),
      var(--void);
  }
  .dim-badge {
    bottom: calc(var(--sheet-peek) + 0.4rem + var(--safe-b));
  }
}

/* Short phones (SE / mini): tighter open sheet */
@media (max-width: 900px) and (max-height: 700px) {
  :root {
    --sheet-open-max: min(32vh, 260px);
  }
  .sheet.is-open,
  .sheet[data-open="true"] {
    height: min(32vh, 260px) !important;
    max-height: min(32vh, 260px) !important;
  }
}

/* Tall phones: still cap open sheet — more sky for the product */
@media (max-width: 900px) and (min-height: 800px) {
  :root {
    --sheet-open-max: min(32vh, 300px);
  }
  .sheet.is-open,
  .sheet[data-open="true"] {
    height: min(32vh, 300px) !important;
    max-height: min(32vh, 300px) !important;
  }
}

/* Tablet+ landscape with side docks: keep stage breathing room */
@media (min-width: 901px) and (max-width: 1100px) {
  .dock-left {
    width: 170px;
  }
  .dock-right {
    width: 220px;
  }
  .dock-color {
    width: 240px;
  }
  .dock-order {
    width: 260px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .upload-orb-ring {
    animation: none;
  }
}

/* Low-tier: drop expensive blur */
body.tier-low .glass,
body.tier-low .sheet,
body.tier-low .mode-tabs,
body.tier-low .dim-badge,
body.tier-low .hint-toast {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(18, 19, 26, 0.94);
}

/* Order status page (shared CSS) */
body:not(.print-stage) {
  overflow: auto;
  background: var(--void);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
body:not(.print-stage) .topbar {
  position: sticky;
  top: 0;
  height: auto;
  padding: 0.85rem 1.25rem;
  background: rgba(12, 13, 18, 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 20;
}
body:not(.print-stage) .wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
body:not(.print-stage) .hero h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  letter-spacing: -0.02em;
}
body:not(.print-stage) .panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
body:not(.print-stage) .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
body:not(.print-stage) .btn:hover {
  text-decoration: none;
}
