/* TOKENS — dark is the default; light values live in the two blocks below (system preference + manual toggle) */
:root {
  --bg: #0e0f11;
  --tile: #15171a;
  --border: #23262b;
  --border-hi: #363a41;
  --text: #e6e8eb;
  --muted: #9aa0a8;
  --faint: #7c828a;
  --accent: hsl(205, 85%, 62%);
  --on-accent: #0e0f11;
  --header-bg: rgba(14, 15, 17, 0.8);
  --sans: 'Space Grotesk', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --header-h: 4rem;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  interpolate-size: allow-keywords;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f3f4f6;
    --tile: #ffffff;
    --border: #e1e4e8;
    --border-hi: #c9ced6;
    --text: #15171a;
    --muted: #4f5560;
    --faint: #696f77;
    --accent: hsl(205, 80%, 40%);
    --on-accent: #ffffff;
    --header-bg: rgba(243, 244, 246, 0.85);
  }
}
:root[data-theme='light'] {
  --bg: #f3f4f6;
  --tile: #ffffff;
  --border: #e1e4e8;
  --border-hi: #c9ced6;
  --text: #15171a;
  --muted: #4f5560;
  --faint: #696f77;
  --accent: hsl(205, 80%, 40%);
  --on-accent: #ffffff;
  --header-bg: rgba(243, 244, 246, 0.85);
}

/* RESET + BASE */
* { margin: 0; padding: 0; box-sizing: border-box; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 0.5rem); }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* HEADER — sticky, translucent; nav + theme / CV / language */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.top.scrolled { border-bottom-color: var(--border); }
/* reading progress: --p (0–1) set by the scroll handler */
.top::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(var(--p, 0));
  transform-origin: left;
}
.top-inner {
  max-width: 1200px;
  height: var(--header-h);
  margin-inline: auto;
  padding-inline: 1.5rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1.5rem;
}
.top nav { display: flex; gap: 1.25rem; font: 500 0.8rem var(--mono); color: var(--muted); }
.top nav a { position: relative; padding-block: 0.25rem; transition: color 0.2s; }
.top nav a::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.2s;
}
.top nav a:hover, .top nav a.active { color: var(--text); }
.top nav a:hover::after, .top nav a.active::after { transform: scaleX(1); }
.actions { display: flex; align-items: center; gap: 0.5rem; }
.theme-toggle, .pill {
  display: inline-grid;
  place-items: center;
  height: 2rem;
  min-width: 2rem;
  padding-inline: 0.65rem;
  border: 1px solid var(--border-hi);
  border-radius: 999px;
  font: 500 0.75rem var(--mono);
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s, transform 0.15s, rotate 0.5s var(--ease);
}
.theme-toggle { padding: 0; font-size: 1rem; }
.theme-toggle:hover, .pill:hover {
  color: var(--text);
  border-color: var(--text);
  background-color: color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateY(-1px);
}
.theme-toggle:active, .pill:active { transform: scale(0.94); }
/* the ◐ turns half a circle with the theme; same selector pair as the light tokens, so no spin on load */
:root[data-theme='light'] .theme-toggle { rotate: 180deg; }
@media (prefers-color-scheme: light) { :root:not([data-theme='dark']) .theme-toggle { rotate: 180deg; } }

/* BENTO GRID */
.bento {
  max-width: 1200px;
  margin-inline: auto;
  padding: 0.75rem 1.5rem 3rem;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}
.s4 { grid-column: span 4; }
.s6 { grid-column: span 6; }
.s8 { grid-column: span 8; }
.s12 { grid-column: span 12; }

.tile {
  display: flex;
  flex-direction: column;
  background: var(--tile);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  /* cursor spotlight: --mx/--my come from the body script, --spot fades in on hover */
  background-image: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 70%);
  transition: border-color 0.2s, transform 0.3s var(--ease), box-shadow 0.3s, background-color 0.2s, --spot 0.3s;
}
.tile:hover { border-color: var(--border-hi); --spot: color-mix(in srgb, var(--accent) 7%, transparent); }
.tile.p:hover { transform: translateY(-4px); box-shadow: 0 14px 30px -20px rgb(0 0 0 / 0.55); }

