/* ========== CSS VARIABLES ========== */
:root {
  --bg: #f8fafb;
  --surface: #ffffff;
  --surface-soft: #f2f5f8;
  --text: #0a0d14;
  --muted: #5c6a7d;
  --line: #e4ebf2;
  --line-strong: #cbd6e3;
  --blue: #0288f0;
  --blue-deep: #016fc4;
  --cyan: #4ad4df;
  --header-height: 68px;
  --container: 800px;
  --body-size: 18px;
  --body-line: 1.82;
  --body-gap: 26px;
  --heading-gap: 36px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --touch-min: 44px;
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  overflow-x: clip;
  overflow-y: auto;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: var(--body-size);
  line-height: var(--body-line);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow-y: auto;
}

::selection { background: rgba(2, 136, 240, 0.12); }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* tap-friendly */
a, button, [role="button"], .button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ========== SKIP LINK ========== */
.skip-link {
  position: fixed; top: calc(12px + var(--safe-top)); left: calc(12px + var(--safe-left));
  z-index: 100; padding: 10px 14px; border-radius: 8px;
  background: var(--text); color: var(--surface);
  transform: translateY(-140%); transition: transform 160ms ease;
}
.skip-link:focus { transform: translateY(0); }

/* ========== HEADER ========== */
.site-header {
  position: fixed; top: 0; right: 0; left: 0; z-index: 50;
  padding-top: var(--safe-top);
  background: rgba(248, 250, 251, 0.8);
  border-bottom: 1px solid rgba(228, 235, 242, 0.85);
  backdrop-filter: blur(18px) saturate(1.4);
  transform: translateY(0); transition: transform 200ms ease;
}
@supports not (backdrop-filter: blur(1px)) {
  .site-header { background: rgba(248, 250, 251, 0.96); }
}
.site-header[data-hidden="true"] { transform: translateY(calc(-1 * var(--header-height) - var(--safe-top) - 10px)); }

.header-inner {
  width: min(100% - 36px, var(--container));
  height: var(--header-height);
  margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 22px;
}
.brand { display: inline-flex; align-items: center; flex-shrink: 0; }
.brand img { width: 160px; height: auto; }

.nav-panel {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; flex: 1; min-width: 0;
}
.primary-nav {
  display: flex; align-items: center; gap: 14px;
  font-size: 14px; color: rgba(10,13,20,0.62); white-space: nowrap;
}
.primary-nav a { padding: 6px 0; transition: color 120ms ease; }
.primary-nav a:hover, .primary-nav a:focus-visible, .primary-nav a[aria-current="page"] { color: var(--blue); }

.nav-cta {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--touch-min); padding: 0 16px;
  border: 1.5px solid var(--text); border-radius: 7px;
  background: var(--text); color: var(--surface);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.nav-cta:hover, .nav-cta:focus-visible { background: var(--blue); border-color: var(--blue); transform: translateY(-1px); }

/* language toggle */
.lang-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: var(--touch-min);
  padding: 0 10px; border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
  white-space: nowrap; flex-shrink: 0; letter-spacing: 0.02em;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.lang-toggle:hover, .lang-toggle:focus-visible {
  color: var(--blue); border-color: var(--blue); background: rgba(2,136,240,0.04);
}

/* menu toggle (mobile) */
.menu-toggle { display: none; width: var(--touch-min); height: var(--touch-min); border: 1.5px solid var(--line); border-radius: 7px; background: transparent; color: var(--text); cursor: pointer; flex-shrink: 0; }
.menu-toggle span { display: block; width: 18px; height: 2px; margin: 5px auto; border-radius: 2px; background: currentColor; transition: transform 140ms ease; }
.site-header[data-open="true"] .menu-toggle span:first-child { transform: translateY(3.5px) rotate(45deg); }
.site-header[data-open="true"] .menu-toggle span:last-child { transform: translateY(-3.5px) rotate(-45deg); }

/* page progress bar */
.page-progress { height: 1.5px; background: transparent; overflow: hidden; }
.page-progress span { display: block; width: 100%; height: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--blue), var(--cyan)); will-change: transform; }

/* ========== NAV BACKDROP (mobile) ========== */
.nav-backdrop {
  display: none; position: fixed; inset: 0; z-index: 45;
  background: rgba(10,13,20,0.3); opacity: 0;
  transition: opacity 180ms ease;
}
.site-header[data-open="true"] ~ .nav-backdrop,
.site-header[data-open="true"] + .nav-backdrop { display: block; }
.site-header[data-open="true"] ~ .nav-backdrop { opacity: 1; }
.site-header[data-open="true"] + .nav-backdrop { opacity: 1; }

