/* ==========================================================
   Ufuk Muncuk — shared site stylesheet
   Used by every page. Page-specific blocks are marked.
   ========================================================== */

@view-transition { navigation: auto; }

:root {
  --paper: #EEF2F1;
  --panel: #FFFFFF;
  --ink: #15202B;
  --ink-2: #4B5865;
  --rule: #D3DBD9;
  --red: #C8102E;      /* channel 1: Northeastern red */
  --teal: #0F766E;     /* channel 2 */
  --grid: rgba(21, 32, 43, 0.07);
  --shadow: 0 1px 0 rgba(21, 32, 43, 0.06), 0 8px 24px -12px rgba(21, 32, 43, 0.18);

  --font: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --measure: 68ch;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E161E;
    --panel: #15202A;
    --ink: #E6ECEA;
    --ink-2: #9CA9B3;
    --rule: #263441;
    --red: #EE4458;
    --teal: #3CB5A8;
    --grid: rgba(230, 236, 234, 0.06);
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --paper: #0E161E; --panel: #15202A; --ink: #E6ECEA; --ink-2: #9CA9B3;
  --rule: #263441; --red: #EE4458; --teal: #3CB5A8; --grid: rgba(230,236,234,.06);
}

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

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
}

img, svg, canvas { max-width: 100%; display: block; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--red) 55%, transparent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem var(--gutter);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, padding .3s var(--ease);
}
.site-head.scrolled { border-bottom-color: var(--rule); padding-block: .6rem; }

.brand {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none; font-weight: 750;
  font-variation-settings: "wdth" 115;
  letter-spacing: -0.01em;
  view-transition-name: brand;
}
.brand-mark { width: 30px; height: 18px; }
.brand-mark path { stroke: var(--red); stroke-width: 2; fill: none; stroke-linecap: round; }

