/* 繪居：預售建案場景式網站。黃描圖紙配色，整站一個 three.js 場景，五站從平面線稿長成實景。 */
:root {
  --paper: #f1e4b3;
  --paper-soft: #fbf8ef;
  --ink: #2d2c29;
  --ink-soft: rgba(45, 44, 41, .72);
  --rule: rgba(45, 44, 41, .26);
  --ochre: #a8792a;
  --red: #c4412d;
  --body: "PingFang TC", "Noto Sans TC", "Source Han Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --title: "Chiron Hei HK", var(--body);
  --gutter: clamp(20px, 3.4vw, 56px);
  --header-h: 76px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --control-radius: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-autospace: normal;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: square; flex: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

/* ── 場景 ── */
.stage { position: fixed; inset: 0; background: var(--paper); touch-action: none; }
.stage-canvas, .stage-fallback, .stage-photo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-fallback, .stage-photo { object-fit: cover; object-position: 50% 50%; pointer-events: none; }
.stage-canvas { opacity: 0; transition: opacity .6s ease; }
.is-ready .stage-canvas { opacity: 1; }
.is-ready .stage-fallback { opacity: 0; transition: opacity .6s ease .1s; }
.no-webgl .stage-fallback { opacity: 1; transition: opacity .5s ease; }
.stage-photo { opacity: 0; transition: opacity .9s ease; }
.stage-photo.is-shown { opacity: 1; }
.stage-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.room-tag, .dim-tag {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  white-space: nowrap; font-size: 13px; line-height: 1.4; color: var(--ink);
  background: var(--paper-soft); border: 1px solid var(--ink); padding: 5px 10px;
  opacity: 0; transition: opacity .2s ease;
}
.room-tag strong { font-weight: 700; margin-right: 8px; }
.room-tag span, .dim-tag span { color: var(--red); font-variant-numeric: tabular-nums; }
.room-tag.is-shown, .dim-tag.is-shown { opacity: 1; }

/* ── 載入：尺寸線慢慢拉長 ── */
.loader {
  position: fixed; z-index: 6; left: 50%; bottom: clamp(28px, 6vh, 64px); transform: translateX(-50%);
  width: min(360px, 70vw); text-align: center; font-size: 13px; color: var(--ink-soft);
  transition: opacity .4s ease, visibility 0s .4s;
}
.loader p { margin: 10px 0 0; }
.loader-percent { color: var(--red); font-variant-numeric: tabular-nums; }
.loader-rule { position: relative; height: 12px; }
.loader-rule::before, .loader-rule::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink); }
.loader-rule::before { left: 0; }
.loader-rule::after { right: 0; }
.loader-rule span { position: absolute; left: 0; top: 50%; height: 1px; width: 100%; background: var(--red); transform-origin: left; transform: scaleX(var(--progress, 0)); }
.is-ready .loader, .no-webgl .loader { opacity: 0; visibility: hidden; }

/* ── 頁首 ── */
.site-header {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0; height: var(--header-h);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  padding: 0 var(--gutter);
  transition: background .4s ease;
}
[data-station="4"] .site-header, [data-station="5"] .site-header {
  background: rgba(251, 248, 239, .88);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: baseline; gap: 12px; color: var(--ink); text-decoration: none; min-height: 44px; align-items: center; }
