/* ==========================================================
   留白教室 White Space
   方向：乾淨利落、白底、方角、作品為主角（Behance 式格狀）
   ========================================================== */

:root {
  --banner: #ffffff;          /* 由後台「網站設定」控制 */
  --bg: #fff;
  --ink: #111;
  --ink-soft: #5f5f5f;        /* 對白底對比 > 6:1 */
  --line: #e4e4e4;
  --placeholder: #f1f1ef;
  --focus: #5b3bd6;
  --scrim: rgba(0, 0, 0, .55);

  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px; --s6: 72px;
  --wrap: 1200px;
  --menu-below: 56px;                                          /* 選單底線 → 卡片 */
  --ease: cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }

[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  -webkit-user-select: none; user-select: none;   /* 不讓文字被選取、複製 */
  -webkit-touch-callout: none;                    /* iPhone 長按不跳出「拷貝／儲存圖片」選單 */
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; -webkit-user-drag: none; }
button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: absolute; left: var(--s2); top: -60px;
  background: var(--ink); color: #fff; padding: 8px 14px;
  z-index: 100; text-decoration: none; transition: top .2s;
}
.skip-link:focus { top: var(--s2); }

/* ==========================================================
   Banner：整條純色、窄版
   ========================================================== */
.banner {
  position: relative;
  background: var(--banner);
  color: var(--ink);
}
/* Banner 版面（比例取自設計稿，1920 寬的畫面）
   logo 字高約 225px；上緣、logo→選單 各約 100px；選單文字下 7px 接底線；線→卡片約 56px（--menu-below）
   Logo 圖檔本身上下各有 4.9% 的留白（40 / 816），算空白時要扣掉，視覺距離才會準 */
.banner {
  --logo-h: 248px;
  --ws: .049;                                                  /* Logo 圖檔留白 ÷ 圖高 */
  --top: 100px;                                                /* 頁面頂端 → Logo 的字 */
  --mid: 100px;                                                /* Logo 的字 → 選單 */
  --logo-pad: calc(var(--logo-h) * var(--ws));
}
.banner__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: calc(var(--top) - var(--logo-pad)) var(--s3) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.banner__logo { margin: 0; height: var(--logo-h); }
.banner__logo a { display: block; height: 100%; border-radius: 0; }      /* Logo 點了回首頁 */
.banner__logo img {
  height: 100%; width: auto;
  animation: fade .8s var(--ease) both;
}

/* ---------- 選單：圖示（設計稿的線條圖，36px 高）+ 文字（Nunito 800），項目均分，下方一條線 ----------
   圖示上緣比圖形高 4px、下緣低 4px，所以 margin / padding 要各扣掉對應的量 */
.menu {
  align-self: stretch;
  margin-top: calc(var(--mid) - var(--logo-pad) - 4px);
  padding: 0 37px 3px 52px;                                     /* 設計稿：左留約 55px、右留約 40px（扣掉圖本身的 3px 內距），項目在中間均分 */
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  border-bottom: 1px solid currentColor;
  font-family: "Nunito", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 800;
  font-size: 15.5px;                                            /* 字高對設計稿：大寫字高約 11px */
  letter-spacing: .054em;                                       /* ≈ 0.84px */
  -webkit-text-stroke: .3px currentColor;                         /* 設計稿的字比 Nunito 800 再稍微粗一點 */
  line-height: 1;
  animation: fade .8s .1s var(--ease) both;
}
.menu:empty { padding-bottom: 0; }
.menu__item {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.menu__img { display: block; height: 36px; width: auto; flex: none; }
.menu__text { position: relative; top: 3px; }                  /* 設計稿的文字比圖示中心低約 3px */
a.menu__item { transition: opacity .15s; }
@media (hover: hover) { a.menu__item:hover { opacity: .55; } }
a.menu__item:focus-visible { outline-offset: 4px; }
.menu__item[aria-current="page"] .menu__text {                  /* 目前所在的分類 */
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}
@media (pointer: coarse) { .menu__item { min-height: 44px; } }   /* 觸控裝置：確保好點 */

.banner--dark { color: #fff; }
.banner--dark .banner__logo img, .banner--dark .menu__img { filter: invert(1); }

/* 平板：選單項目比較擠，縮小一點 */
@media (max-width: 1000px) {
  .menu { gap: 4px 12px; padding-inline: 12px; font-size: 14px; }
  .menu__item { gap: 8px; }
  .menu__img { height: 30px; }
  .menu__text { top: 2px; }
}
/* 手機：照手機設計稿的比例（以螢幕寬度 vw 換算），Logo 小一點、上下留白多一點，選單換行置中 */
@media (max-width: 640px) {
  :root { --menu-below: 7vw; }                                  /* 底線 → 卡片 */
  .banner {
    --logo-h: 40.8vw;                                           /* Logo 字高約 37vw */
    --top: 19vw;                                                /* 頁面頂端 → Logo 的字 */
    --mid: 13.2vw;                                              /* Logo 的字 → 選單 */
    --img-pad: 2.6px;                                           /* 圖示圖檔上下的空白（23.7px 高的 4/36） */
  }
  .menu {
    display: grid;                                              /* 手機稿是兩欄：左欄靠右、右欄靠左，最後一個（單數時）置中 */
    grid-template-columns: auto auto;
    justify-content: center;
    gap: calc(10.4vw - 23.7px) 6vw;                             /* 行距約 10.4vw（圖示上緣到上緣）、欄距 6vw */
    margin-top: calc(var(--mid) - var(--logo-pad) - var(--img-pad));
    padding: 0 0 calc(6.2vw - var(--img-pad));                  /* 最後一行 → 底線 約 6.2vw */
    font-size: 10.5px;                                          /* 手機稿的字比較小，字距比較寬 */
    letter-spacing: .075em;
  }
  .menu__item { gap: 8px; min-height: 0; padding: 8px 0; margin: -8px 0; }   /* 觸控範圍加大但不影響排版 */
  .menu__item:nth-child(odd) { justify-self: end; }
  .menu__item:nth-child(even) { justify-self: start; }
  .menu__item:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; }
  .menu__img { height: 23.7px; }                                /* 圖示本體約 18px 高 */
  .menu__text { top: 1px; }
}

/* ==========================================================
   主內容
   ========================================================== */
main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: var(--menu-below, 56px) var(--s3) var(--s6);
}
@media (max-width: 640px) { main { padding: var(--menu-below) var(--s3) var(--s5); } }   /* 手機：卡片兩側跟底線對齊（24px） */

