/* ==========================================================================
   Cunavo — Shared Components
   Header · Navigation · Mark · Buttons · Store CTA · FAQ · Footer · Device
   ========================================================================== */

/* --- Brand mark (App Icon) ---------------------------------------------
   霧藍灰版：一個收著月曆卡的口袋。網站用去背版本，物件直接放在紙上——
   不套 squircle、不加容器邊線：它本來就是一件有自己陰影的實物，
   再包一層方框就是圖示裡又一個圖示。
   ---------------------------------------------------------------------- */

.mark {
  --mark-size: 44px;
  position: relative;
  flex: none;
  width: var(--mark-size);
  height: var(--mark-size);
  background: url("../assets/icons/mark-160.png") center / contain no-repeat;
}

/* Text-only brand lockup shares the headline’s family and regular weight. */
.wordmark {
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin-right: 0;
  text-transform: lowercase;
  color: var(--color-text-primary);
  white-space: nowrap;
  font-kerning: normal;
}

/* --- Header ------------------------------------------------------------ */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* 不再是毛玻璃：頁首與頁面同一個 #f2f0ec，內容滾到底下就干淨地消失。
     半透明＋模糊在紙白底上只會當卡片穿過時糊成一片，
     區隔改由滾動後才出現的那條髮絲線交代。 */
  background: var(--color-header-bg);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.header.is-scrolled {
  border-bottom-color: var(--color-border);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: var(--header-h);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.header__brand .mark {
  --mark-size: 28px;
}

.header__brand:hover {
  color: var(--color-text-primary);
}

.nav {
  display: none;
}

.nav__list {
  display: flex;
  align-items: center;
  gap: clamp(18px, 2vw, 30px);
  list-style: none;
}

.nav__link {
  position: relative;
  display: inline-block;
  font-size: var(--fs-nav);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--color-text-secondary);
  padding-block: 4px;
}

.nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}

.nav__link:hover {
  color: var(--color-text-primary);
}

.nav__link:hover::after {
  transform: none;
}

.nav__link[aria-current="page"] {
  color: var(--color-text-primary);
}

.header__end {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Theme toggle — 純連結，無 JS 也可用。
   圖示顯示的是「目前的狀態」：浅色是太陽，深色是月亮。
   命中區 44×44（觸控下限），hover 的圓只有 34，
   所以手指好按，眼睛看到的仍是一顆小圖示。 */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-inline: -5px;
  color: var(--color-text-secondary);
  transition: color var(--dur) var(--ease);
}

.theme-toggle::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--color-button-ghost-hover);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.theme-toggle::before {
  content: "";
  position: relative;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--icon-sun) center / contain no-repeat;
  mask: var(--icon-sun) center / contain no-repeat;
}

[data-theme="dark"] .theme-toggle::before {
  -webkit-mask-image: var(--icon-moon);
  mask-image: var(--icon-moon);
}

.theme-toggle:hover {
  color: var(--color-text-primary);
}

.theme-toggle:hover::after {
  opacity: 1;
}

/* --- Mobile navigation ------------------------------------------------- */

.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  padding-inline: 11px;
  align-items: stretch;
}

.nav-toggle__bar {
  display: block;
  height: 1px;
  background: var(--color-icon);
  transition: transform var(--dur) var(--ease), opacity var(--dur-fast) var(--ease);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:first-child {
  transform: translateY(3px) rotate(9deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:last-child {
  transform: translateY(-3px) rotate(-9deg);
}

.sheet {
  position: fixed;
  inset: var(--header-h) 0 0;
  z-index: 90;
  background: var(--color-bg);
  background-image: var(--color-bg-tint);
  padding: var(--space-lg) 0 var(--space-2xl);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility var(--dur);
}

.sheet.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.sheet__list {
  list-style: none;
  border-top: 1px solid var(--color-divider);
}

.sheet__list li {
  border-bottom: 1px solid var(--color-divider);
}

.sheet__link {
  display: flex;
  align-items: center;
  min-height: 56px;
  font-size: 1rem;
  color: var(--color-text-primary);
}

.sheet__link[aria-current="page"] {
  font-weight: 600;
}

.sheet__foot {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-lg);
}

/* --- Store CTA -------------------------------------------------------- */

.store-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

/* 官方 Badge：等高 40px，周圍留白 ≥ 高度 25%。
   圖檔本身不裁切、不改色、不變形 —— 深色下只加一圈容器髮絲線界定邊緣。 */
.store-badge {
  display: block;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: opacity var(--dur) var(--ease), transform var(--dur-fast) var(--ease),
    border-color var(--dur) var(--ease);
}

.store-badge img {
  display: block;
  height: 40px;
  width: auto;
  border-radius: 8px;
}

.store-badge:hover {
  opacity: 0.84;
}

.store-badge:active {
  transform: translateY(0.5px);
  opacity: 0.72;
}

.store-badge:focus-visible {
  outline-offset: 4px;
}

html[data-theme="dark"] .store-badge {
  border-color: rgba(255, 255, 255, 0.14);
}

html[data-theme="dark"] .store-badge:hover {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.3);
}

/* Text link with hairline underline */

/* --- FAQ --------------------------------------------------------------- */

.faq {
  border-top: 1px solid var(--color-border);
}

.faq__item {
  border-bottom: 1px solid var(--color-border);
}

.faq__q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  width: 100%;
  min-height: 66px;
  padding: 17px 4px 17px 0;
  text-align: left;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text-primary);
  transition: color var(--dur) var(--ease);
}

