/* Estate tour: additions to style.css (tokens, controls, cards and labels live there) */

:root { --bar-h: 118px; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bar-row .bar-text { min-width: 0; }
.bar h1 { font-size: 16px; }

.back {
  flex: none;
  width: var(--tap); height: var(--tap);
  margin-left: -6px;
  display: grid; place-items: center;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.back[hidden] { display: none; }
.back:active { transform: scale(0.95); }

/* a soft wash behind the header and the dock so text stays readable over the scene (phones) */
@media (max-width: 859px) {
  .bar::before, .dock::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    pointer-events: none;
    z-index: -1;
  }
  .bar::before { top: 0; bottom: -18px; background: linear-gradient(to bottom, var(--bg) 0%, var(--bg) 62%, rgba(246, 243, 238, 0) 100%); }
  .dock::before { top: -18px; bottom: 0; background: linear-gradient(to top, var(--bg) 0%, var(--bg) 70%, rgba(246, 243, 238, 0) 100%); }
}

/* ------------------------------------------------------------- legend (top-left, counted from the data) */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  transition: opacity 200ms var(--ease-out);
}
.legend[hidden] { display: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend b { font-variant-numeric: tabular-nums; font-weight: 700; }
.dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid;
}
.dot[data-status='available'], .pill[data-status='available']::before { background: var(--avail); border-color: var(--avail-strong); }
.dot[data-status='reserved'],  .pill[data-status='reserved']::before  { background: var(--res);   border-color: var(--res-strong); }
.dot[data-status='sold'],      .pill[data-status='sold']::before      { background: var(--sold);  border-color: var(--sold-strong); }

/* ------------------------------------------------------------- plot card */