.brand-name { font-family: var(--title); font-weight: 600; font-size: 28px; line-height: 1.2; }
.brand-note { font-size: 13px; color: var(--ink-soft); }
.sheet-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 112px)); justify-content: center; list-style: none; margin: 0; padding: 0; }
.sheet-tabs a {
  display: block; min-height: 48px; padding: 4px 12px; text-decoration: none; color: var(--ink-soft);
  border-left: 1px solid var(--rule); transition: color .2s ease, border-color .2s ease;
}
.sheet-tabs span { display: block; font-size: 12px; color: var(--red); font-variant-numeric: tabular-nums; }
.sheet-tabs strong { display: block; font-size: 14px; font-weight: 500; line-height: 1.5; }
.sheet-tabs a:hover { color: var(--ink); }
.sheet-tabs a[aria-current="step"] { color: var(--ink); border-left: 2px solid var(--red); }
.sheet-tabs a[aria-current="step"] strong { font-weight: 700; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.action, .cta {
  display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 8px 0 18px;
  font-size: 14px; text-decoration: none; border: 1px solid var(--rule); background: var(--paper-soft); color: var(--ink);
  border-radius: var(--control-radius); transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.action svg, .cta svg { width: 28px; height: 28px; padding: 6px; background: var(--ink); color: var(--paper-soft); }
.action.is-primary { background: var(--ink); color: var(--paper-soft); border-color: var(--ink); }
.action.is-primary svg { background: var(--ochre); }
.action:hover { border-color: var(--ink); }
.cta { min-height: 52px; padding: 0 10px 0 22px; font-size: 16px; background: var(--ochre); color: #fff; border-color: var(--ochre); }
.cta svg { width: 32px; height: 32px; padding: 8px; background: rgba(255, 255, 255, .18); color: #fff; }
.cta:hover { background: #956a22; }
.menu-button { display: none; }

/* ── 各站文字 ── */
.copy {
  position: fixed; z-index: 4; left: var(--gutter); top: calc(50% + var(--header-h) / 3); transform: translateY(-50%);
  width: min(440px, 29vw);
}
.station { position: absolute; left: 0; top: 0; width: 100%; visibility: hidden; pointer-events: none; }
.station.is-active { position: relative; visibility: visible; pointer-events: auto; }
[data-station="4"] .station.is-active, [data-station="5"] .station.is-active {
  background: rgba(251, 248, 239, .94); padding: 26px 28px 28px; box-shadow: 0 18px 50px rgba(45, 44, 41, .14);
}
.sheet-no { margin: 0; font-size: 13px; color: var(--red); letter-spacing: .02em; }
.title-wrap { position: relative; margin: 30px 0 14px; }
.station-title {
  margin: 0; font-family: var(--title); font-weight: 600; font-size: clamp(32px, 3.2vw, 50px); line-height: 1.24;
  text-wrap: balance;
}
.station-title.is-brand { font-size: clamp(64px, 7.2vw, 112px); line-height: 1.1; }
/* 標題上方的尺寸線：兩端短豎線，中間的數字是這一站的關鍵尺寸 */
.dimension { position: absolute; left: 0; right: 0; top: -20px; height: 12px; display: block; }
.dimension::before, .dimension::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--red); }
.dimension::before { left: 0; }
.dimension::after { right: 0; opacity: 0; }
.dimension i { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--red); transform-origin: left; transform: scaleX(0); }
.dimension b {
  position: absolute; left: 50%; top: -9px; transform: translateX(-50%); padding: 0 6px; background: var(--paper);
  font: 500 12px/1 var(--body); color: var(--red); font-variant-numeric: tabular-nums; opacity: 0;
}
[data-station="4"] .dimension b, [data-station="5"] .dimension b { background: #fbf8ef; }
.station-text { margin: 0 0 22px; font-size: 16px; line-height: 1.8; color: var(--ink-soft); text-wrap: pretty; }
.figures { display: flex; flex-wrap: wrap; gap: 14px 30px; margin: 0; padding-top: 16px; border-top: 1px solid var(--rule); }
.figures div { display: flex; flex-direction: column-reverse; }
.figures dt { font-size: 13px; color: var(--ink-soft); }
.figures dd { margin: 0; font-family: var(--title); font-weight: 600; font-size: 30px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.figures small { font-size: 15px; margin-left: 3px; }
.station-tip { margin: 18px 0 0; font-size: 13px; color: var(--ink-soft); }
.station-tip::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; background: var(--red); vertical-align: 2px; }

.layout-switch { display: inline-flex; margin-top: 22px; border: 1px solid var(--ink); }
.layout-switch button { min-height: 44px; padding: 0 18px; border: 0; background: transparent; font-size: 14px; transition: background .2s ease, color .2s ease; }
.layout-switch button[aria-checked="true"] { background: var(--ink); color: var(--paper-soft); }

.sun-dial { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: baseline; margin-bottom: 18px; }
.sun-dial label { font-size: 13px; color: var(--ink-soft); }
.sun-readout { font-family: var(--title); font-weight: 600; font-size: 26px; font-variant-numeric: tabular-nums; color: var(--ochre); }
.sun-dial input { grid-column: 1 / -1; width: 100%; height: 32px; margin: 0; accent-color: var(--ochre); cursor: ew-resize; }
.sun-scale { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); }
.walk-points { display: flex; align-items: center; gap: 6px; margin: 0 0 18px; }
.walk-points span { font-size: 13px; color: var(--ink-soft); margin-right: 6px; }
.walk-points button { min-height: 44px; padding: 0 14px; border: 1px solid var(--ink); background: transparent; font-size: 14px; transition: background .2s ease, color .2s ease; }
.walk-points button[aria-pressed="true"] { background: var(--ink); color: var(--paper-soft); }
.station.is-active .walk-points { animation-delay: .6s; }
.text-button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--ink); font-size: 14px; border-bottom: 1px solid var(--ink); }

