/* PolyWorks3D — dark workshop instrument panel.
   The ground is the shop banner's near-black; the action colour is the shop's
   own orange, sampled from it, so the storefront and the Etsy listings read as
   one shop rather than two. `--amber` keeps its name because it is referenced
   in a hundred places and renaming it would be churn, not a change. */

:root {
  --ink-900: #0e0e10;
  --ink-850: #141416;
  --ink-800: #1a1a1d;
  --ink-700: #232326;
  --ink-600: #2f2f34;
  --ink-500: #45454c;
  --fog-400: #8a8a93;
  --fog-300: #adadb6;
  --fog-200: #d2d2d8;
  --fog-100: #f0f0f2;

  /* The brand orange, straight off the shop banner. */
  --amber: #E4621F;
  --amber-dim: #a8431a;
  --teal: #4fbfa8;
  --rust: #d9694a;

  --edge: 1px solid var(--ink-600);
  --radius: 4px;
  --radius-lg: 8px;

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

/* The UA's [hidden] rule is a bare element selector, so any class here that
   sets `display` silently defeats it. Make hiding win outright - and use the
   attribute, not the property, so it works on SVG elements too. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink-900);
  color: var(--fog-200);
  font: 400 15px/1.55 var(--sans);
  /* Faint contour lines, so the ground reads as a map surface. */
  background-image:
    repeating-linear-gradient(115deg, rgba(228, 98, 31, .030) 0 1px, transparent 1px 78px),
    repeating-linear-gradient(25deg, rgba(228, 98, 31, .020) 0 1px, transparent 1px 112px);
}

h1, h2, h3 { color: var(--fog-100); font-weight: 600; letter-spacing: -.015em; margin: 0; }

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1240px, 100% - 40px); margin-inline: auto; }

.mono-label {
  font: 500 10.5px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fog-400);
}

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky; top: 0; z-index: 900;
  background: rgba(13, 16, 19, .93);
  backdrop-filter: blur(10px);
  border-bottom: var(--edge);
}
.topbar-inner {
  display: flex; align-items: center; gap: 22px;
  min-height: 58px; flex-wrap: wrap; padding-block: 8px;
}

.brand { display: flex; align-items: center; gap: 10px; }
/* The mark carries its own dark tile and rounded corners, so the box it used
   to sit in - a bordered square with an orange wash - would be a second frame
   around a logo that already has one. */
.brand-mark { flex: none; display: grid; place-items: center; line-height: 0; }
.brand-mark svg { display: block; }
.brand-name { font: 700 16.5px/1 var(--sans); color: var(--fog-100); letter-spacing: -.015em; }
.brand-3d { color: var(--amber); }
.brand-sub { font: 400 10.5px/1 var(--mono); color: var(--fog-400); letter-spacing: .1em; text-transform: uppercase; }

.stepper { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; }
.step-num {
  width: 19px; height: 19px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font: 600 10px/1 var(--mono);
  border: 1px solid var(--ink-500); color: var(--fog-400);
}
.step-label { font-size: 12.5px; color: var(--fog-400); white-space: nowrap; }
.step.is-active { background: var(--ink-800); }
.step.is-active .step-num { border-color: var(--amber); background: var(--amber); color: var(--ink-900); }
.step.is-active .step-label { color: var(--fog-100); }
.step.is-done .step-num { border-color: var(--teal); color: var(--teal); }
.step-rule { width: 18px; height: 1px; background: var(--ink-600); }

/* ------------------------------------------------------------------ hero */

.hero { padding: 46px 0 24px; }
.hero h1 {
  font-size: clamp(28px, 4.4vw, 46px); line-height: 1.08; max-width: 17ch;
  letter-spacing: -.03em;
}
.hero h1 em { font-style: normal; color: var(--amber); }
.hero p { max-width: 62ch; margin: 16px 0 0; color: var(--fog-300); font-size: 16px; }

.hero-facts { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 22px; }
.fact { display: flex; flex-direction: column; gap: 3px; }
.fact b { font: 600 15px/1.2 var(--sans); color: var(--fog-100); }

/* -------------------------------------------------------------- designer */

.designer { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .82fr); gap: 22px; padding-bottom: 40px; }
@media (max-width: 940px) { .designer { grid-template-columns: 1fr; } }

.panel {
  background: var(--ink-850);
  border: var(--edge);
  border-radius: var(--radius-lg);
}

