/* Project pages (/projects/<id>/, /th/projects/<id>/) and the 404 page.
   Load order: tokens.css → fonts.css → project-page.css → i18n.css (flags, close button, Thai) → icons.css → minidemo/frame.css.
   Same calm system as the homepage: DM Sans + Anuphan, warm paper, one blue for actions and links. */
*,*::before,*::after{box-sizing:border-box}
:root{--header-h:64px;--page-max:1080px}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-padding-top:calc(var(--header-h) + 24px)}
@media (prefers-reduced-motion:no-preference){html{scroll-behavior:smooth}}
body{margin:0;padding-top:var(--header-h);background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:var(--fs-body);line-height:var(--lh-body);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
a{color:inherit;text-decoration:none}
button,input{font:inherit;color:inherit}
button,a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button{cursor:pointer}
button[hidden],[hidden]{display:none!important}
img,video{display:block;max-width:100%;height:auto}
figure{margin:28px 0}
figure img,video{width:100%;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface)}
figcaption,.caption{margin:8px 0 24px;font-size:var(--fs-xs);line-height:1.6;color:var(--muted)}
p{margin:0 0 18px;text-wrap:pretty}
h1,h2,h3,h4{font-weight:var(--fw-heading);line-height:var(--lh-heading);letter-spacing:var(--tr-heading);text-wrap:balance}
h1{margin:14px 0 20px;font-size:clamp(2.25rem,1.5rem + 3vw,4rem);line-height:var(--lh-display);letter-spacing:-.025em}
:lang(th) h1{letter-spacing:0}
h2{margin:36px 0 12px;font-size:1.375rem;letter-spacing:-.02em}
h3{font-size:1.1875rem}
h4{font-size:1.0625rem}
.skip{position:fixed;left:12px;top:-120px;z-index:200;padding:10px 16px;border-radius:var(--radius-sm);background:var(--surface);color:var(--ink);box-shadow:var(--shadow-2);font-weight:var(--fw-ui)}
.skip:focus{top:12px}

/* Header: logo · all work · flags. Fixed, not sticky (body has its height as top padding): html keeps scroll-padding-top,
   and a sticky header's own links would sit inside it, so each Tab stop on them scrolled the page up. */
/* Its padding is main's content box (max-width --page-max, gutter inside), so the logo starts on the h1's left edge and
   the flags end on the content's right edge. 100% is the viewport without its scrollbar (the header is fixed). */
.project-header{position:fixed;top:0;left:0;right:0;z-index:10;display:flex;align-items:center;gap:8px;min-height:var(--header-h);padding:0 max(var(--gutter),calc((100% - var(--page-max)) / 2 + var(--gutter)));background:rgb(247 247 245 / .92);-webkit-backdrop-filter:saturate(1.4) blur(10px);backdrop-filter:saturate(1.4) blur(10px);border-bottom:1px solid var(--line)}
.project-header .brand{display:inline-flex;align-items:center;min-height:44px;margin-right:8px;border-radius:var(--radius-sm)}
.project-header .brand img{display:block;width:auto;height:28px}
.back-link{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 12px;border-radius:var(--radius-pill);font-size:var(--fs-sm);font-weight:var(--fw-ui);color:var(--ink-2)}
.back-link:hover{background:var(--surface-2);color:var(--ink)}
.project-header .language-switch{margin-left:auto}

main{max-width:var(--page-max);margin:0 auto;padding:0 var(--gutter)}
.project-intro{max-width:760px;padding:56px 0 28px}
.eyebrow{font-size:var(--fs-sm);font-weight:var(--fw-ui);color:var(--muted)}
.lead{max-width:44rem;font-size:var(--fs-lead);line-height:1.6;color:var(--ink-2)}
:lang(th) .lead{line-height:var(--lh-body)}