/* ==========================================================
   卡片格狀
   ========================================================== */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s4) var(--s3);
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); gap: var(--s3) var(--s2); } }
@media (max-width: 640px) {                                   /* 手機：一排一張，圖片照原圖比例完整顯示（不裁切、不放大） */
  .grid { grid-template-columns: 1fr; gap: var(--s4); }
  .grid .card__media { aspect-ratio: auto; }
  .grid .card__media img { height: auto; transform: none !important; }
}

.grid > li { animation: rise .45s var(--ease) both; }

.card {
  display: block; width: 100%;
  padding: 0; border: 0; background: none;
  text-align: left;
}

.card__media {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--placeholder);
}
.card__media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(var(--z, 1));
  transition: transform .5s var(--ease);
}
.card__media::after {                       /* 滑過時的細邊框 */
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 0 var(--ink);
  transition: box-shadow .2s;
  pointer-events: none;
}

.card__title {
  display: block;
  margin-top: 12px;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.45;
}
.card__summary {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}

@media (hover: hover) {
  .card:hover .card__media img { transform: scale(calc(var(--z, 1) * 1.04)); }
  .card:hover .card__title { text-decoration: underline; text-underline-offset: 4px; }
}
.card:focus-visible { outline-offset: 6px; }

.grid__empty {
  grid-column: 1 / -1;
  padding: var(--s6) 0;
  text-align: center;
  color: var(--ink-soft);
  letter-spacing: .2em;
}

/* ==========================================================
   Footer / 回到頂端
   ========================================================== */
.footer {
  text-align: center;
  padding: var(--s3) var(--s2) var(--s4);
  color: var(--ink-soft);
  font-size: 14px;
  border-top: 1px solid var(--line);
}
.footer p { margin: 0; }

.to-top {
  position: fixed; right: var(--s2); bottom: var(--s2); z-index: 20;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 2px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease), background .15s, color .15s;
}
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--ink); color: #fff; }

/* ==========================================================
   文章視窗：整頁白底（比例取自設計稿，1920 寬）
   上方固定列：左 Logo（字高約 100）、右兩顆圓鈕（下一篇／關閉），下方細線（內容寬 1152）
   大圖 1065 寬完整顯示；結尾左邊小青蛙、右邊一排中文分類連結；最後細線＋版權
   ========================================================== */