.label {
  display: block;
  font: 500 0.68rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}
/* section headings (h2.group): big title + a hairline that starts in the accent and fades out across the row */
.group {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 2.75rem 0.25rem 0.5rem;
  font: 700 clamp(1.5rem, 2.6vw, 2rem)/1.15 var(--sans);
  letter-spacing: -0.02em;
}
.group::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--border-hi) 8rem, transparent); /* accent melts into the hairline, which then fades out */
  transform-origin: left;
}
/* eyebrow labels that title a context tile (not the meta line on project cards) */
.tile:not(.p) > .label, .pitch > .label { font-size: 0.72rem; color: var(--accent); }

/* INTRO + PORTRAIT */
.intro { padding: 2.5rem; justify-content: center; }
.intro h1 { margin-top: 1rem; font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1.05; letter-spacing: -0.03em; }
.intro .role { margin-top: 1rem; font-size: 1.15rem; color: var(--muted); }
.intro .tagline { margin-top: 0.5rem; color: var(--muted); max-width: 46ch; font-weight: 300; }
.cta { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  border-radius: 10px;
  font-weight: 500;
  border: 1px solid var(--border-hi);
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.25s, transform 0.2s var(--ease);
}
.btn:hover { border-color: var(--text); transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { box-shadow: 0 8px 22px -10px var(--accent); }
/* the arrow nudges toward where the button goes: → default, ↓ (.d) scrolls down, ↗ (.e) leaves the site */
.btn .arr { display: inline-block; transition: transform 0.25s var(--ease); }
.btn:hover .arr { transform: translateX(3px); }
.btn:hover .arr.d { transform: translateY(3px); }
.btn:hover .arr.e { transform: translate(2px, -2px); }
.open { margin-top: 1.75rem; font-size: 0.92rem; color: var(--muted); }
.open span { display: block; margin-bottom: 0.3rem; font: 500 0.65rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }

/* WORK / EXPERIENCE / PROJECT TILES */
.metric-label { margin-top: 0.4rem; font-size: 0.8rem; color: var(--faint); }
/* headline: what the project shows, in words; .metric-label under it carries the hard facts */
.hl { margin-top: 1.25rem; font: 500 1.08rem/1.35 var(--sans); color: var(--accent); text-wrap: balance; }
.tile h3 { margin-top: 1.25rem; font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
.tile h3 a { transition: color 0.2s; }
.tile h3 a:hover { color: var(--accent); }
.ext { font-size: 0.7em; color: var(--faint); }
.sublinks { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; font: 500 0.75rem var(--mono); color: var(--accent); }
.sublinks a:hover { text-decoration: underline; }
.desc { margin-top: 0.6rem; color: var(--muted); font-size: 0.92rem; }
.desc a, .about p a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color 0.2s; }
.desc a:hover, .about p a:hover { color: var(--text); }

/* figure: one per tile, 3:2, and a link to the project (live demo when there is one) */
.shot-link {
  position: relative;
  display: block;
  margin-bottom: 1.25rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s;
}
.shot { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; transition: transform 0.5s var(--ease); }
.shot-link:hover { border-color: var(--border-hi); }
.tile.p:hover .shot, .shot-link:focus-visible .shot { transform: scale(1.04); }
/* wide card (Quant, Activities): the .tile.p shape across the row: figure | text, then details and tags at full width.
   Inside details, .cols repeats the split (photo or text | text) so the open card stays balanced */
.tile.p.wide, .wide .cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.5rem; align-items: start; }
.wide .shot-link { margin-bottom: 0; }
.wide > details, .wide > .tags { grid-column: 1 / -1; }
/* .flip alternates the photos: the figure stays left, the details photo goes right, so the details text sits
   under the toggle and the two photos are not stacked in one column */