/* Contribution first, then real links (the first one is the primary action), then quiet share actions. */
.project-contribution{margin:28px 0 20px;padding:20px 22px;border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface)}
.project-contribution h2{margin:4px 0 8px;font-size:1.125rem}
.project-contribution>p:not(.project-role){margin:0;color:var(--ink-2);line-height:1.75}
.project-contribution .project-part{margin:12px 0 0;padding-left:1.15em}
.project-contribution .project-part li{margin:6px 0;line-height:1.65;color:var(--ink-2)}
:lang(th) .project-contribution .project-part li{line-height:1.8}
.project-role{margin:0;font-size:var(--fs-sm);line-height:1.5;color:var(--muted)}
.case-links{display:flex;flex-wrap:wrap;gap:10px;margin:0;padding:0 0 12px}
.case-links a{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:0 18px;border:1px solid var(--line-strong);border-radius:var(--radius-pill);background:var(--surface);color:var(--ink);font-size:var(--fs-sm);font-weight:var(--fw-ui);overflow-wrap:anywhere;transition:background-color var(--dur-2),border-color var(--dur-2)}
.case-links a:hover{background:var(--surface-2)}
.project-primary-links a:first-child{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.project-primary-links a:first-child:hover{background:var(--accent-hover)}
.page-actions{display:flex;flex-wrap:wrap;align-items:center;gap:4px 16px;margin-top:8px}
.page-actions button,.page-actions a{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0;border:0;background:none;color:var(--ink-2);font-size:var(--fs-sm);font-weight:var(--fw-ui)}
.page-actions button:hover,.page-actions a:hover{color:var(--accent-ink)}
.share-status{min-height:0;margin:6px 0 0;font-size:var(--fs-xs);color:var(--accent-ink)}
.share-status:empty{display:none}
.copy-fallback{margin-top:12px}
.copy-fallback label{display:block;font-size:var(--fs-sm)}
.copy-fallback input{width:100%;padding:10px;border:1px solid var(--line-input);border-radius:var(--radius-sm);background:var(--surface)}

/* Body: one left edge for every text column (the intro's), and one width for the stacked demo and hero media
   (the page's content width; frame.css caps the demo section at 940 px elsewhere, so this override is more specific). */
main>.minidemo-section{max-width:none}
/* The one honest line under a demo whose poster already shows the hero image (that image is then a no-JS fallback). */
.minidemo-section .demo-line{margin:6px 0 0;font-size:var(--fs-xs);line-height:1.6;color:var(--muted)}
.hero-media figure{margin:0 0 32px}
.hero-media img{max-height:700px;object-fit:contain;background:var(--surface-2)}
.project-body{max-width:760px}
.project-body p,.project-body li{color:var(--ink-2)}
.project-body,.project-intro,.project-next>*{min-width:0}
.project-body p,.project-intro p,.project-next a{overflow-wrap:anywhere}
.project-brief{padding:20px 0}
.project-setting{padding:12px 16px;border-radius:var(--radius);background:var(--accent-soft);color:var(--accent-ink);font-size:var(--fs-sm);font-weight:var(--fw-ui)}
ul{padding-left:1.2em}
li{margin-bottom:8px}
li::marker{color:var(--subtle)}
/* Skill tags are pills, never a bulleted run of words, in both languages (beats the generic ul/li rules above). */
ul.skill-keywords{display:flex;flex-wrap:wrap;gap:6px 8px;margin:20px 0;padding:0;list-style:none}
ul.skill-keywords>li{display:inline-flex;align-items:center;max-width:100%;margin:0;padding:4px 12px;border:1px solid var(--line);border-radius:var(--radius-pill);background:var(--surface-2);color:var(--ink-2);font-size:var(--fs-xs);line-height:1.5;list-style:none;overflow-wrap:anywhere}
ul.skill-keywords>li::marker{content:none}
ul.skill-keywords>li::before{content:none}
.evidence-note{margin:24px 0;padding:12px 16px;border-left:2px solid var(--line-strong);font-size:var(--fs-sm);color:var(--muted)}
.project-delivery{margin-bottom:28px;padding-bottom:8px;border-bottom:1px solid var(--line)}
.project-delivery h2:first-child{margin-top:20px}
.project-context{padding:0 0 20px;border-top:1px solid var(--line)}
.flow-detail{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:10px;margin:10px 0 32px;padding:28px 20px;border-radius:var(--radius-lg);background:var(--surface-2)}
.flow-detail span{padding:10px 16px;border:1px solid var(--line-strong);border-radius:var(--radius-sm);background:var(--surface);font-size:var(--fs-sm)}
.flow-detail b{font-weight:400;color:var(--muted)}
/* Each arrow travels with the step it leads to, so a wrapped row starts with "→ step" and never ends on an arrow. */
.flow-detail .flow-next{display:inline-flex;align-items:center;gap:inherit;max-width:100%;padding:0;border:0;border-radius:0;background:none}
.hero-diagram{padding:64px 24px}
.project-media-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
.project-media-grid figure{margin:0}
.project-media-grid figure:has(video){grid-column:1/-1}
/* Each picture keeps its own shape (no letterbox frame around photos); a screenshot smaller than its column shows at
   its own size instead of being stretched soft. */
.project-media-grid img{width:auto;max-width:100%;height:auto;max-height:460px;margin-inline:auto;object-fit:contain}
.project-media h2{margin:40px 0 20px}
.scenario-pair{margin:28px 0}
.scenario-videos{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
.scenario-videos figure{margin:0}
.scenario-label{display:inline-block;margin-bottom:8px;padding:2px 10px;border-radius:var(--radius-pill);background:var(--surface-2);color:var(--ink-2);font-size:var(--fs-xs);font-weight:var(--fw-ui)}
.research-detail,.multimedia-results{margin:32px 0;padding-top:24px;border-top:1px solid var(--line)}
.research-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.research-stats>div{padding:18px 14px;border-radius:var(--radius);background:var(--surface-2)}
.research-stats strong{display:block;font-size:clamp(1.625rem,1.2rem + 1.4vw,2.25rem);color:var(--ink)}
.research-stats span{font-size:var(--fs-xs);color:var(--muted)}
.research-detail .connectivity-figure{max-width:620px;margin:auto}
.research-result{padding:24px;border-radius:var(--radius-lg);background:var(--dark);color:var(--on-dark)}
.research-result>span{font-size:var(--fs-xs);color:var(--on-dark-muted)}
.research-result>strong{display:block;font-size:clamp(2rem,1.4rem + 2.6vw,3.25rem);line-height:1.3}
.research-result small{font-size:1.25rem;color:var(--on-dark-muted)}
.research-result p{margin:6px 0;font-size:var(--fs-sm);color:var(--on-dark-2)}
.research-result a{color:var(--accent-on-dark)}
.research-limit{margin-top:18px;font-size:var(--fs-sm)}
.version-note{padding:14px 16px;border-left:2px solid var(--line-strong);background:var(--surface-2);font-size:var(--fs-sm)}
.research-detail .caption a{text-decoration:underline}
.results-kicker{font-size:var(--fs-xs);font-weight:var(--fw-ui);color:var(--muted)!important}
.results-highlight{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:24px 0}
.results-highlight>div{padding:18px 20px;border-radius:var(--radius);background:var(--dark);color:var(--on-dark)}
.results-highlight strong{display:block;font-size:clamp(1.75rem,1.3rem + 1.6vw,2.375rem);color:var(--on-dark)}
.results-highlight small{font-size:1.125rem}
.results-highlight span{font-size:var(--fs-xs);color:var(--on-dark-muted)}
.results-scroll-hint{font-size:var(--fs-xs);color:var(--muted)}
.results-table-wrap,.cleanup-table-wrap{max-width:100%;margin:20px 0;overflow-x:auto;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface)}
table{width:100%;min-width:520px;border-collapse:collapse;text-align:left;font-size:var(--fs-sm)}
caption{padding:14px 16px;text-align:left;font-weight:var(--fw-heading);background:var(--bg)}
th,td{padding:10px 16px;border-bottom:1px solid var(--line);vertical-align:top}
thead{background:var(--bg)}
thead th{font-size:var(--fs-xs);font-weight:var(--fw-ui);color:var(--muted)}
.results-reading,.results-caveat{font-size:var(--fs-sm)}
.cleanup-results{min-width:0;margin:32px 0}
.cleanup-results table{min-width:600px}
.cleanup-results tbody th{min-width:150px;font-weight:var(--fw-ui)}
.cleanup-results tfoot{font-weight:var(--fw-heading);background:var(--bg)}
.cleanup-results tfoot :is(th,td){border-bottom:0}
.cleanup-results .cleanup-units{font-size:var(--fs-xs);color:var(--muted);line-height:1.6}

/* Next project and footer */
.project-next{display:flex;justify-content:space-between;align-items:flex-end;gap:32px;margin:64px 0 40px;padding:28px 32px;border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface)}
.project-next span{display:block;margin-bottom:6px;font-size:var(--fs-sm);color:var(--muted)}
.project-next div a{display:inline-flex;align-items:center;gap:8px;min-height:44px;font-size:1.375rem;font-weight:var(--fw-heading);line-height:1.35;letter-spacing:-.02em}
.project-next div a:hover{color:var(--accent-ink)}
.project-next>a{display:inline-flex;align-items:center;gap:6px;min-height:44px;font-size:var(--fs-sm);font-weight:var(--fw-ui);color:var(--accent-ink);white-space:nowrap}
footer{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 20px;max-width:var(--page-max);margin:0 auto;padding:24px var(--gutter) 40px;border-top:1px solid var(--line);font-size:var(--fs-sm);color:var(--muted)}
footer a{display:inline-flex;align-items:center;gap:6px;min-height:44px;color:var(--ink-2)}
footer a:hover{color:var(--accent-ink)}

/* 404 */
.not-found .project-intro{padding-top:72px}

@media (max-width:650px){
  :root{--header-h:60px}
  .project-header{gap:2px;padding:0 8px 0 12px}
  .project-header .brand{margin-right:4px}
  .back-link{padding:0 10px}
  .project-intro{padding-top:36px}
  .project-contribution{padding:16px}
  .case-links a{flex:1 1 auto}
  .project-media-grid,.scenario-videos{grid-template-columns:minmax(0,1fr);gap:16px}
  .project-media-grid img{height:auto;max-height:500px}
  .project-next{flex-direction:column;align-items:flex-start;gap:16px;margin-top:44px;padding:22px}
  .project-next div a{font-size:1.25rem}
  .research-stats>div{padding:12px 10px}
  .flow-detail{gap:8px;padding:22px 12px}
  .flow-detail span{padding:8px 11px}
  .hero-diagram{padding:40px 15px}
  .results-highlight>div{padding:14px}
  footer{flex-direction:column}
}
/* The back link keeps its words for screen readers and shows only the arrow: a 44 px round target. */
@media (max-width:360px){
  .back-link{min-width:44px;justify-content:center}
  .back-link span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
}
@media print{body{padding-top:0}.project-header{position:static}}