.modal {
  width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #fff;
  color: var(--ink);
  overflow: hidden;
}
.modal[open] { display: block; animation: fade .25s ease; }
.modal::backdrop { background: #fff; }
.modal__scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.modal__scroll:focus { outline: none; }

.modal__head {
  position: sticky; top: 0; z-index: 2;
  max-width: 1152px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 60px 66px 15px 50px;
  border-bottom: 1px solid var(--ink);
  background: #fff;
}
.modal__logo { display: block; flex: none; }
.modal__logo img { display: block; height: 111px; width: auto; }
.modal__actions { display: flex; gap: 8px; margin-bottom: 4px; }

.modal__hero { margin: 33px auto 0; width: min(1065px, calc(100% - 48px)); }
.modal__slides { position: relative; background: var(--placeholder); }
.modal__slides img { display: block; width: 100%; height: auto; opacity: 0; transition: opacity var(--fade, .9s) ease; }   /* 原圖比例，不裁切；疊在一起淡入淡出 */
.modal__slides img + img { position: absolute; inset: 0; height: 100%; object-fit: contain; background: #fff; }   /* 框的比例照第 1 張，其他張完整放進框裡 */
.modal__slides img.is-on { opacity: 1; }
.modal__dots { display: flex; justify-content: center; gap: 4px; padding-top: 12px; }
.modal__dots button { width: 26px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.modal__dots button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #d4d4d4; transition: background .3s; }
.modal__dots button[aria-current="true"]::before { background: #555; }
.modal__dots button:focus-visible { outline: 2px solid #8a5cb8; outline-offset: -4px; border-radius: 50%; }
@media (prefers-reduced-motion: reduce) { .modal__slides img { transition: none; } }

.modal__body { max-width: 1000px; margin: 0 auto; padding: 60px 24px 0; }
.modal__tag { margin: 0 0 6px; font-size: 13px; letter-spacing: .15em; color: var(--ink-soft); }
.modal__title { margin: 0 0 42px; font-weight: 700; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.35; letter-spacing: .1em; text-wrap: balance; }
.modal__text { font-size: 17px; line-height: 2.1; letter-spacing: .12em; }
.modal__text p, .modal__sec-text p { white-space: pre-line; }   /* 保留單行換行 */
.modal__text p { margin: 0 0 1.4em; }
.modal__text p:last-child { margin-bottom: 0; }

/* 內容區塊：圖 400 寬＋文字，左右交錯（設計稿：圖 482–882、文字 950–1435） */
.modal__sections:not(:empty) { margin-top: 60px; display: grid; gap: 60px; }
.modal__sec--img { display: grid; grid-template-columns: 400px 1fr; gap: 68px; align-items: center; }
.modal__sec--flip { grid-template-columns: 1fr 400px; }
.modal__sec--flip figure { order: 2; }
.modal__sec figure { margin: 0; background: var(--placeholder); }
.modal__sec figure img { display: block; width: 100%; height: auto; }
.modal__sec-text { font-size: 17px; line-height: 2.1; letter-spacing: .12em; }
.modal__sec-text p { margin: 0 0 1.4em; }
.modal__sec-text p:last-child { margin-bottom: 0; }
@media (max-width: 900px) {                                       /* 平板、手機：圖在上（置中）、文字在下 */
  .modal__sec--img, .modal__sec--flip { grid-template-columns: 1fr; gap: 28px; }
  .modal__sec--flip figure { order: 0; }
  .modal__sec figure { width: min(64%, 400px); justify-self: center; }
}
@media (max-width: 640px) {
  .modal__sections:not(:empty) { margin-top: 36px; gap: 40px; }
  .modal__sec figure { width: 100%; }                               /* 手機：區塊圖片跟文字一樣寬 */
  .modal__sec-text { font-size: calc((100vw - 44px) / 22.4); line-height: 1.95; letter-spacing: .1em; }
}

/* 結尾：小青蛙＋分類連結 */
.modal__end { max-width: 1000px; margin: 0 auto; padding: 95px 24px 64px; display: flex; align-items: flex-end; gap: 32px; }
.modal__frog { flex: none; width: 119px; height: auto; margin-left: 2px; }
.modal__links { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-bottom: 8px; font-size: 18px; letter-spacing: .15em; }
.modal__links a, .modal__links span { position: relative; padding-left: 12px; color: inherit; text-decoration: none; white-space: nowrap; }
.modal__links a::before, .modal__links span::before { content: ""; position: absolute; left: 0; top: .15em; bottom: .15em; width: 1px; background: currentColor; }
@media (hover: hover) { .modal__links a:hover { opacity: .55; } }
.modal__br { display: none; }
@media (max-width: 760px) {             /* 平板、手機：跟電腦版同一個排法（青蛙＋一排連結），依螢幕寬度等比例縮小 */
  .modal__end { gap: min(32px, 4vw); justify-content: center; }
  .modal__frog { width: min(119px, 15.5vw); margin-left: 0; }
  .modal__links { flex-wrap: nowrap; font-size: min(18px, 2.8vw); gap: 0 min(28px, 2.4vw); margin-bottom: min(8px, 1.2vw); letter-spacing: .06em; }
  .modal__links a, .modal__links span { padding-left: min(12px, 1.6vw); }
}

.modal__footer { max-width: 1152px; margin: 0 auto; padding: 16px 0 28px; border-top: 1px solid var(--ink); text-align: center; font-size: 14px; color: var(--ink-soft); }

/* 電腦版：不滿版，照設計稿（1920 寬時內容 1152、左右各留 384）等比例縮放
   --pw = 內容寬；其他尺寸都用「設計稿數值 × pw / 1152」換算 */
@media (min-width: 1001px) {
  .modal { --pw: min(1152px, 60vw); }
  .modal__head { max-width: var(--pw); padding: calc(var(--pw) * 60 / 1152) calc(var(--pw) * 66 / 1152) 15px calc(var(--pw) * 50 / 1152); }
  .modal__logo img { height: calc(var(--pw) * 111 / 1152); }
  .modal__hero { width: calc(var(--pw) * 1065 / 1152); }
  .modal__body { max-width: calc(var(--pw) * 1000 / 1152); }
  .modal__sec--img { grid-template-columns: calc(var(--pw) * 400 / 1152) 1fr; gap: calc(var(--pw) * 68 / 1152); }
  .modal__sec--flip { grid-template-columns: 1fr calc(var(--pw) * 400 / 1152); }
  .modal__footer { max-width: var(--pw); }
  /* 結尾：青蛙 89 寬（距內文左緣 12）、連結字 16 */
  .modal__end { max-width: calc(var(--pw) * 1000 / 1152); gap: calc(var(--pw) * 22.5 / 1152); padding-bottom: calc(var(--pw) * 50 / 1152); }
  .modal__frog { width: calc(var(--pw) * 89 / 1152); margin-left: calc(var(--pw) * 12 / 1152); }
  .modal__links { font-size: max(13px, calc(var(--pw) * 16 / 1152)); line-height: 1.3; letter-spacing: .06em; gap: 6px calc(var(--pw) * 27 / 1152); margin-bottom: calc(var(--pw) * 16 / 1152); }
  .modal__links a, .modal__links span { padding-left: calc(var(--pw) * 11 / 1152); }
}

/* 圓鈕（圖形照設計稿畫的正圓） */
.circle-btn { width: 43px; height: 43px; display: block; padding: 0; border: 0; background: none; color: var(--ink); transition: opacity .15s, transform .15s var(--ease); }
.circle-btn svg { display: block; width: 100%; height: 100%; }
.circle-btn:focus { outline: none; }
.circle-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: 50%; }   /* 鍵盤操作時才顯示，圓形 */
@media (hover: hover) { .circle-btn:hover { opacity: .55; } }
.circle-btn:active { transform: scale(.94); }

/* 平板 */
@media (max-width: 1000px) {
  .modal__head { padding: 32px 28px 12px 24px; }
  .modal__logo img { height: 84px; }
}
/* 手機：上方列縮小、細線滿版；大圖滿版到邊 */
@media (max-width: 640px) {
  .modal__head { max-width: none; padding: 18px 20px 12px 16px; }
  .modal__logo img { height: 60px; }
  .modal__actions { gap: 6px; margin-bottom: 2px; }
  .circle-btn { width: 36px; height: 36px; }
  .modal__hero { width: 100%; margin-top: 22px; }
  .modal__body { padding: 32px 22px 0; }
  .modal__title { margin-bottom: 24px; letter-spacing: .08em; }
  .modal__text { font-size: calc((100vw - 44px) / 22.4); line-height: 1.95; letter-spacing: .1em; }   /* 一行約 20 個字（字寬 1.1em × 20 = 內文寬） */
  .modal__end { padding: 120px 22px 36px; }   /* 內文和青蛙之間多留一點白 */
  /* 手機：照設計稿（435 寬）量的比例，全部用螢幕寬度換算 —— 青蛙在左，連結分上下兩行、跟青蛙垂直置中 */
  .modal__end { padding-left: 8.1vw; padding-right: 4vw; gap: 5.38vw; align-items: flex-end; justify-content: flex-start; }
  .modal__frog { width: 14.8vw; margin: 0; }
  .modal__links { flex-wrap: wrap; font-size: 3.13vw; line-height: 1.5; gap: .64vw 4.94vw; margin: 0 0 1.85vw; letter-spacing: 0; }   /* 換行元素自己佔一行，上下各算一次間距 */
  .modal__links a, .modal__links span { padding-left: 2.07vw; }
  .modal__links a::before, .modal__links span::before { top: .3em; bottom: .3em; }   /* 直線跟字一樣高 */
  .modal__br { display: block; flex-basis: 100%; height: 0; }
  .modal__footer { padding: 14px 0 22px; font-size: 12px; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

body.modal-open { overflow: hidden; }

/* ==========================================================
   動畫
   ========================================================== */
@keyframes fade     { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise     { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
