/* =========================================================
   SapiensTales — shared design system
   One stylesheet for every page (main site + app pages).
   Per-app accent: <body data-theme="family-story">
   ========================================================= */

:root {
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --brand-soft: #eff6ff;
  --accent: #22d3ee;
  --hero-1: #0b1220;
  --hero-2: #111827;
  --hero-glow-1: rgba(34, 211, 238, .22);
  --hero-glow-2: rgba(37, 99, 235, .30);

  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #ffffff;
  --surface: #f8fafc;
  --card: #ffffff;
  --ok: #16a34a;
  --warn-bg: #fff7ed;
  --warn-line: #f97316;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --container: 1080px;
  --narrow: 780px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
          "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
}

body[data-theme="family-story"] {
  --brand: #e2763f;
  --brand-ink: #b4521f;
  --brand-soft: #fff4ea;
  --accent: #ffd166;
  --hero-1: #9a3f17;
  --hero-2: #c4592a;
  --hero-glow-1: rgba(255, 209, 102, .35);
  --hero-glow-2: rgba(245, 168, 98, .40);
  --surface: #fffaf4;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.7 var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-ink); text-underline-offset: 3px; }
a:hover { color: var(--brand); }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); }
h3 { font-size: 1.15rem; }
p, ul, ol { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; }
li { margin: .3em 0; }
strong { color: var(--ink); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: var(--narrow); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 64px; gap: 12px;
}
.logo {
  grid-column: 2; justify-self: center;
  font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em;
  color: var(--ink); text-decoration: none;
}
.logo:hover { color: var(--ink); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav--left { grid-column: 1; grid-row: 1; justify-self: start; }
.nav--right { grid-column: 3; justify-self: end; }
.nav a, .nav summary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  color: var(--text); font-weight: 500; font-size: .95rem; text-decoration: none;
  cursor: pointer; list-style: none;
}
.nav summary::-webkit-details-marker { display: none; }
.nav a:hover, .nav summary:hover, .nav a[aria-current="page"] { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] { font-weight: 600; }

