/*
 * Quiet, dark and precise: near-black ground, a faint grain and glow, small
 * lowercase monospace labels, white for what matters and grey for the rest.
 * One muted teal accent. Printing switches to a plain white CV.
 */
:root {
  --bg: #0b0c0d;
  --text: #e9ebee;
  --body: #b4bac2;
  --muted: #6f7680;
  --faint: #3a3f45;
  --line: #1d2024;
  --accent: #5fb3b3;
  --tile: #121417;
  --glow: rgba(95, 179, 179, 0.10);
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Light mode: warm paper white, same calm hierarchy, a deeper teal. */
:root[data-theme="light"] {
  --bg: #f6f5f2;
  --text: #15171a;
  --body: #3f454c;
  --muted: #6b7178;
  --faint: #b9bec4;
  --line: #e3e1dc;
  --accent: #2c7f80;
  --tile: #ebe9e4;
  --glow: rgba(44, 127, 128, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

/* Dark / light switch, fixed in the top-right corner. */
.theme-toggle {
  position: fixed; top: 20px; right: 20px; z-index: 40;
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); border-radius: 50%;
  cursor: pointer; transition: color 0.2s, border-color 0.2s, background-color 0.4s var(--ease);
}
.theme-toggle:hover, .theme-toggle:focus-visible { color: var(--text); border-color: var(--faint); }
.theme-toggle svg { width: 16px; height: 16px; }
/* Shows the mode you would switch to: the sun in dark mode, the moon in light mode. */
.theme-toggle .moon, :root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }
@media (max-width: 820px) {
  .theme-toggle { top: 12px; right: 12px; width: 32px; height: 32px; }
}
::selection { background: var(--accent); color: var(--bg); }
img { max-width: 100%; display: block; }
a { color: var(--text); text-decoration: none; }
h1, h2, h3 { font-weight: 500; color: var(--text); }

/* Atmosphere */
.glow {
  position: fixed; inset: -20% -10% auto; height: 70vh; z-index: 0; pointer-events: none;
  background: radial-gradient(50% 60% at 60% 0%, var(--glow), transparent 70%);
}
.grain {
  position: fixed; inset: -50%; z-index: 0; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.5s steps(1) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-1%, 3%); }
}

/* Layout: a slim left column, the content on the right. */
.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 240px 1fr; gap: 72px;
  max-width: 1080px; margin: 0 auto; padding: 72px 28px 40px;
}
.side { position: sticky; top: 72px; align-self: start; display: flex; flex-direction: column; gap: 6px; }
.portrait {
  position: relative; width: 100%; max-width: 240px; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden;
  background: var(--tile); border: 1px solid var(--line); margin-bottom: 14px;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-fallback { display: none; position: absolute; inset: 0; place-items: center; color: var(--accent); font-size: 20px; }
.portrait.no-photo img { display: none; }
.portrait.no-photo .portrait-fallback { display: grid; }
.name { font-weight: 600; font-size: 17px; letter-spacing: 0.01em; }
.role { font-family: var(--mono); font-size: 11.5px; color: var(--muted); line-height: 1.6; }

/* Bracketed section links, the current one lit. */
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 28px; font-family: var(--mono); font-size: 13px; }
.nav a { color: var(--muted); text-transform: lowercase; transition: color 0.2s; width: fit-content; }
.nav a::before { content: '['; }
.nav a::after { content: ']'; }
.nav a:hover, .nav a.active { color: var(--text); }

.side-foot { margin-top: 28px; display: flex; flex-direction: column; gap: 10px; font-family: var(--mono); font-size: 12px; }
.lang-switch { display: flex; align-items: center; gap: 6px; color: var(--faint); }
.lang-switch button, .link-btn {
  font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted);
  text-transform: lowercase; transition: color 0.2s; width: fit-content;
}
.lang-switch button[aria-pressed="true"] { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
.lang-switch button:hover, .link-btn:hover { color: var(--text); }

/* Content */
.main { min-width: 0; }
section, .intro { padding-bottom: 64px; }
h1 { font-size: clamp(26px, 3.4vw, 34px); line-height: 1.2; letter-spacing: -0.01em; margin-bottom: 18px; }
.lede { font-size: 17px; color: var(--body); max-width: 36em; }
h2 {
  font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--muted);
  text-transform: lowercase; letter-spacing: 0.02em; margin-bottom: 20px;
}
h2::before { content: '— '; color: var(--faint); }
h3 { font-size: 15px; }
section > p { max-width: 40em; margin-bottom: 12px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Underlined links that light up. */
.links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 22px; font-family: var(--mono); font-size: 13px; }
.links a { color: var(--muted); border-bottom: 1px solid var(--faint); padding-bottom: 1px; transition: color 0.2s, border-color 0.2s; }
.links a:hover { color: var(--text); border-color: var(--accent); }