.flip .cols > div { grid-column: 1; grid-row: 1; }
.flip .cols > .pic { grid-column: 2; grid-row: 1; }
/* ↗ badge: ::before is the circle, ::after the arrow — an SVG mask (not a font glyph) so it is
   optically centred (path sits 1 unit down-left so the head's weight balances) and takes --accent in both themes. z-index keeps both above the zoomed image.
   border-box is explicit: the global `*` reset doesn't reach pseudo-elements, and the ring's 1px
   border would otherwise make it 2px bigger than the arrow box and shift its centre */
.shot-link::before, .shot-link::after {
  content: '';
  box-sizing: border-box;
  position: absolute;
  z-index: 1;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.25s var(--ease);
}
.shot-link::before { border: 1px solid var(--border-hi); border-radius: 50%; background: var(--tile); }
.shot-link::after {
  z-index: 2;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 18 16 8M7 8h9v9'/%3E%3C/svg%3E") center / 1.125rem no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 18 16 8M7 8h9v9'/%3E%3C/svg%3E") center / 1.125rem no-repeat;
}
.tile.p:hover .shot-link::before, .tile.p:hover .shot-link::after,
.shot-link:focus-visible::before, .shot-link:focus-visible::after { opacity: 1; transform: none; }
@media (hover: none) { .shot-link::before, .shot-link::after { opacity: 0.9; transform: none; } }

