/* ==========================================================================
   base.css — design tokens + reset + typography (shared across all pages)
   v3 · Kinfolk × Monocle warm editorial · Polish Phase P1
   ========================================================================== */

/* ---------- @font-face (self-hosted) -------------------------------------- */
@font-face {
  font-family: 'Fraunces';
  font-weight: 900;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/fraunces-900.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-weight: 300;
  font-style: italic;
  font-display: swap;
  src: url('../assets/fonts/fraunces-300italic.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/jetbrainsmono-variable.woff2') format('woff2-variations'),
       url('../assets/fonts/jetbrainsmono-variable.woff2') format('woff2');
}
/* Noto Sans TC(Google Noto CJK · SIL OFL 1.1)· 繁中正文主力 · subset 2,008 字 · ~350 KB/權重 */
@font-face {
  font-family: 'Noto Sans TC';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/notosanstc-400-subset.woff2') format('woff2');
  unicode-range: U+3000-303F, U+4E00-9FFF, U+3400-4DBF, U+FF00-FFEF, U+2000-206F;
}
@font-face {
  font-family: 'Noto Sans TC';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/notosanstc-700-subset.woff2') format('woff2');
  unicode-range: U+3000-303F, U+4E00-9FFF, U+3400-4DBF, U+FF00-FFEF, U+2000-206F;
}
/* Huninn 金萱(justfont · SIL OFL 1.1)· 保留做 display emphasis(h1/h2 手寫感)· subset 369 KB */
@font-face {
  font-family: 'Huninn';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('../assets/fonts/huninn-subset.woff2') format('woff2');
  unicode-range: U+3000-303F, U+4E00-9FFF, U+3400-4DBF, U+FF00-FFEF, U+2000-206F;
}

/* ---------- design tokens ------------------------------------------------- */
:root {
  /* palette · locked */
  --ink: #0f1a14;
  --paper: #f4ede1;
  --accent: #d97e2b;          /* decorative only — fails AA 4.5:1 on paper */
  --accent-text: #8f4b17;     /* AA-safe accent for body text on --paper */
  --moss: #3e5c44;
  --warn: #c13a3a;

  /* paper layers */
  --surface: #faf6ec;
  --paper-3: #fcf9f0;

  /* rule system */
  --rule: rgba(15, 26, 20, 0.12);
  --hairline: rgba(15, 26, 20, 0.08);

  /* measure tokens · 2026-04-19 iter-12 · codify lede/prose widths that were
     scattered across 4 selectors at inconsistent values (56ch/58ch/60ch/62ch). */
  --measure-lede: 58ch;
  --measure-prose: 62ch;
  --measure-card: min(68ch, 920px);

  /* card horizontal padding · avoids the clamp-regression bug where vw upper
     term exceeds rem ceiling, keeping desktop at mobile width. */
  --card-px-desktop: clamp(1.5rem, 3vw, 2.75rem);

  /* type stacks — 2026-04-18 revised
     · Latin display 走 Fraunces 900 / 300 italic
     · CJK display(h1/h2)走 Huninn 金萱(溫潤手寫感)
     · CJK body(正文 / UI)走 Noto Sans TC(現代 sans-serif · 清晰易讀)
     · 系統字型作 fallback · JetBrains Mono 做 tabular 數字 */
  --font-display: 'Fraunces', 'Huninn', 'Noto Sans TC', 'Songti TC', 'Source Han Serif TC', Georgia, serif;
  --font-body: 'Noto Sans TC', 'PingFang TC', 'Source Han Sans TC', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --font-sans: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-editorial: cubic-bezier(0.19, 1, 0.22, 1);
  --dur-fast: 180ms;
  --dur-mid: 420ms;
  --dur-slow: 820ms;

  /* breakpoints */
  --bp-sm: 640px;
  --bp-md: 900px;
  --bp-lg: 1280px;

  /* spacing scale */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;
  --sp-9: 6rem;
  --sp-10: 9rem;
}

