/* Theme tokens: dark is the default, light is set via data-theme on <html> */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0d; --surface: #131315; --surface-2: #17171a;
  --fg: #ededed; --fg-2: #c9c9cf; --muted: #8a8a92;
  --line: #232328; --line-2: #34343b;
  --accent: #ff5a36; --accent-text: #ff5a36; --on-accent: #141414;
  --grid: rgba(255,255,255,.045); --nav: rgba(12,12,13,.74);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1ea; --surface: #ffffff; --surface-2: #faf8f3;
  --fg: #151515; --fg-2: #34343a; --muted: #6a6a72;
  --line: #e3ded3; --line-2: #cfc8b9;
  --accent: #ff5a36; --accent-text: #c2381a; --on-accent: #141414;
  --grid: rgba(20,20,20,.06); --nav: rgba(244,241,234,.82);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.55 'Inter Tight', system-ui, sans-serif; -webkit-font-smoothing: antialiased; transition: background-color .3s ease, color .3s ease; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* nav */
nav { position: sticky; top: 0; z-index: 20; background: var(--nav); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
nav .wrap { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; text-decoration: none; }
.brand i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
nav ul { list-style: none; display: flex; gap: 24px; margin: 0; padding: 0; }
nav ul a { text-decoration: none; color: var(--muted); font-size: 14px; transition: color .2s; }
nav ul a:hover { color: var(--fg); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--fg); cursor: pointer; transition: border-color .2s, background-color .2s; }
.icon-btn:hover { border-color: var(--fg); }
.icon-btn svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }
@media (max-width: 760px) { nav ul { display: none; } }

