/* Portfolio v2 — editorial chapters & persistent reading location.
   Layout-only layer. Original project text, assets and downloads are retained. */
:root {
  --header-h: 68px;
  --reading-h: 52px;
  --reading-offset: calc(var(--header-h) + var(--reading-h));
  --chapter-white: #fffdf8;
  --chapter-sage: #e5ece7;
  --chapter-sand: #eee8de;
  --chapter-forest: #173e37;
}
html { scroll-padding-top: 0; }
/* A jump target and focused control must not disappear behind the fixed chrome. */
.reading-section, #main-content, main a, main button { scroll-margin-top: calc(var(--reading-offset) + 20px); }
.reading-section:focus, main:focus { outline: none; }
:focus-visible { outline: 2px solid #8b4935; outline-offset: 5px; }
[hidden] { display: none !important; }
.skip-link {
  position: fixed; top: 12px; left: 20px; z-index: 400;
  padding: 12px 22px; background: var(--forest); color: #fff;
  transform: translateY(-180%); border-radius: 5px;
}
.skip-link:focus { transform: none; }
.site-header { background: #f9f7f2; backdrop-filter: none; border-color: #d2d8d0; }
.main-nav a.is-reading::after { right: 0; }
.main-nav a.is-reading { color: var(--forest); }
/* Do not make source material depend on entry animation. */
.reveal { opacity: 1; transform: none; transition: none; }

/* One slim, persistent location indicator. Full contents opens only on request. */
.reading-bar {
  display: none;
  position: sticky; top: var(--header-h); z-index: 90;
  height: var(--reading-h); color: #233c31; background: #e7ece5;
  border-bottom: 1px solid #c7d2c7;
}
.js .reading-bar { display: block; }
.reading-inner { height: 100%; display: flex; align-items: center; gap: 25px; }
.reading-scope {
  flex: 0 1 auto; min-width: 0; max-width: 280px;
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 25px; border-right: 1px solid #bccbbf;
}
.reading-scope:hover { text-decoration: underline; text-underline-offset: 4px; }
.reading-location { min-width: 0; display: flex; align-items: center; gap: 11px; flex: 1; }
.reading-prefix { color: #526657; font-size: 11px; letter-spacing: .035em; white-space: nowrap; }
.reading-number {
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 12px; font-weight: 750; padding: 3px 6px;
  background: #cfddd1; color: #234635; border-radius: 4px; min-width: 28px; text-align: center;
}
.reading-label {
  min-width: 0; font-size: 13px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reading-controls { flex: none; display: flex; align-items: center; gap: 20px; }
.reading-count { font-size: 11px; font-variant-numeric: tabular-nums; letter-spacing: .08em; color: #516455; }
.toc-toggle {
  display: inline-flex; gap: 8px; align-items: center; justify-content: center;
  min-height: 42px; border: none; background: none; color: #254232;
  font-size: 12px; font-weight: 750; cursor: pointer; padding: 6px 0 6px 12px;
}
.toc-toggle:hover { color: #111f17; }
.toc-chevron { font-size: 18px; line-height: 1; transform: translateY(-3px); }
.toc-toggle[aria-expanded="true"] .toc-chevron { transform: rotate(180deg) translateY(-2px); }
.reading-progress { position: absolute; left: 0; bottom: -1px; width: 100%; height: 2px; pointer-events: none; background: transparent; }
.reading-progress > span { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: #315946; }
.toc-panel {
  position: absolute; top: calc(100% + 10px);
  right: max(24px, calc((100vw - var(--max)) / 2));
  width: min(690px, calc(100vw - 48px)); max-height: calc(100svh - var(--reading-offset) - 34px);
  overflow: auto; overscroll-behavior: contain; padding: 26px;
  background: #fffdf8; color: #1c2a22; border: 1px solid #b9c5b9;
  border-radius: 14px; box-shadow: 0 20px 65px rgba(23, 44, 31, .16);
}
.toc-heading { display: flex; justify-content: space-between; align-items: start; gap: 24px; padding-bottom: 18px; border-bottom: 1px solid #d8dfd5; margin-bottom: 10px; }
.toc-eyebrow { font-size: 10px; letter-spacing: .16em; color: #526653; font-weight: 800; }
.toc-heading p { font-size: 15px; margin: 6px 0 0; }
.toc-close { background: none; border: 1px solid #cdd5ca; border-radius: 50%; font-size: 25px; line-height: 1; width: 40px; height: 40px; cursor: pointer; color: #254232; flex: none; }
.toc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.toc-link {
  display: grid; grid-template-columns: 26px minmax(0,1fr) 16px; gap: 9px;
  padding: 14px 12px; border-radius: 6px; border: 1px solid transparent;
  align-items: start; min-height: 65px;
}
.toc-number { font-size: 11px; color: #67796a; padding-top: 2px; font-variant-numeric: tabular-nums; }
.toc-copy strong { display: block; font-size: 14px; line-height: 1.4; font-weight: 700; }
.toc-copy small { display: block; font-size: 11px; line-height: 1.5; margin-top: 5px; color: #617164; }
.toc-arrow { font-size: 15px; color: #315946; }
.toc-link:hover { border-color: #bbcbbd; background: #f1f4ee; }
.toc-link[aria-current="location"] { background: #e3ece1; border-color: #b7c9b8; }
.toc-link[aria-current="location"] .toc-number { color: #1d4932; font-weight: 850; }

/* Chapter typography: large, functional labels BEFORE the editorial headings. */
.chapter-kicker {
  display: flex; align-items: center; gap: 22px; width: 100%;
  color: var(--forest); margin: 0 0 35px;
  text-transform: none; letter-spacing: 0;
}
.chapter-kicker::before { display: none; }
.chapter-number { font-family: var(--serif); font-size: 43px; line-height: 1; font-weight: 400; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.chapter-label { font-family: var(--sans); font-size: 17px; font-weight: 750; line-height: 1.45; margin: 0; letter-spacing: .01em; }
.chapter-rule { flex: 1; height: 1px; margin-left: 16px; background: currentColor; opacity: .23; }
.section { padding: 88px 0 62px; border-top: 1px solid #c9d1c7; }
.section-title { font-size: clamp(38px,4.3vw,62px); line-height: 1.08; }
.section-head { margin-bottom: 46px; align-items: start; }
.section-intro { font-size: 16px; line-height: 1.75; }
body[data-lang="zh"] .display, body[data-lang="zh"] .project-main-title { line-height: 1.16; letter-spacing: -.025em; }
body[data-lang="zh"] .section-title, body[data-lang="zh"] .case-title { line-height: 1.26; letter-spacing: -.025em; }
body[data-lang="zh"] .project-title { line-height: 1.25; }
.chapter-next {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  border-top: 1px solid var(--line); padding-top: 20px; margin-top: 58px;
  color: var(--muted); font-size: 12px;
}
.chapter-next a { display: flex; align-items: center; gap: 12px; color: var(--accent); font-weight: 700; min-height: 36px; }
.chapter-next a:hover { text-decoration: underline; text-underline-offset: 4px; }
.chapter-next-number { font-size: 11px; opacity: .7; }

/* Home: a coherent palette, with genuine structural differences between sections. */
.home-hero { min-height: calc(100svh - var(--reading-offset)); padding-top: 65px; padding-bottom: 76px; background: #f5f2eb; }
.home-page #projects { background: var(--chapter-white); }
.home-page #capabilities { background: var(--chapter-sage); --line: #bdcdc0; }
.home-page #approach { background: var(--chapter-forest); --ink: #f5f4e9; --muted: #cedcd1; --line: #4a6e5e; --accent: #d3e7cf; color: var(--ink); border-top: 0; }
.home-page #experience { background: var(--chapter-sand); --line: #cfc7ba; }
.home-page #about { background: var(--chapter-white); }
.home-page #resume { background: #e3eae8; --line: #bdcac5; }
.home-page #contact { background: #15382f; border: 0; padding: 70px 0 80px; }
.home-page #approach .chapter-kicker { color: #dcebd7; }
.home-page #approach .approach-step { min-height: 240px; padding: 28px 24px 20px; border-top: 1px solid #7c9985; }
.home-page #approach .approach-step::before { margin-bottom: 45px; font-size: 13px; }
.home-page #approach .approach-step h3 { font-size: 24px; margin-bottom: 14px; }
.home-page #approach .approach-step p { font-size: 14px; }
.capability-grid { border: 1px solid #b6c9ba; border-radius: 15px; overflow: hidden; background: #f6f8f3; }
.capability { padding: 30px 27px 34px; }
.capability-index { margin-bottom: 38px; }
.experience-row { padding: 30px 0; grid-template-columns: 160px minmax(240px,.75fr) minmax(0,1fr); }
.experience-date { color: #536650; position: relative; padding-left: 16px; font-weight: 600; }
.experience-date::before { content: ''; width: 5px; height: 5px; border-radius: 50%; position: absolute; left: 0; top: 8px; background: #536650; }
.about-copy .body-lg { margin-top: 26px; }
.about-photo { border: 1px solid #d6d5ca; }
.resume-card { background: #fbfbf6; border-color: #bac9c0; border-radius: 13px; padding: 33px; position: relative; }
.resume-card::after { content: '↗'; position: absolute; top: 25px; right: 25px; color: #406251; font-size: 25px; }
.resume-card:hover { background: #fffef8; border-color: #486958; }
.home-page .contact-panel { background: transparent; padding: 0; border-radius: 0; }
.home-page .contact-panel::after { display: none; }
.home-page .contact-panel .section-title { max-width: 18ch; }
.home-page .contact-panel .chapter-kicker { color: #d2e5cb; }
.home-page .contact-panel p { font-size: 18px; }
.home-page .site-footer { background: #102c25; color: #c0d1c3; border-color: #355648; }

/* Cards read as distinct project records, not fragments of a continuous essay. */
.project-grid { gap: 34px; }
.project-link {
  overflow: hidden; border: 1px solid #d6ddd1; border-radius: 18px; background: #fffefb;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.project-link:hover { border-color: #819b89; box-shadow: 0 10px 25px rgba(36,57,39,.06); }
.project-visual { border: 0; border-radius: 0; border-bottom: 1px solid #e0e3d9; }
.project-copy { display: block; padding: 26px 27px 28px; }
.project-desc { margin-top: 18px; max-width: 65ch; }
.project-card.featured .project-copy { display: grid; padding: 29px 32px 30px; grid-template-columns: 1fr .85fr; gap: 45px; }
.project-card.featured .project-desc { margin-top: 0; }
.project-title { font-size: clamp(27px,2.9vw,39px); }
.project-type { font-size: 10px; letter-spacing: .1em; color: #596d5d; }
.project-number { border-radius: 5px; width: 36px; height: 34px; background: #fffdf7; }
.projects-hero { padding: 62px 0 70px; background: #f5f2eb; }
.projects-hero .lede { max-width: 65ch; }
.archive-section { padding: 60px 0 95px; background: #fffdf8; border-top: 1px solid #c9d1c7; }
.archive-section .chapter-kicker { margin-bottom: 22px; }
.archive-section .filter-row { margin: 0 0 36px; }

/* Case studies: original formats stay intact; each chapter has an unmistakable start. */
.project-hero { background: #f5f2eb; padding-top: 60px; }
.case-section { padding: 78px 0 56px; border-bottom: 0; border-top: 1px solid #cbd1c5; }
.case-section[data-surface="paper"] { background: #fffdf8; }
.case-section[data-surface="sage"] { background: #e8eee8; --line: #c1cec1; }
.case-section[data-surface="sand"] { background: #eee9df; --line: #cec9bd; }
.case-section[data-surface="reflection"] { background: #dfe8e0; --line: #b5c7b8; border-top: 3px solid var(--accent); }
.case-heading { gap: 45px; margin-bottom: 45px; }
.case-index { padding-top: 2px; text-transform: none; letter-spacing: 0; }
.case-index .chapter-number { display: block; font-size: 55px; padding-bottom: 17px; margin-bottom: 15px; border-bottom: 1px solid currentColor; }
.case-index .chapter-label { display: block; font-size: 14px; line-height: 1.55; }
.case-title { max-width: 23ch; font-size: clamp(35px,4.1vw,59px); line-height: 1.1; }
.case-copy-grid { gap: 45px; }
.case-section .flow-step, .case-section .module-card, .case-section .user-path { background: #fcfcf6; border-color: #c4cdbf; }
.case-section .chapter-next { margin-top: 48px; }
.case-section .evidence-item { background: #fbfaf5; border: 1px solid #c4cdbf; border-radius: 8px; }
.case-section .callout { border-radius: 0 10px 10px 0; }
.artifact { margin: 0; background: #fff; }
.artifact figcaption { background: #f8f7f1; color: #53604f; font-size: 12px; }
.hero-artifact { box-shadow: none; border-radius: 14px; }
.next-project { background: #f5f2eb; padding: 50px 0 70px; }
.next-card { border-top: 0; }
.book-sticky { top: calc(var(--reading-offset) + 25px); max-height: calc(100svh - var(--reading-offset) - 50px); }

@media (max-width: 1100px) {
  .reading-scope { max-width: 210px; }
  .reading-inner { gap: 16px; }
  .reading-prefix { display: none; }
}
@media (max-width: 900px) {
  .site-name small { display: none; }
  .reading-scope { max-width: 180px; padding-right: 16px; font-size: 14px; }
  .reading-controls { gap: 14px; }
  .reading-count { display: none; }
}
@media (max-width: 820px) {
  :root { --header-h: 60px; --reading-h: 48px; }
  .header-inner, .container, .footer-inner { width: calc(100% - 36px); }
  .site-name { font-size: 20px; }
  .nav-wrap { z-index: 110; max-height: calc(100svh - var(--header-h)); overflow-y: auto; background: #f9f7f2; }
  .main-nav a { font-size: 16px; display: inline-flex; min-height: 36px; align-items: center; }
  .reading-scope { display: none; }
  .reading-inner { gap: 14px; }
  .reading-location { gap: 9px; }
  .reading-label { font-size: 12px; }
  .reading-number { font-size: 11px; padding: 3px 5px; min-width: 25px; }
  .toc-toggle { font-size: 12px; padding-left: 4px; gap: 6px; }
  .toc-toggle svg { width: 15px; }
  .toc-chevron { font-size: 15px; }
  .toc-panel { right: 18px; width: calc(100vw - 36px); padding: 18px; }
  .toc-grid { grid-template-columns: 1fr; gap: 2px; }
  .toc-link { min-height: 52px; padding: 10px 12px; }
  .toc-copy small { display: none; }
  .toc-heading { padding-bottom: 12px; }
  .toc-heading p { font-size: 13px; }
  .home-hero { min-height: auto; padding: 52px 0 64px; }
  .home-hero .display { font-size: clamp(46px,8.7vw,75px); }
  .section { padding: 62px 0 40px; }
  .chapter-kicker { gap: 15px; margin-bottom: 27px; }
  .chapter-number { font-size: 35px; }
  .chapter-label { font-size: 16px; }
  .chapter-rule { margin-left: 5px; }
  .section-title { font-size: clamp(34px,6.2vw,48px); line-height: 1.16; }
  .section-head { gap: 23px; margin-bottom: 32px; }
  .section-intro { font-size: 15px; }
  .project-card.featured .project-copy { display: block; }
  .project-card.featured .project-desc { margin-top: 18px; }
  .project-copy, .project-card.featured .project-copy { padding: 22px; }
  .project-grid { gap: 24px; }
  .experience-row { grid-template-columns: 1fr; gap: 10px; padding: 25px 0; }
  .experience-place { font-size: 25px; }
  .about-grid { gap: 32px; }
  .about-photo { min-height: auto; max-width: 420px; }
  .chapter-next { margin-top: 35px; padding-top: 16px; }
  .home-page #contact { padding: 56px 0; }
  .home-page .contact-panel p { font-size: 16px; }
  .home-page .contact-panel .section-title { max-width: 100%; }
  .project-hero { padding-top: 42px; padding-bottom: 52px; }
  .case-section { padding: 54px 0 40px; }
  .case-heading { gap: 23px; margin-bottom: 33px; }
  .case-title { font-size: clamp(31px,6.4vw,48px); max-width: 24ch; }
  .case-index { display: flex; align-items: center; gap: 15px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
  .case-index .chapter-number { flex: none; margin: 0; padding: 0; border: 0; font-size: 37px; }
  .case-index .chapter-label { font-size: 14px; }
  .case-copy-grid { gap: 0; }
  .case-copy-grid .spacer { display: none; }
  .case-section .chapter-next { margin-top: 34px; }
  .callout { padding: 25px; }
  .book-sticky { position: relative; top: auto; max-height: 600px; }
  .projects-hero { padding-top: 44px; padding-bottom: 48px; }
  .archive-section { padding: 45px 0 65px; }
}
@media (max-width: 560px) {
  .capability { padding: 26px; }
  .capability-index { margin-bottom: 24px; }
  .home-page #approach .approach-step { min-height: 0; padding: 26px 0; }
  .home-page #approach .approach-step::before { margin-bottom: 18px; }
  .home-page #approach .approach-step h3 { font-size: 25px; }
  .contact-links { gap: 10px; }
  .contact-links a { font-size: 13px; padding: 10px 13px; max-width: 100%; overflow-wrap: anywhere; }
  .chapter-next { font-size: 11px; gap: 12px; }
  .chapter-next > span { flex: none; }
  .chapter-next a { gap: 8px; text-align: right; }
  .project-meta-value { font-size: 14px; }
  .age-table { font-size: 12px; }
  .age-table th, .age-table td { padding: 10px; }
  .flow-step:not(:last-child)::after { display: none; }
}
/* Narrow landscape: save room without removing the user's location indicator. */
@media (max-height: 500px) and (max-width: 1000px) {
  :root { --header-h: 52px; --reading-h: 44px; }
  .toc-panel { top: 100%; max-height: calc(100svh - var(--reading-offset) - 8px); }
  .toc-heading { padding-bottom: 7px; }
}
@media print {
  .site-header, .reading-bar, .chapter-next, .skip-link, .next-project { display: none !important; }
  .section, .case-section { background: white !important; color: #111 !important; padding: 28px 0; }
  .section-title, .section-intro, .chapter-kicker, .approach-step p { color: #111 !important; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Keep multilingual headlines balanced; long mobile chapter names remain readable. */
.display, .section-title, .case-title, .project-main-title, .project-title { text-wrap: balance; }
@media (max-width: 820px) {
  .reading-label { white-space: normal; line-height: 1.3; overflow: visible; text-overflow: clip; }
}