/* ---------- reset --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body, h1, h2, h3, h4, h5, h6, p, blockquote, figure, ul, ol, dl, dd, pre {
  margin: 0;
}

ul, ol { padding: 0; list-style: none; }

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- skip link (WCAG 2.4.1) --------------------------------------- */
.skip-to-main {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 999;
}
.skip-to-main:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: underline;
  border-radius: 2px;
}

/* ---------- base body ----------------------------------------------------- */
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  letter-spacing: 0.01em;
}

/* 中文段落呼吸感 */
:lang(zh), :lang(zh-Hant), html[lang^="zh"] body {
  letter-spacing: 0.02em;
}

/* ---------- typography ---------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-wrap: balance;
  /* Fraunces stylistic tweaks — considered caps + old-style figures */
  font-feature-settings: 'ss01' 1, 'ss02' 1, 'salt' 1;
}

h1 { font-size: clamp(2.5rem, 7vw, 5rem); }
h2 { font-size: clamp(1.75rem, 4.5vw, 3rem); line-height: 1.08; }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); line-height: 1.15; letter-spacing: -0.015em; }

/* anchor-scroll offset so sticky header doesn't eat section titles */
:is(h1, h2, h3)[id],
section[id],
[data-anchor] {
  scroll-margin-top: clamp(4.5rem, 9vh, 6.5rem);
}

h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.14em; }

p {
  font-size: 1rem;
  line-height: 1.75;
  text-wrap: pretty;
}

/* ---------- display-xl · 開篇大字 ---------------------------------------- */
.display-xl {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3.5rem, 14vw, 12rem);
  line-height: 0.86;
  letter-spacing: -0.045em;
  color: var(--ink);
}
.display-xl .ital,
.display-xl em {
  font-weight: 300;
  font-style: italic;
  letter-spacing: -0.02em;
}

/* ---------- eyebrow / kicker · unified small-caps tracking (0.22em) ------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.68;
  font-variant-numeric: tabular-nums;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--moss);
  font-variant-numeric: tabular-nums;
}

/* ornament · thin 1em rule used inline between small-cap labels */
.ornament {
  display: inline-block;
  width: 1.4em;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
  vertical-align: 0.35em;
  margin: 0 0.55em;
}

/* ---------- section number (large italic) -------------------------------- */
.section-no {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2.75rem, 6vw, 5.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  opacity: 0.22;
  display: inline-block;
}

/* ---------- pullquote ----------------------------------------------------- */
.pullquote {
  position: relative;
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.375rem, 3vw, 2.125rem);
  line-height: 1.38;
  letter-spacing: -0.012em;
  color: var(--ink);
  padding-left: clamp(1.25rem, 2.5vw, 1.75rem);
  border-left: 1px solid var(--accent);
  max-width: 34ch;
  margin: clamp(1.75rem, 3.5vw, 2.75rem) 0;
}
.pullquote::before {
  content: "\201C";  /* left double quotation mark */
  position: absolute;
  left: clamp(0.5rem, 1.2vw, 0.9rem);
  top: -0.35em;
  font-size: 2.6em;
  line-height: 1;
  font-weight: 300;
  font-style: italic;
  color: var(--accent);
  opacity: 0.3;
  pointer-events: none;
}
.pullquote cite {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-weight: 500;
  font-style: normal;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--moss);
}

/* ---------- numerals / data chips ---------------------------------------- */
.tnum, var {
  font-family: var(--font-mono);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* highlight a single fact in body flow */
.fact {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(transparent 65%, rgba(217, 126, 43, 0.22) 65%);
  padding: 0 0.15em;
  white-space: nowrap;
}

.footnote {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--ink);
  opacity: 0.72;
}

.latin { font-family: var(--font-display); }
.zht {
  font-family: var(--font-display);
  font-feature-settings: 'palt' 1;
}

em {
  font-style: italic;
  font-weight: 300;
  font-family: var(--font-display);
}

