/* Pixel visual system adapted from The Bartle Test of Gamer Psychology (cyber / nudge). */
:root {
  --o: #ef5826; --o-deep: #d83d0a; --o-soft: #fde6dc;
  --t: #1ea6b9; --t-deep: #168293; --t-soft: #d6f0f3;
  --ink: #2a2422; --px: 4px;
  --pixel: "Press Start 2P", ui-monospace, "Courier New", monospace;
  --mono: "VT323", ui-monospace, "Courier New", monospace;
  --body: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-theme="cyber"] {
  --bg: #0d1117; --bg2: #161b22; --card: #161b22; --text: #e6edf3; --muted: #9aa4af;
  --line: #ef5826; --accent: #1ea6b9; --head: #ef5826; --shadow: #d83d0a;
  --glow: 0 0 8px rgba(239, 88, 38, .6); --on-o: #0d1117; --link: #4cc9db; --focus: #f2c14e;
}
[data-theme="nudge"] {
  --bg: #fffaf7; --bg2: #fde6dc; --card: #ffffff; --text: #2a2422; --muted: #5f5450;
  --line: #2a2422; --accent: #137081; --head: #c43508; --shadow: #ef5826; --glow: none;
  --on-o: #1a1210; --link: #0f6372; --focus: #0b4f5c;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  background: var(--bg); color: var(--text); font-family: var(--body);
  font-size: 17px; line-height: 1.7; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; overflow-wrap: break-word;
  transition: background .3s, color .3s;
}
[data-theme="cyber"] body {
  background-image:
    linear-gradient(rgba(30, 166, 185, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 166, 185, .06) 1px, transparent 1px);
  background-size: 24px 24px;
}
[data-theme="cyber"] body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 90;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px);
}
a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--head); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
main:focus { outline: none; }
ul, ol { list-style: none; }
code { font-family: var(--mono); font-size: 1.15em; background: var(--bg2); padding: 0 .3em; }

.skip {
  position: absolute; left: 8px; top: -80px; z-index: 100; padding: 12px 16px; min-height: 44px;
  background: var(--o); color: var(--on-o); font-family: var(--pixel); font-size: 10px; text-decoration: none;
}
.skip:focus { top: 8px; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 18px; }
.muted, .fine { color: var(--muted); }
.fine { font-size: 14px; }

