/* ============================================================
   ESTIMATE PAGE · the 3D room estimator
   Desktop: viewer left (sticky), steps right.
   Phone: viewer pinned under the header, price pinned at the
   bottom, steps scroll between them.
   ============================================================ */

/* a short introduction, so the room and its controls are in the first screen */
.est-intro { padding-block: var(--s6) var(--s5); }
.est-intro .head { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--s3) var(--s8); align-items: end; }
.est-intro h1 { font-size: var(--t-h2); line-height: 1.08; }
.est-intro .h1-sub { margin-top: var(--s2); }
.est-intro .lead { color: var(--muted); font-size: var(--t-body); max-width: 54ch; }
.send .head { display: grid; gap: var(--s4); justify-items: start; align-content: start; }

.est-app { padding-bottom: var(--section); }
.app-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(min(340px, 100%), 1fr); gap: var(--s7); align-items: start; }

/* ---------- Viewer ---------- */
.viewer-col { position: sticky; top: calc(var(--header-h) + var(--s5) + env(safe-area-inset-top, 0px)); display: grid; gap: var(--s3); min-width: 0; }
.viewer {
  position: relative; height: min(640px, calc(100vh - 200px)); min-height: 380px;
  background: var(--stone); border-radius: var(--r); overflow: hidden;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.viewer.dragging { cursor: grabbing; }
.viewer canvas#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.viewer-fallback { position: absolute; inset: 12%; display: grid; place-items: center; }
.viewer-fallback canvas { max-width: 100%; max-height: 100%; box-shadow: 0 0 0 6px var(--cream); }

.labels { position: absolute; inset: 0; pointer-events: none; }
.labels span {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--display); font-weight: 700; font-size: var(--t-small); line-height: 1;
  color: var(--walnut); background: var(--cream); padding: 5px 8px; border-radius: var(--r-sm);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

.viewer-top { position: absolute; top: var(--s4); left: var(--s4); right: var(--s4); display: flex; justify-content: space-between; pointer-events: none; }
.area-badge { display: grid; gap: 0; background: var(--walnut); color: var(--cream); padding: var(--s2) var(--s3); border-radius: var(--r-sm); line-height: 1.25; }
.area-badge b { font-family: var(--display); font-weight: 700; font-size: var(--t-h3); }
.area-badge span { font-size: var(--t-small); color: var(--on-dark); }

.viewer-tools { position: absolute; left: var(--s4); right: var(--s4); bottom: var(--s4); display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.viewer-tools .hint { font-size: var(--t-small); color: var(--muted); background: rgba(245, 243, 239, .92); padding: 4px 8px; border-radius: var(--r-sm); }

/* room tabs */
.room-tabs { display: flex; gap: var(--s1); overflow-x: auto; scrollbar-width: none; border-bottom: var(--rule) solid var(--line); }
.room-tabs::-webkit-scrollbar { display: none; }
.room-tab {
  flex: none; display: grid; gap: 0; text-align: left; padding: var(--s2) var(--s4) var(--s3);
  background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer;
  color: var(--muted); transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.room-tab b { font-weight: 700; font-size: var(--t-ui); color: inherit; }
.room-tab span { font-size: var(--t-small); font-variant-numeric: tabular-nums; }
.room-tab:hover { color: var(--walnut); }
.room-tab[aria-pressed="true"] { color: var(--walnut); border-bottom-color: var(--accent); }
.room-tab.add { display: flex; align-items: center; gap: var(--s2); color: var(--chestnut); font-weight: 700; font-size: var(--t-ui); }
.room-tab.add .icon { width: 18px; height: 18px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; border: var(--rule-strong) solid var(--walnut); border-radius: var(--r-sm); overflow: hidden; background: var(--white); max-width: 100%; }
.seg label { position: relative; display: flex; flex: 1 1 auto; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  min-height: 40px; padding: 8px 14px; font-weight: 500; font-size: var(--t-ui); white-space: nowrap;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}
.seg span .icon { width: 18px; height: 18px; }
.seg label + label span { border-left: var(--rule-strong) solid var(--walnut); }
.seg input:checked + span { background: var(--walnut); color: var(--cream); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -4px; }
.seg input:not(:checked):hover + span { background: var(--stone); }
.seg-dark { border-color: var(--walnut); }

/* ---------- Controls ---------- */
.controls { display: grid; gap: var(--s5); min-width: 0; }
.controls, .step, .fld, .pair, .dims { min-width: 0; grid-template-columns: minmax(0, 1fr); }
.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.inp { min-width: 0; }
.step { margin: 0; padding: 0 0 var(--s6); border: 0; border-bottom: var(--rule) solid var(--line); display: grid; gap: var(--s5); min-width: 0; }
.step legend { display: flex; align-items: center; gap: var(--s3); padding: 0; margin-bottom: var(--s5); }
/* step numbers: the same serif numerals as the homepage and the contact page */
.step legend .n { flex: none; min-width: 22px; font-family: var(--serif); font-weight: 400; font-size: var(--t-h2-sm); line-height: 1; color: var(--accent); }
.hint { font-size: var(--t-small); color: var(--muted); line-height: 1.5; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.pair .seg { width: 100%; }
.name-row { display: flex; gap: var(--s2); }
.icon-btn {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center;
  border: var(--rule-strong) solid var(--line-strong); border-radius: var(--r-sm); background: var(--white); cursor: pointer; color: var(--walnut);
  transition: border-color var(--t) var(--ease), background-color var(--t) var(--ease);
}
.icon-btn:hover { border-color: var(--walnut); }
.icon-btn[hidden] { display: none; }

.dims { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5) var(--s4); }
.l-only[hidden] { display: none !important; }
.stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 44px; align-items: center; border: var(--rule-strong) solid var(--line-strong); border-radius: var(--r-sm); background: var(--white); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.stepper:focus-within { border-color: var(--walnut); box-shadow: 0 0 0 3px var(--stone); }
.stepper button { height: 45px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--walnut); }
.stepper button:hover { background: var(--stone); }
.stepper button .icon { width: 18px; height: 18px; stroke-width: 2; }
.stepper .inp { border: 0; box-shadow: none; min-height: 45px; padding: 0 0 0 4px; text-align: right; font-family: var(--display); font-weight: 700; font-size: var(--t-h3); background: transparent; -moz-appearance: textfield; }
.stepper .inp::-webkit-outer-spin-button, .stepper .inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { padding: 0 8px 0 4px; font-size: var(--t-ui); color: var(--muted); }
.stepper-sm { grid-template-columns: 44px 56px 44px; width: max-content; }
.stepper-sm .inp { text-align: center; padding: 0; }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; margin: 0; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--chestnut) var(--p, 50%), var(--line-strong) var(--p, 50%)); border-radius: 0; }
.range::-moz-range-track { height: 4px; background: var(--line-strong); }
.range::-moz-range-progress { height: 4px; background: var(--chestnut); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; background: var(--walnut); border: 2px solid var(--cream); border-radius: var(--r-sm); box-shadow: 0 0 0 1px var(--walnut); }
.range::-moz-range-thumb { width: 14px; height: 14px; background: var(--walnut); border: 2px solid var(--cream); border-radius: var(--r-sm); box-shadow: 0 0 0 1px var(--walnut); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--walnut), 0 0 0 4px var(--accent); }

