/* =========================================================
   家庭修復祥和聯盟 — design tokens & base
   Tokens from Gemini review, with QA fixes applied.
   ========================================================= */

:root {
  --bg-primary: #FBF8F3;
  --bg-secondary: #F3ECE1;
  --bg-elevated: #FFFFFF;
  --text-primary: #362B24;
  --text-secondary: #695A50;
  --accent-primary: #9E534D; /* slightly deeper than draft #B86B65 for AA on white */
  --accent-hover: #83443F;
  --accent-soft: #B86B65;
  --accent-calm: #4F675C; /* deeper sage for white text AA */
  --accent-calm-bg: #EBF0EC;
  --safety-alert: #A63A3A;
  --border-subtle: #E2D7C7;
  --shadow-soft: 0 8px 24px rgba(54, 43, 36, 0.06);
  --ease-gentle: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 16px;
  --radius-sm: 10px;
  --content: 680px;
  --wrap: 1200px;
  --font-serif: "Noto Serif CJK TC", "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --font-sans: "Noto Sans CJK TC", "Noto Sans TC", "Source Han Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --header-h: 72px;
  --focus: 0 0 0 3px var(--bg-primary), 0 0 0 5px var(--accent-primary);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: auto; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.85;
  min-height: 100vh;
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin: 0 0 0.6em;
}
h1 { font-size: 2rem; letter-spacing: 0.04em; } /* 32px: slightly tighter than 36/.06em for CJK */
h2 { font-size: 1.5rem; line-height: 1.45; }
h3 { font-size: 1.2rem; font-family: var(--font-sans); letter-spacing: 0; }
p { margin: 0 0 1.2em; }
ul { margin: 0 0 1.2em; padding-left: 1.2em; }
:focus-visible { outline: 3px solid var(--accent-primary); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 12px; top: -40px; z-index: 10000;
  background: var(--bg-elevated); color: var(--text-primary);
  padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow-soft);
}
.skip-link:focus { top: 12px; }

