/*
 * BlueBox 網頁共用樣式 v0.1.0
 * 所有 BlueBox 產品頁共用的 tokens 與基礎元件。不放任何產品專屬值：
 * 產品只在自己的 css 覆寫 --bb-accent 等 tokens，並加產品專屬元件。
 * 規則說明見 docs/BLUEBOX_WEB_STYLE.md。
 */

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  /* 底色：帶溫度的近黑，不用純 #000 */
  --bb-bg: #121110;
  --bb-surface-1: #1a1917;   /* 段落底、浮起區 */
  --bb-surface-2: #22211e;   /* 元件底（FAQ、裝置內卡片） */
  --bb-surface-3: #2c2a27;   /* hover、分隔較強處 */
  --bb-line: rgba(242, 238, 230, 0.09);
  --bb-line-strong: rgba(242, 238, 230, 0.16);

  /* 文字：暖白，三層 */
  --bb-text: #f2eee6;
  --bb-text-2: #b3ada2;      /* 次要（對 --bb-bg ≥ 7:1） */
  --bb-text-3: #8c867c;      /* 輔助、註記（對 --bb-bg ≥ 4.5:1） */

  /* 產品主色：預設中性，產品 css 覆寫 */
  --bb-accent: #d8d3c8;
  --bb-accent-ink: #121110;  /* 主色上的文字 */
  --bb-accent-soft: rgba(216, 211, 200, 0.14);
  --bb-danger: #ff6159;

  /* 字型：只用系統字，不載網路字型 */
  --bb-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Hiragino Sans",
    "Apple SD Gothic Neo", "Helvetica Neue", system-ui, sans-serif;
  --bb-font-display: -apple-system-headline, -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "PingFang TC", "Hiragino Sans", "Apple SD Gothic Neo", "Helvetica Neue", system-ui, sans-serif;
  --bb-font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* 字級階梯 */
  --bb-fs-display: clamp(2.5rem, 1.6rem + 3.6vw, 4.5rem);
  --bb-fs-h2: clamp(1.875rem, 1.4rem + 1.9vw, 2.875rem);
  --bb-fs-h3: 1.25rem;
  --bb-fs-lede: clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem);
  --bb-fs-body: 1.0625rem;
  --bb-fs-small: 0.9375rem;
  --bb-fs-xs: 0.8125rem;

  --bb-lh-tight: 1.08;
  --bb-lh-heading: 1.18;
  --bb-lh-body: 1.6;
  --bb-tracking-display: -0.035em;
  --bb-tracking-heading: -0.022em;

  /* 間距（4 的倍數） */
  --bb-space-1: 4px;
  --bb-space-2: 8px;
  --bb-space-3: 12px;
  --bb-space-4: 16px;
  --bb-space-5: 24px;
  --bb-space-6: 32px;
  --bb-space-7: 48px;
  --bb-space-8: 64px;
  --bb-space-9: 96px;
  --bb-space-10: 144px;
  --bb-section-gap: clamp(88px, 6rem + 4vw, 168px);

  /* 圓角 */
  --bb-radius-sm: 8px;
  --bb-radius-md: 14px;
  --bb-radius-lg: 22px;
  --bb-radius-xl: 32px;
  --bb-radius-pill: 999px;

  /* 陰影：一律有位移與柔和模糊 */
  --bb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.18);
  --bb-shadow-device: 0 2px 4px rgba(0, 0, 0, 0.4), 0 24px 48px -12px rgba(0, 0, 0, 0.6),
    0 60px 120px -40px rgba(0, 0, 0, 0.55);

  /* 動效 */
  --bb-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --bb-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --bb-dur-fast: 160ms;
  --bb-dur-base: 280ms;
  --bb-dur-slow: 700ms;
  --bb-dur-reveal: 360ms;

  /* 版面 */
  --bb-max: 1160px;
  --bb-measure: 34rem;
  --bb-gutter: clamp(16px, 4vw, 40px);
  --bb-nav-h: 60px;

  /* 玻璃（只給導覽列與按鈕） */
  --bb-glass-bg: rgba(30, 29, 27, 0.62);
  --bb-glass-solid: #1e1d1b;
  --bb-glass-blur: saturate(160%) blur(18px);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--bb-nav-h) + 16px);
}