/* search */
.searchbar { display: flex; gap: 8px; margin-bottom: 14px; position: relative; }
.searchbar input {
  flex: 1; min-width: 0;
  background: var(--ink-800); border: var(--edge); border-radius: var(--radius);
  color: var(--fog-100); font: 400 15px/1 var(--sans); padding: 12px 14px;
}
.searchbar input::placeholder { color: var(--fog-400); }
.searchbar input:focus { outline: 2px solid var(--amber); outline-offset: -1px; }

.btn {
  border: var(--edge); border-radius: var(--radius);
  background: var(--ink-700); color: var(--fog-100);
  font: 500 14px/1 var(--sans); padding: 12px 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--ink-600); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #2a1a06; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #ffb453; border-color: #ffb453; }
.btn-ghost { background: transparent; color: var(--fog-300); }
.btn-sm { padding: 8px 11px; font-size: 12.5px; }

.suggestions {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 800;
  background: var(--ink-800); border: var(--edge); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; max-height: 320px; overflow-y: auto;
}
.suggestions button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  color: var(--fog-200); font: 400 13.5px/1.4 var(--sans); padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--ink-700);
}
.suggestions button:last-child { border-bottom: 0; }
.suggestions button:hover, .suggestions button.is-cursor { background: var(--ink-700); color: var(--fog-100); }
.suggestions .sug-main { color: var(--fog-100); }
.suggestions .sug-rest { color: var(--fog-400); font-size: 12.5px; }

/* stage */
.stage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--ink-800); border: var(--edge); border-radius: 999px; padding: 3px; }
.tabs button {
  border: 0; background: none; color: var(--fog-400); cursor: pointer;
  font: 500 12.5px/1 var(--sans); padding: 8px 15px; border-radius: 999px;
}
.tabs button[aria-selected="true"] { background: var(--ink-600); color: var(--fog-100); }
.stage-meta { margin-left: auto; font: 400 11.5px/1 var(--mono); color: var(--fog-400); }

.stage {
  position: relative; aspect-ratio: 1 / 1; width: 100%;
  border: var(--edge); border-radius: var(--radius-lg); overflow: hidden;
  background: var(--ink-800);
}
@media (max-width: 620px) { .stage { aspect-ratio: 4 / 5; } }

#map, #viewer { position: absolute; inset: 0; }
#viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* The map's own panes sit at z-index 200-700, so an unlayered overlay disappears
   behind the tiles. The scrim also keeps the prompt legible over a busy map. */
.stage-empty {
  position: absolute; inset: 0; z-index: 620;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  color: var(--fog-300); text-align: center; padding: 24px; pointer-events: none;
  background: rgba(13, 16, 19, .72); backdrop-filter: blur(1.5px);
}

.frame-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 500; }
.frame-badge {
  position: absolute; top: 12px; left: 12px; z-index: 550;
  font: 500 11px/1 var(--mono); letter-spacing: .08em;
  background: rgba(13, 16, 19, .85); color: var(--fog-200);
  border: var(--edge); border-radius: 3px; padding: 6px 9px;
}
.stage-hint { margin-top: 9px; font-size: 12.5px; color: var(--fog-400); }

/* rotation + relief sliders over the stage */
.stage-controls {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 550;
  display: flex; align-items: center; gap: 12px;
  background: rgba(13, 16, 19, .88); border: var(--edge); border-radius: var(--radius);
  padding: 9px 13px; backdrop-filter: blur(6px);
}
.stage-controls label { font: 500 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fog-400); white-space: nowrap; }
.stage-controls output { font: 500 12px/1 var(--mono); color: var(--fog-100); min-width: 46px; text-align: right; }

input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 60px; height: 20px; background: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--ink-500); border-radius: 3px; }
input[type="range"]::-moz-range-track { height: 3px; background: var(--ink-500); border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; margin-top: -6px;
  border-radius: 50%; background: var(--amber); border: 2px solid var(--ink-900);
}
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border: 2px solid var(--ink-900); border-radius: 50%; background: var(--amber); }
input[type="range"]:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.glow-toggle {
  font: 500 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  color: var(--fog-300); background: transparent; border: var(--edge); border-radius: var(--radius);
  padding: 6px 9px; cursor: pointer;
}
.glow-toggle:hover { color: var(--fog-100); }
.glow-toggle[aria-pressed="true"] { color: #b8ff9a; border-color: #4d7a3a; background: #16210f; }
.glow-toggle:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* build progress */
.build-status {
  position: absolute; inset: 0; z-index: 600; display: grid; place-content: center;
  gap: 14px; justify-items: center; background: rgba(17, 22, 26, .93); padding: 24px; text-align: center;
}
.build-steps { display: grid; gap: 7px; font-size: 13px; text-align: left; }
.build-steps li { display: flex; align-items: center; gap: 9px; color: var(--fog-400); list-style: none; }
.build-steps li.is-done { color: var(--teal); }
.build-steps li.is-active { color: var(--fog-100); }
.build-steps ul { margin: 0; padding: 0; }
.tick { width: 14px; text-align: center; font: 400 12px/1 var(--mono); }
.progress-track { width: min(280px, 70vw); height: 3px; background: var(--ink-600); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--amber); width: 0; transition: width .3s ease; }

