/* just1stock.com 首頁。
   版面：一條「交易日時間軸」貫穿整頁，每個產品掛在它發生的那個時刻上。
   產品卡、時間軸標記、導覽都由 public/products.json 產生（build.mjs），這裡只管長相。 */
:root {
  --bg: #f3f5f8; --surface: #ffffff; --ink: #14263f; --muted: #556578; --line: #d6dde6; --line-strong: #aab6c5;
  --gold: #a87a12; --gold-text: #85600a; --gold-soft: #f6ecd2; --navy: #1f3a5f; --navy-soft: #e6edf6;
  --up: #c8322b; --down: #17784a;            /* 台股慣例：紅漲綠跌，只用在數字 */
  --line-green: #06c755;                      /* LINE 的訊息色，只用在通知示意 */
  --on-gold: #14263f; --gold-bright: #e2b24d;   /* 滑過時的底色，上面放深色字 */
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1622; --surface: #162233; --ink: #e7edf4; --muted: #9aa9bb; --line: #263648; --line-strong: #40566f;
    --gold: #e2b24d; --gold-text: #e2b24d; --gold-soft: #3a2f14; --navy: #9cc0ee; --navy-soft: #1b2c42;
    --up: #ff6b62; --down: #45c98b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.7; }
.wrap { max-width: 1040px; margin: 0 auto; padding-block: 20px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 44px; }
.wrap > * { min-width: 0; }
.stack { display: grid; gap: 44px; }
.stack > * { min-width: 0; }
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: 16px; top: -60px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-weight: 700; text-decoration: none; z-index: 10; }
.skip:focus { top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 頁首 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 900; font-size: 19px; letter-spacing: .01em; }
.brand img { width: 30px; height: auto; display: block; }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: 14px; }
.nav a { text-decoration: none; color: var(--muted); border-bottom: 1px solid transparent; padding: 6px 0; }
.nav a:hover { color: var(--ink); border-bottom-color: var(--gold); }