/* ========== READING MAP SIDEBAR ========== */
.reading-map {
  position: fixed; top: calc(var(--header-height) + var(--safe-top) + 36px);
  left: max(20px, calc((100vw - var(--container)) / 2 - 152px));
  z-index: 35; width: 130px;
}
.reading-map nav { display: flex; flex-direction: column; }
.reading-map a {
  display: block; padding: 6px 0 6px 12px;
  font-size: 12.5px; font-weight: 500; color: #b0bcc8;
  line-height: 1.45; border-left: 2px solid transparent;
  transition: color 180ms ease, border-color 180ms ease;
}
.reading-map a:hover, .reading-map a:focus-visible { color: var(--muted); }
.reading-map a[aria-current="page"] { color: var(--text); font-weight: 650; border-left-color: var(--blue); }

/* reading mode toggle inside sidebar */
.reading-mode-control { padding: 0 0 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.reading-mode-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--muted);
  font-size: 12px; font-family: inherit; cursor: pointer;
  min-height: 32px; transition: color 120ms ease, border-color 120ms ease;
}
.reading-mode-toggle:hover, .reading-mode-toggle:focus-visible { color: var(--blue); border-color: var(--blue); }
.reading-mode-icon { font-size: 13px; line-height: 1; }

/* ========== MOBILE SECTION NAV ========== */
.mobile-section-nav { display: none; }

/* ========== HERO ========== */
.hero { min-height: 100svh; padding: calc(var(--header-height) + var(--safe-top) + 48px) 20px 32px; display: flex; align-items: flex-start; }
.hero-shell { width: min(100%, var(--container)); margin: 0 auto; }
.hero-copy { display: flex; flex-direction: column; }
.hero h1 { margin: 0; font-size: clamp(44px, 5vw, 76px); line-height: 1.06; font-weight: 780; }
.hero-detail { margin-top: clamp(28px, 4.5vw, 44px); }
.hero-summary p { margin-bottom: 14px; color: var(--muted); font-size: var(--body-size); line-height: var(--body-line); }
.hero-summary p:last-child { margin-bottom: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

/* ========== SECTIONS ========== */
.reading-section, .work-section, .path-section, .identity-section, .principles-section, .final-cta {
  position: relative; padding: clamp(64px, 8vw, 96px) 20px;
}
.work-section, .path-section, .identity-section, .principles-section, .final-cta { padding-top: clamp(48px, 5.5vw, 72px); }
#happening { padding-top: clamp(18px, 2.5vw, 34px); }
.section-soft { background: linear-gradient(180deg, rgba(242,245,248,0.65), rgba(248,250,251,0)); }
.section-shell, .wide-shell, .final-shell { width: min(100%, var(--container)); margin: 0 auto; }

/* ========== TYPOGRAPHY ========== */
.chapter-copy h2, .section-intro h2, .final-cta h2 {
  margin: 0 0 var(--heading-gap); color: var(--text);
  font-size: clamp(32px, 3.5vw, 50px); line-height: 1.12; font-weight: 760;
}
.chapter-copy h3, .path-step h3, .principle h3, .work-item h3 {
  margin: 0 0 10px; color: var(--text);
  font-size: clamp(20px, 1.5vw, 24px); line-height: 1.4; font-weight: 700;
}

.chapter-copy p, .final-copy p, .path-close p, .section-intro p,
.work-item p, .principle p, .path-step p, .identity-list li,
.hero-summary p, .work-end, .plain-list li, .closing-line {
  color: var(--muted); font-size: var(--body-size); line-height: var(--body-line);
}
.chapter-copy p, .final-copy p, .path-close p { margin-bottom: var(--body-gap); }
.chapter-copy p:last-child, .final-copy p:last-child, .path-close p:last-child { margin-bottom: 0; }

.subchapter { margin-top: 56px; padding-top: 38px; border-top: 1px solid var(--line); }
.subchapter h3 { margin-bottom: var(--body-gap); }

.strong-line { color: var(--text) !important; font-weight: 700; }
.role-line { color: var(--blue-deep) !important; font-weight: 670; }

.plain-list { display: flex; flex-direction: column; gap: var(--body-gap); margin: var(--body-gap) 0; padding: 0; list-style: none; }
.plain-list li { position: relative; padding-left: 18px; color: var(--text); }
.plain-list li::before { content: ""; position: absolute; top: 0.72em; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }

.text-link { display: inline-flex; align-items: center; gap: 7px; margin-top: calc(var(--body-gap) - 4px); color: var(--text); font-size: 15px; font-weight: 700; min-height: var(--touch-min); padding: 4px 0; transition: gap 120ms ease; }
.text-link::after { content: ""; width: 22px; height: 1.5px; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width 120ms ease; }
.text-link:hover, .text-link:focus-visible { gap: 10px; }
.text-link:hover::after, .text-link:focus-visible::after { width: 34px; }

/* ========== BUTTONS ========== */
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; border: 1.5px solid transparent; border-radius: 7px; font-size: 15px; font-weight: 630; line-height: 1; cursor: pointer; transition: transform 120ms ease, background 120ms ease, color 120ms ease, border-color 120ms ease; }
.button:hover, .button:focus-visible { transform: translateY(-2px); }
.button-primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.button-primary:hover, .button-primary:focus-visible { background: var(--blue); border-color: var(--blue); }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.button-secondary:hover, .button-secondary:focus-visible { color: var(--blue-deep); border-color: var(--blue); }