.spinner {
  width: 26px; height: 26px; border: 2px solid var(--ink-600); border-top-color: var(--amber);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ------------------------------------------------------------ options */

.options { display: flex; flex-direction: column; }
.opt-group { padding: 18px 18px 16px; border-bottom: var(--edge); }
.opt-group:last-of-type { border-bottom: 0; }
.opt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; }
.opt-value { margin-left: auto; font: 500 12px/1 var(--mono); color: var(--fog-100); }

.chip-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.chip {
  position: relative;
  border: var(--edge); border-radius: var(--radius); background: var(--ink-800);
  color: var(--fog-300); font: 500 13px/1 var(--sans); padding: 11px 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.chip:hover { border-color: var(--ink-500); color: var(--fog-100); }
.chip[aria-pressed="true"] { background: var(--ink-600); border-color: var(--amber); color: var(--fog-100); }
.chip-tall { flex-direction: row; padding: 12px 10px; justify-content: flex-start; }

.badge-rec {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  font: 600 8.5px/1 var(--mono); letter-spacing: .1em;
  background: var(--teal); color: var(--ink-900); border-radius: 2px; padding: 3px 5px; white-space: nowrap;
}

.swatch { display: inline-flex; border-radius: 2px; overflow: hidden; border: 1px solid var(--ink-500); flex: none; }
.swatch i { display: block; width: 8px; height: 16px; }
.dot { width: 13px; height: 13px; border-radius: 2px; border: 1px solid var(--ink-500); flex: none; }

.helper { margin: 9px 0 0; font-size: 12.5px; color: var(--fog-400); }
.helper strong { color: var(--fog-200); font-weight: 500; }
.helper.is-warning { color: var(--amber); }

.unit-toggle {
  display: inline-flex; margin-bottom: 10px;
  background: var(--ink-800); border: var(--edge); border-radius: 999px; padding: 3px;
}
.unit-toggle button {
  border: 0; background: none; cursor: pointer; color: var(--fog-400);
  font: 500 11.5px/1 var(--sans); padding: 7px 14px; border-radius: 999px;
}
.unit-toggle button[aria-pressed="true"] { background: var(--ink-600); color: var(--fog-100); }
.unit-toggle button:hover { color: var(--fog-100); }

.custom-area { display: flex; gap: 7px; align-items: center; margin-top: 9px; }
.custom-area input {
  width: 88px; background: var(--ink-800); border: var(--edge); border-radius: var(--radius);
  color: var(--fog-100); font: 400 14px/1 var(--mono); padding: 9px 10px;
}

details.advanced { border-top: var(--edge); }
details.advanced summary {
  padding: 14px 18px; cursor: pointer; font: 500 13px/1 var(--sans); color: var(--fog-300);
  display: flex; align-items: center; gap: 8px; list-style: none;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary::after { content: "+"; margin-left: auto; font: 400 16px/1 var(--mono); color: var(--fog-400); }
details.advanced[open] summary::after { content: "\2212"; }
details.advanced summary:hover { color: var(--fog-100); }
.advanced-body { padding: 0 18px 18px; display: grid; gap: 16px; }

/* sticky CTA */
.cta-dock { position: sticky; bottom: 0; padding: 14px 18px 16px; background: linear-gradient(to top, var(--ink-850) 72%, transparent); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.cta-dock .btn { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }
.cta-note { margin: 9px 0 0; text-align: center; font-size: 11.5px; color: var(--fog-400); }

/* -------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(6, 8, 10, .8);
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(4px);
}
.modal {
  width: min(520px, 100%); background: var(--ink-850); border: var(--edge);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden;
  max-height: 90vh; overflow-y: auto;
}
.modal-head { padding: 20px 22px 0; }
.modal-body { padding: 16px 22px 22px; display: grid; gap: 16px; }
.modal h2 { font-size: 21px; }
.modal p { margin: 8px 0 0; color: var(--fog-300); font-size: 14px; }

.code-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink-900); border: 1px dashed var(--amber-dim); border-radius: var(--radius);
  padding: 16px 18px;
}
.code-value { font: 600 21px/1 var(--mono); letter-spacing: .1em; color: var(--amber); flex: 1; word-break: break-all; }

.summary-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; }
.summary-grid dt { color: var(--fog-400); }
.summary-grid dd { margin: 0; color: var(--fog-100); }

.next-steps { counter-reset: n; display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.next-steps li { display: flex; gap: 11px; font-size: 13.5px; color: var(--fog-300); }
.next-steps li::before {
  counter-increment: n; content: counter(n);
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  background: var(--ink-700); color: var(--fog-200);
  font: 600 10.5px/20px var(--mono); text-align: center;
}

/* ------------------------------------------------------------ reviews */

.reviews { padding: 40px 0 48px; border-top: var(--edge); }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-top: 22px; }
.review { padding: 18px; background: var(--ink-850); border: var(--edge); border-radius: var(--radius-lg); }
.review p { margin: 0 0 12px; font-size: 14px; color: var(--fog-200); }
.review footer { font-size: 12.5px; color: var(--fog-400); }
.stars { color: var(--amber); font-size: 12px; letter-spacing: .12em; margin-bottom: 9px; }

.notice {
  margin-top: 16px; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--ink-600); border-left: 3px solid var(--amber);
  background: var(--ink-850); font-size: 12.5px; color: var(--fog-300);
}
/* Not every notice is a warning. A landmark being recognised is good news, and
   an orange left rule on it reads as a problem the buyer needs to solve. */
.notice.is-good { border-left-color: var(--teal); }

/* ------------------------------------------------- filament picker */

.layer-colours { display: grid; gap: 7px; margin-top: 4px; }
.layer-row { display: grid; grid-template-columns: 16px 1fr minmax(0, 1.35fr); align-items: center; gap: 9px; }
.layer-swatch {
  width: 15px; height: 15px; border-radius: 3px; flex: none;
  border: 1px solid var(--ink-500);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .14);
}
.layer-name { font-size: 13px; color: var(--fog-300); }
.layer-row select {
  width: 100%; min-width: 0;
  background: var(--ink-800); border: var(--edge); border-radius: var(--radius);
  color: var(--fog-100); font: 400 13px/1 var(--sans); padding: 7px 8px;
}
.layer-row select:focus { outline: 2px solid var(--amber); outline-offset: -1px; }