.wrap { width: min(var(--wrap), calc(100% - 40px)); margin-inline: auto; }
.prose { width: min(var(--content), calc(100% - 40px)); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(251, 248, 243, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.site-header__inner {
  display: flex; align-items: center; gap: 16px;
  min-height: var(--header-h);
  width: min(var(--wrap), calc(100% - 32px));
  margin-inline: auto;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none; flex: 0 0 auto;
}
.logo img, .logo svg { width: 32px; height: 32px; }
.logo__name {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  line-height: 1.3;
}
.nav { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover, .nav a[aria-current="page"] { border-bottom-color: var(--accent-soft); }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: 8px; flex: 0 0 auto; }

.btn-motion, .btn-menu {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn-menu { display: none; padding: 8px 12px; }

.btn-exit {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--bg-elevated);
  color: var(--safety-alert);
  border: 1.5px solid var(--safety-alert);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn-exit:hover { background: #FDF2F2; color: var(--safety-alert); }

.nav-drawer { display: none; }

@media (max-width: 860px) {
  h1 { font-size: 1.625rem; }
  h2 { font-size: 1.35rem; }
  body { font-size: 16px; }
  .nav { display: none; }
  .header-tools .btn-motion { display: none; }
  .btn-menu { display: inline-flex; }
  .logo__name { font-size: 0.92rem; max-width: 9.5rem; }
  .site-header__inner { width: min(var(--wrap), calc(100% - 16px)); gap: 8px; }
  .nav-drawer.is-open {
    display: block;
    position: fixed; inset: var(--header-h) 0 0 0;
    background: var(--bg-primary);
    z-index: 35;
    padding: 24px 20px 80px;
    overflow: auto;
  }
  .nav-drawer a {
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 1.05rem;
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 20px;
  border-radius: 12px; border: 0;
  text-decoration: none; cursor: pointer;
  font-weight: 600; line-height: 1.3;
  transition: background-color 200ms var(--ease-gentle), color 200ms var(--ease-gentle);
}
.btn--primary { background: var(--accent-primary); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); color: #fff; }
.btn--calm { background: var(--accent-calm); color: #fff; }
.btn--calm:hover { background: #3E534A; color: #fff; }
.btn--ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.btn--ghost:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn--safety { background: var(--safety-alert); color: #fff; min-height: 64px; font-size: 1.05rem; }
.btn--safety:hover { background: #8E3030; color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn:disabled, button:disabled { opacity: 0.45; cursor: not-allowed; }


/* ---------- Image slots (no AI images this phase) ---------- */
.img-slot {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  padding: 20px;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 180px;
}
.img-slot strong { font-family: var(--font-serif); color: var(--text-primary); font-size: 0.95rem; display: block; margin-bottom: 6px; }
.img-slot--hero { min-height: 320px; }
.img-slot--cover { aspect-ratio: 16 / 10; min-height: 0; }
.img-slot--square { aspect-ratio: 1; min-height: 0; }

/* ---------- Cards & grids ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.cat-card, .article-card, .brand-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 250ms var(--ease-gentle), box-shadow 250ms var(--ease-gentle);
}
a.cat-card:hover, a.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
  color: inherit;
}
.cat-card h2, .article-card h2, .cat-card h3, .article-card h3 { margin-bottom: 0.35em; }
.cat-card p, .article-card p { margin: 0; color: var(--text-secondary); font-size: 0.95rem; }
.kicker {
  font-size: 13px; letter-spacing: 0.08em;
  color: var(--text-secondary); margin-bottom: 8px; text-transform: none;
}

/* ---------- Hero ---------- */
.hero { padding: 64px 0 48px; }
.hero__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  width: min(var(--wrap), calc(100% - 40px));
  margin-inline: auto;
}
.hero .lede { font-size: 1.1rem; color: var(--text-secondary); max-width: 36em; }
@media (max-width: 800px) {
  .hero { padding: 36px 0 28px; }
  .hero__grid { grid-template-columns: 1fr; gap: 24px; }
  .img-slot--hero { min-height: 220px; }
}

/* ---------- Banners ---------- */
.banner-quiz {
  background: var(--accent-calm-bg);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin: 16px auto;
  width: min(var(--wrap), calc(100% - 40px));
}
.banner-help {
  border: 1.5px solid var(--safety-alert);
  background: #FDF6F6;
  border-radius: var(--radius);
  padding: 24px 28px;
  margin: 0 auto 40px;
  width: min(var(--wrap), calc(100% - 40px));
}
.banner-help h2 { font-size: 1.2rem; }
.note {
  background: var(--accent-calm-bg);
  border-left: 4px solid var(--accent-calm);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  color: var(--text-primary);
  margin: 0 0 1.4em;
}
.note--warn {
  background: #FDF6F6;
  border-left-color: var(--safety-alert);
}
.pending {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0.4em 0 0;
}

/* ---------- Brand cards ---------- */
.brand-block {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 32px;
  margin: 48px auto 24px;
  width: min(var(--content), calc(100% - 40px));
}
.brand-block--soft { background: var(--bg-secondary); }
.brand-block--practical {
  background: var(--bg-elevated);
  border-left: 4px solid var(--accent-primary);
}
.brand-block__lead { color: var(--text-secondary); }
.brand-cards {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}
.brand-card { background: var(--bg-elevated); }
.brand-block--soft .brand-card { background: var(--bg-elevated); }
.brand-card h3 { margin-bottom: 0.2em; }
.brand-card .specialty { color: var(--text-secondary); margin-bottom: 0.8em; }
.brand-card dl { margin: 0; }
.brand-card dt { font-size: 12px; color: var(--text-secondary); }
.brand-card dd { margin: 0 0 8px; }
.brand-card a.btn { margin-right: 8px; margin-top: 4px; min-height: 44px; padding: 8px 14px; font-size: 0.95rem; }

/* ---------- Official help phones ---------- */
.help-dials { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.help-dials a { width: 100%; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 72px;
  border-top: 1px solid var(--border-subtle);
  padding: 40px 0 80px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.site-footer__inner { width: min(var(--wrap), calc(100% - 40px)); margin-inline: auto; }
.site-footer a { color: var(--text-primary); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0 20px; padding: 0; list-style: none; }
.companion-static { width: 120px; margin: 8px 0 16px; opacity: 0.85; }

/* ---------- Article ---------- */
.article-hero { padding: 36px 0 8px; }
.crumb { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.crumb a { color: var(--text-secondary); }
.byline { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.prose h2 { margin-top: 1.6em; }
.placeholder-body {
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px 24px;
  background: var(--bg-elevated);
}

/* ---------- Quiz ---------- */
.quiz-shell { width: min(640px, calc(100% - 40px)); margin: 32px auto 48px; }
.quiz-progress {
  height: 6px; background: var(--bg-secondary); border-radius: 99px; margin: 8px 0 24px; overflow: hidden;
}
.quiz-progress > span { display: block; height: 100%; background: var(--accent-soft); width: 0%; }
.quiz-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 32px 40px;
}
.quiz-option {
  display: block; width: 100%;
  text-align: left;
  min-height: 56px;
  margin: 0 0 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1.5px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}
.quiz-option[aria-pressed="true"], .quiz-option.is-selected {
  border-color: var(--accent-primary);
  background: #F8EDEA;
}
.quiz-nav { display: flex; gap: 12px; margin-top: 16px; }
.safety-priority {
  border: 2px solid var(--safety-alert);
  background: #FDF6F6;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

/* ---------- Sections ---------- */
section.block { padding: 28px 0; }
.block > .wrap > h2, .block > h2.wrap { margin-bottom: 20px; }
.muted { color: var(--text-secondary); }
hr.sep { border: 0; border-top: 1px solid var(--border-subtle); margin: 40px auto; width: min(var(--wrap), calc(100% - 40px)); }

/* ---------- Motion ---------- */
.cursor-companion {
  position: fixed; top: 0; left: 0;
  width: 36px; height: 36px;
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  will-change: transform;
  transition: opacity 200ms var(--ease-gentle);
}
.cursor-companion.is-on { opacity: 0.75; }
.cursor-companion.is-faded { opacity: 0; }
.click-layer { position: fixed; inset: 0; pointer-events: none; z-index: 9997; overflow: hidden; }
.click-petal {
  position: absolute; width: 10px; height: 10px;
  background: center / contain no-repeat url("../assets/petal.svg");
  animation: petal-fly 420ms ease-out forwards;
}
.click-word {
  position: absolute;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  animation: word-fly 500ms ease-out forwards;
  box-shadow: var(--shadow-soft);
}
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(184, 107, 101, 0.12);
  transform: scale(0.8);
  animation: ripple 380ms ease-out forwards;
  pointer-events: none;
}
@keyframes petal-fly {
  from { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  to { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -18px)) rotate(40deg); }
}
@keyframes word-fly {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -16px); }
}
@keyframes ripple {
  to { transform: scale(1.4); opacity: 0; }
}

/* Reveal: visible by default. JS adds .will-reveal only to below-fold elements. */
.will-reveal { opacity: 0; transform: translateY(12px); }
.will-reveal.is-in { opacity: 1; transform: none; transition: opacity 450ms var(--ease-gentle), transform 450ms var(--ease-gentle); }

@media (hover: hover) and (pointer: fine) {
  body.has-cursor { cursor: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .will-reveal { opacity: 1; transform: none; }
  .cursor-companion, .click-layer { display: none !important; }
}
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
html.reduce-motion .will-reveal { opacity: 1; transform: none; }
html.reduce-motion .cursor-companion,
html.reduce-motion .click-layer { display: none !important; }

/* Safety pages: still no companion (JS also disables) */
body.is-safety .cursor-companion { display: none !important; }

/* Filter pills */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 24px; }
.pills a, .pills span {
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--bg-elevated);
}
.pills [aria-current="true"] { background: var(--bg-secondary); border-color: var(--accent-soft); }

@media (max-width: 800px) {
  .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .pills::-webkit-scrollbar { display: none; }
  .brand-block, .quiz-card { padding: 24px; }
}

/* GPT/BOBO a11y and layout follow-ups (staging) */
html { scroll-padding-top: 5rem; }
#main:focus { outline: none; }
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
button:focus-visible, a:focus-visible, [role="radio"]:focus-visible, [data-opt]:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 3px;
}
.quiz-option:focus-visible {
  box-shadow: 0 0 0 3px var(--bg-primary), 0 0 0 5px var(--accent-primary);
}
.img-slot--hero { aspect-ratio: 6 / 5; }
.img-slot img { display: block; width: 100%; height: 100%; object-fit: cover; }
html.reduce-motion { scroll-behavior: auto; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
.btn-motion:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.article-hero > .img-slot--cover {
  max-height: 280px;
  width: 100%;
}

/* Illustration slots and charts */
@import url("visuals.css");