/* floor types */
.type-list { display: grid; border-top: 2px solid var(--walnut); }
.type-opt { position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: var(--s4); align-items: center; padding: var(--s3) var(--s3) var(--s3) 0; border-bottom: var(--rule) solid var(--line); cursor: pointer; transition: background-color var(--t) var(--ease), box-shadow var(--t) var(--ease), padding-left var(--t) var(--ease); }
.type-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.type-opt .sw { width: 48px; height: 48px; border-radius: var(--r-sm); overflow: hidden; background: var(--stone); position: relative; transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.type-opt:hover .sw { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(51, 51, 53, .14); }
.type-opt .sw canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.type-opt .nm { font-weight: 700; }
.type-opt .ds { display: block; font-size: var(--t-small); color: var(--muted); font-weight: 400; }
.type-opt .pr { font-size: var(--t-small); color: var(--muted); text-align: right; white-space: nowrap; }
.type-opt .pr b { display: block; font-family: var(--display); font-weight: 700; font-size: var(--t-body); color: var(--walnut); }
.type-opt:hover { background: rgba(165, 133, 48, .12); }
.type-opt:has(input:checked) { background: var(--white); box-shadow: inset 4px 0 0 var(--chestnut); padding-left: var(--s4); }
.type-opt:has(input:focus-visible) { outline: 2px solid var(--walnut); outline-offset: -2px; }

.finish-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.finish-opt { position: relative; display: grid; gap: var(--s2); cursor: pointer; font-size: var(--t-ui); font-weight: 500; }
.finish-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.finish-opt .sw { aspect-ratio: 3 / 2; max-width: 100%; border-radius: var(--r-sm); overflow: hidden; position: relative; background: var(--stone); outline: var(--rule-strong) solid transparent; outline-offset: 2px; transition: outline-color var(--t) var(--ease); }
.finish-opt .sw canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.finish-opt:hover .sw { outline-color: var(--line-strong); }
.finish-opt:has(input:checked) .sw { outline: 2px solid var(--walnut); }
.finish-opt:has(input:checked) { font-weight: 700; }
.finish-opt:has(input:focus-visible) .sw { outline: 2px solid var(--accent); }

/* checkboxes */
.checks { display: grid; border-top: 2px solid var(--walnut); }
.check { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s3); align-items: start; padding: var(--s4) 0; border-bottom: var(--rule) solid var(--line); cursor: pointer; }
.check[hidden] { display: none; }
.check input { position: absolute; opacity: 0; width: 24px; height: 24px; margin: 0; cursor: pointer; }
.check .box { width: 24px; height: 24px; border: var(--rule-strong) solid var(--line-strong); border-radius: var(--r-sm); background: var(--white); display: grid; place-items: center; transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease); }
.check .box .icon { width: 16px; height: 16px; stroke-width: 2.25; color: var(--cream); opacity: 0; transform: scale(.6); transition: opacity var(--t-fast) var(--ease), transform var(--t) var(--ease); }
.check input:checked + .box { background: var(--walnut); border-color: var(--walnut); }
.check input:checked + .box .icon { opacity: 1; transform: none; }
.check input:focus-visible + .box { outline: 2px solid var(--walnut); outline-offset: 2px; }
.check b { display: block; font-weight: 700; font-size: var(--t-ui); line-height: 1.4; }
.check .hint { display: block; margin-top: 2px; }
.doorbars { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }

/* ---------- Summary ---------- */
.summary { display: grid; gap: var(--s4); }
.lines { margin: 0; display: grid; border-top: 2px solid var(--walnut); }
.lines > div { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s3) 0; border-bottom: var(--rule) solid var(--line); font-size: var(--t-ui); }
.lines dt { color: var(--muted); }
.lines dt small { display: block; font-size: var(--t-small); }
.lines dd { margin: 0; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.room-total { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); flex-wrap: wrap; }
.room-total span { font-weight: 700; }
.room-total b { font-family: var(--display); font-weight: 700; font-size: var(--t-sub); line-height: 1.1; }
.workings { font-size: var(--t-ui); color: var(--muted); }
.workings summary { cursor: pointer; font-weight: 700; color: var(--walnut); padding-block: var(--s2); list-style: none; display: inline-flex; gap: var(--s2); align-items: center; border-bottom: 2px solid var(--accent); }
.workings summary::-webkit-details-marker { display: none; }
.workings summary::after { content: "+"; font-family: var(--display); }
.workings[open] summary::after { content: "−"; }
.workings ul { margin: var(--s3) 0 0; padding-left: 1.1em; display: grid; gap: var(--s2); }

.total { background: var(--walnut); color: var(--cream); border-radius: var(--r); padding: var(--s6); display: grid; gap: var(--s4); }
.total .eyebrow { color: var(--on-dark); }   /* gold is under 4.5:1 for small text on charcoal */
.total-rooms { list-style: none; margin: 0; padding: 0; display: grid; border-top: var(--rule) solid rgba(255, 255, 255, .22); }
.total-rooms li { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s3) 0; border-bottom: var(--rule) solid rgba(255, 255, 255, .22); font-size: var(--t-ui); color: var(--on-dark); }
.total-rooms li b { color: var(--cream); font-weight: 500; font-variant-numeric: tabular-nums; }
.grand { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); flex-wrap: wrap; }
.grand span { font-weight: 700; }
.grand b { font-family: var(--display); font-weight: 700; font-size: var(--t-h2-sm); line-height: 1.05; }
.min-note { color: var(--on-dark); }
.total .actions { margin-top: var(--s2); }
.total .link { background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; padding-inline: 0; font-size: var(--t-ui); color: var(--white); border-bottom-color: var(--accent); }
.total .link:hover { color: var(--on-dark); }
.total .link .icon { width: 16px; height: 16px; }