/* ========== WORK ========== */
.work-list, .principle-list { margin-top: 40px; border-top: 1.5px solid var(--line-strong); }
.work-item, .principle { display: flex; flex-direction: column; gap: 8px; padding: 26px 0; border-bottom: 1px solid var(--line); }
.work-item p, .principle p { margin: 0; }
.work-end { margin: 30px 0 0; font-size: var(--body-size); font-weight: 700; color: var(--text); }

/* ========== PATH ========== */
.path-section { background: var(--surface); }
.path-list { position: relative; display: flex; flex-direction: column; margin: 44px 0 0; padding: 0; list-style: none; }
.path-list::before { content: ""; position: absolute; top: 10px; bottom: 10px; left: 7px; width: 2px; background: linear-gradient(180deg, var(--blue), var(--cyan)); }
.path-step { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 0 0 var(--body-gap) 32px; }
.path-step::before { content: ""; position: absolute; top: 5px; left: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--blue); box-shadow: 0 0 0 5px rgba(74,212,223,0.07); }
.path-step p { margin: 0; }
.path-close { margin: 20px 0 0; }

/* ========== IDENTITY ========== */
.identity-grid { display: flex; flex-direction: column; gap: 34px; }
.identity-list { margin: 0; padding: 0; list-style: none; border-top: 1.5px solid var(--line-strong); }
.identity-list li { padding: 16px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.section-intro p { margin-top: calc(var(--body-gap) - 8px); }

/* ========== PRINCIPLES ========== */
.principles-section { background: var(--surface); }
.principle-list { margin-top: 40px; }

/* ========== FINAL CTA ========== */
.final-cta { min-height: 100svh; display: flex; align-items: flex-start; background: linear-gradient(180deg, rgba(248,250,251,0), rgba(242,245,248,0.88)), var(--bg); }
.final-cta h2 { max-width: 660px; }
.final-copy { margin-top: var(--heading-gap); }
.final-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--body-gap); }
.closing-line { margin-top: 52px; color: var(--text); font-size: clamp(22px, 2.5vw, 36px); line-height: 1.22; font-weight: 750; }

/* ========== FOOTER ========== */
.site-footer {
  padding: 44px 20px calc(48px + var(--safe-bottom));
  background: var(--text); color: var(--surface);
}
.footer-inner { width: min(100%, var(--container)); margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.footer-brand { display: inline-flex; margin-bottom: 6px; font-size: 22px; font-weight: 800; }
.site-footer p { margin: 0; color: rgba(255,255,255,0.6); font-size: 14px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 12px 18px; color: rgba(255,255,255,0.68); font-size: 14px; }
.footer-nav a { min-height: var(--touch-min); display: inline-flex; align-items: center; }
.footer-tagline { padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.08); font-size: clamp(18px, 2vw, 28px); line-height: 1.28; font-weight: 740; color: var(--surface) !important; }

/* ========== REVEAL SYSTEM ========== */
.has-js .reveal {
  opacity: 0; filter: blur(6px); transform: translateY(20px);
  transition: opacity 500ms cubic-bezier(0.18, 0.55, 0.35, 1), filter 500ms cubic-bezier(0.18, 0.55, 0.35, 1), transform 500ms cubic-bezier(0.18, 0.55, 0.35, 1);
  pointer-events: none;
}
.reveal.is-line-active,
.reveal.is-line-active * {
  opacity: 1 !important; filter: blur(0) !important; transform: translateY(0) !important;
  pointer-events: auto; transition-duration: 0s !important;
}
body.has-js .reveal.is-line-read {
  opacity: 0.28 !important; filter: blur(0) !important; transform: translateY(0) !important;
  pointer-events: auto;
}

