/*
 * TokenBar 產品覆寫。共用 tokens 與元件在 ../bluebox/bluebox.css，這裡只放：
 * 1. 產品主色與資料色 tokens
 * 2. TokenBar 專屬元件（首屏、模擬畫面）
 * 模擬畫面依 App 實際排版（Shared/LockScreenView、ExpandedIslandView、WidgetUsageView）。
 */

:root {
  /* 產品主色：取自 TokenBar Logo 底座的綠（logo.png 實測 #7DB8A4） */
  --bb-accent: #7db8a4;
  --bb-accent-ink: #0f1a16;
  --bb-accent-soft: rgba(125, 184, 164, 0.14);

  /* 資料色：只用在進度條、百分比、AI 名稱，不塗背景 */
  --tb-claude: #d97757;
  --tb-codex: #6b7fff;
  --tb-low: #ff5f57;

  /* App 內 AI 分區底色（DESIGN_HANDOFF build 18） */
  --tb-claude-zone: #30231e;
  --tb-codex-zone: #1d263b;

  /* 系統畫面（iOS 深色材質近似） */
  --tb-sys-material: rgba(38, 37, 35, 0.72);
  --tb-sys-material-solid: #262523;
  --tb-sys-text-2: rgba(235, 235, 245, 0.6);
}

/* ---------- 首屏 ---------- */
.tb-hero { padding-block: clamp(24px, 4vw, 56px) clamp(56px, 6vw, 96px); overflow: clip; }
.tb-hero__grid {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(32px, 5vw, 80px);
}
.tb-hero__copy .bb-h1 { max-width: 12.5em; }
/* 中文主標：「Claude 和 Codex」要在同一行，桌面手機變大後欄寬變窄，字級稍降並取消 balance */
:lang(zh) .tb-hero__copy .bb-h1 { max-width: 11em; font-size: clamp(2.125rem, 4.4vw, 4rem); text-wrap: wrap; }
.tb-hero__cta { display: flex; flex-wrap: wrap; gap: var(--bb-space-3); margin-top: var(--bb-space-6); }
.tb-hero__req { margin-top: var(--bb-space-4); }
.tb-hero__device { display: grid; justify-items: center; --phone-w: clamp(320px, 40.5vw, 580px); }
/* 首屏主角：手機放大、只露出上半（靈動島＋時鐘＋即時動態），下緣淡出裁掉 */
.tb-phone--hero { --phone-w: inherit; }
.tb-hero__crop {
  height: calc(var(--phone-w) * 0.98);
  overflow: hidden;
  padding: 0 var(--bb-gutter); margin: 0 calc(-1 * var(--bb-gutter)); /* 讓機身陰影不被左右裁到 */
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent);
  mask-image: linear-gradient(to bottom, #000 78%, transparent);
}

@media (max-width: 960px) {
  .tb-hero__grid { grid-template-columns: minmax(0, 1fr); gap: var(--bb-space-6); }
  .tb-hero__device { --phone-w: min(420px, calc(100vw - 2 * var(--bb-gutter))); }
  .tb-hero__crop { height: calc(var(--phone-w) * 0.9); }
}
@media (max-width: 520px) {
  .tb-hero .bb-h1 { font-size: 2.125rem; }
  .tb-hero .bb-lede { margin-top: var(--bb-space-4); font-size: 1.0625rem; }
  .tb-hero__cta { margin-top: var(--bb-space-5); }
  .tb-hero__cta .bb-btn { min-height: 40px; padding: 0 16px; }
}
@media (max-width: 520px) {
  .tb-nav-soon { display: none; }
}

/* ---------- 通用小元件 ---------- */
.tb-low { color: var(--tb-low) !important; }
.tb-c-claude { color: var(--tb-claude); }
.tb-c-codex { color: var(--tb-codex); }