/* schematic diagrams (no data): same 3:2 frame as the figures, drawn in the page palette */
.diagram { background: var(--bg); }
.diagram .box { fill: var(--tile); stroke: var(--border-hi); }
.diagram .box.out { stroke: var(--accent); }
.diagram text { font: 500 15px var(--mono); fill: var(--text); text-anchor: middle; }
.diagram text.muted { font-size: 12.5px; fill: var(--muted); }
.diagram text.sub { font-size: 11px; letter-spacing: 0.08em; fill: var(--faint); text-anchor: start; }
.diagram .arrow { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.diagram .head { fill: var(--accent); }
/* hovering the card makes the pipeline arrows flow */
.tile:hover .diagram .arrow { stroke-dasharray: 5 4; animation: flow 0.8s linear infinite; }

details { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
summary {
  list-style: none;
  cursor: pointer;
  font: 500 0.72rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.2s;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: '+'; display: inline-block; width: 1.1em; color: var(--accent); transition: transform 0.3s var(--ease); }
details[open] summary::before { content: '\2212'; transform: rotate(180deg); }
/* slides open where ::details-content + interpolate-size exist; elsewhere it opens instantly, as before */
details::details-content { block-size: 0; overflow: clip; transition: block-size 0.35s var(--ease), content-visibility 0.35s allow-discrete; }
details[open]::details-content { block-size: auto; }
details[open] :is(p, .pic) { animation: rise 0.4s var(--ease) backwards; }
summary:hover { color: var(--text); }
details p { margin-top: 0.75rem; font-size: 0.9rem; color: var(--muted); }
/* one extra photo per card, shown only when "Contribution & learnings" is open; the .pic frame clips it so it can
   zoom on hover like the card figures (.shot) */
details .pic { margin-top: 0.75rem; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; }
details .pic img { display: block; width: 100%; height: auto; transition: transform 0.5s var(--ease); }
details .pic:hover img { transform: scale(1.04); }
details p strong { display: block; font-weight: 500; color: var(--text); font-size: 0.85rem; }

.tags { margin-top: auto; padding-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tags li { font: 500 0.7rem var(--mono); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.6rem; transition: transform 0.2s var(--ease), color 0.2s, border-color 0.2s, box-shadow 0.2s; }
/* tags are labels, not buttons: on hover they only lift (when motion is on) and light up in the accent */
.tags li:hover { color: var(--text); border-color: var(--accent); box-shadow: 0 0 12px -3px color-mix(in srgb, var(--accent) 60%, transparent); }
.motion .tags li:hover { transform: translateY(-2px); }

/* FOCUS / ABOUT / PHOTOS / SKILLS / CONTACT */
.focus li { padding: 0.8rem 0; border-top: 1px solid var(--border); }
.focus ul { margin-top: 0.75rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 1.5rem; }
.focus strong { display: block; margin-top: 0.15rem; font-weight: 500; }
.focus p { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.about p { margin-top: 0.9rem; color: var(--muted); font-size: 1rem; max-width: 62ch; }
.facts { margin-top: auto; padding-top: 1.5rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.facts li { padding-top: 0.6rem; border-top: 1px solid var(--border); font-size: 0.88rem; }
.facts li span { display: block; font: 500 0.65rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }

/* photo tiles: height follows the row. no aspect-ratio here — with a stretched height it would
   compute a wider width and overflow the column (media.css adds it only where the photo is alone in its row) */
.photo, .portrait { position: relative; margin: 0; padding: 0; overflow: hidden; min-height: 320px; }
/* calibration knob: where cover crops each 4:5 shot — keeps the face (and, for .photo, the hand) in frame */
.photo img, .portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.photo img { object-position: 50% 45%; }
.photo img, .portrait img { transition: transform 0.6s var(--ease); }
.photo:hover img, .portrait:hover img { transform: scale(1.03); }

/* skills: full width, groups in two columns */
.skills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; }
.skills > .label { grid-column: 1 / -1; }
.skills .grp { margin-top: 1rem; }
.skills .tags { margin-top: 0.4rem; padding-top: 0; }

/* contact: full-width band that closes the page — pitch left, link rows right */
/* two columns only while each gets ≥ 22rem, so the email row never runs out of room */
.contact { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1.5rem 3rem; align-items: center; }
.contact h3 { margin-top: 0.75rem; font-size: clamp(1.8rem, 3.5vw, 2.6rem); font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; }
.contact .open + .open { margin-top: 1rem; }
/* the address never breaks; on a very narrow phone the Copy pill wraps under it instead */
.contact li { display: flex; flex-wrap: wrap; align-items: center; column-gap: 0.5rem; border-top: 1px solid var(--border); }
.contact li:last-child { border-bottom: 1px solid var(--border); }
.contact a {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 0;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s, padding-left 0.25s var(--ease);
}
.copy { margin-block: 0.4rem; }
.copy.done { color: var(--accent); border-color: var(--accent); }
.contact a::after { content: '\2192'; margin-left: auto; color: var(--accent); opacity: 0; transform: translateX(-4px); transition: opacity 0.2s, transform 0.2s; }
.contact a:hover { color: var(--text); padding-left: 0.35rem; }
.contact a:hover::after, .contact a:focus-visible::after { opacity: 1; transform: none; }
.contact i { font-size: 1.2rem; color: var(--accent); }
.contact svg { width: 1.1rem; height: 1.1rem; flex: none; color: var(--accent); }
.credit { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem 2.5rem; font: 400 0.75rem var(--mono); color: var(--faint); }

/* MOTION — .motion is set on <html> by the head script, only when reduced motion is off */
@property --spot { syntax: '<color>'; inherits: false; initial-value: transparent; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes flow { to { stroke-dashoffset: -9; } }
@keyframes draw { from { transform: scaleX(0); } }
.motion .group.in::after { animation: draw 0.9s var(--ease) var(--d, 0s) backwards; }
/* scroll reveal: each tile rises in once, staggered by --d.
   `backwards`, not `both`: once done it hands transform back to :hover */
.motion main > :not(.in) { opacity: 0; }
.motion main > .in { animation: rise 0.6s var(--ease) var(--d, 0s) backwards; }
/* theme switch: the new theme grows as a circle from the toggle (--vx/--vy set in toggleTheme) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-wipe 0.55s var(--ease); }
@keyframes theme-wipe {
  from { clip-path: circle(0 at var(--vx) var(--vy)); }
  to { clip-path: circle(150vmax at var(--vx) var(--vy)); }
}
