/* About page: horizontal track (desktop >= 900px) / vertical stack (mobile).
   Replaces about-css/about.css on about.html, about(en).html and about(ja).html.
   Task 6 adds body.is-horizontal (pinning, set by about-scroll.js); Task 7 adds body.has-3d (canvas ready). */

:root {
  --about-text: #cfcfcf;
  --about-title: #dcdcdc;
  --about-quiet: #8a8a8a;
  --about-bar: #d9d9d9;
  --about-font: 'Inter', 'Noto Sans TC', sans-serif;
  --about-display: 'Outfit', 'Noto Sans TC', sans-serif;

  /* Spacing scale (Task 8c): every margin, padding and gap on the page is one of these. */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;

  /* Type scale. Body copy, rows and labels share one letter-spacing family; CJK gets more leading. */
  --fs-display: clamp(34px, 9.5vw, 48px);
  --fs-lead: 14px;
  --fs-body: 13px;
  --fs-row: 12px;
  --fs-label: 11px;
  --fs-micro: 10px;
  --lh-body: 1.65;
  --ls-body: .06em;
  --ls-label: .12em;

  /* Mobile page margin; desktop overrides the grid below. */
  --about-margin: var(--sp-5);
}

/* Japanese (about(ja).html): Japanese glyph forms for the kanji. */
html:lang(ja) {
  --about-font: 'Inter', 'Noto Sans JP', sans-serif;
  --about-display: 'Outfit', 'Noto Sans JP', sans-serif;
}
html:lang(ja) body.about-page .site-header { font-family: 'Inter', 'Noto Sans JP', sans-serif; }

/* The About pages offer three languages (中 / EN / 日; the other pages two): a wider switch. */
.about-page .language-switch { width: clamp(108px, 10.5vw, 180px); }
.about-page .language-switch a { width: 33.334%; }
@media (max-width: 680px) { .about-page .language-switch { width: 86px; } }
@media (max-width: 360px) { .about-page .language-switch { width: 78px; } }
/* Chinese reads better with more leading. */
html:lang(zh) { --lh-body: 1.85; }

/* main.css locks body to a 100vh, overflow:hidden, absolutely positioned box. Undo that here. */
body.about-page {
  position: relative;
  width: auto;
  height: auto;
  min-height: 100vh;
  overflow: visible;
  background: #000;
  color: var(--about-text);
  font-family: var(--about-font);
}

.about-page .site-nav > a { text-decoration: underline; }

/* main.css sets `* { font-family: Noto sans TC }`; every About element opts back into the site fonts. */
.about-track-wrap,
.about-track-wrap p,
.about-track-wrap span,
.about-track-wrap a,
.about-track-wrap strong,
.about-track-wrap time,
.about-track-wrap div { font-family: var(--about-font); }
.about-track-wrap h1,
.about-track-wrap h2 { font-family: var(--about-display); }

/* Custom cursor (moved from about.css). */
#custom-cursor {
  width: 20px;
  height: 20px;
  border: 1px solid #fff;
  background-color: #fff;
  border-radius: 50%;
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 10000;
  opacity: 0;
  mix-blend-mode: difference;
  transition: transform .2s ease, background-color .2s ease;
}

/* Lit text: --lit-color is written by the lamp light (about-lamp.js, desktop only). Unset = today's
   colours, so the page looks exactly as before wherever the lamp is far away. */