/* header */
.top { background: var(--bg2); border-bottom: var(--px) solid var(--line); }
.bar { display: flex; align-items: center; gap: 8px 20px; min-height: 68px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.logo {
  font-family: var(--pixel); font-size: 13px; color: var(--head); text-shadow: var(--glow);
  text-decoration: none; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center;
}
.logo span { color: var(--accent); }
.nav { flex: 1 1 auto; }
.nav ul { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  font-family: var(--pixel); font-size: 10px; text-decoration: none; color: var(--text);
  border-bottom: 3px solid transparent;
}
.nav a:hover { color: var(--head); }
.nav a[aria-current="page"] { border-bottom-color: var(--o); color: var(--head); }
#theme-toggle { margin-left: auto; min-width: 44px; min-height: 44px; padding: 0; display: inline-grid; place-items: center; }
#theme-toggle svg { width: 24px; height: 24px; display: block; }

/* boxes & buttons */
.pbox { background: var(--card); border: var(--px) solid var(--line); box-shadow: 6px 6px 0 var(--shadow); position: relative; }
.btn {
  font-family: var(--pixel); font-size: 11px; line-height: 1.5; min-height: 44px; min-width: 44px;
  padding: 10px 16px; cursor: pointer; border: 3px solid var(--line);
  background: var(--o); color: var(--on-o); text-align: left;
  box-shadow: 4px 4px 0 var(--ink); transition: transform .06s, box-shadow .06s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
[data-theme="cyber"] .btn { box-shadow: 4px 4px 0 #000, var(--glow); }
.btn:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); color: var(--on-o); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { color: var(--head); }
.btn.teal { background: var(--t); color: var(--on-o); }
.btn.teal:hover { color: var(--on-o); }
.btn.sm { font-size: 9px; padding: 8px 10px; }
.btn.big { font-size: 12px; padding: 14px 22px; }
[hidden] { display: none !important; } /* author display rules (.btn) must not defeat the hidden attribute (no-JS theme toggle) */
.actions { display: flex; flex-wrap: wrap; gap: 16px; }

/* layout */
main.wrap { flex: 1; padding-top: 40px; padding-bottom: 72px; }
.screen { display: flex; flex-direction: column; gap: 56px; }
.sec-title { font-family: var(--pixel); font-size: 12px; font-weight: 400; color: var(--accent); display: flex; align-items: center; gap: 12px; margin-bottom: 20px; line-height: 1.5; }
.sec-title::before { content: ""; width: 12px; height: 12px; background: var(--o); flex: 0 0 auto; }
.lede { font-size: 19px; line-height: 1.7; color: var(--text); max-width: 60ch; }
h1, h2, h3 { line-height: 1.3; }

/* hero */
.hero { display: grid; gap: 44px; align-items: center; }
.hero-copy { display: flex; flex-direction: column; gap: 22px; align-items: flex-start; min-width: 0; }
.hero h1 {
  font-family: var(--pixel); font-weight: 400; font-size: clamp(30px, 9vw, 60px); line-height: 1.25; color: var(--head);
}
[data-theme="cyber"] .hero h1 { text-shadow: 4px 4px 0 var(--t-deep), 0 0 18px rgba(239, 88, 38, .6); }
.term { overflow: hidden; min-width: 0; }
.term-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg2); border-bottom: 3px solid var(--line); font-family: var(--mono); font-size: 18px; color: var(--muted); }
.term-bar i { width: 12px; height: 12px; background: var(--o); display: block; }
.term-bar i:nth-child(2) { background: var(--t); }
.term-bar i:nth-child(3) { background: #f2c14e; }
.term-bar span { margin-left: 8px; overflow-wrap: anywhere; }
.term-body { font-family: var(--mono); font-size: 22px; line-height: 1.5; padding: 20px 18px 24px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.ps { color: var(--head); }
.cursor { display: inline-block; width: 12px; height: 22px; vertical-align: text-bottom; background: var(--t); animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* project heads & cards */
.phead { display: grid; gap: 28px; padding: 32px 24px; align-items: center; }
.phead.single { gap: 0; }
.phead-copy { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; min-width: 0; }
.phead h1, .phead h3 { font-family: var(--pixel); font-weight: 400; font-size: clamp(18px, 5.2vw, 32px); line-height: 1.45; color: var(--head); overflow-wrap: anywhere; }
.phead h3 { font-size: clamp(16px, 4.4vw, 24px); }
.phead h3 a { color: inherit; text-decoration: none; }
.phead h3 a:hover { text-decoration: underline; }
[data-theme="nudge"] .phead { background: linear-gradient(135deg, var(--o-soft), var(--t-soft)); }
.badge {
  width: 64px; height: 64px; display: grid; place-items: center; flex: 0 0 auto;
  font-family: var(--pixel); font-size: 11px; background: var(--o); color: var(--on-o); border: 3px solid var(--line); box-shadow: 4px 4px 0 var(--ink);
}
.tokens { display: flex; flex-wrap: wrap; gap: 8px; }
.token { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 10px; font-family: var(--mono); font-size: 20px; line-height: 1; background: var(--bg); color: var(--text); border: 2px solid var(--accent); }
.cards { display: grid; gap: 28px; grid-template-columns: 1fr; }
.card { padding: 24px 22px 26px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.card-img { display: block; width: 100%; max-width: 384px; height: auto; aspect-ratio: 3 / 2; image-rendering: pixelated; image-rendering: -moz-crisp-edges; border: 2px solid var(--line); }
.card h2 { font-size: 20px; }
.card h2 a { color: var(--text); }
.card h2 a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable, link stays the focus target */
.card-live, .card-live a { position: relative; z-index: 1; } /* above the card-wide overlay so live links remain clickable */
.card:focus-within { outline: 3px solid var(--focus); outline-offset: 4px; }
.card a:focus-visible { outline: none; }
.post-card { padding: 24px 22px; display: flex; flex-direction: column; gap: 8px; }
.post-card h2, .post-card h3 { font-size: 22px; }
.posts { display: flex; flex-direction: column; gap: 28px; }
.meta { font-family: var(--mono); font-size: 20px; color: var(--muted); line-height: 1.3; }
.flag { color: var(--head); text-transform: uppercase; }

/* OSV board (original CSS art) */
.osv-art { margin: 0; width: min(100%, 220px); justify-self: start; }
.art-credit { margin: 8px 0 0; font-family: var(--mono); font-size: 15px; line-height: 1.3; color: var(--muted, var(--text)); }
.art-credit a { color: inherit; }
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: 100%; aspect-ratio: 1; padding: 8px; background: var(--ink); border: 3px solid var(--line); justify-self: start; image-rendering: pixelated; }
.board i { display: block; background: #2f2a28; }
.board .c-o { background: var(--o); } .board .c-t { background: var(--t); } .board .c-c { background: #f2c14e; box-shadow: inset 0 0 0 3px var(--ink); }

/* prose */
.prose { max-width: 70ch; }
.prose h2 { font-family: var(--pixel); font-weight: 400; font-size: 14px; line-height: 1.6; color: var(--accent); margin: 48px 0 16px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose ul { margin-bottom: 18px; }
.prose ul { list-style: square; padding-left: 1.4em; }
.prose li { margin-bottom: 8px; padding-left: .2em; }
.prose li::marker { color: var(--o); }
.prose pre { max-width: 100%; overflow-x: auto; margin: 0 0 18px; padding: 12px 14px; background: var(--bg2); font-family: var(--mono); font-size: 18px; line-height: 1.4; }
.prose pre code { background: none; padding: 0; font-size: 1em; }
.credit-box { padding: 20px 22px; margin: 8px 0 0; }
.credit-box p:last-child { margin-bottom: 0; }
.sources { padding: 22px 22px 24px; max-width: 70ch; }
.sources ul { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.notice { border: 3px solid var(--o); background: rgba(239, 88, 38, .14); padding: 18px 20px; max-width: 70ch; }
.notice p + p { margin-top: 10px; }

/* résumé */
.provenance { max-width: 70ch; margin-top: -24px; }
.toc { padding: 12px 14px; }
.toc ul { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.toc a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; font-family: var(--pixel); font-size: 10px; text-decoration: none; }
.cv { max-width: 78ch; }
.cv h2 { font-family: var(--pixel); font-weight: 400; font-size: 14px; color: var(--accent); margin: 56px 0 20px; padding-bottom: 12px; border-bottom: 3px solid var(--line); line-height: 1.6; }
.cv h2:first-child { margin-top: 0; }
.cv h3 { font-size: 20px; margin: 36px 0 4px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; }
.cv h3 .date, .cv .date { font-family: var(--mono); font-size: 21px; font-style: normal; color: var(--head); font-weight: 400; }
.cv .role + .role { margin-top: 8px; }
.cv .company, .cv .org, .cv .school { font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.cv .location { font-weight: 400; font-style: normal; }
.cv .location::before { content: "· "; }
.cv p { margin-bottom: 12px; }
.cv ul { list-style: square; padding-left: 1.4em; margin-bottom: 16px; }
.cv li { margin-bottom: 8px; }
.cv li::marker { color: var(--o); }
.cv h3.skill-category { font-family: var(--mono); font-size: 24px; font-weight: 400; margin-top: 24px; color: var(--accent); }
.cv h3.skill-category + ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.cv h3.skill-category + ul li { margin: 0; padding: 2px 10px; border: 2px solid var(--accent); font-family: var(--mono); font-size: 20px; line-height: 1.4; }

/* footer */
.foot { border-top: var(--px) solid var(--line); background: var(--bg2); padding: 28px 0 36px; font-size: 14px; color: var(--muted); }
.foot .wrap { display: flex; flex-direction: column; gap: 16px; }
.foot-nav ul, .foot-nav li { }
.foot-nav ul { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.foot-nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 14px;
  font-family: var(--pixel); font-size: 10px; text-decoration: none; color: var(--text); border: 3px solid var(--line); background: var(--card);
}
.foot-nav a:hover { background: var(--o); color: var(--on-o); }
.foot .small { font-family: var(--mono); font-size: 18px; }

@media (min-width: 720px) {
  .wrap { padding: 0 32px; }
  body { font-size: 18px; }
  main.wrap { padding-top: 64px; }
  .hero { grid-template-columns: 1.15fr 1fr; gap: 56px; }
  .phead { padding: 44px 40px; grid-template-columns: 1fr auto; }
  .phead.single { grid-template-columns: 1fr; }
  .phead > .badge { display: none; }
  .project .phead { grid-template-columns: auto 1fr auto; }
  .project .phead > .badge { display: grid; width: 96px; height: 96px; font-size: 14px; align-self: start; }
  .cards { grid-template-columns: 1fr 1fr; }
  .osv-art { width: 220px; justify-self: end; }
  .screen { gap: 72px; }
}
@media (min-width: 1000px) {
  .cards { grid-template-columns: 1fr 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .btn:hover, .btn:active { transform: none; }
}

/* support options (footer + project CTA) */
.cta { padding: 28px 24px 30px; max-width: 70ch; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.cta .sec-title { margin-bottom: 0; }
.support { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.support a, .support .unavailable, .foot-nav .unavailable {
  display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 44px; min-width: 44px; padding: 6px 14px;
  font-family: var(--pixel); font-size: 10px; line-height: 1.6; text-decoration: none; color: var(--text); border: 3px solid var(--line); background: var(--card);
}
.support a:hover { background: var(--o); color: var(--on-o); }
.unavailable { border-style: dashed !important; color: var(--muted) !important; cursor: not-allowed; }
.unavailable .note { font-family: var(--mono); font-size: 18px; margin-left: .4em; }

/* Screen: contact line is for print/PDF only (see print.css). */
.cv-contact { display: none; }
