/* =========================================================
   Bahadır Karslı — Portfolio
   Editorial print aesthetic. Paper first, screen second.
   ========================================================= */

:root {
  /* Ink & paper */
  --paper:      #F5F1E8;
  --paper-2:    #EFEADE;
  --paper-edge: #E2DCCB;
  --ink:        #16130E;
  --ink-2:      #4A443A;
  --ink-3:      #857D6E;
  --rule:       #D6CFBC;
  --rule-soft:  #E6E0D0;
  --accent:     #A8341B;   /* rust — used sparingly, like a second ink */
  --accent-2:   #C4562F;
  --highlight:  rgba(168, 52, 27, 0.10);

  /* Type */
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Measure */
  --page:    1180px;
  --gutter:  clamp(20px, 5vw, 64px);
  --margin-col: 190px;
}

/* Dark: the same press run, inked in reverse.
   The OS decides unless the reader has explicitly chosen (data-scheme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme='light']) {
    --paper:      #12100C;
    --paper-2:    #17150F;
    --paper-edge: #221E16;
    --ink:        #F0EADC;
    --ink-2:      #ABA391;
    --ink-3:      #7E7768;
    --rule:       #2E2A20;
    --rule-soft:  #221F18;
    --accent:     #E0724C;
    --accent-2:   #EE8A64;
    --highlight:  rgba(224, 114, 76, 0.12);
  }
}

:root[data-scheme='dark'] {
  --paper:      #12100C;
  --paper-2:    #17150F;
  --paper-edge: #221E16;
  --ink:        #F0EADC;
  --ink-2:      #ABA391;
  --ink-3:      #7E7768;
  --rule:       #2E2A20;
  --rule-soft:  #221F18;
  --accent:     #E0724C;
  --accent-2:   #EE8A64;
  --highlight:  rgba(224, 114, 76, 0.12);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Paper grain — a whisper of texture, never a pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
::selection { background: var(--accent); color: var(--paper); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 1px; }

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

/* ---------------------------------------------------------
   Reading progress — a hairline of ink across the top
   --------------------------------------------------------- */
.progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%;
  transform: scaleX(0); transform-origin: 0 50%;
  background: var(--accent);
  z-index: 60;
}

/* ---------------------------------------------------------
   Masthead
   --------------------------------------------------------- */
.masthead {
  border-bottom: 1px solid var(--ink);
  padding-top: 22px;
  position: relative;
  z-index: 2;
}
.masthead-rule {
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  height: 5px;
  margin-bottom: 18px;
}
.masthead-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 14px;
}
.masthead-name {
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: 'SOFT' 0, 'WONK' 0, 'opsz' 144;
  font-size: clamp(2.6rem, 9.5vw, 7.2rem);
  line-height: 0.9;
  letter-spacing: clamp(0.02em, 1.6vw, 0.14em);
  text-transform: uppercase;
  margin: 0 0 16px;
  text-align: center;
  word-spacing: 0.1em;
}
.masthead-strap {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--rule);
  padding: 11px 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.masthead-strap .live { display: flex; align-items: center; gap: 8px; }