.next-sheet {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 26px; padding: 0;
  border: 0; background: none; color: var(--ink-soft); font-size: 13px;
}
.next-sheet strong { color: var(--ink); font-weight: 500; font-size: 14px; }
.next-sheet svg { animation: nudge 1.8s ease-in-out infinite; }
[data-station="5"] .next-sheet svg { transform: rotate(180deg); animation: none; }
@keyframes nudge { 50% { transform: translateY(4px); } }
[data-station="4"] .next-sheet, [data-station="5"] .next-sheet { padding: 0 14px; background: rgba(251, 248, 239, .9); }

/* 換站：舊的淡出，新的先畫尺寸線，大標跟著尺寸線由左往右露出，再接文字 */
.station > *:not(.title-wrap), .station .station-title { opacity: 0; }
.station.is-active > *:not(.title-wrap) { animation: rise .55s var(--ease-out) forwards; }
.station.is-active .sheet-no { animation-delay: .05s; }
.station.is-active .dimension i { animation: measure .7s var(--ease-out) .15s forwards; }
.station.is-active .dimension::after { animation: appear .01s linear .85s forwards; }
.station.is-active .dimension b { animation: appear .3s ease .7s forwards; }
.station.is-active .station-title { animation: trace .8s var(--ease-out) .2s forwards; }
.station.is-active .station-text { animation-delay: .55s; }
.station.is-active .figures, .station.is-active .layout-switch, .station.is-active .sun-dial, .station.is-active .cta { animation-delay: .65s; }
.station.is-active .station-tip, .station.is-active .text-button { animation-delay: .75s; }
.station.is-leaving { visibility: visible; position: absolute; animation: leave .3s ease forwards; }
.station.is-leaving > *, .station.is-leaving .station-title { opacity: 1; }
.station.is-leaving .dimension i { transform: scaleX(1); }
.station.is-leaving .dimension b, .station.is-leaving .dimension::after { opacity: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes measure { to { transform: scaleX(1); } }
@keyframes appear { to { opacity: 1; } }
@keyframes trace { from { opacity: 1; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
@keyframes leave { to { opacity: 0; transform: translateY(-8px); } }

/* ── 圖框（右下） ── */
.title-block {
  position: fixed; z-index: 5; right: var(--gutter); bottom: clamp(18px, 2.6vw, 36px); width: 264px;
  background: var(--paper-soft); border: 1.5px solid var(--ink); font-size: 12px; color: var(--ink-soft);
}
.title-block-row { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--ink); }
.title-block-row > *, .title-block-foot > * { padding: 8px 12px; }
.title-block-row > * + *, .title-block-foot > * + * { border-left: 1px solid var(--rule); }
.title-block-row strong { font-family: var(--title); font-weight: 600; font-size: 17px; color: var(--ink); }
.title-block-row span { align-self: center; }
.title-block-foot { display: grid; grid-template-columns: repeat(3, 1fr); }
.title-block-page { color: var(--red); font-variant-numeric: tabular-nums; }

/* ── 手機全螢幕選單 ── */
.menu {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--paper);
  overflow-y: auto;
}
.menu[hidden] { display: none; }
.menu.is-open { animation: menu-in .45s var(--ease-out); }
.menu.is-closing { animation: menu-out .3s ease forwards; }
@keyframes menu-in { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes menu-out { to { clip-path: inset(0 0 100% 0); } }
.menu-top { display: flex; justify-content: space-between; align-items: center; min-height: 48px; }
.menu-close, .panel-close { position: relative; width: 44px; height: 44px; border: 1px solid var(--ink); background: var(--paper-soft); }
.menu-close i::before, .menu-close i::after, .panel-close i::before, .panel-close i::after {
  content: ""; position: absolute; left: 12px; right: 12px; top: 50%; height: 1.5px; background: var(--ink);
}
.menu-close i::before, .panel-close i::before { transform: rotate(45deg); }
.menu-close i::after, .panel-close i::after { transform: rotate(-45deg); }
.menu-list { list-style: none; margin: 18px 0 0; padding: 0; }
.menu-list a {
  display: grid; grid-template-columns: 64px 1fr; gap: 2px 14px; padding: 14px 0; border-bottom: 1px solid var(--ink);
  color: var(--ink); text-decoration: none;
}
.menu-list span { grid-row: span 2; font-size: 14px; color: var(--red); padding-top: 9px; font-variant-numeric: tabular-nums; }
.menu-list strong { font-family: var(--title); font-weight: 600; font-size: 30px; line-height: 1.25; }
.menu-list small { font-size: 14px; color: var(--ink-soft); }
.menu-list a[aria-current="step"] strong { color: var(--red); }
.menu.is-open .menu-list li { animation: rise .5s var(--ease-out) both; }
.menu.is-open .menu-list li:nth-child(2) { animation-delay: .05s; }
.menu.is-open .menu-list li:nth-child(3) { animation-delay: .1s; }
.menu.is-open .menu-list li:nth-child(4) { animation-delay: .15s; }
.menu.is-open .menu-list li:nth-child(5) { animation-delay: .2s; }
.menu-foot { margin-top: auto; padding-top: 24px; display: grid; gap: 10px; }
.menu-foot .cta, .menu-foot .action { justify-content: space-between; }
.menu-foot p { margin: 8px 0 0; font-size: 14px; line-height: 1.7; color: var(--ink-soft); }

/* ── 附件面板（建案資料、預約單） ── */
.panel {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(520px, 100vw); height: 100%; max-height: none; max-width: none;
  padding: 28px clamp(22px, 3vw, 40px) 40px; border: 0; border-left: 1.5px solid var(--ink);
  background: var(--paper-soft); color: var(--ink); overflow-y: auto;
}
.panel[open] { animation: panel-in .4s var(--ease-out); }
.panel::backdrop { background: rgba(45, 44, 41, .35); }
@keyframes panel-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-close-form { position: sticky; top: 0; display: flex; justify-content: flex-end; margin: 0 0 -30px; z-index: 1; }
.panel h2 { margin: 10px 0 16px; font-family: var(--title); font-weight: 600; font-size: 34px; line-height: 1.24; }
.panel h3 { margin: 30px 0 12px; font-size: 18px; }
.panel-lead { margin: 0 0 20px; font-size: 15px; line-height: 1.8; color: var(--ink-soft); }
.data-table { margin: 0; border-top: 1.5px solid var(--ink); }
.data-table div { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.data-table dt { color: var(--ink-soft); }
.data-table dd { margin: 0; }
.material-list { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.material-list li { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--rule); font-size: 15px; line-height: 1.7; }
.material-list strong { font-weight: 500; color: var(--ochre); }
.mini-form { margin-top: 28px; }
.mini-form label, .field label, .field legend { display: block; margin-bottom: 6px; font-size: 14px; color: var(--ink-soft); }
.mini-form-row { display: flex; gap: 8px; }
.mini-form-row input { flex: 1; min-width: 0; }
input:not([type="radio"]):not([type="range"]), select {
  min-height: 48px; padding: 0 12px; border: 1px solid var(--ink); background: #fff; border-radius: var(--control-radius); width: 100%;
}
.booking-form { display: grid; gap: 16px; }
.field { margin: 0; padding: 0; border: 0; }
fieldset.field { display: flex; flex-wrap: wrap; gap: 8px; }
fieldset.field legend { width: 100%; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--ink); }
.choice input:checked + span { background: var(--ink); color: var(--paper-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.booking-form .cta { justify-self: start; }
.form-done { margin: 12px 0 0; padding: 12px 14px; border-left: 3px solid var(--ochre); background: rgba(168, 121, 42, .1); font-size: 14px; line-height: 1.7; }
.panel-note { margin: 28px 0 0; font-size: 13px; color: var(--ink-soft); }

/* ── 中等寬度 ── */
@media (max-width: 1180px) {
  .sheet-tabs { grid-template-columns: repeat(5, minmax(0, 92px)); }
  .sheet-tabs a { padding: 4px 8px; }
  .brand-note { display: none; }
}

/* ── 手機與直向：場景在上，文字卡在下 ── */
@media (max-width: 860px), (orientation: portrait) and (max-width: 1024px) {
  :root { --header-h: 64px; }
  .site-header { grid-template-columns: 1fr auto; gap: 12px; padding: 0 16px; background: rgba(241, 228, 179, .9); }
  [data-station="4"] .site-header, [data-station="5"] .site-header { background: rgba(251, 248, 239, .9); }
  .sheet-tabs, .header-actions .action { display: none; }
  .brand-name { font-size: 24px; }
  .menu-button {
    display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--ink);
    background: var(--paper-soft); font-size: 14px;
  }
  .menu-button i { position: relative; width: 18px; height: 10px; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
  .copy {
    left: 0; right: 0; top: auto; bottom: 0; transform: none; width: auto;
    padding: 18px 20px calc(14px + env(safe-area-inset-bottom));
    background: rgba(251, 248, 239, .96); border-top: 1.5px solid var(--ink);
  }
  [data-station="4"] .station.is-active, [data-station="5"] .station.is-active { background: none; padding: 0; box-shadow: none; }
  .title-wrap { margin: 32px 0 10px; }
  .station-title { font-size: clamp(26px, 7vw, 34px); }
  .station-title.is-brand { font-size: clamp(48px, 13vw, 64px); }
  .station-text { font-size: 15px; line-height: 1.7; margin-bottom: 12px; }
  .figures { gap: 8px 22px; padding-top: 10px; }
  .figures dd { font-size: 22px; }
  .station-tip { display: none; }
  .layout-switch, .sun-dial { margin-top: 4px; }
  .sun-dial { margin-bottom: 6px; }
  .text-button { display: none; }
  .next-sheet { margin-top: 10px; }
  [data-station="4"] .next-sheet, [data-station="5"] .next-sheet { padding: 0; background: none; }
  .title-block { display: none; }
  .loader { bottom: auto; top: 38%; }
  .stage-photo, .stage-fallback { height: 60%; }
}
@media (max-width: 860px) and (max-height: 700px), (orientation: portrait) and (max-height: 700px) {
  .station-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .15s !important; }
  .station.is-active .station-title, .station.is-active > * { opacity: 1; clip-path: none; }
  .next-sheet svg { animation: none; }
}