.plot-card { padding-right: 16px; }
.pc-head { display: flex; align-items: center; gap: 10px; padding-right: 44px; }
.plot-card h2 { margin: 0; font-size: 19px; line-height: 1.2; font-weight: 700; color: var(--ink); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--panel-line);
}
.pill::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid; }
.pc-type, .pc-beds, .pc-size { white-space: nowrap; } /* never break mid-phrase: each is one line, even at 360 px */
.pc-type { margin: 6px 0 0; font-size: 14px; font-weight: 700; }
.pc-beds { margin: 2px 0 0; font-size: 14px; }
.pc-size { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pc-note { margin: 8px 0 0; font-size: 13.5px; color: var(--ink); }
.pc-note:empty { display: none; }
.pc-actions { display: flex; gap: 8px; margin-top: 12px; }
.pc-actions [hidden] { display: none; }

.btn {
  flex: 1 1 auto;
  min-height: var(--tap);
  padding: 0 10px;
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px; font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:active { transform: scale(0.97); }

/* ------------------------------------------------------------- available plots chips */

.chips-wrap { order: 2; }
.chips-wrap[hidden] { display: none; }
.chips-label { margin: 0 0 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.chip:active { transform: scale(0.97); }
.chip[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* in-house controls sit in the same slot as the chips */
.controls { order: 2; }
.controls[hidden] { display: none; }

/* ------------------------------------------------------------- estate labels (CSS2D) */

.plot-label, .road-label { pointer-events: none; }
.plot-label .tag {
  display: inline-block;
  padding: calc(2px * var(--ls, 1)) calc(8px * var(--ls, 1));
  font-size: calc(12px * var(--ls, 1));
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  transition: opacity 140ms ease;
}
.plot-label .tag[data-selected='true'] { border-color: var(--select-strong); }
/* tighter pills when twelve-pixel ones would collide (phones, full-estate view) */
#labels.compact .plot-label .tag { padding: calc(1px * var(--ls, 1)) calc(6px * var(--ls, 1)); font-size: calc(11px * var(--ls, 1)); }
.road-label .road-name {
  display: inline-block;
  font-size: calc(12px * var(--ls, 1));
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 0 3px var(--road), 0 0 3px var(--road);
  transition: opacity 140ms ease;
}
.plot-label .tag.hide, .road-label .road-name.hide { opacity: 0; }

/* ------------------------------------------------------------- desktop: left panel */

@media (min-width: 860px) {
  .bar { width: 360px; }
  .bar h1 { font-size: 18px; }
  .dock { top: var(--bar-h); }
  .chips-wrap { order: 2; }
  .chips { flex-wrap: wrap; overflow: visible; }
  .chip, .chips-label { }
}

@media (hover: hover) and (pointer: fine) {
  .back:hover { background: var(--bg); }
  .btn:not(.primary):hover { background: var(--bg); }
  .btn.primary:hover { background: var(--select-strong); border-color: var(--select-strong); }
  .chip[aria-pressed='false']:hover { background: var(--bg); }
}

@media (prefers-reduced-motion: reduce) {
  .back, .btn, .chip { transition: background-color 120ms ease, color 120ms ease; }
  .back:active, .btn:active, .chip:active { transform: none; }
  .legend { transition: none; }
}


/* ------------------------------------------------------------- eye level */

.card .step { width: 100%; margin-top: 12px; }
.card .step[hidden] { display: none; }

.eye-chip {
  position: fixed;
  z-index: 3;
  left: var(--gutter);
  top: var(--chip-top, 96px);
  max-width: calc(100vw - 2 * var(--gutter));
  padding: 8px 14px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(60, 50, 30, 0.08);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
  pointer-events: none;
}
.eye-chip[hidden], .eye-hint[hidden], .minimap[hidden] { display: none; }
@starting-style {
  .eye-chip, .minimap { opacity: 0; transform: translateY(6px); }
}

.eye-hint {
  position: fixed;
  z-index: 3;
  left: var(--gutter);
  top: calc(var(--chip-top, 96px) + 46px);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  pointer-events: none;
  opacity: 1;
  transition: opacity 400ms ease;
}
.eye-hint.gone { opacity: 0; }

.minimap {
  position: fixed;
  z-index: 3;
  right: var(--gutter);
  bottom: calc(var(--dock-h, 110px) + 10px);
  width: 112px;
  height: 122px;
  padding: 4px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(60, 50, 30, 0.1);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.minimap svg { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.mm-room { fill: var(--floor); cursor: pointer; }
.mm-room.cur { fill: var(--select); }
.mm-wall { fill: none; stroke: var(--wall-side); stroke-width: 0.22; stroke-linejoin: round; pointer-events: none; }
.mm-open { stroke: var(--floor); stroke-width: 0.4; pointer-events: none; }
.mm-block { fill: var(--builtin); pointer-events: none; }
.mm-void { fill: none; stroke: var(--builtin); stroke-width: 0.12; stroke-dasharray: 0.35 0.25; pointer-events: none; }
.mm-cone { fill: var(--accent); opacity: 0.26; pointer-events: none; }
.mm-you { fill: var(--accent); stroke: #fff; stroke-width: 0.16; pointer-events: none; }

@media (min-width: 860px) {
  .eye-chip { left: 392px; top: 20px; max-width: calc(100vw - 420px); }
  .eye-hint { left: 392px; top: 66px; }
  .minimap { right: 24px; bottom: 24px; width: 230px; height: 250px; padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .eye-chip, .minimap, .eye-hint { transition: opacity 120ms ease; transform: none; }
}


/* ------------------------------------------------------------- boot: first paint, then the 3D fades in */

#stage { opacity: 0; transition: opacity 420ms ease; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body.ready #stage { opacity: 1; }
body.booting .dock, body.booting .minimap, body.booting .eye-chip { visibility: hidden; }

.first-paint {
  position: fixed;
  inset: 0;
  z-index: 2;
  padding: calc(var(--bar-h, 118px) + 8px) var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 24px);
  overflow: auto;
  background: var(--bg);
  transition: opacity 360ms ease;
}
.first-paint[hidden] { display: none; }
.first-paint.done { opacity: 0; pointer-events: none; }
.fp-note { margin: 0 0 12px; font-size: 15px; color: var(--muted); }
.fp-list h2 { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.fp-list ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.fp-list a {
  display: inline-flex; align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px; font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- touch: the 3D owns its gestures */

html, body { touch-action: pan-x pan-y; } /* no pinch-zoom of the page itself */
#stage, #stage canvas, .minimap { touch-action: none; }
button, a, .chip, .seg button { touch-action: manipulation; }

/* ------------------------------------------------------------- chips: head row, show-all toggle, room chips */

.chips-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 4px; }
.chips-head .chips-label { margin: 0; }
.chips-toggle {
  min-height: var(--tap);
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.chip .dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-width: 1.5px; vertical-align: 0; }
.room-chips { order: 2; }
.controls { order: 3; }
.room-chips[hidden] { display: none; }

/* ------------------------------------------------------------- hint fades out after the first drag or tap */

.eye-hint { transition: opacity 300ms ease; }

/* minimap rooms are focusable (keyboard) */
.mm-room:focus-visible { outline: 2px solid var(--select-strong); outline-offset: -2px; stroke: var(--select-strong); stroke-width: 0.25; }

/* ------------------------------------------------------------- fallback (no WebGL) */

body.no-3d { overflow: auto; height: auto; touch-action: auto; position: static; }
body.no-3d #stage, body.no-3d .dock, body.no-3d .minimap, body.no-3d .eye-chip, body.no-3d .eye-hint, body.no-3d .first-paint { display: none; }
body.no-3d .bar { position: sticky; background: var(--bg); pointer-events: auto; }
body.no-3d .back { display: none; }
.fallback { max-width: 760px; margin: 0 auto; padding: 8px var(--gutter) 48px; }
.fallback[hidden] { display: none; }
.fb-why { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.fb-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.fb-card { padding: 16px; border: 1px solid var(--panel-line); border-radius: 16px; background: var(--panel); }
.fb-card-head { display: flex; align-items: center; gap: 10px; }
.fb-card-head h2 { margin: 0; font-size: 19px; }
.fb-card .pc-type, .fb-card .pc-beds, .fb-card .pc-size { white-space: normal; }
.fb-plans { display: grid; gap: 14px; margin-top: 16px; }
.fb-plans figure { margin: 0; }
.fb-plans figcaption { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.fb-plan { width: 100%; height: auto; max-height: 70vh; background: var(--bg); border-radius: 12px; }
.fb-room-fill { fill: var(--floor); }
.fb-wall { fill: none; stroke: var(--wall-side); stroke-width: 0.2; stroke-linejoin: round; }
.fb-open { stroke: var(--floor); stroke-width: 0.34; }
.fb-block { fill: var(--builtin); }
.fb-void { fill: none; stroke: var(--builtin); stroke-width: 0.1; stroke-dasharray: 0.3 0.22; }
.fb-porch { fill: var(--floor); stroke: var(--wall-side); stroke-width: 0.1; }
.fb-room { font-weight: 700; fill: var(--ink); font-family: inherit; }
.fb-dims { fill: var(--muted); font-family: inherit; font-variant-numeric: tabular-nums; }
.fb-note { margin: 14px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------- desktop: panel order */

@media (min-width: 860px) {
  .controls { order: 1; }
  .card { order: 2; }
  .chips-wrap, .room-chips { order: 3; }
  .foot { order: 9; }
  .first-paint { padding-left: 392px; }
}

@media (prefers-reduced-motion: reduce) {
  #stage, .first-paint, .eye-hint { transition: none; }
}

body.clean .bar, body.clean .dock, body.clean .first-paint { display: none; }
body.clean.nolabels #labels { display: none; }

/* the header title is one line, always (checked at 360 px) */
.bar-text h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fb-foot { margin-top: 14px; }
.fb-foot .note { font-size: 12px; }

/* the brand is a link back to the homepage; a 44 px tap area without moving the layout */
.bar a.brand { display: inline-block; position: relative; text-decoration: none; pointer-events: auto; }
.bar a.brand::before { content: ''; position: absolute; inset: -14px -10px; }


/* ------------------------------------------------------------- finishes: switch note, room-card list, look button */

/* the two notes stack on the left of the footer; the finishes note keeps its space while Layout is on */
.foot .notes { flex: 1; min-width: 0; }
.foot .notes .note { margin: 0; text-align: left; }
.foot .finishes-note { margin-top: 2px; }
.finishes-note {
  visibility: hidden;
  opacity: 0;
  transition: opacity 200ms ease-out, visibility 0s linear 200ms;
}
.finishes-note[data-on='true'] {
  visibility: visible;
  opacity: 1;
  transition: opacity 200ms ease-out, visibility 0s;
}
.finishes-note[hidden] { display: none; }

/* the card's finishes list opens and closes with the switch */
.fin-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms var(--ease-out);
}
.fin-wrap[data-open='true'] { grid-template-rows: 1fr; }
.fin-clip { min-height: 0; overflow: hidden; }
.fin-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  opacity: 0;
  transition: opacity 120ms ease-out;
}
.fin-wrap[data-open='true'] .fin-list { opacity: 1; transition: opacity 200ms ease-out 60ms; }
.fin-list li {
  display: grid;
  grid-template-columns: 16px 50px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.25;
}
.fin-sw {
  width: 16px; height: 16px;
  border-radius: 5px;
  background: var(--sw);
  border: 1px solid rgba(31, 29, 26, 0.3); /* keeps white and pale swatches visible on the white card */
}
.fin-label { color: var(--muted); }
.fin-name { font-weight: 700; color: var(--ink); }
.card .look-btn { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .fin-wrap, .fin-list, .finishes-note { transition: none; }
}


/* ------------------------------------------------------------- "See the finished look": full-screen viewer */

.look {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 64px) var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 24px);
  border: 0;
  background: rgba(31, 29, 26, 0.985); /* near-solid: the white card behind must not ghost through */
  color: #fff;
  overflow: hidden;
  opacity: 0;
  transition: opacity 140ms ease-out, display 140ms allow-discrete, overlay 140ms allow-discrete;
}
.look[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition-duration: 220ms;
}
@starting-style { .look[open] { opacity: 0; } }
.look::backdrop { background: transparent; }

.look-figure {
  margin: 0;
  max-width: min(100%, 1200px);
  transform: scale(0.97);
  transition: transform 140ms ease-out;
}
.look[open] .look-figure { transform: none; transition-duration: 220ms; }
@starting-style { .look[open] .look-figure { transform: scale(0.97); } }

.look-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-width: min(100%, 880px);
  min-height: min(56vw, 40dvh);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
}
.look-frame.loaded { min-width: 0; min-height: 0; background: transparent; }
.look-img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 190px);
  border-radius: 12px;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.look-frame.loaded .look-img { opacity: 1; }
.look-img[hidden], .look-empty[hidden] { display: none; }
.look-empty {
  display: grid;
  place-items: center;
  width: min(100%, 880px);
  aspect-ratio: 3 / 2;
  max-height: calc(100dvh - 190px);
  margin: 0;
  padding: 24px;
  border: 1.5px dashed rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  text-align: center;
  font-size: 16px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.88);
}
.look-tag {
  position: absolute;
  left: 10px; bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(31, 29, 26, 0.74);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  pointer-events: none;
}
.look figcaption { margin: 12px 2px 0; font-size: 14px; line-height: 1.4; color: rgba(255, 255, 255, 0.78); }
.look figcaption b { display: block; font-size: 16px; color: #fff; }
.look-caption:empty { display: none; }

.look-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  width: var(--tap); height: var(--tap);
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.look-close:active { transform: scale(0.95); }
.look :focus-visible { outline-color: #fff; }
@media (hover: hover) and (pointer: fine) { .look-close:hover { background: rgba(255, 255, 255, 0.24); } }

@media (prefers-reduced-motion: reduce) {
  .look-figure, .look[open] .look-figure { transform: none; transition: none; }
  .look-close { transition: background-color 120ms ease; }
  .look-close:active { transform: none; }
}

/* with the finishes list open, the built-ins are named in it: drop the "Included:" line to keep the card short */
.card:has(.fin-wrap[data-open='true']) .included { display: none; }

/* controls: Layout | Finishes and Plan view share one row; the floor switch (two-storey types) sits above them */
.controls #seg-storey { order: -1; }

/* room labels that would overlap a more important room's label step aside (see resolveRoomLabels in tour.js) */
.room-label { transition: opacity 140ms ease; }
.room-label.hide { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .room-label { transition: none; } }
