/* ==========================================================================
   palette — Midnight Library: ivory on charcoal, nothing else
   ========================================================================== */
:root {
  --desk:        #0B0B0E;
  --card:        #131319;
  --text:        #F2ECD8;
  --hair:        #1C1C22;

  --text-1:   rgba(242, 236, 216, 1);
  --text-07:  rgba(242, 236, 216, 0.7);
  --text-06:  rgba(242, 236, 216, 0.6);
  --text-05:  rgba(242, 236, 216, 0.5);
  --text-04:  rgba(242, 236, 216, 0.4);
  --text-03:  rgba(242, 236, 216, 0.3);
  --text-02:  rgba(242, 236, 216, 0.2);
  --text-015: rgba(242, 236, 216, 0.15);
  --text-01:  rgba(242, 236, 216, 0.10);
  --text-004: rgba(242, 236, 216, 0.04);

  /* vertical rhythm: body line-height is the base unit (17 × 1.7 = 28.9px) */
  --line:       28.9px;
  --line-half:  14.45px;
  --line-2:     57.8px;
  --line-3:     86.7px;
  --line-4:     115.6px;
  --line-5:     144.5px;
  --line-6:     173.4px;
  --line-7:     202.3px;
  --line-8:     231.2px;

  --sidebar-w:  280px;
  --card-inset: 16px;
  --card-radius: 14px;
  --col-width:  620px;

  --ease:       cubic-bezier(0.22, 0.61, 0.36, 1);

  color-scheme: dark;
}

/* ==========================================================================
   reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--desk);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

::selection { background: var(--text-015); color: var(--text); }
::-moz-selection { background: var(--text-015); color: var(--text); }

/* ==========================================================================
   typography — Midnight Library triple stack:
     Playfair Display (display serif, hero only)
     Source Serif 4 (body reading serif, everything that's read)
     JetBrains Mono (labels, breadcrumbs, links)
   ========================================================================== */
body {
  font-family: 'Source Serif 4', 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 28.9px;
  font-optical-sizing: auto;
  font-feature-settings: "liga" 1, "dlig" 1, "kern" 1;
  font-variant-numeric: tabular-nums;
  hanging-punctuation: first last allow-end;
  -webkit-hyphens: manual;
  hyphens: manual;
}

.mono, .mono-label, .mono-link, .sidebar__label, .sidebar__brand, .card__breadcrumb, .card__end, .mono-label--num {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', ui-monospace, monospace;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "calt" 0, "tnum" 1;
}

.mono-label {
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-03);
}
.mono-label--num { color: var(--text-04); }

.mono-link {
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.06em;
  color: var(--text-06);
  display: inline-block;
  position: relative;
  scale: 1;
  transition: color 240ms var(--ease), scale 200ms var(--ease);
}
.mono-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms var(--ease);
}
.mono-link:hover, .mono-link:focus-visible { color: var(--text-1); }
.mono-link:hover::after, .mono-link:focus-visible::after { transform: scaleX(1); }
.mono-link:active {
  scale: 0.96;
  transition-duration: 80ms;
}

/* extend hit area on prominent CTAs without changing layout */
.project__link::before,
.hero__link::before,
.contacts .mono-link::before {
  content: "";
  position: absolute;
  inset: -11px -14px;
}

/* ==========================================================================
   layout — sidebar on desk, card floating
   ========================================================================== */
.skip {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px; height: 1px;
  overflow: hidden;
}
.skip:focus {
  left: 16px; top: 16px;
  width: auto; height: auto;
  z-index: 100;
  background: var(--card);
  padding: 8px 12px;
  border-radius: 4px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  padding: 40px 40px 32px 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: transparent;
  z-index: 1;
  transition: opacity 320ms var(--ease), transform 320ms var(--ease);
}

.card {
  position: fixed;
  top: var(--card-inset);
  right: var(--card-inset);
  bottom: var(--card-inset);
  left: var(--sidebar-w);
  background: var(--card);
  border-radius: var(--card-radius);
  overflow: hidden;
  z-index: 2;
  box-shadow:
    inset 0 1px 0 var(--text-004),
    0 20px 40px rgba(0, 0, 0, 0.30),
    0 2px 8px rgba(0, 0, 0, 0.20);
  transition: left 320ms var(--ease);
}

body.sidebar-collapsed .sidebar {
  opacity: 0;
  transform: translateX(-16px);
  pointer-events: none;
}
body.sidebar-collapsed .card {
  left: var(--card-inset);
}