body {
  margin: 0;
  background: var(--bb-bg);
  color: var(--bb-text);
  font-family: var(--bb-font);
  font-size: var(--bb-fs-body);
  line-height: var(--bb-lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 中文行高略高 */
:lang(zh) body, body:lang(zh) { --bb-lh-body: 1.75; --bb-lh-heading: 1.3; --bb-lh-tight: 1.2; --bb-tracking-display: -0.01em; --bb-tracking-heading: 0; }

h1, h2, h3, h4 { margin: 0; font-family: var(--bb-font-display); font-weight: 700; text-wrap: balance; }
/* 中文標題只在空格與標點處換行，避免「一／眼就知道」這種斷法 */
:lang(zh) :is(h1, h2, h3, h4) { word-break: keep-all; overflow-wrap: anywhere; line-break: strict; }
/* 中文內文：斷在標點或詞與詞之間（空格），太長才強制換行 */
:lang(zh) p { word-break: keep-all; overflow-wrap: anywhere; line-break: strict; text-wrap: pretty; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
a:hover { text-decoration-color: var(--bb-accent); }
button { font: inherit; color: inherit; }

::selection { background: var(--bb-accent); color: var(--bb-accent-ink); }

:focus-visible {
  outline: 2px solid var(--bb-accent);
  outline-offset: 3px;
  border-radius: 6px;
}

html { scrollbar-color: var(--bb-surface-3) var(--bb-bg); }

.bb-num { font-variant-numeric: tabular-nums; }

.bb-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.bb-skip {
  position: absolute; left: var(--bb-gutter); top: -100px; z-index: 100;
  padding: 10px 16px; border-radius: var(--bb-radius-sm);
  background: var(--bb-accent); color: var(--bb-accent-ink); font-weight: 600; text-decoration: none;
}
.bb-skip:focus { top: 12px; }

/* ---------- Layout ---------- */
.bb-wrap {
  width: 100%;
  max-width: calc(var(--bb-max) + var(--bb-gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--bb-gutter);
}

.bb-section { padding-block: calc(var(--bb-section-gap) / 2); }
.bb-section + .bb-section { border-top: 1px solid var(--bb-line); }

.bb-section__head { max-width: 44rem; margin-bottom: var(--bb-space-8); }
.bb-section__head--center { margin-inline: auto; text-align: center; }

.bb-h1 {
  font-size: var(--bb-fs-display);
  line-height: var(--bb-lh-tight);
  letter-spacing: var(--bb-tracking-display);
}
.bb-h2 {
  font-size: var(--bb-fs-h2);
  line-height: var(--bb-lh-heading);
  letter-spacing: var(--bb-tracking-heading);
}
.bb-h3 {
  font-size: var(--bb-fs-h3);
  line-height: var(--bb-lh-heading);
  letter-spacing: -0.01em;
  font-weight: 650;
}
.bb-lede {
  margin-top: var(--bb-space-5);
  font-size: var(--bb-fs-lede);
  color: var(--bb-text-2);
  max-width: var(--bb-measure);
}
.bb-section__head--center .bb-lede { margin-inline: auto; }
.bb-body { color: var(--bb-text-2); max-width: var(--bb-measure); }
.bb-note { font-size: var(--bb-fs-xs); color: var(--bb-text-3); }

/* ---------- Nav ---------- */
.bb-nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bb-glass-solid);
  border-bottom: 1px solid var(--bb-line);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .bb-nav {
    background: var(--bb-glass-bg);
    -webkit-backdrop-filter: var(--bb-glass-blur);
    backdrop-filter: var(--bb-glass-blur);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .bb-nav { background: var(--bb-glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.bb-nav__inner {
  display: flex; align-items: center; gap: var(--bb-space-4);
  height: var(--bb-nav-h);
}
.bb-brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; font-weight: 650; letter-spacing: -0.01em;
  margin-right: auto; min-width: 0;
}
.bb-brand img { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.bb-brand span { white-space: nowrap; }

/* 語言切換：分段按鈕 */
.bb-lang {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: var(--bb-radius-pill);
  background: rgba(242, 238, 230, 0.06);
  border: 1px solid var(--bb-line);
}
.bb-lang button {
  border: 0; background: transparent; cursor: pointer;
  padding: 4px 10px; border-radius: var(--bb-radius-pill);
  font-size: var(--bb-fs-xs); font-weight: 600; color: var(--bb-text-2);
  transition: background var(--bb-dur-fast) var(--bb-ease-out), color var(--bb-dur-fast) var(--bb-ease-out);
}
.bb-lang button:hover { color: var(--bb-text); }
.bb-lang button[aria-pressed="true"] { background: var(--bb-surface-3); color: var(--bb-text); }

/* ---------- Buttons ---------- */
.bb-btn {
  --_bg: var(--bb-surface-2);
  --_fg: var(--bb-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: var(--bb-radius-pill);
  border: 1px solid var(--bb-line-strong);
  background: var(--_bg); color: var(--_fg);
  font-size: var(--bb-fs-small); font-weight: 600; letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: transform var(--bb-dur-fast) var(--bb-ease-out), background var(--bb-dur-fast) var(--bb-ease-out),
    border-color var(--bb-dur-fast) var(--bb-ease-out);
}
.bb-btn:hover { --_bg: var(--bb-surface-3); }
.bb-btn:active { transform: scale(0.98); }
.bb-btn--primary { --_bg: var(--bb-accent); --_fg: var(--bb-accent-ink); border-color: transparent; }
.bb-btn--primary:hover { --_bg: var(--bb-accent); filter: brightness(1.06); }
.bb-btn--sm { min-height: 34px; padding: 0 14px; font-size: var(--bb-fs-xs); }

/* 玻璃按鈕：有 backdrop-filter 才半透明，否則實色 */
.bb-btn--glass { --_bg: var(--bb-glass-solid); }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .bb-btn--glass {
    --_bg: rgba(242, 238, 230, 0.07);
    -webkit-backdrop-filter: var(--bb-glass-blur);
    backdrop-filter: var(--bb-glass-blur);
  }
  .bb-btn--glass:hover { --_bg: rgba(242, 238, 230, 0.12); }
}

/* 不可點（例如「即將推出」）：保留形狀，降低存在感，不假裝能按 */
.bb-btn[aria-disabled="true"] {
  cursor: default;
  --_bg: transparent;
  --_fg: var(--bb-text-2);
  border-style: dashed;
  border-color: var(--bb-line-strong);
  filter: none;
}
.bb-btn[aria-disabled="true"]:active { transform: none; }
.bb-btn[aria-disabled="true"]:hover { --_bg: transparent; }

/* ---------- Feature row：一個功能配一個畫面 ---------- */
.bb-features { display: grid; gap: clamp(64px, 3rem + 4vw, 128px); }
.bb-feature {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(32px, 6vw, 96px);
}
.bb-feature--flip { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.bb-feature--flip .bb-feature__text { order: 2; }
.bb-feature__text .bb-body { margin-top: var(--bb-space-4); }
.bb-feature__text .bb-note { margin-top: var(--bb-space-4); max-width: var(--bb-measure); }
.bb-feature__media {
  /* 畫面是每列的主角：產品 css 用 @container bb-media 依框寬放大模擬畫面 */
  container: bb-media / inline-size;
  display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
  padding: clamp(20px, 2.6vw, 36px);
  border-radius: var(--bb-radius-xl);
  background: var(--bb-surface-1);
  border: 1px solid var(--bb-line);
}
@media (max-width: 860px) {
  .bb-feature, .bb-feature--flip { grid-template-columns: minmax(0, 1fr); gap: var(--bb-space-6); }
  .bb-feature--flip .bb-feature__text { order: 0; }
}

/* ---------- Steps（順序有意義才用編號） ---------- */
.bb-steps { list-style: none; display: grid; gap: var(--bb-space-6); counter-reset: bb-step; }
.bb-steps li {
  counter-increment: bb-step;
  display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: var(--bb-space-4);
}
.bb-steps li::before {
  content: counter(bb-step);
  grid-row: span 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--bb-fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--bb-text); background: var(--bb-surface-2); border: 1px solid var(--bb-line-strong);
}
.bb-steps h3 { font-size: 1.0625rem; font-weight: 650; line-height: 1.35; padding-top: 5px; }
.bb-steps p { margin-top: var(--bb-space-1); }
.bb-steps p { color: var(--bb-text-2); font-size: var(--bb-fs-small); }

/* ---------- Points：信任清單（不用卡片） ---------- */
.bb-points {
  list-style: none;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(32px, 6vw, 96px);
}
.bb-points li { padding-block: var(--bb-space-6); border-top: 1px solid var(--bb-line-strong); }
.bb-points h3 { font-size: 1.125rem; font-weight: 650; line-height: var(--bb-lh-heading); }
.bb-points p { margin-top: var(--bb-space-2); color: var(--bb-text-2); font-size: var(--bb-fs-small); max-width: 30rem; }
@media (max-width: 720px) { .bb-points { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Plan：價格說明（不寫數字也成立） ---------- */
.bb-plan {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px); align-items: start;
}
.bb-plan__terms { list-style: none; display: grid; }
.bb-plan__terms li {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--bb-space-3);
  padding-block: var(--bb-space-4); border-bottom: 1px solid var(--bb-line);
}
.bb-plan__terms li:first-child { border-top: 1px solid var(--bb-line); }
.bb-plan__terms svg { width: 20px; height: 20px; margin-top: 3px; color: var(--bb-accent); }
.bb-plan__terms strong { display: block; font-weight: 650; }
.bb-plan__terms span { color: var(--bb-text-2); font-size: var(--bb-fs-small); }
@media (max-width: 860px) { .bb-plan { grid-template-columns: minmax(0, 1fr); } }

/* ---------- FAQ ---------- */
.bb-faq { max-width: 48rem; border-top: 1px solid var(--bb-line-strong); }
.bb-faq details { border-bottom: 1px solid var(--bb-line-strong); }
.bb-faq summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: var(--bb-space-4);
  padding-block: var(--bb-space-5);
  font-size: 1.0625rem; font-weight: 600;
}
.bb-faq summary::-webkit-details-marker { display: none; }
.bb-faq summary:hover { color: var(--bb-text); }
.bb-faq summary::after {
  content: ""; flex: none; width: 10px; height: 10px; margin-right: 4px;
  border-right: 1.75px solid var(--bb-text-2); border-bottom: 1.75px solid var(--bb-text-2);
  transform: translateY(-3px) rotate(45deg);
  transition: transform var(--bb-dur-base) var(--bb-ease-out);
}
.bb-faq details[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.bb-faq details > div { padding-bottom: var(--bb-space-5); color: var(--bb-text-2); max-width: 42rem; }
.bb-faq details > div p + p { margin-top: var(--bb-space-3); }

/* ---------- Device：手機外框（純 CSS） ---------- */
.bb-phone {
  --phone-w: 300px;
  position: relative;
  width: var(--phone-w);
  aspect-ratio: 9 / 19.5;
  padding: calc(var(--phone-w) * 0.035);
  border-radius: calc(var(--phone-w) * 0.17);
  background: linear-gradient(145deg, #3a3835, #1c1b19 40%, #2a2826);
  box-shadow: var(--bb-shadow-device), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  flex: none;
}
.bb-phone__screen {
  position: relative; height: 100%; overflow: hidden;
  border-radius: calc(var(--phone-w) * 0.135);
  background: #000;
  isolation: isolate;
}

/* ---------- Closer：頁尾前的結尾 CTA ---------- */
.bb-closer { padding-block: var(--bb-space-9) calc(var(--bb-section-gap) / 2); border-top: 1px solid var(--bb-line); }
.bb-closer__inner { display: grid; justify-items: center; text-align: center; }
.bb-closer__icon {
  width: 104px; height: 104px; border-radius: 23px;
  box-shadow: var(--bb-shadow-device);
  margin-bottom: var(--bb-space-5);
}
.bb-closer .bb-lede { margin-top: var(--bb-space-3); margin-inline: auto; }
.bb-closer .bb-btn { margin-top: var(--bb-space-6); }

/* ---------- Footer ---------- */
.bb-footer {
  border-top: 1px solid var(--bb-line);
  padding-block: var(--bb-space-8) var(--bb-space-7);
  color: var(--bb-text-3); font-size: var(--bb-fs-xs);
}
.bb-footer__row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--bb-space-4) var(--bb-space-6);
}
.bb-footer__mark { display: inline-flex; align-items: center; gap: 8px; color: var(--bb-text-2); font-weight: 650; letter-spacing: 0.01em; }
.bb-footer__mark svg { width: 18px; height: 18px; }
.bb-footer nav { display: flex; flex-wrap: wrap; gap: var(--bb-space-5); }
.bb-footer a { color: var(--bb-text-2); text-decoration: none; }
.bb-footer a:hover { color: var(--bb-text); text-decoration: underline; }
.bb-footer__legal { margin-top: var(--bb-space-5); max-width: 46rem; }

/* ---------- Motion：捲動時輕微淡入（只在 JS 啟用後生效） ---------- */
.bb-js .bb-reveal { opacity: 0; transform: translateY(6px); transition: opacity var(--bb-dur-reveal) var(--bb-ease-out), transform var(--bb-dur-reveal) var(--bb-ease-out); }
.bb-js .bb-reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .bb-js .bb-reveal { opacity: 1; transform: none; }
}