/* show-all reading mode */
body.is-show-all .reveal {
  opacity: 1 !important; filter: blur(0) !important; transform: translateY(0) !important;
  pointer-events: auto !important; transition-duration: 300ms !important;
}
body.is-show-all .reveal.is-line-active,
body.is-show-all .reveal.is-line-read { opacity: 1 !important; }

/* ========== SUB-PAGE UTILITY CLASSES ========== */
.sub-hero { min-height: 60svh; }
.hero-detail--compact { margin-top: 28px; }
.subchapter--flush { margin-top: 0; padding-top: 0; border-top: 0; }
.final-cta--compact { min-height: auto; padding: clamp(60px, 7vw, 88px) 20px; }
.chapter-copy .button { margin-top: 12px; }
.mt-18 { margin-top: 18px; }
.mt-24 { margin-top: 24px; }
.mt-28 { margin-top: 28px; }
.mt-40 { margin-top: 40px; }
.mt-44 { margin-top: 44px; }
.text-closing-note { margin-top: 40px; font-size: 18px; color: var(--muted); }

/* ========== FOCUS RING ========== */
:focus-visible { outline: 2.5px solid rgba(2,136,240,0.28); outline-offset: 3px; }

/* ========== RESPONSIVE ========== */

/* tablet: hide sidebar, adjust padding */
@media (max-width: 1024px) {
  .reading-map { display: none !important; }
  .hero-shell, .section-shell, .wide-shell, .final-shell { width: min(100% - 48px, var(--container)); }
  .header-inner { width: min(100% - 40px, var(--container)); }
  :root { --body-size: 17px; --body-gap: 24px; --heading-gap: 32px; }
}

/* mobile */
@media (max-width: 720px) {
  :root { --header-height: 62px; --body-size: 17px; --body-gap: 22px; --heading-gap: 30px; }

  .brand img { width: 136px; }
  .menu-toggle { display: inline-block; }
  .primary-nav { font-size: 16px; }
  .footer-nav { font-size: 16px; gap: 14px 22px; }

  .nav-panel {
    position: absolute; z-index: 5; top: calc(var(--header-height) + 1px);
    right: 10px; left: 10px; display: flex; flex-direction: column; gap: 12px;
    padding: 16px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; box-shadow: 0 16px 44px rgba(10,13,20,0.06);
    opacity: 0; pointer-events: none; transform: translateY(-6px);
    transition: opacity 110ms ease, transform 110ms ease;
  }
  .site-header[data-open="true"] .nav-panel { opacity: 1; pointer-events: auto; transform: translateY(0); }
  .primary-nav { display: flex; flex-direction: column; }
  .primary-nav a { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .nav-cta { width: 100%; }
  .lang-toggle { width: 100%; justify-content: center; padding: 12px 0; }

  .hero { min-height: auto; padding-top: calc(var(--header-height) + var(--safe-top) + 40px); }
  .hero h1 { font-size: clamp(32px, 8.5vw, 46px); }
  .button { width: 100%; }
  .chapter-copy h2, .section-intro h2, .final-cta h2 { font-size: clamp(28px, 5vw, 38px); }

  /* sub-page utilities on mobile */
  .sub-hero { min-height: 45svh; }
  .final-cta--compact { padding: clamp(40px, 5vw, 60px) 16px; }
  .text-closing-note { font-size: 16px; }

  /* mobile section nav */
  .mobile-section-nav {
    display: flex; overflow-x: auto; gap: 8px;
    padding: 10px calc(16px + var(--safe-left));
    background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: calc(var(--header-height) + var(--safe-top)); z-index: 34;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    transition: top 200ms ease;
  }
  .site-header[data-hidden="true"] ~ .mobile-section-nav {
    top: var(--safe-top);
  }
  .mobile-section-nav::-webkit-scrollbar { display: none; }
  .mobile-section-nav a {
    flex-shrink: 0; padding: 7px 13px; font-size: 13px; font-weight: 500;
    color: var(--muted); border-radius: 6px; background: var(--surface-soft);
    white-space: nowrap; min-height: 36px; display: inline-flex; align-items: center;
  }
  .mobile-section-nav a[aria-current="page"] { color: #fff; background: var(--blue); }
}

@media (min-width: 501px) and (max-width: 720px) {
  .mobile-section-nav a { font-size: 14px; padding: 8px 15px; }
}

/* tiny phone */
@media (max-width: 359px) {
  :root { --body-size: 15px; --body-gap: 18px; --heading-gap: 24px; --header-height: 56px; }
  .brand img { width: 120px; }
  .hero h1 { font-size: 28px; }
  .chapter-copy h2, .section-intro h2, .final-cta h2 { font-size: 24px; }
  .button { min-height: 44px; font-size: 14px; }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .has-js .reveal { opacity: 1; filter: none; transform: none; }
}