.sitefoot { border-top: var(--edge); padding: 24px 0 40px; font-size: 12.5px; color: var(--fog-400); }
.sitefoot p { margin: 0 0 7px; }

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(14px);
  z-index: 1200; background: var(--ink-700); border: var(--edge); border-radius: var(--radius);
  padding: 11px 17px; font-size: 13.5px; color: var(--fog-100); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { border-left: 3px solid var(--rust); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* The basemap style is a light one, so invert it and rotate the hue back to
   keep water blue and parks green rather than the candy colours a plain invert
   produces. Only the canvas is filtered — the controls sit outside it and stay
   readable. */
.maplibregl-map { background: var(--ink-800); font-family: var(--sans); }
.maplibregl-canvas {
  filter: invert(1) hue-rotate(180deg) brightness(.94) contrast(.86) saturate(.68);
}
.maplibregl-ctrl-group {
  background: var(--ink-800) !important; border: var(--edge) !important;
}
.maplibregl-ctrl-group button + button { border-top: var(--edge) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) opacity(.75); }
.maplibregl-ctrl-group button:hover { background: var(--ink-700) !important; }
.maplibregl-ctrl-attrib {
  background: rgba(13, 16, 19, .8) !important; color: var(--fog-400) !important;
}
.maplibregl-ctrl-attrib a { color: var(--fog-300) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1) opacity(.6); }

/* A chip for something the printer cannot do is shown and disabled rather than
   hidden: "why is there no black frame?" is a worse question than a greyed-out
   one with a tooltip. */
.chip:disabled {
  opacity: .38;
  cursor: not-allowed;
  border-style: dashed;
}
.chip:disabled:hover { background: var(--ink-800); }

/* The slot budget, once it is spent. */
.opt-value.is-full { color: var(--amber); }