/* hero */
.hero { position: relative; padding: 56px 0 52px; border-bottom: 1px solid var(--line); overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 70% 90% at 25% 40%, #000 35%, transparent 80%);
          mask-image: radial-gradient(ellipse 70% 90% at 25% 40%, #000 35%, transparent 80%); }
.hero-grid { position: relative; display: grid; grid-template-columns: 1fr 200px; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(56px, 8vw, 108px); line-height: .9; letter-spacing: -.05em; font-weight: 700; margin: 14px 0 18px; }
.lead { font-size: clamp(18px, 1.9vw, 22px); line-height: 1.45; color: var(--fg-2); max-width: 600px; margin: 0; }
.term { margin-top: 24px; display: inline-block; font: 13px/1.75 'JetBrains Mono', ui-monospace, monospace; color: var(--fg-2); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.term b { color: var(--accent-text); font-weight: 500; }
.caret { display: inline-block; width: 8px; height: 15px; margin-left: 2px; background: var(--accent); vertical-align: -3px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.portrait { width: 200px; aspect-ratio: 1 / 1; border-radius: 22px; overflow: hidden; border: 1px solid var(--line-2); background: var(--surface); }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 760px) {
  .hero { padding: 36px 0 40px; }
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .portrait { width: 132px; order: -1; border-radius: 18px; }
}

/* sections */
section { padding: 80px 0; border-bottom: 1px solid var(--line); }
.sec-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 36px; }
.sec-head .idx { font: 600 13px 'JetBrains Mono', monospace; color: var(--accent-text); }
.sec-head h2 { margin: 0; font-size: clamp(28px, 3.6vw, 40px); letter-spacing: -.03em; font-weight: 600; line-height: 1.1; }
.sec-head .aside { margin-left: auto; }
@media (max-width: 760px) { section { padding: 56px 0; } .sec-head .aside { display: none; } }

/* skills (level bars) */
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 56px; }
.skill { display: grid; grid-template-columns: 148px 1fr 52px; align-items: center; gap: 16px; padding: 6px 0; }
.skill .name { font-size: 15px; font-weight: 500; }
.segs { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.segs i { height: 10px; border-radius: 2px; background: var(--line-2); transition: background-color .2s ease var(--d, 0ms); }
.lit .segs i.on, html:not(.js) .segs i.on { background: var(--fg); }
.lit .skill.top .segs i.on, html:not(.js) .skill.top .segs i.on { background: var(--accent); }
.skill .lvl { font: 500 12px 'JetBrains Mono', monospace; color: var(--muted); text-align: right; }
@media (max-width: 760px) {
  .skills { grid-template-columns: 1fr; gap: 12px; }
  .skill { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .skill .segs { grid-column: 1 / -1; grid-row: 2; }
}

/* stack: parts-list table */
.spec { border-top: 1px solid var(--line); }
.spec-row { display: grid; grid-template-columns: 84px 190px 1fr; gap: 20px; align-items: baseline; padding: 18px 10px; border-bottom: 1px solid var(--line); border-radius: 10px; transition: background-color .2s; }
.spec-row:hover { background: var(--surface); }
.spec-row .n { font: 600 13px 'JetBrains Mono', monospace; color: var(--accent-text); }
.spec-row .t { font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.spec-row .d { color: var(--fg-2); font-size: 16px; line-height: 1.5; }
@media (max-width: 760px) { .spec-row { grid-template-columns: 60px 1fr; gap: 6px 12px; padding: 16px 4px; } .spec-row .d { grid-column: 2; } }

/* mini-game */
.game { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px; }
.game-top { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend .sw { width: 12px; height: 12px; display: inline-block; }
.sw.player { background: var(--accent); border-radius: 3px; }
.sw.coin { background: var(--fg); border-radius: 50%; }
.sw.bug { background: var(--muted); border-radius: 3px; }
.score { display: flex; align-items: center; gap: 16px; }
.score b { font: 600 14px 'JetBrains Mono', monospace; color: var(--accent-text); }
.btn-sm { border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 8px 16px; font: 600 14px 'Inter Tight', sans-serif; cursor: pointer; }
.game canvas { display: block; width: 100%; height: 300px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); touch-action: manipulation; cursor: pointer; }
.game-note { margin: 12px 0 0; font-size: 14px; color: var(--muted); }

/* engineering solutions (cards) */
.log { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 26px; transition: border-color .2s, transform .2s; }
.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card .n { font: 600 13px 'JetBrains Mono', monospace; color: var(--accent-text); }
.card h3 { margin: 12px 0 10px; font-size: 21px; line-height: 1.2; letter-spacing: -.02em; font-weight: 600; }
.card p { margin: 0; color: var(--fg-2); font-size: 16px; }
@media (max-width: 760px) { .log { grid-template-columns: 1fr; } }

/* interests + contact */
.interests { display: flex; flex-wrap: wrap; gap: 10px; }
.interests span { border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 14px; font-size: 15px; color: var(--fg-2); }
.big { display: inline-block; font-size: clamp(30px, 5.4vw, 64px); font-weight: 600; letter-spacing: -.03em; text-decoration: none; line-height: 1.1; border-bottom: 2px solid var(--accent); padding-bottom: 4px; word-break: break-word; }
.mail { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 18px; }
.copy-btn { width: 48px; height: 48px; flex: none; }
.copy-btn svg { width: 20px; height: 20px; }
.copy-btn .i-check, .copy-btn.copied .i-copy { display: none; }
.copy-btn.copied .i-check { display: block; color: var(--accent-text); }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 28px; padding-bottom: 40px; }

/* reveal on scroll — only when JS is available */
html.js .reveal { opacity: 0; transform: translateY(12px); transition: opacity .6s ease, transform .6s ease; }
html.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.js .reveal { opacity: 1; transform: none; transition: none; }
  .segs i { transition: none; }
  .caret { animation: none; }
}

/* language switch: a quiet link in the footer */
footer .lang { color: inherit; text-decoration: none; border-bottom: 1px solid var(--line-2); transition: color .2s, border-color .2s; }
footer .lang:hover { color: var(--fg); border-color: var(--fg); }
.interests-title { margin: 40px 0 14px; }
