/* 自動補樣式：js/router.js（_build/style.py） */
/* ==========================================================================
   router.js 使用但先前沒有樣式的 class
   - 頂部列：#topbar.l-topbar > .l-topbar__inner > (.l-topbar__lead, h1, .l-topbar__actions)
   - 導覽：.l-tabbar__brand、.l-tabbar__item、.l-tabbar__pro
   - 錯誤卡：.s-router-error
   ========================================================================== */

/* ---------- 頂部列：內層容器 ---------- */
/* .l-topbar 本身是 grid，只有一個子節點；這裡讓 inner 佔滿並接手三欄排版。 */
.l-topbar__inner {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(44px, 1fr) minmax(0, auto) minmax(44px, 1fr);
  align-items: center;
  column-gap: var(--sp-1);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

/* 左側：返回或關閉按鈕；沒有按鈕時仍保留 44px，讓標題維持置中 */
.l-topbar__lead {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: var(--tap);
  min-height: var(--tap);
}

.l-topbar__inner > .l-topbar__actions {
  min-width: var(--tap);
}

/* ---------- 頂部列：動作按鈕 ---------- */
.l-topbar .l-topbar__action {
  flex: none;
  color: var(--primary);
  transition:
    background-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}

.l-topbar .l-topbar__action svg {
  flex: none;
}

/* 文字預設隱藏（sm、md 只顯示圖示，名稱由 aria-label 與 title 提供） */
.l-topbar__action-text {
  display: none;
  font-size: var(--fs-callout);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .l-topbar .l-topbar__action:hover {
    background: var(--primary-tint);
  }
}

/* ---------- 頂部列：lg（≥1024 且非矮螢幕） ---------- */
@media (min-width: 1024px) and (min-height: 501px), (min-width: 1024px) and (orientation: portrait) {
  .l-topbar__inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: var(--sp-2);
  }

  /* 沒有返回鍵時，不保留空位，標題靠左 */
  .l-topbar__lead:empty {
    display: none;
  }

  .l-topbar__lead {
    min-width: 0;
  }

  .l-topbar__inner > .l-topbar__actions {
    min-width: 0;
    gap: var(--sp-2);
  }

  .l-topbar .l-topbar__action {
    width: auto;
    min-width: var(--tap);
    padding: 0 var(--sp-3);
    gap: var(--sp-2);
    border-radius: var(--r-btn);
  }

  .l-topbar .l-topbar__action:has(> .l-topbar__action-text) {
    padding: 0 var(--sp-4);
    background: var(--primary-soft);
  }

  .l-topbar__action-text {
    display: inline;
  }

  @media (hover: hover) and (pointer: fine) {
    .l-topbar .l-topbar__action:has(> .l-topbar__action-text):hover {
      background: var(--primary-soft);
      filter: brightness(.96);
    }
  }
}

/* ---------- 導覽：品牌 ---------- */
/* 必須蓋過 base.css 中 .l-tabbar__brand > :not(svg):not(img) 的 display 規則，故多一層選擇器 */
.l-tabbar .l-tabbar__brand > .l-tabbar__brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  color: var(--text-on-primary);
  line-height: 0;
}

.l-tabbar .l-tabbar__brand-mark svg {
  width: 22px;
  height: 22px;
  color: inherit;
}

/* rail 與 sm：只顯示圖形，文字隱藏 */
.l-tabbar .l-tabbar__brand > .l-tabbar__brand-text {
  display: none;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  line-height: 1.2;
}

.l-tabbar__brand-name {
  display: block;
  font-size: var(--fs-title3);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}

.l-tabbar__brand:focus-visible {
  outline-offset: 3px;
}

@media (min-width: 1024px) and (min-height: 501px), (min-width: 1024px) and (orientation: portrait) {
  .l-tabbar .l-tabbar__brand > .l-tabbar__brand-mark {
    width: 40px;
    height: 40px;
    background: var(--primary);
  }

  .l-tabbar .l-tabbar__brand > .l-tabbar__brand-text {
    display: flex;
  }

  .l-tabbar__brand {
    flex-wrap: nowrap;
    gap: var(--sp-3);
  }
}

/* 矮螢幕 rail：品牌圓形縮小，圖示跟著縮小 */
@media (orientation: landscape) and (max-height: 500px) {
  .l-tabbar .l-tabbar__brand-mark svg {
    width: 18px;
    height: 18px;
  }
}

/* ---------- 導覽：項目的圖示與文字 ---------- */
.l-tabbar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  line-height: 0;
  pointer-events: none;
}

.l-tabbar__label {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-align: center;
}

@media (min-width: 1024px) and (min-height: 501px), (min-width: 1024px) and (orientation: portrait) {
  .l-tabbar__label {
    flex: 1 1 auto;
    text-align: left;
  }
}

/* ---------- 導覽：Pro 狀態卡（只在 lg 側欄底部顯示） ---------- */
.l-tabbar__pro-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 48px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-card);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-callout);
  line-height: 1.3;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease);
}

.l-tabbar__pro-card svg {
  flex: none;
}

.l-tabbar__pro-card > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.l-tabbar__pro-card:active {
  transform: scale(.98);
}

/* 已啟用：安靜的狀態顯示，不可點 */
.l-tabbar__pro-card.is-active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-2);
  cursor: default;
}

.l-tabbar__pro-card.is-active svg {
  color: var(--primary);
}

.l-tabbar__pro-card.is-active:active {
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  a.l-tabbar__pro-card:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
  }
}

/* ---------- 空前綴頁面容器（router 以 layout 組出的備援 class） ---------- */
.s-page-- {
  width: 100%;
  margin-inline: auto;
  max-width: var(--content-max, 760px);
}

/* ---------- 畫面載入失敗卡 ---------- */
.s-router-error {
  width: 100%;
  max-width: 440px;
  margin: clamp(24px, 10vh, 96px) auto 0;
  padding: var(--sp-8) var(--sp-6);
  gap: var(--sp-3);
  text-align: center;
}

.s-router-error > svg {
  box-sizing: border-box;
  width: 64px;
  height: 64px;
  padding: 16px;
  margin-bottom: var(--sp-1);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.s-router-error .c-empty__title {
  font-size: var(--fs-title2);
  line-height: var(--lh-title2);
}

.s-router-error .c-empty__text {
  margin-bottom: var(--sp-2);
}

.s-router-error .c-btn {
  min-width: 160px;
}

@container view (max-width: 400px) {
  .s-router-error {
    padding: var(--sp-6) var(--sp-4);
  }
  .s-router-error .c-btn {
    width: 100%;
  }
}

/* ---------- 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  .l-topbar .l-topbar__action,
  .l-tabbar__pro-card {
    transition-duration: 0.01ms !important;
  }
  .l-tabbar__pro-card:active {
    transform: none;
  }
}
