/* FProject — 3D track map configurator */
:root {
  --bg: #f3f1ed;
  --panel: #ffffff;
  --ink: #121212;
  --ink-2: #3d3b37;
  --muted: #6c6862;
  --line: #e6e2db;
  --line-2: #d6d1c8;
  --soft: #f6f4f0;
  --accent: #c8101c;
  --accent-ink: #ffffff;
  --r: 14px;
  --r-sm: 10px;
  --header: 60px;
  --panel-w: 440px;
  --display: 'Fira Sans Condensed', 'Arial Narrow', sans-serif;
  --body: 'Onest', system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(20, 18, 14, .06), 0 8px 24px rgba(20, 18, 14, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
svg { display: block; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  height: var(--header); display: flex; align-items: center; gap: 18px;
  padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.brand { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: .05em; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }
.top-product { font-size: 14px; color: var(--muted); padding-left: 18px; border-left: 1px solid var(--line-2); }
.top-contact { margin-left: auto; font-size: 14px; color: var(--ink-2); text-decoration: none; }
.top-contact:hover { color: var(--accent); }

/* ---------- layout ---------- */
.cfg {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w);
  height: calc(100dvh - var(--header));
}

/* ---------- stage ---------- */
.stage { position: relative; overflow: hidden; background: #7d7b77; }
.stage-canvas { position: absolute; inset: 0; cursor: grab; }
.stage-canvas.is-grabbing { cursor: grabbing; }
.stage-canvas canvas { width: 100% !important; height: 100% !important; display: block; }

.stage-badge {
  position: absolute; left: 20px; top: 20px; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px; background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--ink-2); box-shadow: var(--shadow);
  pointer-events: none;
}
.stage-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(200, 16, 28, .18); }

.stage-hint {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); margin: 0;
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  background: rgba(18, 18, 18, .78); color: #fff; font-size: 13px; white-space: nowrap;
  pointer-events: none; transition: opacity .5s, transform .5s;
}
.stage-hint svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.stage-hint.is-gone { opacity: 0; transform: translate(-50%, -8px); }
.hint-touch { display: none; }
@media (hover: none) { .hint-touch { display: inline; } .hint-desk { display: none; } }

.stage-tools {
  position: absolute; left: 20px; right: 20px; bottom: 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; pointer-events: none;
}
.stage-tools > * { pointer-events: auto; }
.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px); box-shadow: var(--shadow); }
.seg button {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .2s, color .2s;
}
.seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
.tool-row { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px); box-shadow: var(--shadow); cursor: pointer; color: var(--ink);
  transition: transform .15s, background .2s;
}
.icon-btn:hover { background: #fff; transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.stage-loader {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  background: rgba(226, 224, 220, .55); backdrop-filter: blur(3px); font-size: 14px; color: var(--ink-2);
  transition: opacity .35s; pointer-events: none;
}
.stage-loader.is-done { opacity: 0; }
.loader-bar { width: 180px; height: 3px; border-radius: 3px; background: rgba(0, 0, 0, .1); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }

.toast {
  position: absolute; left: 50%; top: 20px; transform: translate(-50%, -12px); opacity: 0;
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px;
  transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.scale-note {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(8px); box-shadow: var(--shadow); font-size: 13px; color: var(--ink-2);
  white-space: nowrap; opacity: 0; transition: opacity .3s; pointer-events: none;
}
.stage.is-wall .scale-note { opacity: 1; }
.stage.is-wall .stage-hint { opacity: 0; }
@media (max-width: 860px) { .scale-note { top: auto; bottom: 128px; font-size: 12px; max-width: calc(100% - 24px); text-overflow: ellipsis; overflow: hidden; } }

/* room + wall-colour picker, wall mode only, sitting just above the tools row */
.room-bar {
  position: absolute; left: 20px; right: 20px; bottom: 76px; z-index: 1;
  display: none; align-items: center; gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.room-bar::-webkit-scrollbar { display: none; }
.stage.is-wall .room-bar { display: flex; }
.room-chips, .wall-swatches {
  display: flex; gap: 6px; flex-shrink: 0; padding: 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.room-chips button {
  min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; transition: background .2s, color .2s;
}
.room-chips button[aria-checked="true"] { background: var(--ink); color: #fff; }
.wall-swatches button {
  width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--c); cursor: pointer; position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .16);
}
.wall-swatches button[aria-checked="true"]::after {
  content: ''; position: absolute; inset: -4px; border: 2px solid var(--ink); border-radius: 50%;
}
@media (max-width: 860px) { .room-bar { left: 12px; right: 12px; bottom: 60px; } }

/* full-screen preview */
.icon-btn .ico-close { display: none; }
.stage.is-full .icon-btn .ico-open { display: none; }
.stage.is-full .icon-btn .ico-close { display: block; }
.stage.is-full {
  position: fixed !important; inset: 0; width: 100vw; height: 100dvh !important; min-height: 0; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
body.has-full { overflow: hidden; }

/* ---------- panel ---------- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 28px 28px 8px; scrollbar-width: thin; }

.title-block { margin-bottom: 22px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.title-block h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 44px; line-height: 1; text-transform: uppercase; letter-spacing: .01em; }
.sub { margin: 8px 0 0; font-size: 15px; color: var(--muted); }

.step { padding: 20px 0; border-top: 1px solid var(--line); }
.step-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.step h2 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.n { width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; }
.step-val { font-size: 13px; color: var(--muted); }

.search { position: relative; display: block; margin-bottom: 10px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search input {
  width: 100%; height: 44px; padding: 0 12px 0 38px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--soft); font: inherit; font-size: 15px; color: var(--ink);
}
.search input:focus { outline: none; border-color: var(--ink); background: #fff; }

/* one-row track slider */
.cslider { position: relative; }
.circuits {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scroll-behavior: smooth;
  padding: 2px; margin: -2px; scrollbar-width: none;
}
.circuits::-webkit-scrollbar { display: none; }
.cs-btn {
  position: absolute; top: 50%; z-index: 2; width: 34px; height: 34px; margin-top: -17px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line-2); box-shadow: 0 4px 12px rgba(0,0,0,.14); font-size: 20px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; transition: opacity .2s, transform .15s;
}
.cs-btn:hover { transform: scale(1.08); } .cs-btn:active { transform: scale(.94); }
.cs-btn.prev { left: -6px; } .cs-btn.next { right: -6px; }
.cs-btn:disabled { opacity: 0; pointer-events: none; }
.cc {
  position: relative; display: flex; flex: 0 0 calc((100% - 16px) / 3); scroll-snap-align: start; flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 8px 9px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; cursor: pointer; text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cc:hover { border-color: var(--line-2); transform: translateY(-1px); }
.cc[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.cc svg { width: 100%; height: 54px; }
.cc svg path { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.cc[aria-checked="true"] svg path { stroke: var(--accent); }
.cc-name { font-size: 13px; font-weight: 600; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-rel { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.cc-rel i { flex: 1; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.cc-rel i::after { content: ''; display: block; height: 100%; width: var(--w); background: var(--ink-2); }
.circuits-empty { grid-column: 1 / -1; padding: 18px 6px; font-size: 14px; color: var(--muted); }

.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opts-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 420px) { .opts.opts-3 button { gap: 8px; padding: 0 10px; font-size: 14px; } .opts-3 .sw { width: 20px; height: 20px; } }
.opts button {
  min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; cursor: pointer; font-size: 15px; font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
}
.opts button:hover { border-color: var(--line-2); }
.opts button[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.sw { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 2px rgba(0, 0, 0, .12); }

.included { list-style: none; margin: 0; padding: 18px 0 20px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.included li { display: flex; gap: 10px; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.included svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.buy {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff;
}
.price { display: flex; align-items: baseline; gap: 10px; }
.price .now { font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1; }
.price s { font-size: 15px; color: var(--muted); }
.cta {
  min-height: 54px; display: inline-flex; align-items: center; gap: 10px; padding: 0 26px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 16px; font-weight: 600; cursor: pointer; transition: background .2s, transform .15s;
}
.cta:hover { background: #a90d17; transform: translateY(-1px); }
.cta svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.noscript { padding: 24px; text-align: center; }

/* ---------- tablet / phone ---------- */
@media (max-width: 1100px) { :root { --panel-w: 380px; } .panel-scroll { padding: 24px 22px 8px; } .buy { padding-inline: 22px; } }

/* phone-only logo inside the preview */
.stage-logo { display: none; }

@media (max-width: 860px) {
  /* App-like phone layout: nothing scrolls except the options sheet, so there is no sticky
     jumping. The grey preview runs up under the status bar and takes ~68% of the screen. */
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; background: #7d7b77; }
  .top { display: none; }
  .cfg { display: block; height: 100%; }
  .stage {
    position: fixed; top: 0; left: 0; right: 0; height: 68svh; min-height: 0; z-index: 6;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .stage-logo {
    display: block; position: absolute; left: 16px; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 2;
    font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: .05em; color: #fff; text-decoration: none;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .25);
  }
  .stage-logo span { color: #ff3b44; }
  .stage-badge { display: none; }
  .stage-hint { top: calc(env(safe-area-inset-top, 0px) + 50px); bottom: auto; font-size: 12px; }
  .stage-tools { left: 12px; right: 12px; bottom: 26px; }
  .icon-btn { width: 42px; height: 42px; }
  .tool-row { gap: 8px; }
  .panel {
    position: fixed; left: 0; right: 0; top: calc(68svh - 16px); bottom: 0; z-index: 7;
    border-left: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -6px 18px rgba(0, 0, 0, .12);
  }
  .panel-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 16px 16px 12px; }
  .title-block { margin-bottom: 12px; }
  .title-block h1 { font-size: 30px; }
  .sub { font-size: 14px; margin-top: 4px; }
  .step { padding: 14px 0; }
  .circuits { padding-bottom: 6px; }
  .cc { flex: 0 0 112px; }
  .cs-btn { display: none; }
  .buy { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0, 0, 0, .06); }
  .price .now { font-size: 28px; }
  .cta { min-height: 50px; padding: 0 22px; }
}

@media (max-width: 380px) { .seg button { padding: 0 9px; } .icon-btn[data-act="reset"] { display: none; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* rooms are real photos now: the wall colour swatches no longer apply */
.wall-swatches { display: none !important; }

/* studio only: the room view is switched off */
[hidden] { display: none !important; }
.stage-tools { justify-content: flex-end; }