.pip {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: pip 2.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pip {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* Theme toggle — a small printer's mark */
.toggle {
  background: none; border: 1px solid var(--rule);
  color: var(--ink-2); cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px; border-radius: 2px;
  transition: border-color 0.2s, color 0.2s;
}
.toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------
   Lede — the opening spread
   --------------------------------------------------------- */
.lede { padding: clamp(44px, 7vw, 84px) 0 clamp(36px, 5vw, 60px); }
.lede-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: clamp(28px, 5vw, 72px);
  align-items: start;
}
.headline {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 0, 'WONK' 1, 'opsz' 144;
  font-weight: 400;
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0 0 26px;
  text-wrap: balance;
}
.headline em {
  font-style: italic;
  font-variation-settings: 'WONK' 1;
  color: var(--accent);
}
.lede-body p {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: 1.02rem;
}
/* Drop cap */
.lede-body p.opening::first-letter {
  font-family: var(--display);
  font-weight: 600;
  float: left;
  font-size: 3.9em;
  line-height: 0.82;
  padding: 4px 10px 0 0;
  color: var(--accent);
}

/* Right rail — the contact block, set like a colophon */
.rail {
  border-top: 3px solid var(--ink);
  padding-top: 16px;
}
.rail-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px;
}
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li { border-bottom: 1px solid var(--rule-soft); }
.rail-list a {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 10px 0;
  text-decoration: none;
  font-family: var(--mono); font-size: 12.5px;
  transition: color 0.15s, padding-left 0.2s;
}
.rail-list a:hover { color: var(--accent); padding-left: 6px; }
.rail-list .k { color: var(--ink-3); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.rail-list .v { text-align: right; word-break: break-word; }

/* ---------------------------------------------------------
   Figures — the data spread
   --------------------------------------------------------- */
.figures {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.fig {
  padding: 26px 18px 24px;
  border-right: 1px solid var(--rule);
}
.fig:last-child { border-right: none; }
.fig-val {
  font-family: var(--display);
  font-variation-settings: 'opsz' 144;
  font-weight: 600;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  font-variant-numeric: lining-nums tabular-nums;
}
.fig-key {
  font-family: var(--mono); font-size: 10px; line-height: 1.5;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3);
}

/* ---------------------------------------------------------
   Spread — the editorial two-column section frame
   --------------------------------------------------------- */
.spread {
  display: grid;
  grid-template-columns: var(--margin-col) 1fr;
  gap: clamp(20px, 4vw, 56px);
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(52px, 7vw, 90px) var(--gutter);
  border-bottom: 1px solid var(--rule);
}
.spread:last-of-type { border-bottom: none; }

.spread-label { position: sticky; top: 28px; align-self: start; }
.spread-no {
  font-family: var(--display);
  font-variation-settings: 'opsz' 144;
  font-size: 3rem; font-weight: 600; line-height: 1;
  color: var(--rule);
  margin-bottom: 6px;
  font-variant-numeric: lining-nums;
}
.spread-title {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink); margin: 0 0 8px; font-weight: 500;
}
.spread-note {
  font-size: 12.5px; color: var(--ink-3); line-height: 1.5;
  font-style: italic; font-family: var(--display);
  font-variation-settings: 'opsz' 9;
}

/* ---------------------------------------------------------
   Entries — experience & projects
   --------------------------------------------------------- */
.entry { padding: 0 0 34px; margin-bottom: 34px; border-bottom: 1px solid var(--rule-soft); }
.entry:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.entry-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px 24px; flex-wrap: wrap; margin-bottom: 4px;
}
.entry-title {
  font-family: var(--display);
  font-variation-settings: 'opsz' 144, 'WONK' 0;
  font-weight: 600; font-size: 1.42rem; line-height: 1.25;
  letter-spacing: -0.01em; margin: 0;
}
.entry-title .qualifier { color: var(--ink-3); font-weight: 400; font-size: 0.72em; }
.entry-title a {
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 1px; background-repeat: no-repeat; background-position: 0 100%;
  transition: color 0.15s;
}
.entry-title a:hover { color: var(--accent); }
.entry-title a::after { content: ' ↗'; font-size: 0.62em; vertical-align: 0.28em; color: var(--accent); }

.entry-when {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.05em; white-space: nowrap;
}
.entry-org {
  font-family: var(--display); font-variation-settings: 'opsz' 9;
  font-style: italic; font-size: 1rem; color: var(--accent); margin-bottom: 14px;
}
.entry-role {
  font-family: var(--display); font-variation-settings: 'opsz' 9;
  font-style: italic; font-size: 0.95rem; color: var(--ink-3); margin-bottom: 14px;
}

.entry ul { margin: 0; padding: 0; list-style: none; }
.entry li {
  position: relative; padding-left: 20px; margin-bottom: 10px;
  color: var(--ink-2); font-size: 0.95rem;
}
.entry li::before {
  content: '—'; position: absolute; left: 0; color: var(--accent); opacity: 0.5;
}
.entry li:last-child { margin-bottom: 0; }
.entry em { font-style: italic; color: var(--ink); }

/* Tags — set as a running index line, not pills */
.tags {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule-soft);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3);
  display: flex; flex-wrap: wrap; gap: 4px 0;
}
.tags span::after { content: ' · '; color: var(--rule); }
.tags span:last-child::after { content: ''; }
.tags span { transition: color 0.15s; }
.entry:hover .tags span { color: var(--ink-2); }

/* ---------------------------------------------------------
   Publication — a proper citation
   --------------------------------------------------------- */
.cite {
  border-left: 3px solid var(--accent);
  padding-left: 22px;
}
.cite-authors {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  letter-spacing: 0.04em; margin-bottom: 12px;
}
.cite-authors strong { color: var(--ink); }
.cite-title {
  font-family: var(--display); font-variation-settings: 'opsz' 144;
  font-weight: 600; font-size: 1.35rem; line-height: 1.3;
  margin-bottom: 12px; text-wrap: balance;
}
.cite-where { color: var(--ink-2); font-size: 0.93rem; }
.cite-where a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid var(--highlight);
  font-family: var(--mono); font-size: 0.86em;
}
.cite-where a:hover { border-color: var(--accent); }

