/*
 * Kitchen configurator — the stylesheet.
 *
 * Room studio's design language, carried over: dark glass panels, a dock of
 * section buttons at the bottom centre, a control panel on the right that
 * becomes a bottom sheet on a phone, icon buttons and a quality select at
 * the top right, a loading screen with a real progress bar and a veil for
 * discrete changes. Every target is 44 px or more; the safe-area insets are
 * honoured. Everything the room had that a kitchen has not (the seat grid,
 * the display readout, the transport) is gone, and the kitchen's own pieces
 * (the unit strip, the floating and dimension labels, the floor disc, the
 * price pill and summary table, the image swatches) are at the end.
 */

:root {
  color-scheme: dark;
  --ink: #eef1ec;
  --muted: #a8b4ac;
  --panel: #17231ef2;
  --line: #ffffff19;
  --accent: #c2daab;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  background: #0e1712;
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------- controls */

button, input, select { font: inherit; }
button, select { color: inherit; background: #ffffff08; border: 1px solid var(--line); border-radius: 12px; }
button { cursor: pointer; min-height: 44px; padding: 10px 14px; touch-action: manipulation; transition: background .18s, color .18s, border-color .18s; }
button:hover { background: #ffffff16; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [role=option]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button[aria-pressed=true] { background: var(--accent); color: #203124; border-color: transparent; }
svg { width: 21px; height: 21px; flex-shrink: 0; }

/* ---------------------------------------------------------------- the stage */

#stage { position: absolute; inset: 0; }
#stage canvas { width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#stage > canvas { position: absolute; inset: 0; z-index: 1; }
.top-actions, .dock, .control-panel, .walk-stick, .look-hint { z-index: 3; }
#loading { z-index: 5; }
#veil { position: absolute; inset: 0; background: #0b1210; opacity: 0; pointer-events: none; transition: opacity 150ms ease; z-index: 2; }

/* ---------------------------------------------------------------- top right */

.top-actions {
  position: absolute;
  top: max(26px, env(safe-area-inset-top));
  right: max(26px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  align-items: center;
}
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; flex-shrink: 0; background: #15201bdd; backdrop-filter: blur(15px); }
.icon-button[aria-pressed=true] { background: var(--accent); color: #203124; }
.status {
  font-size: 11px;
  background: #15201be6;
  backdrop-filter: blur(15px);
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 30px;
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.price-pill { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; min-height: 40px; }
.price-pill:hover { background: #1f2e26e6; }
.status-toast { min-height: 40px; display: flex; align-items: center; }
/* An announcement for screen readers only (the price, which the pill already shows): out of view, still in the tree. */
.status-toast.quiet { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.quality-select {
  width: auto;
  min-height: 40px;
  padding: 8px 30px 8px 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  background: #15201be6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23eef1ec' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center/12px;
  backdrop-filter: blur(15px);
  border: 1px solid var(--line);
  border-radius: 30px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.quality-select:hover { background-color: #1f2e26e6; }

/* ---------------------------------------------------------------- the dock */

.dock {
  position: absolute;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  padding: 7px;
  background: var(--panel);
  border: 1px solid #ffffff25;
  border-radius: 20px;
  box-shadow: 0 12px 40px #0005;
  backdrop-filter: blur(22px);
}
.dock button { display: flex; align-items: center; gap: 9px; border-color: transparent; background: transparent; padding: 11px 17px; font-size: 12px; font-weight: 500; border-radius: 13px; }
.dock button[aria-expanded=true] { background: #e6eedf; color: #203124; }

/* ---------------------------------------------------------------- the panel */

.control-panel {
  position: absolute;
  right: 26px;
  top: 88px;
  width: clamp(310px, 24vw, 380px);
  max-height: calc(100% - 114px - var(--safe-bottom));
  background: var(--panel);
  border: 1px solid #ffffff25;
  border-radius: 22px;
  box-shadow: 0 14px 55px #0004;
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-heading { padding: 23px 21px 19px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading h2 { font-size: 20px; letter-spacing: -.5px; font-weight: 500; margin: 0; }
.panel-heading p { font-size: 11px; color: var(--muted); margin: 4px 0 0; }
.panel-heading .icon-button { border: none; background: #ffffff08; width: 36px; height: 36px; min-height: 44px; min-width: 44px; }
.panel-scroll { padding: 0 21px 22px; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b8c6bd45 transparent; touch-action: pan-y; }
.panel-grip { display: none; }

.help { font-size: 11px; line-height: 1.6; color: var(--muted); margin: 14px 0; }
.segments { display: flex; background: #0002; border: 1px solid var(--line); border-radius: 13px; padding: 4px; gap: 3px; }
.segments button { flex: 1; border: 0; background: none; font-size: 12px; padding: 9px 6px; border-radius: 9px; }
.segments button[aria-pressed=true] { background: #e6eedf; color: #203124; }
.wide { width: 100%; margin-top: 14px; }

details { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 5px; }
summary { cursor: pointer; font-size: 11px; color: #c1cfc5; padding: 14px 0; min-height: 44px; touch-action: manipulation; }
.details-content { padding: 0 0 7px; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 46px; font-size: 12px; cursor: pointer; }
input[type=checkbox] { appearance: none; width: 34px; height: 21px; border: 1px solid #ffffff28; border-radius: 20px; background: #26312b; position: relative; flex-shrink: 0; cursor: pointer; }
input[type=checkbox]:before { content: ''; position: absolute; left: 3px; top: 3px; width: 13px; height: 13px; border-radius: 50%; background: #bcc5bf; transition: transform .15s; }
input[type=checkbox]:checked { background: #bcd6a8; }
input[type=checkbox]:checked:before { transform: translateX(13px); background: #24472b; }
input[type=checkbox]:disabled { opacity: .38; cursor: default; }

.range-label { display: flex; justify-content: space-between; font-size: 12px; margin: 23px 0 4px; color: #d8e2d9; }
.range-label output { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; height: 36px; margin: 0; accent-color: #c6dfb3; cursor: pointer; touch-action: pan-y; }
input[type=range]::-webkit-slider-thumb { width: 21px; height: 21px; }
input[type=range]:disabled { opacity: .38; cursor: default; }
select { width: 100%; min-height: 44px; padding: 10px 12px; background: #26362d; }
select:disabled { opacity: .5; cursor: default; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset-grid button { display: flex; align-items: center; gap: 11px; font-size: 11px; min-height: 52px; }
.preset-orb { width: 23px; height: 23px; border-radius: 50%; background: linear-gradient(145deg, #f0e2b8, #bbcdda); box-shadow: inset 0 0 0 1px #ffffff2a; flex-shrink: 0; }
.preset-orb.soft { background: linear-gradient(145deg, #e9edf2, #aab4bb); }
.preset-orb.evening { background: linear-gradient(145deg, #e0a262, #3f4550); }
/* The two plan shapes on the layout buttons. */
.shape { width: 22px; height: 22px; flex-shrink: 0; border: 2px solid currentColor; border-radius: 3px; opacity: .8; }
.shape-straight { border-width: 0 0 4px; border-radius: 0; height: 16px; }
.shape-l { border-width: 0 0 4px 4px; border-radius: 0; }

.color-heading { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin: 10px 0 6px; }
.color-heading:not(:first-child) { margin-top: 23px; }
input[type=color] { width: 44px; height: 44px; background: none; padding: 9px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatches button { position: relative; flex: 1 0 40px; min-width: 40px; max-width: 64px; height: 44px; padding: 8px; border-color: transparent; background: none; }
.swatches button:before { content: ''; display: block; width: 27px; height: 27px; margin: auto; background: var(--swatch); background-size: cover; background-position: center; border-radius: 50%; border: 1px solid #ffffff44; }
.swatches button:hover { border-color: #ffffff45; }
.swatches button[aria-pressed=true] { background: none; border-color: var(--accent); }
.swatches button[aria-pressed=true]:before { box-shadow: 0 0 0 2px #17231e, 0 0 0 4px var(--accent); }
/* An image swatch: the thumbnail from the manifest fills the disc. */
.swatches button[style*="url("]:before { border-color: #ffffff66; }

.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions button, .actions select { flex: 1; font-size: 11px; min-width: 0; }

/* ---------------------------------------------------------------- walking */

.walk-stick { position: absolute; left: 28px; bottom: calc(110px + var(--safe-bottom)); width: 132px; height: 132px; touch-action: none; user-select: none; -webkit-user-select: none; }
.stick-base { position: relative; width: 100%; height: 100%; border-radius: 50%; background: #17231eb8; border: 1px solid #ffffff2e; backdrop-filter: blur(12px); box-shadow: 0 10px 30px #0005; display: grid; place-items: center; cursor: grab; transition: background .18s, border-color .18s; }
.walk-stick.active .stick-base { background: #1d2c25d9; border-color: #c2daab80; cursor: grabbing; }
.stick-knob { width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #dcecd0, #a9c497 70%); box-shadow: 0 4px 12px #0006, inset 0 0 0 1px #ffffff40; pointer-events: none; transition: transform .06s linear; }
.walk-stick.active .stick-knob { transition: none; }
.stick-mark { position: absolute; width: 0; height: 0; border: 5px solid transparent; opacity: .55; pointer-events: none; }
.stick-mark.n { top: 9px; left: calc(50% - 5px); border-bottom-color: #e6eedf; border-top: 0; }
.stick-mark.s { bottom: 9px; left: calc(50% - 5px); border-top-color: #e6eedf; border-bottom: 0; }
.stick-mark.w { left: 9px; top: calc(50% - 5px); border-right-color: #e6eedf; border-left: 0; }
.stick-mark.e { right: 9px; top: calc(50% - 5px); border-left-color: #e6eedf; border-right: 0; }
.look-hint { position: absolute; bottom: calc(139px + var(--safe-bottom)); right: 32px; font-size: 11px; color: #eef4e9; pointer-events: none; text-shadow: 0 1px 8px #000; }
.panel-open .look-hint { right: calc(clamp(310px, 24vw, 380px) + 50px); }

/* ---------------------------------------------------------------- loading and progress */

#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; background: #17231e; }
#loading p { font-size: 18px; letter-spacing: -.3px; margin: 22px 0 7px; }
#loading small { font-size: 11px; color: #9bad9f; }
#loading progress { width: min(260px, 65vw); margin: 14px 0 12px; }
progress { appearance: none; border: 0; height: 3px; border-radius: 4px; background: #ffffff10; overflow: hidden; }
progress::-webkit-progress-bar { background: #ffffff10; }
progress::-webkit-progress-value { background: #76bfc4; border-radius: 4px; }
progress::-moz-progress-bar { background: #76bfc4; }
progress:indeterminate { background: linear-gradient(90deg, #ffffff0b 20%, #76bfc4 50%, #ffffff0b 80%); background-size: 220% 100%; animation: progress-slide 1.8s ease-in-out infinite; }
.inline-progress { padding: 14px 0 3px; font-size: 10px; color: #c9dddb; }
.inline-progress progress { width: 100%; display: block; margin: 8px 0; }
.inline-progress small { font-size: 9px; color: var(--muted); }
.error { position: absolute; top: 35%; left: 10%; right: 10%; padding: 24px; text-align: center; background: #223d2d; z-index: 20; border-radius: 16px; }
@keyframes progress-slide { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }

/* ---------------------------------------------------------------- the kitchen's own pieces */

/* The unit strip: one tile per unit in the run, scrolling sideways, the selected one in the accent. */
.unit-strip { display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #b8c6bd45 transparent; padding: 12px 2px 8px; margin: 0 -2px; scroll-snap-type: x proximity; }
.unit-strip [role=option] { flex: 0 0 64px; width: 64px; min-height: 56px; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 10px; scroll-snap-align: center; }
.unit-strip [role=option] strong { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.1; }
.unit-strip [role=option] span { font-size: 8.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--muted); }
.unit-strip [role=option][aria-selected=true] { background: var(--accent); color: #203124; border-color: transparent; }
.unit-strip [role=option][aria-selected=true] span { color: #34483a; }
.strip-empty { font-size: 11px; color: var(--muted); margin: 8px 2px; }

/* Labels over the kitchen: positioned by main.js each render, never interactive. */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.floating-label, .dim-label { position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap; background: #15201be6; backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 20px; padding: 6px 11px; font-size: 11px; color: var(--ink); will-change: transform; }
.floating-label { font-weight: 500; }
.dim-label { font-size: 10px; color: #d8e2d9; font-variant-numeric: tabular-nums; }

/* The ring that marks where a click on the floor walks to. */
.floor-disc { position: absolute; left: 0; top: 0; width: 24px; height: 24px; margin: -12px 0 0 -12px; border: 2px solid var(--accent); border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 4px #c2daab33; z-index: 2; transition: opacity .3s; }

/* The summary. */
.price-headline { font-size: 26px; font-weight: 500; letter-spacing: -.5px; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.summary-table th, .summary-table td { padding: 7px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-weight: 400; }
.summary-table thead th, .summary-table tr:first-child th { color: var(--muted); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.summary-table td { text-align: right; white-space: nowrap; padding-left: 10px; color: #d8e2d9; }
.summary-table th[scope=row] { color: var(--ink); }
.summary-table .summary-total th, .summary-table .summary-total td { border-bottom: 0; padding-top: 12px; font-weight: 500; font-size: 12px; }

/* Poster mode: the kitchen alone. */
body[data-poster] .top-actions, body[data-poster] .dock, body[data-poster] #controls, body[data-poster] #labels, body[data-poster] .walk-stick, body[data-poster] .look-hint, body[data-poster] .floor-disc { display: none !important; }

/* ---------------------------------------------------------------- responsive */

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

@media (max-width: 1180px) {
  .control-panel { max-height: calc(100% - 204px - var(--safe-bottom)); }
}

@media (max-width: 1000px) {
  .dock button { padding: 11px 14px; }
  .control-panel { width: 290px; right: 18px; }
  .top-actions { right: 18px; }
  .panel-heading { padding: 20px 18px 16px; }
  .panel-scroll { padding: 0 18px 20px; }
}

@media (max-width: 700px) {
  .top-actions { top: calc(15px + env(safe-area-inset-top)); right: 14px; left: 14px; gap: 6px; justify-content: flex-end; }
  .top-actions .icon-button { width: 44px; height: 44px; }
  .price-pill { min-height: 44px; padding: 10px 12px; max-width: 120px; }
  /* Announcements drop under the row, so they never push the buttons off the screen. */
  .status-toast { position: absolute; top: 52px; right: 0; max-width: calc(100vw - 28px); }
  .dock { bottom: calc(12px + var(--safe-bottom)); width: calc(100% - 28px); max-width: 400px; padding: 5px; gap: 2px; border-radius: 18px; }
  .dock button { flex: 1; flex-direction: column; gap: 3px; padding: 8px 3px; font-size: 9px; min-height: 55px; }
  .dock svg { width: 20px; height: 20px; }
  .control-panel { top: auto; left: 10px; right: 10px; width: auto; bottom: calc(91px + var(--safe-bottom)); max-height: min(54dvh, 460px); border-radius: 21px; }
  /* The grip is a 44 px target that overlaps the heading's top padding, so the sheet stays as short as before. */
  .panel-grip { display: flex; min-height: 44px; height: 44px; margin-bottom: -22px; position: relative; z-index: 1; flex-shrink: 0; align-items: flex-start; justify-content: center; background: transparent; border: 0; padding: 9px 0 0; }
  .panel-grip span { height: 3px; width: 33px; background: #a9bbb355; border-radius: 4px; }
  .panel-heading { padding: 0 18px 13px; flex-shrink: 0; }
  .panel-heading h2 { font-size: 19px; }
  .panel-heading p { font-size: 10px; margin-top: 2px; }
  .panel-scroll { padding: 0 18px 17px; }
  .help { font-size: 11px; margin: 12px 0; }
  details { margin-top: 15px; }
  .range-label { margin-top: 16px; }
  .swatches { gap: 6px; }
  .swatches button { flex-basis: 44px; min-width: 44px; }
  .quality-select { min-height: 44px; padding: 8px 28px 8px 12px; }
  .walk-stick { left: 16px; bottom: calc(96px + var(--safe-bottom)); width: 124px; height: 124px; }
  .look-hint { right: 16px; bottom: calc(133px + var(--safe-bottom)); background: #17231e80; padding: 8px 11px; border-radius: 18px; }
  .panel-open .walk-stick, .panel-open .look-hint { visibility: hidden; }
}

/* The site's portrait stage can be narrower than the phone's viewport. Keep
   the complete price readable and every action at its 44 px touch size. */
@media (max-width: 360px) {
  .top-actions { flex-wrap: wrap; }
  .top-actions .quality-select, .top-actions .price-pill { flex: 1 0 calc(50% - 3px); max-width: none; min-width: 0; }
  .status-toast { top: 102px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .top-actions { top: 10px; right: 14px; }
  .dock { left: 16px; bottom: 12px; transform: none; width: auto; }
  .dock button { padding: 9px 12px; }
  .control-panel { top: 65px; right: 14px; left: auto; width: 290px; bottom: auto; max-height: calc(100% - 77px); }
  .panel-grip { display: none; }
  .panel-heading { padding: 14px 16px; }
  .panel-scroll { padding: 0 16px 16px; }
  .walk-stick { bottom: 88px; width: 116px; height: 116px; }
  .look-hint { right: 320px; bottom: 110px; }
  .panel-open .walk-stick { visibility: visible; }
}
