/* 正視眼鏡行「府城」：酒紅絨布（定案 A）＋昭源宋體 300 */
:root {
  --sans: "PingFang TC", "Noto Sans TC", "Source Han Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --display: "Chiron Sung HK", "Noto Serif TC", "Source Han Serif TC", "PMingLiU", serif;
  --display-weight: 300;
  --bg: #1e0a10;          /* 酒紅絨布的暗部（跟 3D 畫面的底色一致） */
  --ink: #f4ece0;         /* 奶白 */
  --muted: rgb(244 236 224 / 0.74);
  --line: rgb(244 236 224 / 0.26);
  --brass: #c9a25e;       /* 黃銅：尺寸線、編號 */
  --brass-soft: rgb(201 162 94 / 0.16);
  --wine: #5a1a24;
  --slip: #f4ece0;        /* 配鏡單 */
  --slip-ink: #17110d;
  --stamp: #b23a2a;
  --gutter: clamp(20px, 5.5vw, 96px);
  --control-radius: 2px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --z-stage: 0;
  --z-content: 2;
  --z-bom: 3;
  --z-header: 4;
  --z-menu: 6;
  --z-panel: 7;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
.display { font-family: var(--display); font-weight: var(--display-weight); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 3D 畫面與備用靜態圖 ---------- */
.stage { position: fixed; inset: 0; z-index: var(--z-stage); }
.render img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.live { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; opacity: 0; transition: opacity 0.6s var(--ease); }
.live:active { cursor: grabbing; }
.is-live .live { opacity: 1; }
.is-live .render { visibility: hidden; }

/* 尺寸線與引線（SVG 只畫線，標籤是下面的 HTML，英文版才翻得到） */
.annotations { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.annotations .mark { opacity: 0; transition: opacity 0.45s var(--ease); }
.annotations .mark.is-on { opacity: 1; }
.annotations line, .annotations polyline { stroke: var(--brass); stroke-width: 1; fill: none; }
.annotations .ext { stroke: var(--line); }
.annotations .dot { fill: var(--brass); }
.callouts { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.callouts li {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12px; line-height: 1.3; color: var(--muted);
  opacity: 0; transition: opacity 0.45s var(--ease);
  text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg);
}
.callouts li.is-on { opacity: 1; }
.callouts b { font-size: 17px; font-weight: var(--display-weight); color: var(--brass); }
.is-static .annotations, .is-static .callouts { display: none; }

/* ---------- 頁首 ---------- */
.masthead {
  position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-header);
  display: flex; align-items: center; gap: 12px;
  padding: 14px var(--gutter);
}
.brand { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-right: auto; color: inherit; text-decoration: none; }
.brand-name { font-size: 22px; line-height: 1.3; }
.brand-meta { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.masthead-actions { display: flex; gap: 10px; align-items: center; }
.menu-toggle {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--control-radius); background: none; cursor: pointer;
}
.menu-toggle:hover { border-color: var(--ink); }
.menu-icon { width: 16px; height: 9px; border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.menu-label { font-size: 14px; }

/* ---------- 按鈕 ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 26px;
  border: 1px solid var(--ink); border-radius: var(--control-radius);
  background: var(--ink); color: var(--slip-ink); font-size: 15px; cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.button:hover { background: transparent; color: var(--ink); }
.button--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.button--ghost:hover { border-color: var(--ink); }
.button--small { min-height: 44px; padding: 0 18px; font-size: 14px; }
:is(.button, .menu-toggle, .swatch, .lens-types button, .steps button, .bom button, .menu-list button, .panel-close, .menu-close, .brand, input, select):focus-visible {
  outline: 2px solid var(--brass); outline-offset: 3px;
}

/* ---------- 各站內容 ---------- */
.stations { position: fixed; inset: 0; z-index: var(--z-content); pointer-events: none; }
.station {
  position: absolute; left: var(--gutter); top: 50%; transform: translateY(-46%);
  width: min(36vw, 500px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s var(--ease), visibility 0s linear 0.4s;
}
.station.is-active { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.5s var(--ease) 0.2s, visibility 0s; }

.kicker { margin: 0 0 6px; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.part-no {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid var(--brass); border-radius: 50%; color: var(--brass); font-size: 14px; line-height: 1;
}
.title {
  position: relative; margin: 0 0 18px; padding: 0.04em 0.06em 0.08em 0;
  font-size: clamp(54px, 6.2vw, 96px); line-height: 1.14; letter-spacing: 0;
  text-wrap: balance;
}
.lede { margin: 0 0 22px; color: var(--muted); max-width: 30em; text-wrap: pretty; }

/* 大標出場：先描出外框，再像繪圖機一樣由左往右填上實心字（::after 疊一份同樣的字，用 clip-path 揭開） */
.station.is-active .title { color: transparent; -webkit-text-stroke: 1px var(--line); }
.station.is-active .title::after {
  content: attr(data-text);
  position: absolute; inset: 0; padding: inherit;
  color: var(--ink); -webkit-text-stroke: 0;
  clip-path: inset(0 100% 0 0);
  animation: plot-fill 1.1s var(--ease) 0.35s forwards;
}
@keyframes plot-fill { to { clip-path: inset(0 0 0 0); } }

.swatches, .lens-types { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.swatch, .lens-types button {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 12px;
  border: 1px solid var(--line); border-radius: var(--control-radius); background: none; cursor: pointer; font-size: 14px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.lens-types button { padding: 0 16px; }
.swatch:hover, .lens-types button:hover { border-color: var(--ink); }
.swatch[aria-pressed="true"], .lens-types button[aria-pressed="true"] { border-color: var(--brass); background: var(--brass-soft); }
.swatch-chip { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.swatch-chip--tortoise { background: radial-gradient(circle at 30% 35%, #2a1206 0 22%, transparent 24%), radial-gradient(circle at 70% 65%, #2a1206 0 18%, transparent 20%), #b8702a; }
.swatch-chip--black { background: #0d0c0c; }
.swatch-chip--honey { background: linear-gradient(135deg, #f1c27a, #c98a3c); }

.price { margin: 0 0 22px; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.price .display { font-size: 32px; line-height: 1.2; }
.price small { font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 22px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.hint::before { content: ""; width: 28px; height: 1px; background: var(--brass); }
.hint-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .hint-touch { display: inline; } .hint-desktop { display: none; } }

.lens-note { margin: -6px 0 24px; display: flex; flex-direction: column; gap: 4px; min-height: 3.6em; font-size: 15px; }
.lens-price { color: var(--brass); font-size: 21px; line-height: 1.3; }

.facts { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 0; margin: 0 0 24px; border-top: 1px solid var(--line); }
.facts div { padding: 12px 24px 0 0; margin-right: 24px; border-right: 1px solid var(--line); }
.facts div:last-child { border-right: 0; margin-right: 0; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 22px; line-height: 1.35; }

.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); }
.steps li + li { border-left: 1px solid var(--line); }
.steps button {
  width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: none; cursor: pointer; font-size: 15px; transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.steps button:hover { background: var(--brass-soft); }
.steps button[aria-pressed="true"] { background: var(--brass); color: var(--bg); }
.step-no { font-size: 13px; opacity: 0.8; }
.step-note { margin: 0 0 18px; min-height: 3.5em; font-size: 15px; color: var(--muted); }
.footnote { margin: 0; color: var(--brass); font-size: 18px; }
.contact { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- 零件表（組裝圖右下角的表格，兼站點選單） ---------- */
.bom {
  position: fixed; right: var(--gutter); bottom: clamp(20px, 4vh, 44px); z-index: var(--z-bom);
  background: rgb(30 10 16 / 0.9); border: 1px solid var(--line); font-size: 13px;
}
.bom-list { list-style: none; margin: 0; padding: 0; }
.bom-list button {
  display: grid; grid-template-columns: 48px 1fr 44px; align-items: center; width: 100%; min-height: 36px; padding: 0;
  border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; text-align: left;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.bom-list button:hover { background: var(--brass-soft); }
.bom-list button[aria-current="step"] { background: var(--brass); color: var(--bg); }
.bom-no, .bom-qty { text-align: center; font-size: 15px; }
.bom-name { padding: 0 14px; min-width: 128px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); height: 100%; display: flex; align-items: center; }
.bom-list button[aria-current="step"] .bom-name { border-color: rgb(30 10 16 / 0.3); }
.bom-title { margin: 0; display: grid; grid-template-columns: 1fr 44px; color: var(--muted); }
.bom-title span { padding: 9px 14px; }
.bom-title span + span { padding: 9px 0; text-align: center; border-left: 1px solid var(--line); }

/* 矮的筆電螢幕：零件表縮小一點，不跟眼鏡搶位置 */
@media (min-width: 901px) and (max-height: 760px) {
  .bom-list button { min-height: 30px; }
  .bom-title span { padding-block: 6px; }
}

/* ---------- 選單：像攤開一條眼鏡布 ---------- */
.menu { position: fixed; inset: 0; z-index: var(--z-menu); background: rgb(10 3 5 / 0.6); }
.menu-cloth {
  position: absolute; inset: 0;
  display: grid; grid-template-rows: auto auto 1fr auto; align-content: start;
  padding: 22px var(--gutter) 32px;
  background: radial-gradient(120% 90% at 100% 0%, #4a1320 0%, #300a13 60%, #23070e 100%);
  /* 從右上角折起來的一小塊，往左下攤開 */
  clip-path: polygon(calc(100% - 64px) 0, 100% 0, 100% 64px, 100% 64px);
  transition: clip-path 0.5s var(--ease);
  overflow-y: auto;
}
.menu.is-open .menu-cloth { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
.menu-close {
  justify-self: end; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: var(--control-radius);
  background: none; cursor: pointer; position: relative;
}
.menu-close span::before, .menu-close span::after, .panel-close span::before, .panel-close span::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 1px; background: currentColor;
}
.menu-close span::before, .panel-close span::before { transform: translate(-50%, -50%) rotate(45deg); }
.menu-close span::after, .panel-close span::after { transform: translate(-50%, -50%) rotate(-45deg); }
.menu-brand { margin: 0 0 18px; font-size: 22px; color: var(--muted); }
.menu-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.menu-list li { border-bottom: 1px solid var(--line); opacity: 0; transform: translateY(8px); transition: opacity 0.35s var(--ease), transform 0.35s var(--ease); }
.menu.is-open .menu-list li { opacity: 1; transform: none; }
.menu.is-open .menu-list li:nth-child(2) { transition-delay: 0.05s; }
.menu.is-open .menu-list li:nth-child(3) { transition-delay: 0.1s; }
.menu.is-open .menu-list li:nth-child(4) { transition-delay: 0.15s; }
.menu.is-open .menu-list li:nth-child(5) { transition-delay: 0.2s; }
.menu-list button {
  display: grid; grid-template-columns: 56px auto 1fr; align-items: baseline; gap: 18px; width: 100%;
  padding: 18px 0; border: 0; background: none; cursor: pointer; text-align: left;
}
.menu-no { color: var(--brass); font-size: 16px; }
.menu-name { font-size: clamp(30px, 4vw, 48px); line-height: 1.2; }
.menu-desc { font-size: 14px; color: var(--muted); }
.menu-list button[aria-current="step"] .menu-name { color: var(--brass); }
.menu-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 32px; padding-top: 28px; }
.menu-foot p { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- 配鏡單面板 ---------- */
.panel { position: fixed; inset: 0; z-index: var(--z-panel); background: rgb(10 3 5 / 0.55); }
.panel-sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); overflow-y: auto;
  padding: 26px 32px 40px; background: var(--slip); color: var(--slip-ink);
  transform: translateX(104%); transition: transform 0.4s var(--ease);
}
.panel.is-open .panel-sheet { transform: none; }
.panel-close { position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border: 1px solid rgb(23 17 13 / 0.3); background: none; cursor: pointer; color: var(--slip-ink); }
.slip-head { display: flex; align-items: baseline; gap: 16px; padding-right: 56px; margin-bottom: 20px; border-bottom: 2px solid var(--slip-ink); padding-bottom: 10px; }
.slip-shop { margin: 0; font-size: 18px; }
.slip-no { margin: 0 0 0 auto; font-size: 12px; color: rgb(23 17 13 / 0.7); }
.slip-title { margin: 0 0 14px; font-size: 30px; line-height: 1.3; }
.slip-table, .slip-rx { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 15px; }
.slip-table th, .slip-table td { padding: 10px 0; border-bottom: 1px solid rgb(23 17 13 / 0.2); text-align: left; vertical-align: top; }
.slip-table th { width: 6em; font-weight: 400; color: rgb(23 17 13 / 0.7); }
.slip-table td.display { font-size: 19px; }
.slip-rx caption { text-align: left; font-size: 13px; color: rgb(23 17 13 / 0.7); padding-bottom: 6px; }
.slip-rx th, .slip-rx td { border: 1px solid rgb(23 17 13 / 0.35); padding: 8px 6px; text-align: center; }
.slip-rx thead th { font-weight: 400; font-size: 13px; }
.slip-rx td.display, .slip-rx th.display { font-size: 18px; }
.slip-note { margin: 0; font-size: 13px; color: rgb(23 17 13 / 0.72); }
.exam-steps { list-style: none; margin: 0 0 18px; padding: 0; counter-reset: exam; }
.exam-steps li { display: grid; grid-template-columns: 4.2em 1fr; column-gap: 12px; padding: 10px 0; border-bottom: 1px solid rgb(23 17 13 / 0.2); font-size: 14px; color: rgb(23 17 13 / 0.78); }
.exam-steps b { display: block; font-weight: 500; color: var(--slip-ink); font-size: 15px; grid-column: 2; }
.exam-time { grid-row: span 2; font-size: 18px; color: var(--wine); }

.reserve-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 4px; font-size: 13px; color: rgb(23 17 13 / 0.75); }
.field--wide { grid-column: 1 / -1; }
.field input, .field select {
  min-height: 46px; padding: 0 12px; border: 1px solid rgb(23 17 13 / 0.35); border-radius: var(--control-radius);
  background: #fff; color: var(--slip-ink); font-size: 16px;
}
.field input[aria-invalid="true"] { border-color: var(--stamp); }
.reserve-form .button { background: var(--slip-ink); color: var(--slip); border-color: var(--slip-ink); }
.reserve-form .button:hover { background: transparent; color: var(--slip-ink); }
.form-message { grid-column: 1 / -1; margin: 0; min-height: 1.6em; font-size: 14px; color: var(--wine); }
.slip-stamp {
  display: inline-block; margin: 18px 0 0 6px; padding: 6px 14px;
  border: 3px double var(--stamp); color: var(--stamp); font-size: 26px; letter-spacing: 0.08em;
  transform: rotate(-12deg) scale(1.6); opacity: 0; pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.2, 1.6, 0.4, 1), opacity 0.2s;
}
.panel.is-booked .slip-stamp { opacity: 0.85; transform: rotate(-12deg) scale(1); }

/* ---------- 截圖與備用圖 ---------- */
.is-still .station, .is-still .station.is-active, .is-still .annotations .mark, .is-still .callouts li, .is-still .live { transition: none; }
.is-still .station.is-active .title { color: var(--ink); -webkit-text-stroke: 0; }
.is-still .station.is-active .title::after { display: none; }
.is-capture .masthead, .is-capture .stations, .is-capture .bom, .is-capture .annotations, .is-capture .callouts, .is-capture .cxdigi-language-link { display: none !important; }

/* ---------- 手機與窄螢幕：眼鏡在上半、內容在下半 ---------- */
@media (max-width: 900px), (max-aspect-ratio: 1/1) {
  .brand-meta { display: none; }
  .masthead { padding: 10px 16px; background: linear-gradient(to bottom, var(--bg) 40%, transparent); }
  .masthead-actions .button { display: none; }
  .station {
    top: auto; bottom: 0; left: 0; right: 0; transform: none; width: auto;
    max-height: 56dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 36px 20px 28px;
    background: linear-gradient(to bottom, transparent, var(--bg) 46px);
  }
  .title { font-size: clamp(42px, 12vw, 64px); margin-bottom: 10px; }
  .lede { font-size: 15px; margin-bottom: 16px; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts div { padding-right: 10px; margin-right: 10px; }
  .facts dd { font-size: 18px; }
  .steps button { flex-direction: column; gap: 0; min-height: 60px; font-size: 14px; }
  .bom { display: none; }
  .callouts li { font-size: 11px; }
  .callouts b { font-size: 15px; }
  .menu-list button { grid-template-columns: 40px 1fr; gap: 4px 12px; }
  .menu-desc { grid-column: 2; }
  .panel-sheet { padding: 22px 20px 32px; }
  .reserve-form { grid-template-columns: 1fr; }
}
@media (max-width: 900px) and (min-aspect-ratio: 1/1) {
  /* 橫放的手機或小平板：文字放左邊、窄一點 */
  .station { top: 64px; bottom: 0; right: auto; width: min(50vw, 420px); max-height: none; background: linear-gradient(to right, var(--bg) 70%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .station.is-active .title { color: var(--ink); -webkit-text-stroke: 0; }
  .station.is-active .title::after { display: none; }
  .station, .station.is-active, .annotations .mark, .callouts li, .menu-cloth, .menu-list li, .panel-sheet, .slip-stamp, .live { transition: none; }
}