/* ---------- utilities ----------------------------------------------------- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

/* rule · hairline system */
hr, .rule {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: var(--sp-6) 0;
}
.hairline {
  border: 0;
  height: 1px;
  background: var(--hairline);
  margin: 0;
}
.divider-numbered {
  display: flex;
  align-items: baseline;
  gap: clamp(1rem, 2vw, 1.5rem);
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
}
.divider-numbered::before {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline);
  transform: translateY(-0.25em);
}

/* ---------- editorial link underline · ≤180ms hover feels alive ---------- */
.link-draw {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: background-size 180ms var(--ease-out);
  padding-bottom: 1px;
}
.link-draw:hover,
.link-draw:focus-visible {
  background-size: 100% 2px;
}
a.link-reverse {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0 1px;
  transition: background-size 280ms var(--ease-editorial);
  padding-bottom: 1px;
}
a.link-reverse:hover,
a.link-reverse:focus-visible {
  background-size: 100% 1px;
}

/* ---------- section-number ornament · magazine-spread opener ------------- */
.section-mark {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: clamp(0.5rem, 1vw, 0.85rem);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}
.section-mark::before {
  content: "";
  flex: 0 0 1.75rem;
  height: 1px;
  background: currentColor;
  transform: translateY(-0.25em);
  opacity: 0.7;
}

/* ---------- images -------------------------------------------------------- */
picture, .img-wrap {
  display: block;
  overflow: hidden;
  background: var(--surface);
}
picture img, .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-editorial);
}
a:hover > picture img,
a:hover > .img-wrap img,
.img-hover:hover img {
  transform: scale(1.03);
}

/* ---------- fonts-loaded reveal · subtle editorial entrance -------------- */
html:not(.fonts-loaded) .hero-title,
html:not(.fonts-loaded) .display-xl,
html:not(.fonts-loaded) .day-title,
html:not(.fonts-loaded) .page-header h1,
html:not(.fonts-loaded) h1,
html:not(.fonts-loaded) h2 {
  opacity: 0;
  transform: translateY(6px);
}
html.fonts-loaded .hero-title,
html.fonts-loaded .display-xl,
html.fonts-loaded .day-title,
html.fonts-loaded .page-header h1,
html.fonts-loaded h1,
html.fonts-loaded h2 {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 520ms var(--ease-editorial),
              transform 520ms var(--ease-editorial);
}