.dropdown { position: relative; }
.dropdown summary::after {
  content: ""; width: 7px; height: 7px; margin-left: 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.dropdown[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.dropdown .menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 230px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 6px; display: grid;
}
.dropdown .menu a { border-radius: 10px; padding: 10px 12px; }

@media (max-width: 720px) {
  .site-header .bar { grid-template-columns: 1fr; padding-top: 10px; padding-bottom: 6px; gap: 2px; }
  .logo { grid-column: 1; grid-row: 1; }
  .nav--left, .nav--right { grid-column: 1; justify-self: center; }
  .nav--left { grid-row: 2; }
  .nav--right { grid-row: 3; }
  .site-header { position: relative; }
  .dropdown .menu { left: 50%; transform: translateX(-50%); }
}

/* Language switch (app pages) */
.subbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.subbar .container { display: flex; justify-content: flex-end; padding-top: 8px; padding-bottom: 8px; }
.lang-switch { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang-btn {
  font: inherit; font-size: .9rem; border: 0; background: none; color: var(--muted);
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
}
.lang-btn.active { background: var(--brand); color: #fff; font-weight: 600; }
body.lang-zh-TW [lang="en"], body.lang-en [lang="zh-TW"] { display: none !important; }

/* ---------- Buttons ---------- */
.btn, .download-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px;
  background: var(--brand); color: #fff; font-weight: 600; text-decoration: none;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 30%, transparent);
  transition: transform .15s, filter .15s;
}
.btn:hover, .download-btn:hover { color: #fff; filter: brightness(1.06); transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--brand-ink); border: 1px solid var(--line); box-shadow: none; }
.btn--ghost:hover { color: var(--ink); background: var(--surface); }
.link-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ---------- Hero (one layout for every page) ----------
   Same height, padding, left edge, type sizes everywhere.
   Only the colour changes per app (data-theme). */
.hero {
  position: relative; overflow: hidden; color: #cbd5e1;
  background:
    radial-gradient(1000px 420px at 8% -10%, var(--hero-glow-1), transparent 60%),
    radial-gradient(800px 400px at 92% 0%, var(--hero-glow-2), transparent 60%),
    linear-gradient(180deg, var(--hero-1), var(--hero-2));
}
.hero-inner {
  min-height: 360px;
  padding-top: 56px; padding-bottom: 56px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  text-align: left;
}
.hero h1 { color: #fff; font-size: clamp(2rem, 4.5vw, 3rem); margin: 0 0 .35em; }
.hero p { color: #e2e8f0; font-size: 1.1rem; font-weight: 500; line-height: 1.6; max-width: 44em; margin: 0 0 .4em; }
.hero p.description { font-weight: 400; margin-top: .4em; }
.hero strong { color: #fff; }
.eyebrow {
  display: inline-block; margin-bottom: 12px;
  font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; font-weight: 600;
  color: var(--brand);
}
.hero .eyebrow { color: var(--accent); }
.hero .cta-row { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 12px; }
.app-icon { width: 64px; height: 64px; border-radius: 16px; margin: 0 0 18px; box-shadow: 0 10px 24px rgba(0,0,0,.25); }
.app-icon-link { display: inline-block; }
/* app pages: icon sits beside the title so app headers stay the same height as the rest */
.hero-title { display: flex; align-items: center; gap: 18px; margin-bottom: .35em; }
.hero-title .app-icon { margin: 0; flex: 0 0 auto; }
.hero-title h1 { margin: 0; }
.hero .download-btn { margin-top: 22px; background: #fff; color: var(--brand-ink); }
.hero .download-btn:hover { color: var(--brand-ink); }
@media (max-width: 640px) { .hero-inner { min-height: 280px; padding-top: 44px; padding-bottom: 44px; } }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section--alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { max-width: 720px; margin-bottom: 32px; }
.section-title, .section-subtitle { text-align: left; }
.section-title { font-size: clamp(1.5rem, 3vw, 2rem); }
.section-subtitle { color: var(--muted); max-width: 640px; margin: 0 0 32px; }

/* ---------- Grids & cards ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3, .feature-grid, .benefits-grid { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .feature-grid, .benefits-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .feature-grid, .benefits-grid { grid-template-columns: 1fr; } }

.card, .feature-card, .benefit-item, .faq-item, .step {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.card h3, .feature-title, .benefit-title, .step-title { font-size: 1.08rem; font-weight: 700; color: var(--ink); margin-bottom: .4em; }
.card p:last-child { margin-bottom: 0; }
.feature-desc, .benefit-desc, .step-desc { color: var(--text); }
.feature-icon, .benefit-icon {
  width: 48px; height: 48px; display: grid; place-items: center;
  font-size: 1.5rem; border-radius: 12px; background: var(--brand-soft); margin-bottom: 14px;
}
.badge {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  background: var(--brand); color: #fff;
}

/* Steps */
.steps, .step-list { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; margin: 0; list-style: none; }
@media (max-width: 800px) { .steps, .step-list { grid-template-columns: 1fr; } }
.step-number, .step-list .badge {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 700; margin-bottom: 14px;
}
.step-list li { margin: 0; }

/* Check list */
.check-list, .commitment-list { list-style: none; padding: 0; margin: 0 0 1em; }
.check-list li, .commitment-list li { position: relative; padding-left: 32px; margin: .55em 0; }
.check-list li::before, .commitment-list li::before {
  content: "✓"; position: absolute; left: 0; top: .1em;
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; color: #fff; background: var(--ok);
}
.restriction-list { list-style: none; padding: 0; }
.restriction-list li { position: relative; padding-left: 32px; margin: .55em 0; }
.restriction-list li::before {
  content: "✕"; position: absolute; left: 0; top: .1em;
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  font-size: .75rem; font-weight: 700; color: #fff; background: #dc2626;
}

/* Highlight cards (mission / vision) */
.kv-card {
  border-radius: var(--radius); padding: 28px;
  background: linear-gradient(135deg, var(--brand-soft), #fff);
  border: 1px solid var(--line);
}

/* Fact list (About) */
.facts { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 24px; }
@media (max-width: 640px) { .facts { grid-template-columns: 1fr; } }
.facts > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 18px; }
.facts strong { display: block; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Documents (legal / support) ---------- */
.doc { padding: 56px 0 80px; }
.doc .container > * { max-width: var(--narrow); }
.doc h2 { margin-top: 2.2em; padding-top: 1.2em; border-top: 1px solid var(--line); }
.doc h2:first-child, .doc .content-block:first-child h2, .doc section:first-child > h2 { margin-top: 0; padding-top: 0; border-top: 0; }
.doc h3 { margin-top: 1.6em; }
.doc section { scroll-margin-top: 90px; }
.doc table, .privacy-table { width: 100%; border-collapse: collapse; margin: 1em 0 1.5em; font-size: .95rem; }
.doc th, .doc td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
.doc th { background: var(--surface); color: var(--ink); }
.doc .table-wrap { overflow-x: auto; }
.content-block + .content-block h2 { margin-top: 2.2em; }

.toc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 22px; margin: 0 0 32px;
}
.toc h2 { font-size: .8rem !important; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px !important; padding: 0 !important; border: 0 !important; }
.toc ul { display: flex; flex-wrap: wrap; gap: 6px 10px; list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0; }
.toc a { display: inline-block; padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; font-weight: 500; }

/* Callouts */
.callout, .tip-box, .info-box, .highlight-box, .meta-info, .contact-box, .warning-box {
  border-radius: var(--radius-sm); padding: 18px 20px; margin: 1.2em 0;
  background: var(--brand-soft); border-left: 4px solid var(--brand);
}
.callout > :last-child, .tip-box > :last-child, .info-box > :last-child, .highlight-box > :last-child,
.contact-box > :last-child, .warning-box > :last-child { margin-bottom: 0; }
.warning-box, .callout--warn { background: var(--warn-bg); border-left-color: var(--warn-line); }
.meta-info { background: var(--surface); border-left-color: var(--line); color: var(--muted); font-size: .95rem; }
.flow-diagram {
  white-space: pre; overflow-x: auto; font: .9rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 20px; margin: 1em 0;
}
.doc-footnote { color: var(--muted); font-size: .92rem; margin-top: 2.5em; padding-top: 1.2em; border-top: 1px solid var(--line); }
.footer-note { color: var(--muted); font-size: .92rem; }

/* FAQ */
.faq-item { margin: 0 0 16px; }
.faq-question { font-weight: 700; color: var(--ink); font-size: 1.05rem; margin-bottom: 10px; }
.faq-answer > :last-child { margin-bottom: 0; }

/* Screenshots */
.screenshot-grid {
  display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.screenshot-item { text-align: center; }
.screenshot-item img, .screenshot {
  width: 100%; max-width: 240px; margin: 0 auto; border-radius: 22px;
  border: 1px solid var(--line); box-shadow: var(--shadow); background: #fff;
}
.screenshot-caption { margin-top: 10px; color: var(--muted); font-size: .92rem; }
.screenshot-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(150px, 220px)); margin: 1em 0 1.5em; }
.faq-answer > .screenshot { max-width: 240px; margin: 1em 0 1.5em; }

/* CTA band */
.cta { text-align: left; }
.cta .container { padding-top: 64px; padding-bottom: 64px; }
.cta h2 { color: var(--ink); }

/* Contact */
.contact-info { display: grid; gap: 10px; }

/* ---------- Footer ---------- */
.site-footer { background: #0b1220; color: #94a3b8; font-size: .95rem; }
body[data-theme="family-story"] .site-footer { background: #2a1a10; color: #d6c3b4; }
.site-footer .cols {
  display: grid; gap: 28px; grid-template-columns: 1.4fr 1fr 1fr 1fr; padding-top: 48px; padding-bottom: 32px;
}
@media (max-width: 800px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .site-footer .cols { grid-template-columns: 1fr; } }
.site-footer h3 { color: #fff; font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 12px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 6px 0; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer .footer-brand { color: #fff; font-weight: 800; font-size: 1.15rem; margin-bottom: 8px; display: inline-block; }
.site-footer .bottom { border-top: 1px solid rgba(148, 163, 184, .18); padding-top: 18px; padding-bottom: 26px; font-size: .88rem; }
.site-footer .bottom p { margin: 0; }

/* Card grids inside narrow document pages: two columns read better */
.doc .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .doc .feature-grid { grid-template-columns: 1fr; } }

/* Intro paragraph that opens the first section */
.lead { font-size: 1.15rem; line-height: 1.75; color: var(--ink); max-width: 46em; margin: 0 0 40px; }

.btn--on-dark { color: #fff; border-color: rgba(255,255,255,.35); }
.btn--on-dark:hover { color: #fff; background: rgba(255,255,255,.08); }

/* Language switch sits inside the coloured header (Family Story pages) */
.hero-inner { position: relative; }
.hero .lang-switch {
  position: absolute; top: 18px; right: 20px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3);
}
.hero .lang-btn { color: #fff; }
.hero .lang-btn.active { background: #fff; color: var(--brand-ink); }
@media (max-width: 640px) { .hero-inner:has(.lang-switch) { padding-top: 64px; } .hero .lang-switch { top: 14px; right: 16px; } .hero .lang-btn { padding: 4px 12px; font-size: .85rem; } }