.lit-target { color: var(--lit-color, #cfcfcf); }

/* The lamp's hit area (about-lamp.js): a transparent circle over the bulb, moved with a transform.
   Mobile: inside .about-opening. Desktop: moved into .about-track, so it scrolls with the text. */
.about-lamp-hit {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  touch-action: none; /* a long-press must not turn into a page scroll */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.about-lamp-hit:focus { outline: none; }
.about-lamp-hit:focus-visible { outline: 1px solid rgba(255, 255, 255, .7); outline-offset: 2px; }
body.is-lamp-held { -webkit-user-select: none; user-select: none; }

/* The plug's hit area (about-lamp.js, desktop): over the plug in its floor socket; click or drag it
   up to pull it out (the lamp goes dark), click again to plug it back in. */
.about-plug-hit {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: 64px;
  height: 64px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.about-plug-hit:focus { outline: none; }
.about-plug-hit:focus-visible { outline: 1px solid rgba(255, 255, 255, .7); outline-offset: 2px; }

/* ---------- Mobile-first: vertical stack ---------- */

.about-track-wrap { position: relative; }
.about-track { display: block; }

.about-track section { position: relative; }

.about-opening {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #000;
}
.about-stage { position: absolute; inset: 0; }
.about-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
body.has-3d .about-fallback { display: none; }

/* The WebGL canvas (about-scene.js). Mobile: inside .about-stage only. Desktop: fixed over the
   whole viewport, BEHIND the text (round 2b: the meadow runs on behind the text block, so the
   text must sit on top of it) and below the header. The opening's own black background steps
   aside while the 3D runs (the page is black anyway). Never takes pointer events. */
.about-3d-canvas { display: block; pointer-events: none; }
.about-stage > .about-3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.about-3d-canvas.is-fixed { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
@media (min-width: 900px) {
  body.has-3d .about-opening { background: transparent; }
  body.has-3d .about-track-wrap { position: relative; z-index: 1; }
}

/* ----- Type ----- */

.about-title {
  margin: 0 0 var(--sp-5);
  font-size: var(--fs-display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: .02em;
  color: var(--about-title);
  text-wrap: balance;
  line-break: strict;
}
/* An opening quote hangs into the margin so the title's letters share the greeting's left edge
   (about-page.js adds the class when the CMS title starts with one). */
.about-title.has-hanging-quote { text-indent: -.4em; }
/* zh: about-page.js puts <wbr> between words, so lines only break between them. Keyed on the
   <wbr>s themselves: a CMS rewrite (textContent) removes them and wrapping falls back to normal. */
.about-title:has(wbr) { word-break: keep-all; }

/* Body copy: intro columns and the contact note. */
.about-intro p,
.about-closing p,
.about-contact-note {
  margin: 0 0 1.5em;
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);
  text-wrap: pretty;
  line-break: strict;
  overflow-wrap: break-word;
  orphans: 3;
  widows: 3;
}
.about-intro .about-col > p:last-child,
.about-closing .about-col > p:last-child { margin-bottom: 0; }
/* Same element class list as body copy, so this needs the extra class to win (Task 8c fix 4). */
.about-intro .about-greeting.lit-target {
  margin: 0;
  font-size: var(--fs-lead);
  line-height: 1.6;
  letter-spacing: .08em;
}
/* The CMS may send an empty string for a field (e.g. closing_html); don't leave a gap for it. */
.about-track-wrap p.lit-target:empty { display: none; }

/* ----- Intro ----- */

.about-intro { padding: var(--sp-8) var(--about-margin) 0; }
.about-intro-head { margin-bottom: var(--sp-7); }
.about-col { max-width: 560px; }

/* ----- Experience ----- */

.about-experience { padding: var(--sp-9) var(--about-margin) 0; }

/* ----- Closing (after Experience): what the work is for ----- */

.about-closing { padding: var(--sp-9) var(--about-margin) 0; }
.about-experience-inner { max-width: 640px; }
.about-experience-title {
  margin: 0;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid #5c5c5c;
  font-size: var(--fs-label);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: var(--ls-label);
  color: var(--about-text);
}
.about-axis {
  display: flex;
  justify-content: space-between;
  margin: var(--sp-2) 0 var(--sp-5);
  font-size: var(--fs-micro);
  line-height: 1.4;
  letter-spacing: var(--ls-label);
  color: var(--about-quiet);
  font-variant-numeric: tabular-nums;
}
.about-timeline-bars { position: relative; margin-bottom: var(--sp-5); }

/* Bars are placed by YuAboutTimeline.renderTimeline: style.left / style.width in % of this column.
   Relative positioning keeps them stacked in normal flow while `left` shifts them along the axis.
   School = outlined, work = solid; a little extra air where the school group ends. */
.about-bar {
  --bar-h: 6px;
  position: relative;
  display: block;
  box-sizing: border-box;
  height: var(--bar-h);
  margin-bottom: 5px;
  opacity: .9;
  transition: opacity .25s ease;
}
.about-bar:last-child { margin-bottom: 0; }
.about-bar[data-kind=school] {
  border: 1px solid var(--lit-color, #cfcfcf);
  background: transparent;
}
.about-bar[data-kind=work] { background: var(--lit-color, #d9d9d9); }
.about-bar[data-kind=school] + .about-bar[data-kind=work] { margin-top: var(--sp-3); }

/* Row: [kind marker] [position + company, wraps] [dates, right edge]. */
.about-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: var(--sp-3);
  align-items: start;
  padding: 5px 0;
  font-size: var(--fs-row);
  line-height: 18px;
  letter-spacing: .06em;
  color: var(--lit-color, var(--about-text));
  cursor: default;
  transition: opacity .25s ease;
}
/* The marker repeats the row's bar style (outlined school / solid work) at a glance. */
.about-row::before {
  content: '';
  width: 6px;
  height: 6px;
  margin-top: 6px;
  box-sizing: border-box;
  border: 1px solid currentColor;
}
.about-row[data-kind=work]::before { background: currentColor; }
.about-row-what { min-width: 0; }
/* A company that doesn't fit after the position moves to the next line whole. */
.about-row-what > span { display: inline-block; }
/* Phones, English: rows are too long for one line, so every company gets its own (one rhythm). */
@media (max-width: 899.98px) {
  html:lang(en) .about-row-what > span { display: block; }
}
.about-row strong { font-weight: 600; margin-right: .5em; }
.about-row time {
  padding-left: var(--sp-4);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Timeline feed failed or empty: keep the heading, drop the placeholder axis. */
.about-experience.is-empty .about-axis { display: none; }

/* Hover link-up: the hot bar/row stays bright, the rest dim. */
.about-bar.is-hot,
.about-row.is-hot,
.about-row.is-open { opacity: 1; }
.about-experience:has(.is-hot) .about-bar:not(.is-hot),
.about-experience:has(.is-hot) .about-row:not(.is-hot):not(.is-open) { opacity: .35; }

/* Rows with a description or photo open a detail card (about-timeline.js createDetailCard). */
.about-row.has-detail,
.about-bar.has-detail { cursor: pointer; }
.about-row.has-detail:focus { outline: none; }
.about-row.has-detail:focus-visible { outline: 1px solid rgba(255, 255, 255, .6); outline-offset: 2px; }
.about-row.is-open strong { text-decoration: underline; text-underline-offset: 3px; }
.about-detail {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 120px);
  overflow: auto;
  box-sizing: border-box;
  padding: 14px 16px 16px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  background: rgba(16, 16, 18, .94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--about-text, #cfcfcf);
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: .04em;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .25s ease;
}
.about-detail.is-on { opacity: 1; transform: none; }
.about-detail[hidden] { display: none; }
.about-detail.is-sheet { left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; max-height: 60vh; }
.about-detail-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 28px;
  cursor: pointer;
  opacity: .7;
}
.about-detail-close:hover { opacity: 1; }
.about-detail-img {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  margin: 18px 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
}
.about-detail-img[hidden] { display: none; }
.about-detail-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding-right: 26px; }
.about-detail-img:not([hidden]) + .about-detail-head { padding-right: 0; }
.about-detail-head strong { font-weight: 600; color: #fff; }
.about-detail-head time { width: 100%; font-size: 12px; opacity: .65; font-variant-numeric: tabular-nums; }
.about-detail-text { margin: 10px 0 0; white-space: pre-line; }
.about-detail-text[hidden] { display: none; }

/* ----- Contact ----- */

/* Bottom padding keeps the copyright clear of the fixed "Talk to YU-AI" button. */
.about-contact { padding: var(--sp-9) var(--about-margin) 128px; }
.about-contact-inner { max-width: 400px; }
.about-contact-note { margin-bottom: var(--sp-6); }
.about-contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin: 0 0 var(--sp-4);
}
.about-contact-links a {
  font: 400 var(--fs-body)/1.5 'Outfit', sans-serif;
  letter-spacing: .06em;
  color: #aaa;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color .2s ease;
}
.about-contact-links a:hover,
.about-contact-links a:focus-visible { color: #fff; }
.about-contact .copyright {
  margin: 0;
  font-size: var(--fs-micro);
  line-height: 1.5;
  letter-spacing: .08em;
  color: #818181;
}
/* The plug (desktop only) is drawn by the 3D scene at this slot's left edge. */
.about-plug-slot { display: none; }

/* ---------- Desktop: one horizontal track ---------- */
@media (min-width: 900px) {
  :root {
    --fs-display: clamp(36px, 3.3vw, 60px);
    /* Column grid: every text column is --about-col wide, separated by --about-gutter. */
    --about-col: 260px;
    --about-gutter: var(--sp-7);
    /* Air between one section's last column and the next section's first. */
    --about-section-gap: clamp(128px, 12vw, 208px);
    /* The shared top line ("horizon") of the intro title, the Experience heading and the contact note:
       30% down on a tall screen, never closer than 48px under the header. */
    --about-top: max(calc(var(--site-header, 113px) + var(--sp-7)), calc(50vh - 200px));
    /* Clearance below the text: the floor line the lamp and cord rest on (0.85 x viewport, see
       YuAboutScene.getLayout().floorY), a resting bulb (about 5.4vh tall) and 24px above that.
       about-page.js writes the live value (floorClearance). */
    --about-floor-gap: calc(15vh + 5.4vh + var(--sp-5));
  }

  /* Before Task 6 pins the track it simply overflows sideways; once pinned, clip the overflow. */
  html:has(body.about-page:not(.is-horizontal)) { overflow-x: auto; }
  body.about-page.is-horizontal { overflow-x: clip; }

  .about-track {
    position: relative; /* containing block for the lamp's hit button */
    display: flex;
    flex-wrap: nowrap;
    height: 100vh;
    width: max-content;
  }
  .about-track > section {
    flex: 0 0 auto;
    box-sizing: border-box;
    height: 100vh;
  }

  /* First viewport = opening (left 55vw) + start of the intro (title from 57vw), as in 6303-633. */
  .about-opening { width: 55vw; }

  .about-intro {
    display: flex;
    align-items: flex-start;
    gap: var(--about-gutter);
    padding: var(--about-top) var(--about-section-gap) var(--about-floor-gap) 2vw;
  }
  .about-intro-head {
    flex: 0 0 auto;
    /* Wide enough for a 7-character clause of the zh title on one line (「以敞開的靈魂，」). */
    width: max(clamp(260px, 22vw, 400px), calc(var(--fs-display) * 7.4));
    margin: 0 var(--sp-6) 0 0; /* title block to first column: gutter + 32px */
  }
  /* Japanese: the longer clause 「すべてに目を向ける”」 (10 characters) stays on one line. */
  html:lang(ja) .about-intro-head { width: max(clamp(260px, 22vw, 400px), calc(var(--fs-display) * 10.6)); }
  /* Text columns. about-page.js raises --cols when a column would run into the floor clearance, so
     the text flows sideways instead of down. The long intro starts as two columns. */
  .about-col {
    --cols: 1;
    flex: 0 0 auto;
    width: calc(var(--cols) * var(--about-col) + (var(--cols) - 1) * var(--about-gutter));
    max-width: none;
    columns: var(--cols);
    column-gap: var(--about-gutter);
  }
  .about-col--wide { --cols: 2; }

  .about-experience {
    padding: var(--about-top) var(--about-section-gap) var(--about-floor-gap) 0;
  }
  /* The closing column: on the same top line, after Experience. */
  .about-closing {
    display: flex;
    align-items: flex-start;
    gap: var(--about-gutter);
    padding: var(--about-top) var(--about-section-gap) var(--about-floor-gap) 0;
  }
  .about-experience-inner {
    width: 640px;
    max-width: none;
  }
  /* about-page.js sets data-list-cols when the rows would run into the floor clearance: the list
     flows into extra columns and the section grows sideways instead. Columns are per language
     because English rows are about half as long again. */
  .about-experience { --about-row-col: 400px; }
  html:lang(en) .about-experience { --about-row-col: 520px; }
  .about-experience[data-list-cols] .about-experience-inner {
    width: max(640px, calc(var(--about-list-cols) * var(--about-row-col) + (var(--about-list-cols) - 1) * var(--about-gutter)));
  }
  .about-experience[data-list-cols] .about-timeline-list {
    column-count: var(--about-list-cols);
    column-gap: var(--about-gutter);
  }
  .about-experience[data-list-cols] .about-row { break-inside: avoid; }

  /* Short laptop screens: a denser timeline, so the rows still fit in two columns. */
  @media (max-height: 820px) {
    .about-axis { margin-bottom: var(--sp-4); }
    .about-bar { --bar-h: 5px; margin-bottom: 4px; }
    .about-bar[data-kind=school] + .about-bar[data-kind=work] { margin-top: var(--sp-2); }
    .about-timeline-bars { margin-bottom: var(--sp-4); }
    .about-row { padding: 3px 0; }
  }

  /* Contact: note + links on the top line, copyright on the bottom line (just above the floor
     clearance), the plug standing on the floor to their right. */
  .about-contact {
    display: flex;
    align-items: stretch;
    padding: var(--about-top) 0 var(--about-floor-gap) 0;
  }
  .about-contact-inner {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    width: calc(var(--about-col) + 120px);
    max-width: none;
  }
  .about-contact .copyright { margin-top: auto; }
  /* Only the slot's left edge matters (about-lamp.js stands the plug on the floor line there): one
     section gap after the text, and an end margin that keeps the plug clear of the fixed
     "Talk to YU-AI" button (right: 4vw, about 182px wide) when the track is scrolled to the end. */
  .about-plug-slot {
    display: block;
    flex: 0 0 auto;
    align-self: flex-end;
    width: 120px;
    height: 1px;
    margin: 0 calc(4vw + 240px) 0 var(--about-section-gap);
  }
}

/* One pointer on desktop: the round custom cursor (#custom-cursor, about-cursor.js) is the
   cursor, so the browser's own (the grey circle from main.css and the hover circles) is hidden.
   Text fields keep the text caret; over the 3D character the custom cursor becomes the YU-AI
   star (about-lift-chat.js). */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  body.about-page,
  body.about-page * { cursor: none !important; }
  body.about-page input,
  body.about-page textarea { cursor: text !important; }
  /* Panels above the custom cursor (the YU-AI chat, a project modal, previews, the detail card)
     keep the normal cursor; about-cursor.js hides the round one over them. */
  body.about-page #yu-ai-widget-root,
  body.about-page #yu-ai-widget-root *,
  body.about-page .pm-root,
  body.about-page .pm-root *,
  body.about-page .yu-ai-citation-preview,
  body.about-page .yu-ai-citation-preview *,
  body.about-page .about-detail,
  body.about-page .about-detail * { cursor: auto !important; }
  body.about-page #yu-ai-widget-root :is(a, button, [role=button]),
  body.about-page .pm-root :is(a, button, [role=button]),
  body.about-page .yu-ai-citation-preview :is(a, button),
  body.about-page .about-detail button,
  body.about-page .yu-lift-note,
  body.about-page .yu-lift-note * { cursor: pointer !important; }
  body.about-page #yu-ai-widget-root :is(input, textarea),
  body.about-page .pm-root :is(input, textarea) { cursor: text !important; }
}
