/* ============================================================
   base.css — 所有模板共用，永不修改
   Tenshi Design Studio 積木系統
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { font-size: 16px; scroll-behavior: smooth; }
body  { -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img, video { max-width: 100%; height: auto; display: block; }
a    { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
/* 後台文字編輯器產生的連結與條列（shared/rich_text.php 還原時加上 class） */
.rich-a { text-decoration: underline; text-underline-offset: 3px; }
.rich-ul, .rich-ol { display: block; margin: .4em 0; padding-left: 1.4em; text-align: left; }
.rich-li { display: list-item; list-style: disc; }
.rich-ol > .rich-li { list-style: decimal; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── 間距系統 ── */
:root {
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  48px;
  --space-2xl: 80px;
  --space-3xl: 120px;
  /* 內容積木的上下留白：所有內容積木共用這一個值，跟著風格預設（--space-2xl）變；手機見下方 */
  --section-y: var(--space-2xl);

  /* 字體大小系統 */
  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */
  --text-3xl:  1.875rem;  /* 30px */
  --text-4xl:  2.25rem;   /* 36px */
  --text-5xl:  3rem;      /* 48px */
  --text-6xl:  3.75rem;   /* 60px */

  /* 動畫緩動 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-base: 260ms;
  --dur-slow: 420ms;

  /* 版面 */
  --container-max: 1200px;
  --navbar-height: 64px;

  /* 商品圖片比例 token — 可在 theme-vars.css 或積木後台覆蓋
     1 = 1:1 正方形  |  0.8 = 4:5 直式  |  1.333 = 4:3 橫式 */
  --product-img-ratio: 1;

  /* 積木大量引用、但先前從未定義的顏色變數 → 跟隨主題 */
  --c-body:  var(--c-text);
  --c-muted: var(--c-text-muted);
}

/* ── 版面容器 ── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

@media (max-width: 767px) {
  .container { padding: 0 var(--space-md); }
}

/* ── Section 共用間距（內容積木統一用 --section-y） ── */
.section      { padding: var(--section-y) 0; }
.section-sm   { padding: var(--space-xl)  0; }
.section-lg   { padding: var(--space-3xl) 0; }

@media (max-width: 767px) {
  :root { --section-y: min(var(--space-2xl), 64px); }   /* 手機一律收斂，最多 64px */
}

/* ── 通用格線 ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }

@media (max-width: 767px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── 通用工具 ── */
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ============================================================
   v6.1 視覺升級：陰影、緩動、字階、hover lift（純加法）
   ============================================================ */
:root {
  /* 陰影系統（依層級遞增，柔和半透明） */
  --shadow-xs:  0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm:  0 2px 6px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md:  0 4px 14px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg:  0 12px 32px rgba(15, 23, 42, .12), 0 4px 8px rgba(15, 23, 42, .05);
  --shadow-xl:  0 24px 56px rgba(15, 23, 42, .16), 0 8px 16px rgba(15, 23, 42, .06);
  --shadow-glow: 0 0 0 4px rgba(200, 168, 75, .18);

  /* 進階緩動（更精細手感） */
  --ease-out-soft: cubic-bezier(.22, 1, .36, 1);
  --ease-spring:   cubic-bezier(.34, 1.56, .64, 1);
  --dur-quick:     120ms;

  /* 字階補強（與 --text-* 對齊，給標題用） */
  --display-xl: clamp(2.4rem, 5vw, 3.75rem);
  --display-lg: clamp(2rem,   4vw, 3rem);
  --display-md: clamp(1.6rem, 3vw, 2.25rem);
  --display-sm: clamp(1.25rem, 2vw, 1.5rem);

  /* line-height 系統 */
  --leading-tight:  1.2;
  --leading-snug:   1.4;
  --leading-normal: 1.65;
  --leading-relaxed:1.8;
}

/* fade-up 升級緩動（不改觸發機制，僅替換 transition） */
.fade-up { transition: opacity 600ms var(--ease-out-soft), transform 600ms var(--ease-out-soft); }

/* 通用 hover lift（任何卡片可加 .lift-hover） */
.lift-hover { transition: transform var(--dur-base) var(--ease-out-soft), box-shadow var(--dur-base) var(--ease-out-soft); will-change: transform; }
.lift-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

/* 通用按鈕焦點環（無障礙） */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
  border-radius: var(--radius-btn, 4px);
}