/* ==========================================================================
   sidebar chrome
   ========================================================================== */
.sidebar__brand {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-05);
  transition: color 240ms var(--ease);
  margin-bottom: var(--line-4);
}
.sidebar__brand:hover, .sidebar__brand:focus-visible { color: var(--text-1); }

.sidebar__section { margin-bottom: var(--line-3); width: 100%; }
.sidebar__section--index { margin-bottom: 0; }

.sidebar__label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-03);
  margin-bottom: var(--line);
}

.sidebar__list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sidebar__list a {
  font-family: 'Source Serif 4', serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-05);
  font-optical-sizing: auto;
  transition: color 240ms var(--ease);
  display: inline-block;
}
.sidebar__list a:hover, .sidebar__list a:focus-visible {
  color: var(--text-1);
}
.sidebar__list a[aria-current="page"] {
  color: var(--text-1);
}

.sidebar__list--low a { font-style: normal; }

/* ==========================================================================
   card chrome — breadcrumb + end marker
   ========================================================================== */
.card__chrome {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 72px;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    #131319 0%,
    #131319 58%,
    rgba(19, 19, 25, 0) 100%
  );
}
.card__breadcrumb {
  position: absolute;
  top: 28px;
  left: 32px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--text-04);
  pointer-events: auto;
  transition: opacity 240ms var(--ease);
  max-width: calc(100% - 64px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* custom scrollbar — 4px, only on card:hover */
.card__scroll::-webkit-scrollbar { width: 4px; }
.card__scroll::-webkit-scrollbar-track { background: transparent; }
.card__scroll::-webkit-scrollbar-thumb {
  background: var(--text-01);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 240ms var(--ease);
}
.card:not(:hover) .card__scroll::-webkit-scrollbar-thumb {
  background: transparent;
}
.card__scroll {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.card:hover .card__scroll {
  scrollbar-color: var(--text-01) transparent;
}

.card__column {
  /* centered then nudged 4% left of perfect center */
  max-width: var(--col-width);
  margin-left: max(64px, calc(50% - (var(--col-width) / 2) - 4%));
  margin-right: auto;
  padding: 20vh 40px var(--line) 0;
  position: relative;
}

.card__end {
  padding: var(--line-2) 0 0 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-02);
  pointer-events: none;
}

/* ==========================================================================
   views — staggered children on enter
   ========================================================================== */
.view {
  display: none;
}
.view[data-active] {
  display: block;
}

.view.is-entering > .hero {
  animation: view-enter 560ms var(--ease) both;
}
.view.is-entering > .thinking {
  animation: view-enter 560ms var(--ease) 80ms both;
}
.view.is-entering > .projects,
.view.is-entering > .timeline,
.view.is-entering > .contacts {
  animation: view-enter 560ms var(--ease) 160ms both;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   hero
   ========================================================================== */
.hero {
  margin-bottom: var(--line-6);
}
.hero .mono-label--num {
  display: block;
  margin-bottom: var(--line);
}
.hero__line {
  font-family: 'Playfair Display', 'Didot', 'Bodoni', serif;
  font-weight: 400;
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--text-1);
  font-feature-settings: "liga" 1, "dlig" 1, "kern" 1;
  max-width: 18ch;
  text-wrap: balance;
}
.hero__line--project {
  font-weight: 900;
  font-size: 64px;
  letter-spacing: -0.035em;
  line-height: 0.98;
  margin-bottom: var(--line-half);
}
.hero__sub {
  font-family: 'Source Serif 4', serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 1.65;
  color: var(--text-07);
  max-width: 32ch;
  margin-top: var(--line);
  margin-bottom: var(--line);
  font-optical-sizing: auto;
}
.hero__link { display: inline-block; margin-top: var(--line-half); }

.cursor {
  display: inline-block;
  width: 2px;
  height: 0.82em;
  background: var(--text);
  margin-left: 6px;
  vertical-align: baseline;
  opacity: 0.6;
  animation: cursor-blink 460ms linear 3 200ms forwards;
  transform: translateY(1px);
}
@keyframes cursor-blink {
  0%, 49%   { opacity: 0.6; }
  50%, 100% { opacity: 0; }
}

/* ==========================================================================
   thinking block
   ========================================================================== */
.thinking {
  margin-bottom: var(--line-8);
}
.thinking .mono-label {
  display: block;
  margin-bottom: var(--line);
}
.thinking .spinner {
  display: inline-block;
  width: 1ch;
  margin-right: 10px;
  text-align: center;
  color: color-mix(in srgb, var(--text) 75%, transparent);
  vertical-align: baseline;
}
.thinking .label-text {
  display: inline-block;
  transition: opacity 280ms var(--ease);
}
.thinking .label-text.is-fading { opacity: 0; }
.thinking__text {
  font-family: 'Source Serif 4', serif;
  font-weight: 300;
  font-size: 18px;
  line-height: 30.6px;
  color: var(--text-07);
  max-width: 44ch;
  text-wrap: pretty;
  font-optical-sizing: auto;
}
.thinking__text em {
  font-style: italic;
  font-weight: 400;
  font-feature-settings: "liga" 1, "dlig" 1;
}

/* ==========================================================================
   projects (home view, stacked)
   ========================================================================== */
.projects {
  display: flex;
  flex-direction: column;
  gap: var(--line-3);
  margin-bottom: var(--line-4);
}
.project {
  display: flex;
  flex-direction: column;
  gap: var(--line-half);
  max-width: 44ch;
}
.project .mono-label--num {
  margin-bottom: calc(var(--line-half) * -0.5);
}
.project__name {
  font-family: 'Playfair Display', serif;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.25;
  color: var(--text-1);
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.project__desc {
  font-family: 'Source Serif 4', serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 28.9px;
  color: var(--text-07);
  text-wrap: pretty;
  margin: 0;
  font-optical-sizing: auto;
}
.project__link {
  margin-top: var(--line-half);
  align-self: flex-start;
}

/* ==========================================================================
   timeline — experience + education entries
   ========================================================================== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--line-3);
  margin-bottom: var(--line-4);
}
.entry {
  display: flex;
  flex-direction: column;
  gap: var(--line-half);
  max-width: 46ch;
}
.entry__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: calc(var(--line-half) * -0.25);
}
.entry__place {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', ui-monospace, monospace;
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-04);
}
.entry__role {
  font-family: 'Playfair Display', serif;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.25;
  color: var(--text-1);
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.entry__desc {
  font-family: 'Source Serif 4', serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 28.9px;
  color: var(--text-07);
  text-wrap: pretty;
  font-optical-sizing: auto;
}
.entry__bullets {
  display: flex;
  flex-direction: column;
  gap: var(--line-half);
  margin-top: calc(var(--line-half) * 0.25);
}
.entry__bullets li {
  font-family: 'Source Serif 4', serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 28.9px;
  color: var(--text-07);
  text-wrap: pretty;
  padding-left: 1.4em;
  position: relative;
  font-optical-sizing: auto;
}
.entry__bullets li::before {
  content: "—";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--text-03);
}
.entry__bullets em {
  font-style: italic;
  font-weight: 400;
  color: var(--text-1);
}
.entry__links {
  display: flex;
  flex-direction: column;
  gap: var(--line-half);
  margin-top: calc(var(--line-half) * 0.25);
}
.entry__links li { line-height: 1.6; }

/* ==========================================================================
   contacts list (contact view)
   ========================================================================== */
.contacts {
  display: flex;
  flex-direction: column;
  gap: var(--line);
  margin-top: var(--line-2);
}
.contacts li { line-height: 1; }

/* ==========================================================================
   focus — keyboard only
   ========================================================================== */
:focus { outline: none; }
:focus-visible {
  outline: 1px solid var(--text-03);
  outline-offset: 4px;
  border-radius: 1px;
}

/* ==========================================================================
   responsive — below 900px shrink, below 700px hide sidebar
   ========================================================================== */
@media (max-width: 1100px) {
  :root {
    --sidebar-w: 240px;
  }
  .sidebar { padding-left: 40px; }
}

@media (max-width: 900px) {
  :root {
    --sidebar-w: 200px;
    --card-inset: 12px;
  }
  .sidebar { padding: 32px 28px 28px 32px; }
  .card__column { padding-left: 0; }
  .hero__line { font-size: 34px; }
  .hero__line--project { font-size: 44px; }
}

@media (max-width: 700px) {
  :root {
    --card-inset: 0px;
    --card-radius: 0px;
    --mobile-nav-h: 56px;
  }

  /* sidebar becomes a single-row nav pinned to the top of the viewport */
  .sidebar {
    position: fixed;
    inset: 0 0 auto 0;
    width: auto;
    height: var(--mobile-nav-h);
    padding: 14px 24px 12px 24px;
    background: var(--desk);
    z-index: 4;

    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto;
    column-gap: 18px;
    align-items: center;

    opacity: 1;
    transform: none;
    pointer-events: auto;
    overflow: hidden;
  }

  .sidebar__brand {
    margin: 0;
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    padding-top: 0;
    font-size: 11px;
  }

  .sidebar__section {
    margin: 0;
    width: auto;
    min-width: 0;
  }
  .sidebar__section--index { grid-column: 2; grid-row: 1; align-self: center; }

  .sidebar__label { display: none; }
  .sidebar__list {
    flex-direction: row;
    gap: 16px;
    white-space: nowrap;
    align-items: baseline;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
            mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
  }
  .sidebar__list::-webkit-scrollbar { display: none; }
  .sidebar__list a { font-size: 14px; line-height: 1.2; }
  .sidebar__list--low a { font-size: 13px; color: var(--text-04); }
  .sidebar__list--low a[aria-current="page"],
  .sidebar__list--low a:hover,
  .sidebar__list--low a:focus-visible { color: var(--text-1); }

  /* collapse shortcut is a no-op on mobile */
  body.sidebar-collapsed .sidebar {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  body.sidebar-collapsed .card { left: 0; top: var(--mobile-nav-h); }

  .card {
    left: 0;
    top: var(--mobile-nav-h);
    box-shadow: none;
  }
  .card__column {
    margin-left: 32px;
    margin-right: 32px;
    padding: 12vh 0 var(--line-6);
    max-width: none;
  }
  .card__chrome { height: 56px; }
  .card__breadcrumb { left: 24px; top: 18px; }
  .hero__line { font-size: 30px; max-width: none; }
  .hero__line--project { font-size: 38px; }
  .thinking__text, .project__desc, .hero__sub { max-width: 36ch; }
}

@media (max-width: 420px) {
  .hero__line { font-size: 26px; }
  .hero__line--project { font-size: 32px; }
}

/* ==========================================================================
   reduced motion — respect the setting
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor { display: none; }
}

/* ==========================================================================
   print — typeset CV
   ========================================================================== */
@media print {
  @page {
    size: A4;
    margin: 28mm 22mm 28mm 22mm;
  }
  html, body {
    background: #ffffff;
    color: #111111;
    overflow: visible;
    height: auto;
    font-size: 10.5pt;
    line-height: 1.55;
  }
  .sidebar, .cursor, .card__breadcrumb, .card__end, .skip { display: none !important; }
  .card {
    position: static;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    inset: auto;
    overflow: visible;
  }
  .card__scroll {
    position: static;
    overflow: visible;
  }
  .card__column {
    max-width: none;
    margin: 0;
    padding: 0;
  }
  .view { display: block !important; animation: none; page-break-after: always; }
  .view:last-child { page-break-after: avoid; }
  .view[data-view="home"] { page-break-after: always; }
  .hero { margin-bottom: 16pt; }
  .hero__line {
    font-size: 22pt;
    font-weight: 400;
    color: #111;
    letter-spacing: -0.01em;
    max-width: none;
  }
  .hero__line--project { font-size: 18pt; }
  .hero__sub { color: #333; font-size: 10.5pt; }
  .mono-label {
    color: #666;
    font-size: 8pt;
    letter-spacing: 0.14em;
  }
  .thinking { margin-bottom: 16pt; }
  .thinking__text {
    color: #333;
    font-size: 10.5pt;
    max-width: none;
  }
  .projects { gap: 14pt; }
  .project { max-width: none; page-break-inside: avoid; }
  .project__name { font-size: 11pt; color: #111; }
  .project__desc { color: #333; font-size: 10.5pt; }
  .timeline { gap: 14pt; }
  .entry { max-width: none; page-break-inside: avoid; }
  .entry__role { font-size: 11pt; color: #111; }
  .entry__place { color: #666; font-size: 8pt; letter-spacing: 0.14em; }
  .entry__desc { color: #333; font-size: 10.5pt; }
  .entry__bullets { gap: 4pt; margin-top: 4pt; }
  .entry__bullets li { color: #333; font-size: 10.5pt; }
  .entry__bullets li::before { color: #888; }
  .mono-link { color: #555; }
  .mono-link::after { display: none; }
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #888;
    font-family: 'JetBrains Mono', monospace;
  }
  a[href^="#"]::after, a[href^="mailto:"]::after { content: ""; }
}