.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.site-nav a {
  position: relative; display: block; padding: .45rem .75rem;
  text-decoration: none; color: var(--ink-2); font-size: .95rem; font-weight: 500;
  border-radius: 6px; transition: color .2s;
}
.site-nav a::after {
  content: ""; position: absolute; left: .75rem; right: .75rem; bottom: .2rem; height: 2px;
  background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after, .site-nav a[aria-current="page"]::after { transform: scaleX(1); }
.site-nav a[aria-current="page"] { color: var(--ink); }

.menu-toggle {
  display: none; font: inherit; font-weight: 600; font-size: .95rem;
  background: none; border: 1px solid var(--rule); color: var(--ink);
  padding: .4rem .8rem; border-radius: 6px; cursor: pointer;
}

@media (max-width: 760px) {
  .menu-toggle { display: block; }
  .site-nav {
    position: fixed; inset: 3.6rem 0 auto 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    clip-path: inset(0 0 100% 0); transition: clip-path .4s var(--ease);
  }
  .site-nav.open { clip-path: inset(0 0 0 0); }
  .site-nav ul { flex-direction: column; padding: .5rem var(--gutter) 1.25rem; }
  .site-nav a { font-size: 1.15rem; padding: .7rem 0; }
  .site-nav a::after { left: 0; right: auto; width: 2rem; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .75rem 1.15rem; border-radius: 8px;
  border: 1px solid var(--ink); color: var(--ink); background: transparent;
  text-decoration: none; font-weight: 600; font-size: .98rem;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--red) 85%, #000); }
.btn svg { width: 1.05em; height: 1.05em; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- footer ---------- */
.site-foot {
  margin-top: 6rem; padding: 3rem var(--gutter) calc(2.5rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rule);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2rem;
  color: var(--ink-2); font-size: .95rem;
}
.site-foot strong { display: block; color: var(--ink); font-weight: 650; margin-bottom: .35rem; }
.site-foot p { margin: 0; }

/* ==========================================================
   CV PAGE
   ========================================================== */

.cv-hero { padding: clamp(2rem, 5vw, 4rem) var(--gutter) 0; position: relative; }
.cv-hero .role { margin: 0 0 1rem; color: var(--ink-2); font-weight: 500; max-width: 46ch; }
.cv-hero h1 {
  margin: 0; font-weight: 820; line-height: .92;
  font-size: clamp(3.4rem, 15vw, 9rem);
  font-variation-settings: "wdth" 125;
  letter-spacing: -0.035em;
}
.cv-hero h1 .ln { display: block; overflow: hidden; }
.cv-hero h1 .ln > span { display: inline-block; transform: translateY(105%); animation: rise 1s var(--ease) forwards; }
.cv-hero h1 .ln:nth-child(2) > span { animation-delay: .12s; }
@keyframes rise { to { transform: none; } }

.cv-hero .lede { max-width: 52ch; font-size: 1.18rem; margin: 1.75rem 0 2rem; }
@media (min-width: 1040px) {
  .hero-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4rem; align-items: end; }
  .hero-grid h1 { font-size: clamp(5rem, 9.5vw, 9.5rem); }
  .cv-hero .lede { margin-top: 0; }
}
.cv-hero .actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.cv-hero .fade-in { opacity: 0; animation: fade .9s var(--ease) .45s forwards; }
@keyframes fade { to { opacity: 1; } }

/* spectrum plot */
.scope {
  margin: clamp(2.5rem, 6vw, 4rem) calc(var(--gutter) * -1) 0;
  padding: 0 var(--gutter);
  position: relative;
}
.scope-frame {
  position: relative; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
#sweep { width: 100%; height: clamp(220px, 32vw, 340px); cursor: crosshair; touch-action: pan-y; }
.scope-read {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 2rem;
  padding: .85rem 1.1rem; border-top: 1px solid var(--rule); font-size: .92rem; color: var(--ink-2);
}
.scope-read b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.scope-read .ch { display: inline-block; width: .7rem; height: .18rem; background: var(--red); vertical-align: middle; margin-right: .4rem; border-radius: 2px; }

/* layout with rail */
.cv-body {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(2rem, 5vw, 5rem);
  padding: clamp(3.5rem, 8vw, 6rem) var(--gutter) 0;
  max-width: 1280px; margin: 0 auto;
}
.rail { position: sticky; top: 6rem; align-self: start; }
.rail ol { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 1px solid var(--rule); position: relative; }
.rail a { display: block; padding: .32rem 0; text-decoration: none; color: var(--ink-2); font-size: .93rem; transition: color .2s, transform .3s var(--ease); }
.rail a:hover { color: var(--ink); }
.rail a.active { color: var(--ink); font-weight: 600; transform: translateX(4px); }
.rail .marker {
  position: absolute; left: -2px; width: 3px; border-radius: 2px; background: var(--red);
  top: 0; height: 1.9rem; transition: transform .45s var(--ease), height .45s var(--ease);
}
.rail .pdf { margin-top: 1.5rem; font-size: .93rem; }

@media (max-width: 960px) {
  .cv-body { grid-template-columns: 1fr; }
  .rail { display: none; }
}

.cv-section { padding-bottom: clamp(3rem, 7vw, 5rem); }
.cv-section > h2 {
  margin: 0 0 1.75rem; font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.1;
  font-weight: 760; font-variation-settings: "wdth" 115; letter-spacing: -0.015em;
  display: flex; align-items: baseline; gap: .9rem;
}
.cv-section > h2::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
  transform: scaleX(0); transform-origin: left; transition: transform 1.1s var(--ease) .15s;
}
.cv-section.in > h2::after { transform: scaleX(1); }
.cv-section > h2 .count { font-size: .55em; color: var(--ink-2); font-weight: 500; font-variation-settings: "wdth" 100; }

.interests { max-width: var(--measure); font-size: 1.15rem; margin: 0; }

/* timeline */
.timeline { position: relative; list-style: none; margin: 0; padding: 0 0 0 1.75rem; max-width: 78ch; }
.timeline::before { content: ""; position: absolute; left: 5px; top: .5rem; bottom: .5rem; width: 1px; background: var(--rule); }
.timeline .trace {
  position: absolute; left: 4px; top: .5rem; width: 3px; border-radius: 2px; background: var(--red);
  height: calc(100% - 1rem); transform-origin: top; transform: scaleY(var(--p, 0));
}
.timeline > li { position: relative; padding-bottom: 1.9rem; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute; left: calc(-1.75rem + 1px); top: .45rem;
  width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-2);
  transition: border-color .4s, background .4s, transform .4s var(--ease);
}
.timeline > li.lit::before { border-color: var(--red); background: var(--red); transform: scale(1.15); }
.when { font-size: .9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 500; }
.timeline h3 { margin: .1rem 0 .15rem; font-size: 1.12rem; font-weight: 650; line-height: 1.35; }
.timeline .where { margin: 0; color: var(--ink-2); }
.timeline .note { margin: .45rem 0 0; }

/* awards */
.awards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; list-style: none; margin: 0; padding: 0; }
.awards li {
  position: relative; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 1.1rem 1.2rem 1.15rem;
  overflow: hidden; transition: transform .35s var(--ease), border-color .3s;
}
.awards li::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--red);
  transform: scaleY(0); transform-origin: bottom; transition: transform .45s var(--ease);
}
.awards li:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--red) 40%, var(--rule)); }
.awards li:hover::before { transform: scaleY(1); }
.awards .yr { font-size: .88rem; color: var(--red); font-weight: 650; font-variant-numeric: tabular-nums; }
.awards h3 { margin: .25rem 0 .2rem; font-size: 1.02rem; font-weight: 650; line-height: 1.35; }
.awards p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.awards li.fellow { background: transparent; }

