/* 105 Old Lake Rd. Palette taken from the house: bark siding, teal-green trim, cream soffit, lake blue. */

@font-face {
  font-family: "Fraunces Variable";
  src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk Variable";
  src: url("../fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f4efe6;
  --panel: #fbf8f2;
  --ink: #2b2420;
  --muted: #6e6258;
  --bark: #5b4a3e;
  --bark-deep: #3a2e26;
  --teal: #2e6b5e;
  --teal-soft: #dbe9e4;
  --cream: #f4efe6;
  --lake: #3f7f9f;
  --line: #d9cfbf;
  --radius: 10px;
  --font-head: "Fraunces Variable", Georgia, serif;
  --font-ui: "Hanken Grotesk Variable", system-ui, sans-serif;
  --bar-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--lake); outline-offset: 2px; }

/* ---- top bar ---- */
.bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 5;
  height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) calc(14px + var(--safe-r)) 0 calc(14px + var(--safe-l));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
}
.brand {
  margin: 0;
  font: 600 19px/1 var(--font-head);
  letter-spacing: -0.01em;
  color: var(--bark-deep);
  white-space: nowrap;
}
.brand span {
  margin-left: 8px;
  font: 500 12px/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}
.tabs { display: flex; align-self: stretch; gap: 2px; }
.tabs button {
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.tabs button[aria-current="page"] { color: var(--bark-deep); border-bottom-color: var(--teal); }

main {
  position: fixed;
  inset: calc(var(--bar-h) + env(safe-area-inset-top, 0px)) 0 0 0;
}

/* ---- 3D view ---- */
.view { position: absolute; inset: 0; background: #c3deef; }
#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#scene:focus-visible { outline-offset: -3px; }
body[data-tab="walk"] #scene { cursor: crosshair; }
body[data-tab="model"] #scene { cursor: grab; }
body[data-tab="costs"] .view { display: none; }
body[data-tab="walk"] .model-only,
body[data-tab="model"] .walk-only { display: none !important; }

.notice {
  position: absolute;
  inset: 30% 10% auto;
  margin: 0;
  padding: 18px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hud { position: absolute; z-index: 2; user-select: none; -webkit-user-select: none; }
.hud-top-left { top: 12px; left: calc(12px + var(--safe-l)); display: grid; gap: 8px; justify-items: start; max-width: min(300px, 62vw); }
.hud-top-right { top: 12px; right: calc(12px + var(--safe-r)); }
.hud-bottom-left { bottom: calc(12px + var(--safe-b)); left: calc(12px + var(--safe-l)); }

.card, .switch, .jump, .minimap {
  background: rgba(251, 248, 242, 0.93);
  border: 1px solid rgba(58, 46, 38, 0.22);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(43, 36, 32, 0.14);
}

.switch { display: flex; padding: 3px; }
.switch button {
  padding: 7px 13px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-weight: 600;
  color: var(--muted);
}
.switch button[aria-pressed="true"] { background: var(--teal); color: #fff; }

.summary {
  margin: 0;
  padding: 3px 9px;
  border-radius: 7px;
  background: rgba(43, 36, 32, 0.62);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.35;
}

.room { padding: 9px 12px; display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; align-items: baseline; }
.room strong { font: 600 18px/1.2 var(--font-head); color: var(--bark-deep); }
.room-size { grid-column: 1 / -1; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.room-note { grid-column: 1 / -1; color: #8f3d2c; font-size: 12.5px; }
.room-note:empty, .room-size:empty { display: none; }
.chip {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #e7dfd2;
  color: var(--bark);
}
.chip[data-tag="new"] { background: var(--teal); color: #fff; }
.chip[data-tag="changed"] { background: #f0d9a8; color: #6b4a10; }

.jump { padding: 7px 10px; font-weight: 600; max-width: 100%; }

.minimap { display: block; width: 164px; height: auto; }

.tools { padding: 10px 12px; display: grid; gap: 7px; }
.tools label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tools input { width: 17px; height: 17px; accent-color: var(--teal); }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.presets button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-weight: 600;
  font-size: 13px;
}

.legend { margin: 0; padding: 9px 12px; list-style: none; font-size: 12.5px; display: grid; gap: 3px; max-width: 250px; }
.legend i { display: inline-block; width: 18px; height: 5px; margin-right: 6px; vertical-align: middle; border: 1px solid rgba(0, 0, 0, 0.25); }
.legend .sw-lot { background: #fdfbf5; }
.legend .sw-setback { background: #d4573f; }
.legend .sw-depth { background: #f2c14e; }
.legend .fine { color: var(--muted); margin-top: 3px; }

.hint {
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 14px;
  width: max-content;
  max-width: 92vw;
  text-align: center;
  border-radius: 99px;
  background: rgba(43, 36, 32, 0.72);
  color: #fff;
  font-size: 13px;
  pointer-events: none;
  transition: opacity 0.8s;
}
.hint.is-gone { opacity: 0; }
.for-touch { display: none; }

/* ---- touch arrows: see-through, big, bottom centre ---- */
.pad {
  display: none;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  grid-template-areas: ". f ." "l b r";
  gap: 8px;
  touch-action: none;
}
.pad button {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  background: rgba(43, 36, 32, 0.3);
  color: rgba(255, 255, 255, 0.92);
  font-size: 22px;
  line-height: 1;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
.pad button.is-held { background: rgba(46, 107, 94, 0.72); }
.pad [data-move="forward"] { grid-area: f; }
.pad [data-move="back"] { grid-area: b; }
.pad [data-move="turnLeft"] { grid-area: l; }
.pad [data-move="turnRight"] { grid-area: r; }

@media (pointer: coarse) {
  .pad { display: grid; }
  .for-touch { display: block; }
  .hint { bottom: calc(168px + var(--safe-b)); }
}
@media (pointer: coarse) and (not (any-pointer: fine)) {
  .for-mouse { display: none; }
}

@media (max-width: 760px) {
  :root { --bar-h: 48px; }
  .pad { display: grid; }
  .hint { bottom: calc(168px + var(--safe-b)); }
  .brand { font-size: 16px; }
  .brand span, .tabs .wide { display: none; }
  .tabs button { padding: 0 10px; }
  .minimap { width: 108px; }
  .room strong { font-size: 16px; }
  .summary { font-size: 11.5px; }
  .legend { max-width: 190px; font-size: 11.5px; }
}

/* ---- costs tab: scrolls by itself; costs.js fills it ---- */
.costs {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px calc(18px + var(--safe-r)) calc(40px + var(--safe-b)) calc(18px + var(--safe-l));
}
.costs h2, .costs h3 { font-family: var(--font-head); color: var(--bark-deep); }