/* 開場 */
.hero { display: grid; gap: 18px; }
.hero > * { min-width: 0; }
.hero h1 { font-size: clamp(30px, 6vw, 52px); line-height: 1.18; font-weight: 900; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.hero h1 em { font-style: normal; color: var(--gold); }
.hero p { margin: 0; max-width: 34em; color: var(--muted); font-size: 17px; }

/* 交易日時間軸。標記分幾層由 build.mjs 依三種寬度各算一次：
   --nl/--nm/--ns 是寬／中／窄螢幕的層數，每個標記的 --l/--m/--s 是它在第幾層（0 最上面）。 */
.day { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 20px 16px; display: grid; gap: 14px; }
.day > * { min-width: 0; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.day-head b { color: var(--ink); font-weight: 700; }
.ruler { --n: var(--nl, 2); --row: 34px; position: relative; height: calc(var(--n) * var(--row) + 82px); margin: 0 6px; }
.ruler .base { position: absolute; left: 0; right: 0; top: calc(var(--n) * var(--row) + 32px); height: 2px; background: var(--line-strong); }
/* 時段：--lane 0 是最裡面那層，重疊時外層每層高 8px、圍在外面 */
.ruler .sess { --lane: 0; position: absolute; top: calc(var(--n) * var(--row) + 28px - var(--lane) * 4px); height: calc(10px + var(--lane) * 8px); border-radius: 99px; background: var(--navy-soft); border: 1px solid var(--line-strong); }
.ruler .sess.soon { background: transparent; border-style: dashed; }
.tick { position: absolute; top: calc(var(--n) * var(--row) + 26px); width: 1px; height: 14px; background: var(--line-strong); }
.tick span { position: absolute; top: 20px; left: 0; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.4; color: var(--muted); white-space: nowrap; }
.tick.first span { transform: none; }
.tick.last span { transform: translateX(-100%); }
/* --x 是時刻的位置；--r 是 1 表示標籤往左長（靠右邊的標記），0 表示往右長。 */
.pin { --lv: var(--l, 0); --r: var(--rl, 0); position: absolute; top: calc(var(--lv) * var(--row)); left: calc(var(--x) + (var(--r) * 2 - 1) * 13px); transform: translateX(calc(var(--r) * -100%)); display: block; text-decoration: none; }
.pin .lab { background: var(--ink); color: var(--bg); border-radius: 8px; padding: 5px 10px; font-size: 13px; line-height: 22px; font-weight: 700; white-space: nowrap; display: flex; gap: 8px; align-items: baseline; }
.pin .lab .mono { font-weight: 500; color: var(--gold-soft); }
.pin .stem { position: absolute; top: 35px; left: calc(12px + var(--r) * (100% - 26px)); width: 2px; height: calc((var(--n) - var(--lv)) * var(--row) - 4px); background: var(--ink); }
.pin .dot { position: absolute; top: calc((var(--n) - var(--lv)) * var(--row) + 26px); left: calc(6px + var(--r) * (100% - 26px)); width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); }
/* 即將推出的標記：空心 */
.pin.soon .lab { background: var(--surface); color: var(--ink); outline: 1.5px dashed var(--ink); outline-offset: -1.5px; }
.pin.soon .lab .mono { color: var(--muted); }
.pin.soon .dot { background: var(--surface); }
.pin:hover .lab, .pin:focus-visible .lab { background: var(--gold-bright); color: var(--on-gold); }
.pin:hover .lab .mono, .pin:focus-visible .lab .mono { color: var(--on-gold); }
.pin { z-index: calc(1 + var(--lv)); }                 /* 下層的標籤蓋在上層標記的直線前面 */
.pin:hover, .pin:focus-visible { z-index: 20; }
@media (max-width: 900px) { .ruler { --n: var(--nm, 2); } .pin { --lv: var(--m, 0); --r: var(--rm, 0); } }
@media (max-width: 560px) {
  .ruler { --n: var(--ns, 2); } .pin { --lv: var(--s, 0); --r: var(--rs, 0); }
  .day { padding: 16px 16px 12px; }
  .tick.minor span { display: none; }
}
@media (max-width: 359px) { .tick.tight span { display: none; } }

/* 產品 */
.products { display: grid; gap: 28px; }
.product { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 26px; scroll-margin-top: 16px; }
@media (max-width: 700px) { .product { grid-template-columns: minmax(0, 1fr); padding: 20px; } }
.when { font-family: var(--font-mono); font-size: 13px; color: var(--gold-text); letter-spacing: .04em; display: flex; gap: 10px; align-items: center; }
.when::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.product h2 { font-size: clamp(22px, 3.6vw, 30px); font-weight: 900; line-height: 1.25; margin: 6px 0 4px; text-wrap: balance; }
.product .name { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.product p { margin: 10px 0 0; color: var(--muted); max-width: 32em; }
.rules { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; font-size: 15px; }
.rules li { padding-left: 18px; position: relative; }
.rules li::before { content: ""; position: absolute; left: 2px; top: .72em; width: 7px; height: 2px; background: var(--gold); }
.cta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; margin-top: 14px; padding: 10px 16px; border-radius: 9px; background: var(--ink); color: var(--bg); text-decoration: none; font-weight: 700; font-size: 15px; }
.cta:hover { background: var(--gold-bright); color: var(--on-gold); }
.cta .mono { font-weight: 500; font-size: 12.5px; opacity: .85; }
.side { display: grid; gap: 14px; align-content: start; min-width: 0; container-type: inline-size; }
.side > * { min-width: 0; }
.fig { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 8px; background: var(--bg); }
.fig svg { width: 100%; max-width: 460px; height: auto; display: block; margin-inline: auto; }
.fig svg text { font-family: var(--font-body); }
.fig svg text.m { font-family: var(--font-mono); }
.fig figcaption, .note { font-size: 12.5px; line-height: 1.6; color: var(--muted); margin-top: 6px; }
.product p.note, .product p.asof { font-size: 12.5px; line-height: 1.6; margin: 6px 0 0; max-width: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stats div { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--font-mono); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats dd .unit { font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
/* 右欄窄的時候（手機、平板直向）數字改成兩欄；落單的最後一格佔滿一列 */
@container (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.live[data-state="loading"] dd, .live[data-state="loading"] td.num { color: var(--muted); }
.asof a, .note a { color: var(--ink); text-underline-offset: 2px; }
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
caption { text-align: left; font-size: 12.5px; line-height: 1.6; color: var(--muted); padding-bottom: 6px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td .tag { font-family: var(--font-body); font-size: 12px; color: var(--muted); margin-left: 4px; }
table.wrap-cells td, table.wrap-cells th { white-space: normal; text-align: left; vertical-align: top; }
table.wrap-cells td:first-child { font-weight: 700; white-space: nowrap; padding-right: 14px; }
table.wrap-cells td:last-child { color: var(--muted); }
@media (max-width: 420px) { table.wrap-cells td:first-child { white-space: normal; min-width: 7.5em; } }
@container (max-width: 300px) {
  table { font-size: 13px; }
  th, td { padding: 6px 4px; }
  td .tag { font-size: 11px; margin-left: 2px; }
}
.up { color: var(--up); }
.down { color: var(--down); }
.unavailable { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.6; color: var(--muted); margin: 0; }
.product p.unavailable { margin: 0; max-width: none; }
.unavailable b { color: var(--ink); font-weight: 700; }
.bubble { border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); padding: 12px 14px; max-width: 320px; font-size: 14.5px; position: relative; }
.bubble .from { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bubble .from i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-green); display: inline-block; }
.bubble b { font-weight: 700; }
.product.solo { grid-template-columns: minmax(0, 1fr); }
.soon-tag { display: inline-block; padding: 7px 14px; border-radius: 9px; border: 1.5px dashed var(--line-strong); font-size: 14px; font-weight: 700; color: var(--muted); }
.product p.soon-tag { margin-top: 14px; max-width: none; }
.product .cta + p, .product .soon-tag + p { margin-top: 16px; }
.product p.soon-note { margin-top: 14px; }
.product.soon { border-style: dashed; grid-template-columns: minmax(0, 1fr); background: transparent; }
.product.soon h2 { color: var(--muted); font-weight: 700; font-size: 20px; margin: 4px 0 0; }
.product.soon .when { color: var(--muted); }

/* 共用的底層 */
.base-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0; border-top: 2px solid var(--ink); }
.base-row div { padding: 14px 16px 0 0; }
.base-row h3 { margin: 0 0 2px; font-size: 15px; }
.base-row p { margin: 0; font-size: 14px; color: var(--muted); }
h2.sec { font-size: 20px; font-weight: 900; margin: 0 0 10px; }
footer { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 6px; }
footer p { margin: 0; }
footer a { text-underline-offset: 2px; }

/* 找不到頁面 */
.lost { min-height: 60vh; display: grid; align-content: center; gap: 14px; }
.lost h1 { font-size: clamp(28px, 6vw, 44px); font-weight: 900; line-height: 1.2; margin: 0; }
.lost p { margin: 0; color: var(--muted); }