/* Key figures, as quiet numbers. */
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 200px)); gap: 18px 40px; margin-top: 32px; }
.figures dt { font-family: var(--mono); font-size: 22px; color: var(--text); }
.figures dd { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* Expertise */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 40px; }
.item p { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.item h3::before { content: '◦ '; color: var(--accent); }
.tags { margin-top: 30px; display: grid; gap: 12px; }
.tag-row { display: grid; grid-template-columns: 150px 1fr; gap: 16px; font-size: 13.5px; }
.tag-label { font-family: var(--mono); font-size: 12px; color: var(--muted); text-transform: lowercase; padding-top: 2px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px 0; color: var(--body); }
.tag-list > span:not(:last-child)::after { content: '·'; color: var(--faint); margin: 0 10px; }
/* Manufacturer names keep their own capitals; small heading above each group. */
.tag-label.brand { text-transform: none; color: var(--accent); }
.tag-heading { font-family: var(--mono); font-size: 12px; color: var(--muted); text-transform: lowercase; margin-top: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.tag-heading:first-child { margin-top: 0; }

/* How I train: numbered rows. */
.steps { list-style: none; counter-reset: s; display: grid; gap: 14px; }
/* Number in the left margin; the bold word and sentence flow as one paragraph. */
.steps li { counter-increment: s; position: relative; padding-left: 44px; font-size: 14.5px; }
.steps li::before { content: counter(s, decimal-leading-zero); position: absolute; left: 0; top: 3px; font-family: var(--mono); font-size: 12px; color: var(--accent); }
.steps strong { color: var(--text); font-weight: 500; }

/* Experience: date on the left, the job on the right. */
.row { display: grid; grid-template-columns: 130px 1fr; gap: 20px; padding: 18px 0; border-top: 1px solid var(--line); }
.row:last-child { border-bottom: 1px solid var(--line); }
.row-date { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px; }
.row-meta { font-family: var(--mono); font-size: 12px; color: var(--accent); margin: 2px 0 8px; }
.row ul { list-style: none; display: grid; gap: 4px; font-size: 14px; }
.row li::before { content: '– '; color: var(--faint); }
/* Earlier career, introduced by a quiet label. */
.row-group { font-family: var(--mono); font-size: 12px; color: var(--muted); text-transform: lowercase; margin: 40px 0 12px; }
/* Internships listed inside one row: title, dates, then the place below. */
.row .sub { gap: 12px; margin-top: 8px; }
.row .sub li::before { content: none; }
.sub b { color: var(--text); font-weight: 500; }
.sub .when { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 10px; }
.sub .where { display: block; font-size: 13.5px; color: var(--body); }
.h2-next { margin-top: 36px; }
/* Brand under each device card. */
.item-brand { font-family: var(--mono); font-size: 12px; color: var(--accent); margin: 2px 0 6px; }

/* Gallery */
.filters { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 20px; font-family: var(--mono); font-size: 12.5px; }
.filters button { font: inherit; background: none; border: 0; cursor: pointer; color: var(--muted); text-transform: lowercase; transition: color 0.2s; }
.filters button::before { content: '['; color: var(--faint); }
.filters button::after { content: ']'; color: var(--faint); }
.filters button[aria-selected="true"], .filters button:hover { color: var(--text); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.gallery-grid figure {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 6px;
  background: var(--tile); border: 1px solid var(--line); cursor: zoom-in;
}
.gallery-grid img {
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(0.35) brightness(0.85); transition: filter 0.5s var(--ease), transform 0.8s var(--ease);
}
.gallery-grid figure:hover img { filter: none; transform: scale(1.03); }
.gallery-grid figcaption {
  position: absolute; inset: auto 0 0; padding: 22px 12px 10px; font-size: 12.5px; color: var(--text);
  background: linear-gradient(to top, rgba(8, 9, 10, 0.88), transparent);
  opacity: 0; transform: translateY(6px); transition: opacity 0.3s, transform 0.3s var(--ease);
}
.gallery-grid figure:hover figcaption, .gallery-grid figure:focus-within figcaption { opacity: 1; transform: none; }
.gallery-grid figcaption small { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.gallery-empty {
  padding: 26px; border: 1px dashed var(--faint); border-radius: 6px; color: var(--muted);
  font-family: var(--mono); font-size: 12.5px;
}
code { font-family: var(--mono); color: var(--text); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(6, 7, 8, 0.95);
  display: flex; align-items: center; justify-content: center; gap: 12px; padding: 20px;
}
.lightbox[hidden] { display: none; }
.lightbox figure { max-width: min(1100px, 100%); text-align: center; }
.lightbox img { max-height: 80vh; width: auto; margin: 0 auto; border-radius: 4px; }
.lightbox figcaption { color: var(--body); margin-top: 12px; font-family: var(--mono); font-size: 12.5px; }
.lightbox button {
  background: none; color: var(--muted); border: 1px solid var(--faint); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; font-size: 20px; flex-shrink: 0; transition: color 0.2s;
}
.lightbox button:hover { color: var(--text); }
.lb-close { position: absolute; top: 18px; right: 18px; }

/* Education, languages */
.pairs { list-style: none; }
.pairs li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.pairs strong { color: var(--text); font-weight: 500; }
.pairs span { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; padding-top: 2px; white-space: nowrap; }

/* Footer */
.foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 18px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); text-transform: lowercase;
}

/* Sections settle in as they arrive. */
/* Hidden only once the script runs (html.js), so the page never stays blank. */
.js .reveal { opacity: 0; transform: translateY(10px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.js .reveal.seen { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .grain { animation: none; }
  html { scroll-behavior: auto; }
}

/* Phones and small tablets: the left column becomes a header. */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; gap: 36px; padding-top: 40px; }
  .side { position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; margin-top: 18px; }
  .side-foot { flex-direction: row; gap: 20px; margin-top: 14px; }
  .figures { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .tag-row { grid-template-columns: 1fr; gap: 4px; }
  .row { grid-template-columns: 1fr; gap: 4px; }
}

/* "Save CV as PDF": a clean white CV, without the gallery and the extras. */
@media print {
  @page { margin: 14mm; }
  :root, :root[data-theme="light"] { --bg: #fff; --text: #111; --body: #333; --muted: #666; --faint: #bbb; --line: #ddd; --accent: #0e6f73; }
  body { font-size: 10.5pt; background: #fff; }
  .no-print, .lightbox { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .side { position: static; margin-bottom: 14px; }
  .portrait { display: none; }
  .reveal { opacity: 1; transform: none; }
  section, .intro { padding-bottom: 18px; break-inside: avoid-page; }
  .row, .item, .steps li { break-inside: avoid; }
  a { color: inherit; }
}
