:root {
  --bg: #0d0f12;
  --surface: #161a20;
  --surface-2: #1e232b;
  --border: #2a303a;
  --text: #e8eaed;
  --muted: #9aa3ae;
  --accent: #ff6a3d;
  --accent-ink: #0d0f12;
  --radius: 12px;
  --max: 1080px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --border: #dde1e6;
    --text: #15181d;
    --muted: #5b6470;
    --accent: #d9481c;
    --accent-ink: #ffffff;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dde1e6;
  --text: #15181d;
  --muted: #5b6470;
  --accent: #d9481c;
  --accent-ink: #ffffff;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .95rem; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.controls { display: flex; align-items: center; gap: 10px; flex: none; }

/* Language switch */
.i18n-pending body { visibility: hidden; }
.lang-switch { display: flex; padding: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.lang-switch button {
  border: 0; border-radius: 999px; padding: 6px 9px; cursor: pointer;
  background: transparent; color: var(--muted);
  font-family: inherit; font-size: .75rem; font-weight: 700; line-height: 1; letter-spacing: .04em;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Theme switch */
.theme-switch {
  position: relative; flex: none; width: 56px; height: 30px; padding: 0; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
  transition: border-color .2s;
}
.theme-switch:hover, .theme-switch:focus-visible { border-color: var(--accent); }
.theme-switch .icon { position: absolute; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); color: var(--muted); }
.theme-switch .sun { left: 7px; }
.theme-switch .moon { right: 7px; }
.theme-switch .knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); transition: transform .2s ease;
}
.theme-switch[aria-checked="true"] .knob { transform: translateX(26px); }
@media (prefers-reduced-motion: reduce) { .theme-switch .knob { transition: none; } }

/* Sections */
section { padding: 72px 0; }
section + section { border-top: 1px solid var(--border); }
.eyebrow { color: var(--accent); font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.section-title { font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: 28px; }
.muted { color: var(--muted); }

/* Hero */
.hero { padding: 96px 0 80px; }
.hero .wrap { display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 800; margin-bottom: 12px; }
.hero .role { font-size: clamp(1.1rem, 2.2vw, 1.35rem); color: var(--muted); margin-bottom: 28px; }
.hero .role strong { color: var(--text); font-weight: 600; }
.hero-photo { width: 220px; aspect-ratio: 1; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px; font-weight: 600; font-size: .95rem;
  border: 1px solid var(--border); color: var(--text); background: var(--surface);
  transition: border-color .15s, transform .15s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* About */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 48px; }
.facts { list-style: none; margin: 0; padding: 20px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.facts li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.facts li:last-child { border-bottom: 0; }
.facts span:first-child { color: var(--muted); }
.facts span:last-child { text-align: right; }
.skills h3 { font-size: .8rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 24px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding: 0; list-style: none; }
.tags li { padding: 4px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .85rem; }

/* Timeline */
.timeline { display: grid; gap: 16px; }
.job { display: grid; grid-template-columns: 160px 1fr; gap: 24px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.job .when { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.job h3 { font-size: 1.15rem; margin-bottom: 2px; }
.job .where { color: var(--accent); font-weight: 600; font-size: .95rem; margin-bottom: 10px; }
.job ul { margin: 0; padding-left: 18px; color: var(--muted); }
.job li + li { margin-top: 4px; }

/* Projects */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: border-color .2s, transform .2s;
}
.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-3px); }
.card img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; background: var(--surface-2); }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { font-size: 1.15rem; margin: 0; }
.card .meta { color: var(--muted); font-size: .9rem; }
.card .more { margin-top: auto; padding-top: 8px; color: var(--accent); font-weight: 600; font-size: .9rem; }

/* Contact */
.contact-links { display: flex; flex-wrap: wrap; gap: 12px; }

footer { padding: 32px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; }

/* Project page */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .95rem; margin-bottom: 20px; }
.project-head { padding: 48px 0 24px; }
.project-head h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; }
.project-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 40px; align-items: start; padding-bottom: 72px; }
.project-grid h2 { font-size: 1.3rem; margin-top: 32px; }
.project-grid ul { padding-left: 18px; }
.project-grid li + li { margin-top: 6px; }
.info { position: sticky; top: 84px; }
.info dl { margin: 0; padding: 20px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.info dt { color: var(--muted); font-size: .85rem; }
.info dd { margin: 0 0 12px; font-weight: 500; }
.info dd:last-child { margin-bottom: 0; }

.video {
  position: relative; aspect-ratio: 16 / 9; width: 100%; padding: 0; border: 0; cursor: pointer;
  border-radius: var(--radius); overflow: hidden; background: #000 center / cover no-repeat;
}
.video::after {
  content: ""; position: absolute; inset: 50% auto auto 50%; width: 72px; height: 50px; transform: translate(-50%, -50%);
  border-radius: 12px; background: rgba(0, 0, 0, .7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center / 28px no-repeat;
  transition: background-color .15s;
}
.video:hover::after, .video:focus-visible::after { background-color: var(--accent); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video.playing::after { display: none; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
.gallery a { border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.gallery img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; transition: transform .25s; }
.gallery a:hover img { transform: scale(1.04); }

.lightbox { padding: 0; border: 0; background: transparent; max-width: 96vw; max-height: 92vh; }
.lightbox::backdrop { background: rgba(0, 0, 0, .88); }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }
.lightbox button {
  position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.4rem; cursor: pointer;
}
.lightbox button:hover { background: var(--accent); }
.lightbox .prev { left: 16px; }
.lightbox .next { right: 16px; }
.lightbox .close { top: 32px; right: 16px; transform: none; }

/* Responsive */
@media (max-width: 820px) {
  section { padding: 56px 0; }
  .hero { padding: 56px 0; }
  .hero .wrap { grid-template-columns: 1fr; gap: 28px; }
  .hero-photo { width: 140px; order: -1; }
  .about-grid, .project-grid { grid-template-columns: 1fr; gap: 28px; }
  .info { position: static; }
  .job { grid-template-columns: 1fr; gap: 6px; padding: 20px; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  html { scroll-padding-top: 112px; }
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 6px; row-gap: 6px; }
  .controls { order: 2; }
  .nav { order: 3; width: 100%; margin-left: -7px; gap: 0; }
  .nav a { padding: 6px 7px; font-size: .9rem; }
  .projects { grid-template-columns: 1fr; }
}