/* simple definition list rows */
.rows { margin: 0; max-width: 82ch; }
.rows > div { display: grid; grid-template-columns: 8.5rem 1fr; gap: 1.25rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.rows > div:last-child { border-bottom: 1px solid var(--rule); }
.rows dt { color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 500; }
.rows dd { margin: 0; }
.rows dd strong { font-weight: 650; }
@media (max-width: 560px) { .rows > div { grid-template-columns: 1fr; gap: .25rem; } }

/* publications */
.pub-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  font: inherit; font-size: .92rem; font-weight: 550; cursor: pointer;
  padding: .42rem .85rem; border-radius: 999px; border: 1px solid var(--rule);
  background: var(--panel); color: var(--ink-2); transition: all .25s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pub-search {
  flex: 1 1 220px; max-width: 320px; font: inherit; font-size: .95rem;
  padding: .5rem .85rem; border-radius: 8px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink);
}
.pub-search:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent); }
.pub-status { font-size: .9rem; color: var(--ink-2); margin: 0 0 1rem; min-height: 1.4em; }

.pubs { list-style: none; margin: 0; padding: 0; max-width: 86ch; }
.pub {
  display: grid; grid-template-columns: 3.4rem 1fr; gap: 1rem;
  padding: 1.1rem 0; border-top: 1px solid var(--rule);
  view-transition-name: var(--vt);
}
.pub .y { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 500; padding-top: .05rem; }
.pub .t { margin: 0 0 .25rem; font-weight: 640; line-height: 1.4; }
.pub .a { margin: 0; color: var(--ink-2); font-size: .97rem; }
.pub .a b { color: var(--ink); font-weight: 650; }
.pub .v { margin: .15rem 0 0; font-size: .97rem; }
.pub .v i { font-style: italic; }
.tag {
  display: inline-block; margin-left: .35rem; padding: .05rem .5rem; border-radius: 4px;
  font-size: .8rem; font-weight: 600; vertical-align: .1em;
  background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red);
}
.tag.alt { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal); }
.pub[hidden] { display: none; }
.pub.hit { animation: hit .5s var(--ease); }
@keyframes hit { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
mark { background: color-mix(in srgb, var(--red) 22%, transparent); color: inherit; border-radius: 2px; padding: 0 .1em; }

/* patents */
.patents { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; max-width: 86ch; }
.patents li { display: grid; grid-template-columns: 3.4rem 1fr; gap: 1rem; }
.patents .num { display: inline-block; margin-top: .2rem; font-size: .9rem; color: var(--teal); font-weight: 600; font-variant-numeric: tabular-nums; }
.patents h3 { margin: 0; font-size: 1.02rem; font-weight: 640; line-height: 1.4; }
.patents p { margin: 0; color: var(--ink-2); font-size: .95rem; }

/* projects */
.projects { display: grid; gap: .75rem; max-width: 86ch; }
.project {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden;
  transition: border-color .3s, box-shadow .3s;
}
.project[open] { border-color: color-mix(in srgb, var(--red) 35%, var(--rule)); box-shadow: var(--shadow); }
.project summary {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center;
  padding: 1.05rem 1.2rem;
}
.project summary::-webkit-details-marker { display: none; }
.project summary h3 { margin: 0; font-size: 1.05rem; font-weight: 650; line-height: 1.35; }
.project summary .when { display: block; margin-bottom: .1rem; }
.project .plus { width: 22px; height: 22px; position: relative; flex: none; }
.project .plus::before, .project .plus::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2px; background: var(--ink-2);
  border-radius: 2px; translate: -50% -50%; transition: transform .35s var(--ease), background .3s;
}
.project .plus::after { transform: rotate(90deg); }
.project[open] .plus::after { transform: rotate(0); }
.project[open] .plus::before, .project[open] .plus::after { background: var(--red); }
.project .body { padding: 0 1.2rem 1.25rem; }
.project .body p { margin: 0 0 .9rem; max-width: var(--measure); }
.figs { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.figs li { font-size: .88rem; padding: .3rem .65rem; border-radius: 6px; background: var(--paper); border: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.figs b { font-weight: 650; }

/* skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; }
.skills h3 { margin: 0 0 .75rem; font-size: 1rem; font-weight: 650; }
.skills ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.skills li {
  font-size: .92rem; padding: .3rem .65rem; border-radius: 6px; border: 1px solid var(--rule); background: var(--panel);
  opacity: 0; transform: scale(.92); transition: opacity .4s var(--ease), transform .4s var(--ease);
  transition-delay: calc(var(--i, 0) * 35ms);
}
.cv-section.in .skills li { opacity: 1; transform: none; }

.plain { max-width: var(--measure); margin: 0 0 1rem; }
.plain-list { margin: 0; padding-left: 1.1rem; max-width: var(--measure); }
.plain-list li { margin-bottom: .35rem; }

/* project animations */
.anim { margin: .25rem 0 1rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); overflow: hidden; }
.anim canvas { width: 100%; height: clamp(240px, 36vw, 320px); display: block; touch-action: pan-y; }
.anim canvas.draggable { cursor: grab; touch-action: none; }
.anim canvas.draggable.dragging { cursor: grabbing; }
.anim .ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem 1.4rem; padding: .7rem .95rem; border-top: 1px solid var(--rule); background: var(--panel); font-size: .9rem; color: var(--ink-2); }
.anim .ctrl b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.anim .slider { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; }
.anim input[type="range"] { accent-color: var(--red); width: min(220px, 60vw); }
.anim .chip { font-size: .85rem; padding: .3rem .7rem; }
.status { font-weight: 650; padding: .15rem .55rem; border-radius: 4px; }
.status.ok { color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, transparent); }
.status.hit { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.anim-note { font-size: .92rem; color: var(--ink-2); }

.todo { outline: 1.5px dashed var(--red); outline-offset: 2px; border-radius: 3px; color: var(--red); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; transition-delay: 0s !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .cv-hero h1 .ln > span { transform: none; }
  .cv-hero .fade-in { opacity: 1; }
  .skills li { opacity: 1; transform: none; }
  @view-transition { navigation: none; }
}

@media print {
  .site-head, .rail, .scope, .pub-tools, .pub-status, .site-foot, .actions { display: none !important; }
  .reveal, .skills li { opacity: 1 !important; transform: none !important; }
  body { background: #fff; }
}