/* 通用圖片 hover 微縮放（給 .img-zoom 用） */
.img-zoom { overflow: hidden; }
.img-zoom > img { transition: transform 700ms var(--ease-out-soft); will-change: transform; }
.img-zoom:hover > img { transform: scale(1.06); }

/* 標題輔助 class */
.h-display-xl { font-size: var(--display-xl); line-height: var(--leading-tight); font-weight: 800; letter-spacing: -.01em; }
.h-display-lg { font-size: var(--display-lg); line-height: var(--leading-tight); font-weight: 800; letter-spacing: -.005em; }
.h-display-md { font-size: var(--display-md); line-height: var(--leading-snug); font-weight: 700; }

/* 尊重使用者「降低動效」設定 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ============================================================
   v6.1 通用 density modifier
   積木 render.php 可在 <section> 加 class="... density-compact|density-spacious"
   讓使用者透過 data.density 控制留白疏密
   ============================================================ */
.density-compact   { padding-top: calc(var(--section-y) * .6) !important;  padding-bottom: calc(var(--section-y) * .6) !important; }
.density-normal    { /* 預設使用 --section-y */ }
.density-spacious  { padding-top: calc(var(--section-y) * 1.4) !important; padding-bottom: calc(var(--section-y) * 1.4) !important; }

/* ============================================================
  v6.2 共通 appearance modifier
  後台寫入 data.appearance / data.advanced，由 render helper 輸出安全 class 與 CSS 變數。
  ============================================================ */
.appearance-theme-light { background: var(--block-bg, var(--c-bg, #fff)) !important; color: var(--block-text, var(--c-body, #475569)); }
.appearance-theme-dark  { background: var(--block-bg, var(--c-heading, #1B2A4A)) !important; color: var(--block-text, #fff); }
.appearance-theme-accent{ background: var(--block-bg, var(--block-accent, var(--c-accent, #C8A84B))) !important; color: var(--block-text, #fff); }
.appearance-align-left  { text-align: left; }
.appearance-align-center{ text-align: center; }
.appearance-align-right { text-align: right; }
.appearance-radius-none { --radius-card: 0; --radius-img: 0; --radius-btn: 0; }
.appearance-radius-sm   { --radius-card: 4px; --radius-img: 4px; --radius-btn: 4px; }
.appearance-radius-md   { --radius-card: 10px; --radius-img: 10px; --radius-btn: 6px; }
.appearance-radius-lg   { --radius-card: 18px; --radius-img: 18px; --radius-btn: 999px; }
.appearance-shadow-none { --shadow-card: none; --shadow-lift: none; --shadow-lg: none; }
.appearance-shadow-soft { --shadow-card: 0 4px 18px rgba(15,23,42,.08); --shadow-lift: 0 12px 34px rgba(15,23,42,.14); }
.appearance-shadow-lift { --shadow-card: 0 10px 28px rgba(15,23,42,.12); --shadow-lift: 0 18px 48px rgba(15,23,42,.18); }
.appearance-animation-none .fade-up,
.appearance-animation-none.fade-up { opacity: 1 !important; transform: none !important; animation: none !important; transition: none !important; }
[style*="--block-space-top"] { padding-top: var(--block-space-top) !important; }
[style*="--block-space-bottom"] { padding-bottom: var(--block-space-bottom) !important; }
[style*="--block-accent"] { --c-accent: var(--block-accent); --accent: var(--block-accent); }
/* 後台「樣式／進階設定」的背景色、文字色：不必先選色彩主題也會生效（原本只有搭配淺色／深色／強調色主題才有作用） */
[style*="--block-bg"] { background: var(--block-bg) !important; }
[style*="--block-text"] {
  color: var(--block-text);
  --c-text: var(--block-text); --c-body: var(--block-text); --c-heading: var(--block-text);
  --c-muted: var(--block-text); --c-text-muted: var(--block-text);
}
[style*="--block-media-ratio"] img { aspect-ratio: var(--block-media-ratio); object-fit: cover; }


/* ============================================================
   v7 風格層（style preset）
   風格檔 shared/styles/<name>.css 在 :root 定義 --font-display、--sh-*、
   --heading-* 等變數；未指定風格時這些變數不存在，積木以
   var(--x, 原值) 退回原本外觀。
   積木標題區塊共用掛鉤 class：.sh（容器）.sh__tag .sh__title .sh__desc
   ============================================================ */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display, inherit); }