.faq__q:hover {
  color: var(--color-text-secondary);
}

.faq__sign {
  position: relative;
  flex: none;
  width: 12px;
  height: 12px;
  margin-right: 4px;
}

.faq__sign::before,
.faq__sign::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: var(--color-text-secondary);
  transition: transform var(--dur-slow) var(--ease), opacity var(--dur) var(--ease);
}

.faq__sign::after {
  transform: rotate(90deg);
}

.faq__q[aria-expanded="true"] .faq__sign::after {
  transform: rotate(180deg);
  opacity: 0;
}

.faq__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-slow) var(--ease);
}

.faq__panel[data-open="true"] {
  grid-template-rows: 1fr;
}

.faq__panel > div {
  overflow: hidden;
}

.faq__a {
  max-width: 27.5rem;
  padding: 0 var(--space-xl) 24px 0;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text-secondary);
  text-wrap: pretty;
}

/* --- Footer ------------------------------------------------------------ */

.footer {
  border-top: 1px solid var(--color-border);
  padding-block: var(--v-4) var(--space-lg);
}

.footer__top {
  display: grid;
  gap: var(--v-3);
  padding-bottom: var(--v-3);
}

.footer__brand {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 12px 14px;
  align-items: center;
  align-content: start;
}

.footer__brand .wordmark { font-size: 32px; }

.footer__brand .mark {
  --mark-size: 36px;
}

.footer__tagline {
  grid-column: 1 / -1;
  font-size: var(--fs-caption);
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
}

.footer__col h2 {
  font-size: var(--fs-eyebrow);
  font-weight: 400;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.footer__links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.footer__links a {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.footer__links a:hover {
  color: var(--color-text-primary);
}

.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-divider);
  font-variant-numeric: tabular-nums;
}

.footer__meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-caption);
  color: var(--color-text-muted);
}

.footer__meta .divider {
  width: 1px;
  height: 8px;
  background: var(--color-border-strong);
}

/* --- Device + 首頁畫面 -------------------------------------------------
   設計稿「01 首頁 B 輸入中」：金額已輸入 120，常用金額換成金額建議，
   事項格浮起，算式鍵盤的 = 停用。以真實幾何撰寫（390×844、事項格 82、
   金額格 112、鍵高 62、底部安全區 34），整個畫面再用 --k 等比縮放。
   ---------------------------------------------------------------------- */

.device {
  --k: calc((var(--dw) - 18) / 390);
  position: relative;
  width: calc(var(--dw) * 1px);
  padding: 9px;
  border-radius: 46px;
  background: var(--device-shell);
  box-shadow: var(--screen-device-shadow);
}