/* ---------- reduced motion ------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  picture img, .img-wrap img {
    transform: none !important;
  }
}

/* ---------- print -------------------------------------------------------- */
@media print {
  body { background: #fff; color: #000; }
  .eyebrow, .kicker, .section-no { opacity: 1; color: #444; }
}

/* ---------- perf utility: content-visibility for below-the-fold blocks --
   Opt-in per-section via class; preserves a reasonable size box so the
   scrollbar + anchor links stay honest while off-screen. Skips on
   reduce-motion / print for safety. */
.cv-auto {
  content-visibility: auto;
  contain-intrinsic-size: 1px 1200px;
}
@media print, (prefers-reduced-motion: reduce) {
  .cv-auto { content-visibility: visible; contain-intrinsic-size: auto; }
}

/* ===== 320px 超小螢幕 (iPhone SE 1st gen) ===== */
@media (max-width: 320px) {
  :root { --text-base: 15px; }
  h1 { font-size: clamp(30px, 9vw, 44px); letter-spacing: -0.02em; }
  .eyebrow { font-size: 11px; letter-spacing: 0.16em; }
  .main-menu { gap: 8px; }
  /* Hero title can otherwise clip at 320 because the 20vw clamp lower bound
     hits 64px against a ~288px readable width. Tighten kerning + min floor. */
  .hero-title { font-size: clamp(3rem, 18vw, 5rem); letter-spacing: -0.04em; }
  .display-xl { font-size: clamp(3rem, 15vw, 5rem); letter-spacing: -0.035em; }
  .pullquote { padding-left: 0.75rem; }
  .container { padding-inline: 0.85rem; }
}

/* ===== 768px tablet portrait — covers iPad mini / standard iPad ==========
   Avoids copy-over-image collision on day-hero & place-hero at this width. */
@media (min-width: 721px) and (max-width: 820px) {
  /* Give day hero a stronger bottom gradient so copy doesn't fight the image */
  .day-hero::after {
    background: linear-gradient(
      180deg,
      rgba(15, 26, 20, 0.15) 0%,
      rgba(15, 26, 20, 0.45) 50%,
      rgba(15, 26, 20, 0.78) 100%
    );
  }
  .day-title { font-size: clamp(3rem, 8.5vw, 5.5rem); }
  .day-lede { font-size: 1.0625rem; }
  /* place-hero copy needs a little more vertical breathing */
  .place-hero-copy { padding-block: clamp(2rem, 4vw, 3rem); }
}

/* ===== 1440px+ 超大桌面 · magazine breathing room ===== */
@media (min-width: 1440px) {
  main, .site-header { max-width: 1280px; margin-inline: auto; }
  .hero-title { font-size: clamp(64px, 10vw, 220px); }
  /* Generous vertical rhythm between sections on desktop — Kinfolk spreads */
  .list-main { padding-top: clamp(3rem, 5vw, 4.5rem); padding-bottom: clamp(4rem, 7vw, 6rem); }
  .flight-summary { padding-block: clamp(3.5rem, 5.5vw, 5rem); }
  .main-menu { margin-top: clamp(3.5rem, 5vw, 5rem); }
  .day-routestrip { margin-block: clamp(2rem, 3.5vw, 3rem); }
}
/* ===== 1920px+ — prevent content from floating in a sea of paper ===== */
@media (min-width: 1920px) {
  main, .site-header { max-width: 1360px; }
}

/* ===== Nav 繁中主標 + 英文小字副標 (zht-primary nav) ===== */
.site-header nav a small {
  font-family: var(--font-mono, var(--mono, monospace));
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-left: 0.35rem;
  font-weight: 400;
  vertical-align: 0.15em;
  display: inline-block;
}

@media (max-width: 640px) {
  /* 手機上 nav 空間緊,只留繁中主標 */
  .site-header nav a small { display: none; }
}

/* ===== 手機橫放 — short viewport safety ===== */
@media (orientation: landscape) and (max-height: 500px) {
  .hero { min-height: auto; padding-block: 2rem; }
  .day-hero { height: auto; min-height: 320px; padding-block: 1.5rem; }
  .place-hero { height: auto; min-height: 260px; max-height: 80vh; }
  .day-hero-copy { padding-block: 1.25rem; }
  .day-title { font-size: clamp(2.25rem, 7vw, 3.5rem); }
  .countdown-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  /* timeline hero-event can get cramped in landscape */
  .timeline-event.hero-event { padding: 1.4rem 1.1rem 1.4rem 1.25rem; }
}

/* ===== 414 / 375 range — tap-target + padding sanity for list cards ===== */
@media (min-width: 360px) and (max-width: 414px) {
  .restaurant-card { padding: 1.1rem 1.05rem 1.25rem; }
  .restaurant-card .rc-name { font-size: 1.2rem; }
  .restaurant-card dl.rc-meta { gap: 0.3rem 0.6rem; }
  .exchange-layer { padding: 1.1rem 1.05rem 1.2rem; }
  .community-list li > a { padding: 1rem 1.05rem 1.1rem; }
}

/* ===== 純觸控裝置 (no hover) ===== */
@media (hover: none) {
  .menu-card:hover, .meal-card:hover, .restaurant-card:hover { transform: none; }
  a:hover { text-decoration-thickness: auto; }
}

/* ===== 列印友善 ===== */
@media print {
  :root { --ink: #000; --paper: #fff; --accent: #333; }
  body { font-size: 11pt; line-height: 1.5; color: #000; background: #fff; }
  .site-header, nav, footer, .affiliate-cta, #map, .visited-check { display: none !important; }
  a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
  img, picture { max-width: 50%; page-break-inside: avoid; }
  h1, h2, h3 { page-break-after: avoid; }
  .day-timeline li { page-break-inside: avoid; }
}
