/* ------------------------------------------------------------------
   metinalpdogan.com
   ------------------------------------------------------------------ */

:root {
  --bg: #f5f4ef;
  --surface: #ecebe4;
  --fg: #16171a;
  --muted: #55585f;
  --faint: #8a8d93;
  --rule: #dcdad2;
  --accent: #b4540a;
  --accent-ink: #fff8ee;
  --link: #9a4508;
  --featured: rgba(214, 140, 30, 0.085);
  --chart-bar: #c9c6bc;

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --measure: 880px;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f12;
    --surface: #15181d;
    --fg: #e7e5df;
    --muted: #a2a5ac;
    --faint: #6d7179;
    --rule: #23272e;
    --accent: #f2b54a;
    --accent-ink: #14110a;
    --link: #f2c46e;
    --featured: rgba(242, 181, 74, 0.06);
    --chart-bar: #3a3f48;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d0f12;
  --surface: #15181d;
  --fg: #e7e5df;
  --muted: #a2a5ac;
  --faint: #6d7179;
  --rule: #23272e;
  --accent: #f2b54a;
  --accent-ink: #14110a;
  --link: #f2c46e;
  --featured: rgba(242, 181, 74, 0.06);
  --chart-bar: #3a3f48;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { display: block; max-width: 100%; }

a { color: var(--link); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
b { font-weight: 600; }
sub, sup { line-height: 0; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.page { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- nav ---------- */

.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.scrolled { border-bottom-color: var(--rule); }
.brand { font-family: var(--mono); font-size: 13px; color: var(--fg); text-decoration: none; letter-spacing: .01em; }
.nav nav { display: flex; align-items: center; gap: 22px; }
.nav nav a { font-family: var(--mono); font-size: 13px; color: var(--muted); text-decoration: none; }
.nav nav a:hover { color: var(--fg); }
.theme-toggle { display: grid; place-items: center; width: 28px; height: 28px; color: var(--muted); border-radius: 6px; }
.theme-toggle:hover { color: var(--fg); background: var(--surface); }

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 48px;
  align-items: start;
  padding: 56px 0 8px;
}
.kicker {
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 14px;
}
.hero h1 { font-size: clamp(36px, 5.4vw, 50px); line-height: 1.05; font-weight: 500; letter-spacing: -0.025em; margin-bottom: 22px; }
.hero-text p { color: var(--muted); margin-bottom: 14px; max-width: 58ch; }
.hero-text .lede { color: var(--fg); font-size: 17.5px; line-height: 1.58; }

.links { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 0; margin: 22px 0 0; }
.links a {
  display: inline-block; font-family: var(--mono); font-size: 13px; text-decoration: none;
  color: var(--fg); padding: 5px 11px; border: 1px solid var(--rule); border-radius: 999px;
  transition: border-color .15s, background .15s;
}
.links a:hover { border-color: var(--accent); background: var(--featured); }

/* portrait: an <img> that a canvas takes over to run reverse diffusion */
.portrait { margin: 6px 0 0; }
.portrait-frame {
  position: relative; display: block; width: 100%; aspect-ratio: 1;
  border-radius: 14px; overflow: hidden; background: var(--surface); cursor: crosshair;
}
.portrait-frame img, .portrait-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.portrait-frame canvas { opacity: 0; }
.portrait.live .portrait-frame canvas { opacity: 1; }
.portrait figcaption {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 9px;
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
}
.portrait figcaption .hint { opacity: 0; transition: opacity .2s; }
.portrait:hover figcaption .hint, .portrait:focus-within figcaption .hint { opacity: 1; }

/* ---------- education ---------- */

.block-first { padding-top: 44px; }
.edu { list-style: none; margin: 0; padding: 0; }
.edu li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 4px 24px;
  padding: 10px 0; border-top: 1px solid var(--rule);
}
.edu li:last-child { border-bottom: 1px solid var(--rule); }
.edu-what { font-size: 15px; color: var(--muted); line-height: 1.5; }
.edu-what b { color: var(--fg); font-weight: 600; }
.edu-note { display: block; font-family: var(--mono); font-size: 12px; color: var(--faint); margin-top: 2px; }
.edu-when { font-family: var(--mono); font-size: 12.5px; color: var(--faint); white-space: nowrap; }

/* ---------- sections ---------- */

.block { padding-top: 64px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-h { font-size: 22px; font-weight: 500; letter-spacing: -0.015em; }
.block > .section-h { margin-bottom: 18px; }
.section-note { font-family: var(--mono); font-size: 12px; color: var(--faint); }

/* news */
.news { list-style: none; margin: 0; padding: 0; }
.news li { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 7px 0; font-size: 15px; color: var(--muted); }
.news .date { font-family: var(--mono); font-size: 12.5px; color: var(--faint); padding-top: 2px; }
.news b { color: var(--fg); }

/* publication / project entries */
.entry {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px;
  padding: 18px; margin: 0 -18px 6px; border-radius: 10px;
}
.entry.featured { background: var(--featured); box-shadow: inset 2px 0 0 var(--accent); }
.entry h3 { font-size: 16.5px; line-height: 1.38; margin-bottom: 6px; }
.entry h3 a { color: var(--fg); text-decoration: none; }
.entry h3 a:hover { color: var(--link); }
.authors { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.authors b { color: var(--fg); }
.venue { font-size: 14px; color: var(--fg); margin-bottom: 8px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent); padding: 2px 7px; border-radius: 4px; line-height: 1.5;
}
.badge-outline { color: var(--accent); background: transparent; box-shadow: inset 0 0 0 1px var(--accent); }
.tldr { font-size: 14.5px; line-height: 1.55; color: var(--muted); margin-bottom: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.actions a { font-family: var(--mono); font-size: 12.5px; }
.actions a::before { content: "["; color: var(--faint); margin-right: 1px; }
.actions a::after { content: "]"; color: var(--faint); margin-left: 1px; }

/* thumbnails */
.thumb {
  position: relative; display: block; align-self: start;
  width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
a.thumb img { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
a.thumb:hover img { transform: scale(1.03); }

.tile { display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 16px; text-decoration: none; }
.tile-k { font-family: var(--mono); font-size: 10.5px; color: var(--faint); letter-spacing: .03em; }
.tile-big { font-family: var(--mono); font-size: 21px; font-weight: 500; color: var(--fg); letter-spacing: -0.02em; white-space: nowrap; }
.tile-big s { color: var(--faint); text-decoration-thickness: 1.5px; font-weight: 400; }
.tile-arrow { color: var(--accent); margin: 0 6px; }

.chart svg { width: 100%; height: 100%; }
.chart text { font-family: var(--mono); font-size: 9.5px; fill: var(--muted); }
.chart .c-title { fill: var(--faint); font-size: 9.5px; }
.chart .c-bar { fill: var(--chart-bar); rx: 1.5; }
.chart .c-best .c-bar { fill: var(--accent); }
.chart .c-best text { fill: var(--fg); font-weight: 500; }

.apf-wrap { cursor: crosshair; touch-action: pan-y; }
.apf-wrap canvas { width: 100%; height: 100%; }
.thumb-hint {
  position: absolute; left: 8px; bottom: 6px; font-family: var(--mono); font-size: 9.5px; color: var(--faint);
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.apf-wrap:hover .thumb-hint { opacity: 1; }

/* experience / education */
.row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-top: 1px solid var(--rule); }
.row:last-child { border-bottom: 1px solid var(--rule); }
.when { font-family: var(--mono); font-size: 12.5px; color: var(--faint); padding-top: 3px; }
.what h3 { font-size: 15.5px; font-weight: 600; line-height: 1.4; }
.where { font-family: var(--mono); font-size: 11.5px; font-weight: 400; color: var(--faint); margin-left: 8px; letter-spacing: 0; }
.role { font-size: 14px; color: var(--muted); }
.what p:not(.role) { font-size: 14.5px; color: var(--muted); margin-top: 4px; line-height: 1.55; }

.misc { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.misc .section-h { margin-bottom: 10px; }
.misc .section-h + .plain + .section-h, .misc .plain + .section-h { margin-top: 26px; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { font-size: 14.5px; color: var(--muted); padding: 4px 0 4px 16px; position: relative; line-height: 1.5; }
.plain li::before { content: ""; position: absolute; left: 0; top: 13px; width: 6px; height: 1px; background: var(--faint); }

.footer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px;
  margin-top: 80px; padding: 22px 0 40px; border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 12px; color: var(--faint);
}
.resample { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 4px 0; }
.resample:hover { color: var(--accent); }

/* ------------------------------------------------------------------
   Reverse-diffusion intro
   ------------------------------------------------------------------ */

#noise {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 100;
  pointer-events: none; display: none; image-rendering: pixelated;
  /* first-paint stand-in until the script draws real Gaussian samples */
  background: #808080 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* The runway is the stretch of scroll that walks t from T to 0. While inside it the
   page is pinned to the viewport, so it denoises in place and then scrolls on. */
#runway { display: none; }
.diffusing #runway { display: block; height: 110vh; }
.pinned .page { position: fixed; top: 0; left: 0; right: 0; }

#hud {
  position: fixed; left: 50%; bottom: 28px; z-index: 101; transform: translateX(-50%);
  display: none; flex-direction: column; align-items: center;
  font-family: var(--mono); font-size: 12px; line-height: 1.65; color: #f4f2ec;
  text-align: center; white-space: nowrap; cursor: pointer;
  background: rgba(10, 11, 13, .76); padding: 10px 18px 9px; border-radius: 8px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.intro #noise, .diffusing #noise { display: block; }
.intro #hud, .diffusing #hud { display: flex; }
.hud-line { display: block; }
.hud-gap { display: inline-block; width: 18px; }
.hud-cta { display: block; margin-top: 5px; color: #ffd27a; font-weight: 500; letter-spacing: .02em; }
.hud-arrow { display: inline-block; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
#hud:focus-visible { outline: 2px solid #ffd27a; outline-offset: 3px; }
.intro .page { opacity: 0; }

/* if the script never runs, reveal the page anyway */
.intro #noise, .intro #hud { animation: failsafe-hide .01s 4s forwards; }
.intro .page { animation: failsafe-show .01s 4s forwards; }
@keyframes failsafe-hide { to { opacity: 0; visibility: hidden; } }
@keyframes failsafe-show { to { opacity: 1; } }

.skip {
  position: fixed; left: 12px; top: 12px; z-index: 102; transform: translateY(-300%);
  background: var(--bg); color: var(--fg); padding: 6px 12px; border-radius: 6px;
  font-family: var(--mono); font-size: 13px; text-decoration: none; box-shadow: 0 0 0 1px var(--rule);
}
.skip:focus { transform: none; }

/* The script folds the runway away and adjusts the scroll position itself, so the
   browser must not "helpfully" anchor the scroll too; pull-to-refresh would also
   fight the hold-to-renoise gesture at the top. */
.diffusing, .diffusing body { overflow-anchor: none; overscroll-behavior-y: none; }

/* "keep scrolling ↑ to return to noise": progress for the one-second hold */
#renoise {
  position: fixed; left: 50%; top: 70px; z-index: 30; transform: translate(-50%, -6px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap;
  background: var(--bg); box-shadow: 0 0 0 1px var(--rule), 0 6px 24px rgba(0, 0, 0, .08);
  padding: 7px 14px 8px; border-radius: 8px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .18s, transform .18s, visibility 0s .18s;
}
#renoise.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .18s, transform .18s; }
.renoise-bar { display: block; width: 100%; height: 2px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.renoise-bar i { display: block; height: 100%; width: calc(var(--k, 0) * 100%); background: var(--accent); }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  :root { --gutter: 16px; }
  .nav nav { gap: 14px; }
  .nav nav a[href="#experience"] { display: none; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 36px; }
  .portrait { order: -1; width: 168px; }
  .portrait figcaption .hint { display: none; }
  .block-first { padding-top: 36px; }
  .edu li { flex-direction: column; gap: 2px; }
  #hud { font-size: 11px; bottom: 22px; padding: 9px 14px 8px; }
  .entry { grid-template-columns: 1fr; gap: 14px; padding: 16px; margin: 0 -16px 8px; }
  .thumb { max-width: 340px; }
  .news li { grid-template-columns: 1fr; gap: 0; }
  .row { grid-template-columns: 1fr; gap: 2px; }
  .misc { grid-template-columns: 1fr; gap: 26px; }
  .where { display: block; margin: 0; }
}

@media (max-width: 380px) {
  .nav nav a[href="#projects"] { display: none; }
}

@media print {
  #noise, #hud, #runway, #renoise, .skip, .nav, .footer .resample, .theme-toggle { display: none !important; }
  .page, .reveal { opacity: 1 !important; filter: none !important; animation: none !important; }
  .page { position: static !important; }
  .reveal::after { display: none !important; }
}