/* ---------- Send ---------- */
.send { background: var(--stone); border-top: 0; }
.send-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: var(--s8); align-items: start; }
.recap { margin-top: var(--s4); display: grid; gap: var(--s2); }
.recap .lbl { font-family: var(--display); font-weight: 600; font-size: var(--t-ui); letter-spacing: 0; color: var(--muted); }
.recap ul { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--walnut); }
.recap li { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s3) 0; border-bottom: var(--rule) solid var(--line-strong); font-size: var(--t-ui); }
.recap li span { color: var(--muted); }
.recap li b { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.send-card { background: var(--white); border-radius: var(--r); padding: var(--s6); }
.sent { display: grid; gap: var(--s3); justify-items: start; }
.sent-icon { width: 44px; height: 44px; display: grid; place-items: center; background: var(--ink); color: var(--gold); border-radius: var(--r); }
.sent .link { background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; padding-inline: 0; margin-top: var(--s2); }

/* ---------- Phone price bar ---------- */
.est-bar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .app-grid { grid-template-columns: minmax(0, 1.1fr) minmax(320px, 1fr); gap: var(--s6); }
}
@media (max-width: 960px) {
  .est-intro { padding-block: var(--s5) var(--s4); }
  .est-intro .head { grid-template-columns: minmax(0, 1fr); }
  .app-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
  .viewer-col {
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px)); z-index: 5;
    background: var(--cream); padding-block: var(--s2);
    margin-inline: calc(-1 * max(var(--gutter), env(safe-area-inset-left, 0px)));
    padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px));
  }
  .viewer { height: clamp(220px, 38vh, 420px); min-height: 0; }
  .viewer-tools .hint { display: none; }
  .send-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s6); }
  .est-bar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--walnut); color: var(--cream);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform var(--t) var(--ease);
  }
  .est-bar.away { transform: translateY(110%); }
  .est-bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 68px; }
  .est-bar .bar-total { min-width: 0; }
  .est-bar .bar-total b { white-space: nowrap; }
  .est-bar .btn { flex: none; }
  .bar-total { display: grid; line-height: 1.2; }
  .bar-total .small { color: var(--on-dark); }
  .bar-total b { font-family: var(--display); font-weight: 700; font-size: var(--t-h3); }
  .estimate-page .site-footer { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 520px) {
  .pair, .dims { grid-template-columns: minmax(0, 1fr); }
  .dims { gap: var(--s4); }
  .type-opt .ds { display: none; }
  .total, .send-card { padding: var(--s5); }
  .viewer-top { top: var(--s3); left: var(--s3); right: var(--s3); }
  .viewer-tools { left: var(--s3); right: var(--s3); bottom: var(--s3); }
  .area-badge b { font-size: var(--t-h3); }
  .labels span { font-size: var(--t-small); padding: 4px 6px; }
  .total .actions .btn { width: 100%; }
}

.step-intro { margin-top: calc(var(--s3) * -1); }
.step .checks { border-top: var(--rule) solid var(--line); }

/* smallest phones: keep the running price on one line */
@media (max-width: 360px) { .est-bar .bar-total b { font-size: var(--t-h3); } .est-bar .btn { padding-inline: 14px; } }