/* ---------------------------------------------------------
   Awards
   --------------------------------------------------------- */
.award { display: grid; grid-template-columns: 64px 1fr; gap: 20px; padding: 0 0 28px; margin-bottom: 28px; border-bottom: 1px solid var(--rule-soft); }
.award:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.award-year {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.04em; padding-top: 6px;
}
.award-name {
  font-family: var(--display); font-variation-settings: 'opsz' 144;
  font-weight: 600; font-size: 1.2rem; line-height: 1.3; margin-bottom: 8px;
}
.award p { margin: 0; color: var(--ink-2); font-size: 0.93rem; }

/* ---------------------------------------------------------
   Index — skills set as a back-of-book index
   --------------------------------------------------------- */
.index-group { margin-bottom: 26px; }
.index-group:last-child { margin-bottom: 0; }
.index-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent);
  padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--rule);
}
.index-items {
  display: flex; flex-wrap: wrap; gap: 3px 0;
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-2);
  line-height: 1.9;
}
.index-items span::after { content: ' , '; color: var(--ink-3); white-space: pre; }
.index-items span:last-child::after { content: ''; }

/* ---------------------------------------------------------
   Education
   --------------------------------------------------------- */
.edu { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.edu-school {
  font-family: var(--display); font-variation-settings: 'opsz' 144;
  font-weight: 600; font-size: 1.45rem; margin-bottom: 6px;
}
.edu-prog { color: var(--ink-2); font-size: 0.95rem; }
.edu-honors { color: var(--accent); font-weight: 500; }
.edu-when {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  text-align: right; letter-spacing: 0.05em; line-height: 1.8;
}

/* ---------------------------------------------------------
   Colophon
   --------------------------------------------------------- */
.colophon {
  border-top: 3px solid var(--ink);
  margin-top: 30px;
  padding: 34px 0 60px;
  text-align: center;
}
.colophon-mark {
  font-family: var(--display); font-variation-settings: 'opsz' 144;
  font-size: 1.5rem; font-weight: 600; letter-spacing: 0.2em;
  text-transform: uppercase; margin-bottom: 16px;
}
.colophon-links {
  display: flex; justify-content: center; gap: 8px 22px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 11.5px; margin-bottom: 20px;
}
.colophon-links a { color: var(--ink-2); text-decoration: none; transition: color 0.15s; }
.colophon-links a:hover { color: var(--accent); }
.colophon-note {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3); line-height: 1.9;
}

/* ---------------------------------------------------------
   Reveal
   --------------------------------------------------------- */
/* Scoped to .js-on so a failed script can never leave the page blank. */
.js-on .reveal { opacity: 0; transform: translateY(12px); }
.js-on .reveal.in {
  opacity: 1; transform: none;
  transition: opacity 0.7s cubic-bezier(0.2, 0.6, 0.2, 1), transform 0.7s cubic-bezier(0.2, 0.6, 0.2, 1);
}

/* ---------------------------------------------------------
   Responsive — the spread folds to a single column
   --------------------------------------------------------- */
@media (max-width: 900px) {
  .lede-grid { grid-template-columns: 1fr; }
  .rail { border-top-width: 1px; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .fig { border-bottom: 1px solid var(--rule); }
  .fig:nth-child(2n) { border-right: none; }
  .fig:last-child { grid-column: 1 / -1; border-bottom: none; }
  .spread { grid-template-columns: 1fr; gap: 22px; }
  .spread-label {
    position: static;
    display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
    border-bottom: 1px solid var(--rule); padding-bottom: 10px;
  }
  .spread-no { font-size: 1.5rem; margin-bottom: 0; }
  .spread-title { margin-bottom: 0; }
  .spread-note { flex-basis: 100%; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .masthead-name { letter-spacing: 0.04em; }
  .award { grid-template-columns: 1fr; gap: 6px; }
  .award-year { padding-top: 0; }
  .edu-when { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js-on .reveal, .reveal { opacity: 1; transform: none; transition: none; }
  .pip { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------
   Print — it was always meant to be paper
   --------------------------------------------------------- */
@media print {
  :root { --paper: #fff; --ink: #000; --ink-2: #333; --ink-3: #666; --accent: #000; --rule: #ccc; --rule-soft: #e5e5e5; }
  body::before, .progress, .toggle { display: none; }
  .spread { break-inside: avoid; padding: 24px 0; }
  .entry, .award, .cite { break-inside: avoid; }
  .spread-label { position: static; }
  a { text-decoration: none; }
}