/* 服務圖示：Desktop 淺底、CLI 深底（同 App 的 ChannelIcon） */
.tb-ico {
  --s: 17px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--s); height: var(--s);
  border-radius: calc(var(--s) * 0.24);
  overflow: hidden;
}
.tb-ico img { width: 100%; height: 100%; object-fit: contain; }
.tb-ico--claude-desktop { background: #f4eadf; }
.tb-ico--claude-cli { background: #242323; }
.tb-ico--claude-desktop img, .tb-ico--claude-cli img { width: 64%; height: 64%; }

/* 相對更新時間標籤（App 的 UpdatedAtLabel） */
.tb-age {
  display: inline-block; padding: 0 5px; margin-left: 4px;
  border-radius: 5px; background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.78);
}

/* ---------- 鎖定畫面 ---------- */
.tb-lock {
  --u: calc(var(--phone-w) * 0.93 / 393); /* 1 單位 = iPhone 的 1 pt（螢幕約 393 pt 寬），跟著機身縮放 */
  background:
    radial-gradient(120% 70% at 30% 0%, #3a3128 0%, transparent 60%),
    radial-gradient(110% 80% at 90% 100%, #23302b 0%, transparent 65%),
    #15130f;
  color: #fff;
  font-family: var(--bb-font);
}
.tb-lock__date {
  margin-top: calc(var(--u) * 66);
  text-align: center; font-size: calc(var(--u) * 19); font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}
.tb-lock__time {
  text-align: center; line-height: 1;
  font-size: calc(var(--u) * 96); font-weight: 700; letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--bb-font-display);
}
.tb-lock__buttons {
  position: absolute; left: calc(var(--u) * 46); right: calc(var(--u) * 46); bottom: calc(var(--u) * 40);
  display: flex; justify-content: space-between;
}
.tb-lock__buttons span {
  width: calc(var(--u) * 50); height: calc(var(--u) * 50); border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}
.tb-lock__home {
  position: absolute; left: 50%; bottom: calc(var(--u) * 8);
  width: 36%; height: calc(var(--u) * 4); border-radius: 4px;
  transform: translateX(-50%); background: rgba(255, 255, 255, 0.85);
}

/* ---------- 靈動島 ---------- */
.tb-island {
  background: #000; color: #fff;
  font-family: var(--bb-font-mono);
  font-variant-numeric: tabular-nums;
}
.tb-island--compact {
  --u: calc(var(--phone-w, 360px) * 0.93 / 393);
  position: absolute; top: calc(var(--u) * 11); left: 50%; transform: translateX(-50%);
  width: calc(var(--u) * 236); height: calc(var(--u) * 37);
  border-radius: 999px;
  display: flex; align-items: center; justify-content: space-between;
  padding-inline: calc(var(--u) * 11);
  font-size: calc(var(--u) * 12); font-weight: 600;
  z-index: 2;
}
.tb-island--compact .tb-ico { --s: calc(var(--u) * 16); }
.tb-island__slot { display: inline-flex; align-items: center; gap: calc(var(--u) * 4); }
.tb-island__val { min-width: 4ch; }
.tb-island__slot--end .tb-island__val { text-align: right; }
.tb-island--static { position: relative; top: auto; left: auto; transform: none; }

/* ---------- 即時動態卡片（鎖定畫面） ---------- */
.tb-live {
  /* 示意圖：卡片緊接在時鐘下方（真機在畫面下緣），讓首屏一眼看到 */
  margin: calc(var(--u) * 26) calc(var(--u) * 14) 0;
  position: relative;
  padding: calc(var(--u) * 15) calc(var(--u) * 15) calc(var(--u) * 12);
  border-radius: calc(var(--u) * 22);
  background: var(--tb-sys-material-solid);
  display: grid; gap: calc(var(--u) * 7);
  font-size: calc(var(--u) * 11);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .tb-live { background: var(--tb-sys-material); -webkit-backdrop-filter: blur(24px) saturate(150%); backdrop-filter: blur(24px) saturate(150%); }
}
.tb-live__row {
  display: grid; align-items: center;
  grid-template-columns: auto minmax(0, 1fr) auto calc(var(--u) * 82);
  column-gap: calc(var(--u) * 6);
}
.tb-live__icons { display: inline-flex; gap: 2px; }
.tb-live .tb-ico { --s: calc(var(--u) * 17); }
.tb-live__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-live__pct { font-weight: 700; font-size: calc(var(--u) * 12); text-align: right; min-width: 4ch; }
.tb-live__cd { text-align: right; color: var(--tb-sys-text-2); font-size: calc(var(--u) * 11); white-space: nowrap; }
.tb-live__foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: calc(var(--u) * 9); color: var(--tb-sys-text-2);
}
.tb-live__foot .tb-age { font-size: inherit; }

/* ---------- 運作方式：Mac 選單列 ---------- */
.tb-how {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(40px, 6vw, 96px);
}
.tb-how__media {
  padding: clamp(20px, 3vw, 40px);
  border-radius: var(--bb-radius-xl);
  background: var(--bb-surface-1);
  border: 1px solid var(--bb-line);
  overflow: hidden;
}
@media (max-width: 860px) { .tb-how { grid-template-columns: minmax(0, 1fr); } }

.tb-mac { max-width: 420px; margin-inline: auto; font-size: 12px; }
.tb-mac__bar {
  display: flex; justify-content: flex-end; align-items: center; gap: 14px;
  height: 28px; padding-inline: 10px;
  border-radius: 10px 10px 0 0;
  background: rgba(242, 238, 230, 0.07);
  border: 1px solid var(--bb-line); border-bottom: 0;
}
.tb-mac__item { display: inline-grid; place-items: center; width: 30px; height: 22px; border-radius: 6px; }
.tb-mac__item--on { background: rgba(242, 238, 230, 0.16); }
.tb-mac__item img { width: 18px; height: 18px; }
.tb-mac__clock { color: var(--bb-text-2); font-size: 12px; font-weight: 500; }
.tb-mac__panel {
  margin: 6px 0 0 auto; width: min(100%, 340px);
  padding: 12px; border-radius: 14px;
  background: #1c1b19; border: 1px solid var(--bb-line-strong);
  box-shadow: var(--bb-shadow-device);
  display: grid; gap: 8px;
}
.tb-mac__head { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13px; padding: 2px 2px 4px; }
.tb-mac__head img { border-radius: 5px; }
.tb-mac__age { margin-left: auto; font-weight: 400; font-size: 10px; color: var(--bb-text-3); white-space: nowrap; }
.tb-mac__ai { border-radius: 10px; padding: 10px 12px 12px; display: grid; gap: 9px; }
.tb-mac__ai--claude { background: var(--tb-claude-zone); --tint: var(--tb-claude); }
.tb-mac__ai--codex { background: var(--tb-codex-zone); --tint: var(--tb-codex); }
.tb-mac__ai-head { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12px; }
.tb-mac__ai-head .tb-ico { --s: 16px; }
.tb-meter {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; column-gap: 8px; align-items: baseline;
}
.tb-meter__label { color: rgba(255, 255, 255, 0.7); font-size: 11px; }
.tb-meter__pct { font-weight: 700; font-size: 15px; text-align: right; }
.tb-meter__meta { grid-column: 1 / -1; color: rgba(255, 255, 255, 0.6); font-size: 10px; }
.tb-bar { grid-column: 1 / -1; position: relative; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--tint) 20%, transparent); overflow: hidden; }
.tb-bar > span { position: absolute; inset: 0 auto 0 0; width: calc(var(--p) * 1%); border-radius: inherit; background: var(--tint); }