/* 深色下外殼是暗的，靠一圈內側髮絲高光讓邊緣被看見 */
html[data-theme="dark"] .device {
  box-shadow: var(--screen-device-shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.device__screen {
  position: relative;
  width: 100%;
  aspect-ratio: 390 / 844;
  border-radius: 38px;
  overflow: hidden;
  background: var(--screen-bg);
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 390px;
  height: 844px;
  transform: scale(var(--k));
  transform-origin: top left;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.screen__status {
  flex: none;
  height: 50px;
  margin-inline: -16px;
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
}

.screen__status div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.screen__status i {
  display: block;
  width: 17px;
  height: 11px;
  border-radius: 2px;
  background: var(--ink-2);
  opacity: 0.72;
}

.screen__status i:nth-child(2) {
  width: 16px;
  border-radius: 3px;
}

.screen__status i:last-child {
  width: 25px;
  height: 12px;
  border-radius: 4px;
  background: none;
  border: 1.5px solid var(--ink-2);
  opacity: 0.45;
}

.screen__tabs {
  flex: none;
  height: 40px;
  margin-left: -7px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.screen__tabs span {
  height: 30px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  border-radius: 13px;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.screen__tabs span.is-on {
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: var(--screen-tab);
}

.screen__card {
  flex: none;
  margin-top: 19px;
  padding: 17px 20px 0;
  border-radius: 30px;
  background: var(--screen-card);
  border: 1px solid var(--screen-card-border);
  box-shadow: var(--screen-shadow);
}

.screen__budget {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.screen__budget span {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.screen__budget strong {
  color: var(--ink);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.012em;
}

.screen__meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-3);
}

.screen__meta b {
  font-weight: 500;
  color: var(--ink-2);
}

.screen__meta i {
  display: block;
  width: 1px;
  height: 8px;
  background: var(--rule-strong);
}

.screen__input {
  margin: 15px -20px 0;
  padding: 0 20px;
  height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--rule);
}

.screen__label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.screen__value {
  display: flex;
  align-items: baseline;
}

.screen__value b {
  margin-right: 4px;
  font-size: 19px;
  font-weight: 400;
  color: var(--ink-3);
  transform: translateY(-1px);
}

/* 輸入中：金額是畫面上最大的東西 */
.screen__value strong {
  color: var(--ink);
  font-size: 58px;
  font-weight: 560;
  line-height: 1;
  letter-spacing: -0.03em;
}

.screen__block {
  flex: none;
  margin-top: 19px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.screen__block .screen__label {
  padding-left: 4px;
}

.screen__amounts {
  display: grid;
  grid-template-columns: repeat(4, 82px);
  gap: 10px;
}

.screen__amounts span {
  height: 52px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 14px;
  background: var(--screen-card);
  border: 1px solid var(--screen-cell-border);
  box-shadow: var(--screen-shadow-cell);
}

.screen__amounts em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink-2);
}

.screen__items {
  flex: none;
  margin-top: 19px;
  display: grid;
  grid-template-columns: repeat(4, 82px);
  gap: 10px;
}

.screen__items span {
  height: 60px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: var(--screen-card);
  border: 1px solid var(--screen-cell-border);
}

.screen__items span.is-alt {
  background: var(--screen-key-op);
}

.screen__keys {
  flex: none;
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, 82px);
  gap: 9px 10px;
}

.screen__key {
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 400;
  color: var(--ink);
  background: var(--screen-key);
  border: 1px solid var(--screen-cell-border);
}

.screen__key.is-op {
  font-size: 24px;
  color: var(--ink-2);
  background: var(--screen-key-op);
  border-color: var(--rule);
}

/* 停用 = 去掉墨色，不改邊界 */
.screen__key.is-off {
  font-size: 24px;
  color: var(--ink-4);
  background: var(--screen-key-op);
  border-color: var(--rule);
}

.screen__home {
  position: absolute;
  left: 50%;
  bottom: 9px;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: rgba(100, 98, 95, 0.28);
  z-index: 2;
}

/* --- Responsive -------------------------------------------------------- */

@media (min-width: 768px) {
  :root {
    --header-h: 62px;
  }

  .footer__top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--v-3) var(--space-lg);
  }
}

/* 頁腰踩回頁面自己的十二欄：品牌 2–5 欄，三組連結各自對齊欄線。
   原本是 1.6fr 1fr 1fr 1fr 的自由比例，與全頁任何一條緣都對不上；
   且 768–1024 之間卡在 2×2，品牌旁邊留下一大片空白。 */
@media (min-width: 900px) {
  .footer__top {
    grid-template-columns: var(--rail) repeat(12, minmax(0, 1fr));
    column-gap: var(--gut);
    row-gap: 0;
  }

  .footer__brand {
    grid-column: 2 / span 4;
  }

  .footer__col:nth-child(2) {
    grid-column: 7 / span 2;
  }

  .footer__col:nth-child(3) {
    grid-column: 9 / span 2;
  }

  .footer__col:nth-child(4) {
    grid-column: 11 / span 3;
  }
}

@media (min-width: 1024px) {
  .nav {
    display: block;
  }

  .nav-toggle,
  .sheet {
    display: none;
  }
}

/* Keep the navigation and footer brand typographic, like the page headings. */
.header__brand .mark, .footer__brand .mark { display: none; }