.tb-how__steps { max-width: 30rem; }

/* ---------- 功能區 ---------- */
.tb-feat-h { font-size: clamp(1.625rem, 1.3rem + 1.2vw, 2.25rem); }

/* F1：展開靈動島 */
.tb-f1 { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 28px; width: 360px; }
.tb-island--expanded {
  width: 360px;
  padding: 18px 20px 12px;
  border-radius: 44px;
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; row-gap: 8px;
  font-family: var(--bb-font);
  box-shadow: var(--bb-shadow-sm);
}
.tb-xcol { display: grid; gap: 5px; align-content: start; min-width: 0; }
.tb-xcol__head { display: flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12px; }
.tb-xcol__head .tb-ico { --s: 16px; }
.tb-xcol__line { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-xcol__cd { font-size: 10px; color: var(--tb-sys-text-2); }
.tb-xfoot { grid-column: 1 / -1; text-align: center; font-size: 9px; color: var(--tb-sys-text-2); }
.tb-f1__compact { width: 330px; max-width: 100%; display: grid; justify-items: center; }
.tb-f1__compact .tb-island--static { --phone-w: 440px; box-shadow: var(--bb-shadow-sm); }

/* F2：Widget */
.tb-f2 { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 24px; width: 452px; }
.tb-widget {
  width: 170px; height: 170px; padding: 14px;
  border-radius: 24px; background: #1f1e1c;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--bb-shadow-sm);
  display: flex; flex-direction: column; gap: 6px;
  color: #fff;
}
.tb-widget__group { display: grid; gap: 1px; }
.tb-widget__row { display: flex; align-items: center; gap: 4px; font-size: 10px; }
.tb-widget__row .tb-ico { --s: 12px; }
.tb-widget__row b { margin-left: auto; font-size: 11px; }
.tb-widget__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-widget__sub { display: flex; justify-content: space-between; font-size: 9px; color: var(--tb-sys-text-2); }
.tb-widget__foot { margin-top: auto; font-size: 9px; color: rgba(235, 235, 245, 0.42); }

.tb-lockmini {
  width: 248px; max-width: 100%; padding: 22px 18px 26px;
  border-radius: 28px;
  background: radial-gradient(120% 90% at 20% 0%, #3a3128, transparent 60%), #15130f;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #fff;
  box-shadow: var(--bb-shadow-sm);
}
.tb-lockmini__time { text-align: center; font-size: 54px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; color: rgba(255, 255, 255, 0.9); font-family: var(--bb-font-display); }
.tb-rect { margin: 12px auto 0; width: 196px; display: grid; gap: 1px; }
.tb-rect__row { display: grid; grid-template-columns: minmax(0, 1fr) 30px 40px; align-items: center; column-gap: 3px; font-size: 10px; }
.tb-rect__row span { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-rect__row b { text-align: right; font-family: var(--bb-font-mono); }
.tb-rect__row i { font-style: normal; white-space: nowrap; text-align: right; font-size: 9px; color: rgba(255, 255, 255, 0.62); }

/* F3：通知與提醒時點 */
.tb-f3, .tb-f4 { width: 360px; display: grid; gap: 22px; }
.tb-notif {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 10px; align-items: center;
  padding: 12px; border-radius: 22px;
  background: var(--tb-sys-material-solid); color: #fff;
  box-shadow: var(--bb-shadow-sm);
  font-size: 13px; line-height: 1.3;
}
.tb-notif__app { width: 38px; height: 38px; border-radius: 9px; }
.tb-notif__top { display: flex; justify-content: space-between; gap: 8px; }
.tb-notif__top b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-notif__top span { color: var(--tb-sys-text-2); font-size: 12px; flex: none; }
.tb-notif__sub { font-weight: 600; }
.tb-notif__body { color: rgba(255, 255, 255, 0.86); }
.tb-notif__att.tb-ico { --s: 38px; border-radius: 9px; align-self: center; }

/* iOS 分組清單（設定頁樣式） */
.tb-list { color: #fff; }
.tb-list__head { padding: 0 16px 6px; font-size: 12px; color: var(--tb-sys-text-2); }
.tb-list__group { border-radius: 14px; background: #1f1e1c; border: 1px solid rgba(255, 255, 255, 0.05); overflow: hidden; }
.tb-list__row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 0 16px; font-size: 14px;
}
.tb-list__row + .tb-list__row { border-top: 1px solid rgba(255, 255, 255, 0.07); }
.tb-list__row svg { width: 18px; height: 18px; color: var(--bb-accent); flex: none; }
.tb-list__foot { padding: 8px 16px 0; font-size: 12px; color: var(--bb-accent); font-weight: 600; }
.tb-check { justify-content: flex-start; }
.tb-check svg { width: 20px; height: 20px; }

/* 模擬畫面依展示框寬度等比放大，大致填滿框（模擬畫面以 360px 寬設計） */
@container bb-media (min-width: 330px) { .tb-f1, .tb-f3, .tb-f4 { zoom: 0.92; } }
@container bb-media (min-width: 360px) { .tb-f1, .tb-f3, .tb-f4 { zoom: 1; } }
@container bb-media (min-width: 420px) { .tb-f1, .tb-f3, .tb-f4 { zoom: 1.15; } }
@container bb-media (min-width: 470px) { .tb-f1, .tb-f3, .tb-f4 { zoom: 1.3; } }
@container bb-media (max-width: 329px) { .tb-f1, .tb-f3, .tb-f4 { zoom: 0.82; } }
@container bb-media (max-width: 451px) { .tb-f2 { width: 248px; } }
@container bb-media (min-width: 452px) { .tb-f2 { zoom: 1; } }
@container bb-media (min-width: 496px) { .tb-f2 { zoom: 1.08; } }
