/* ---------------------------------------------------------------
   Warm charcoal, one coffee accent. Serif for prose, sans for chrome.
   Coffee marks the research claim, the current section, and focus.
--------------------------------------------------------------- */
:root {
  --sidebar-w: 22rem;
  --bg: #141311;
  --bg-raise: #1c1b18;
  --line: #2e2c28;
  --line-soft: #262420;
  --text: #e7e2d9;
  --text-dim: #b1aaa0;
  --text-faint: #8c867c;
  --accent: #D2B48C;
  --serif: "Newsreader", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Public Sans", "Segoe UI", Helvetica, Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: #3c3a36 transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 500; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent);
  color: #141311;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 100;
  padding: 0.55rem 0.8rem;
  background: var(--accent);
  color: #141311;
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 500;
  transform: translateY(-150%);
}

.skip-link:focus { transform: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------
   Sidebar
--------------------------------------------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: var(--bg);
  z-index: 40;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar__inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 2.15rem 2rem 1.25rem 2.15rem;
}

.sidebar__panel {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sidebar__panel-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.nav-toggle { display: none; }

/* Identity ---------------------------------------------------- */
.avatar {
  position: relative;
  width: 5rem;
  height: 6rem;
  margin-bottom: 1.1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-raise);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  transform: scale(1.12);
  transform-origin: center 30%;
  display: block;
}

.avatar img[hidden] { display: none; }

.avatar__fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.avatar img[hidden] + .avatar__fallback { display: grid; }

.identity__name {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.identity__name span { display: block; }

.identity__role {
  margin-top: 0.65rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-dim);
}

.identity__role span { display: block; }

.identity__org {
  margin-top: 0.2rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-faint);
}

/* Contacts ---------------------------------------------------- */
.contacts {
  display: flex;
  flex-direction: column;
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.contacts a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.32rem 0;
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-dim);
  transition: color 0.15s ease;
}

.contacts a:hover { color: var(--text); }

.contacts svg {
  flex: none;
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.contacts li:nth-child(3) svg,
.contacts li:nth-child(4) svg {
  fill: currentColor;
  stroke: none;
}

.contacts a:hover svg { color: var(--accent); }

.contacts__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Nav --------------------------------------------------------- */
.nav {
  position: relative;
  display: flex;
  flex-direction: column;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.nav__link {
  display: block;
  padding: 0.34rem 0 0.34rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-faint);
  transition: color 0.15s ease;
}

.nav__link:hover { color: var(--text); }

.nav__link[aria-current="true"] { color: var(--text); }

.nav__marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 0;
  background: var(--accent);
  opacity: 0;
  transition: transform 0.2s ease, height 0.2s ease, opacity 0.2s ease;
}

/* Footer of the margin --------------------------------------- */
.sidebar__footer {
  margin-top: 1.15rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------
   Main
--------------------------------------------------------------- */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.main__inner {
  max-width: 50rem;
  padding: 2.15rem 3rem 5.5rem 2.75rem;
}

.intro__body {
  max-width: 38rem;
  font-size: 1.125rem;
  line-height: 1.7;
  text-wrap: pretty;
}

/* Sections ---------------------------------------------------- */
.section {
  padding-top: 4.25rem;
  scroll-margin-top: 1.5rem;
}

.section__head {
  margin-bottom: 1.65rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.section__title {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.statement {
  margin: 0 0 2.5rem;
  padding: 0.15rem 0 0.15rem 1.15rem;
  border-left: 1px solid var(--accent);
  max-width: 38rem;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.entries__label {
  margin: 0 0 1.15rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-faint);
}

/* Entries ----------------------------------------------------- */
.entries { display: flex; flex-direction: column; }

.entry {
  display: grid;
  grid-template-columns: 11.25rem 1fr;
  column-gap: 2rem;
  row-gap: 0.3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line-soft);
}

.entry:first-child { border-top: 0; padding-top: 0.15rem; }

.entry__meta { padding-top: 0.28rem; }

.entry__meta time {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.45;
  color: var(--text-faint);
  white-space: nowrap;
}

.entry__title,
.card__title {
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.015em;
  text-wrap: pretty;
}

.entry__sub {
  margin-top: 0.28rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-faint);
}

.bullets {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.bullets li {
  position: relative;
  padding-left: 1rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dim);
  text-wrap: pretty;
}

.bullets li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--text-faint);
}

/* Keywords ---------------------------------------------------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0;
  margin-top: 0.85rem;
}

.tags li {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-dim);
}

.tags li:not(:last-child)::after {
  content: "·";
  margin: 0 0.45rem;
  color: var(--text-faint);
}

.doc {
  margin-top: 0.85rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.doc a {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.22em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.doc a:hover {
  color: var(--text);
  text-decoration-color: var(--accent);
}

/* Projects — same record rhythm as the dated entries ---------- */
.cards { display: flex; flex-direction: column; }

.card {
  padding: 1.45rem 0;
  border-top: 1px solid var(--line-soft);
}

.card:first-child { border-top: 0; padding-top: 0.15rem; }

.card__text {
  max-width: 40rem;
  margin-top: 0.5rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-dim);
  text-wrap: pretty;
}

/* Skills ------------------------------------------------------ */
.skills { margin: 0; }

.skills__group {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 1.5rem;
  align-items: baseline;
  padding: 1.05rem 0;
  border-top: 1px solid var(--line-soft);
}

.skills__group:first-child { border-top: 0; padding-top: 0.15rem; }

.skills__label {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-faint);
}

.skills__items { margin: 0; }
.skills__items .tags { margin-top: 0; }

/* Colophon ---------------------------------------------------- */
.page-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  margin-top: 4.5rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-faint);
}

.page-footer a {
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.page-footer a:hover {
  color: var(--text);
  text-decoration-color: var(--accent);
}

/* ---------------------------------------------------------------
   Desktop composition. The margin and the text column are one
   spread; on a wide screen that spread sits in the middle.
--------------------------------------------------------------- */
@media (min-width: 961px) {
  body {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 50rem);
    justify-content: center;
    align-items: start;
  }

  .sidebar {
    position: sticky;
    top: 0;
    left: auto;
    width: auto;
    height: 100vh;
  }

  .main {
    margin-left: 0;
    min-width: 0;
  }
}

@media (max-height: 700px) and (min-width: 961px) {
  .sidebar__inner { padding-top: 1.35rem; padding-bottom: 0.85rem; }
  .avatar { width: 4.15rem; height: 5rem; margin-bottom: 0.7rem; }
  .identity__name { font-size: 1.5rem; }
  .identity__role { margin-top: 0.4rem; }
  .contacts { margin-top: 0.85rem; padding-top: 0.65rem; }
  .nav { margin-top: 0.55rem; padding-top: 0.55rem; }
  .sidebar__footer { margin-top: 0.7rem; padding-top: 0.6rem; }
}

/* ---------------------------------------------------------------
   Narrow desktop
--------------------------------------------------------------- */
@media (max-width: 1180px) {
  :root { --sidebar-w: 19.5rem; }

  .main__inner { padding: 2.5rem 2.25rem 4.5rem 2.15rem; }

  .entry { column-gap: 1.5rem; }
}

/* ---------------------------------------------------------------
   Small screens — identity stays visible; sections open beneath
--------------------------------------------------------------- */
@media (max-width: 960px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .sidebar__inner {
    min-height: 0;
    padding: 0;
  }

  .sidebar__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4.25rem;
    padding: 0.7rem max(1.25rem, env(safe-area-inset-right)) 0.7rem max(1.25rem, env(safe-area-inset-left));
  }

  .identity {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    min-width: 0;
  }

  .avatar {
    width: 2.35rem;
    height: 2.8rem;
    margin: 0;
    flex: none;
  }

  .avatar img { transform: scale(1.14); }

  .identity__text { min-width: 0; }

  .identity__name {
    font-size: 1.05rem;
    line-height: 1.2;
    letter-spacing: -0.015em;
  }

  .identity__name span { display: inline; }
  .identity__name span + span::before { content: "\00a0"; }

  .identity__role {
    margin-top: 0.1rem;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .identity__role span { display: inline; }
  .identity__role span + span::before { content: " & "; }

  body.menu-open { overflow: hidden; }

  .sidebar.is-open ~ .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(8, 7, 6, 0.84);
  }

  .identity__org { display: none; }

  .nav-toggle {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.35rem 0.1rem 0.35rem 0.6rem;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--sans);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
  }

  .nav-toggle:hover { color: var(--text); }

  .nav-toggle__bars {
    display: grid;
    gap: 4px;
    width: 14px;
  }

  .nav-toggle__bars span {
    display: block;
    height: 1px;
    background: currentColor;
    transform-origin: center;
    transition: transform 0.2s ease, opacity 0.15s ease;
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(1) {
    transform: translateY(5px) rotate(45deg);
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(2) { opacity: 0; }

  .nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(3) {
    transform: translateY(-5px) rotate(-45deg);
  }

  .sidebar__panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    display: grid;
    grid-template-rows: 0fr;
    background: var(--bg);
    visibility: hidden;
    transition: grid-template-rows 0.22s ease, visibility 0.22s ease;
  }

  .sidebar.is-open .sidebar__panel {
    grid-template-rows: 1fr;
    visibility: visible;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
    transition: grid-template-rows 0.22s ease, visibility 0s;
  }

  .sidebar__panel-inner {
    overflow: hidden;
    min-height: 0;
  }

  .sidebar.is-open .sidebar__panel-inner {
    overflow: auto;
    max-height: calc(100dvh - 4.5rem);
    padding: 0.35rem max(1.25rem, env(safe-area-inset-right)) 1.35rem max(1.25rem, env(safe-area-inset-left));
  }

  .contacts {
    margin-top: 0.35rem;
    padding-top: 0.85rem;
  }

  .contacts a,
  .nav__link {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .sidebar__panel-inner > .sidebar__footer {
    margin-top: 0.85rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
  }

  .main { margin-left: 0; }

  .main__inner {
    max-width: none;
    padding: 2.25rem max(1.25rem, env(safe-area-inset-right)) 3.5rem max(1.25rem, env(safe-area-inset-left));
  }

  .section { padding-top: 3.25rem; scroll-margin-top: 5.25rem; }

  .statement { font-size: 1.125rem; }

  .entry,
  .skills__group {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .entry__meta { padding-top: 0; }
}

@media (max-width: 420px) {
  .nav-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .identity__role { display: none; }
}

/* ---------------------------------------------------------------
   Print — paper, not a dark screenshot
--------------------------------------------------------------- */
@media print {
  .nav-toggle,
  .nav,
  .nav-backdrop,
  .skip-link { display: none !important; }

  body { display: block; }

  .sidebar,
  .main { position: static; width: auto; height: auto; margin: 0; border: 0; }

  html, body {
    background: #fff;
    color: #1c1b17;
  }

  .sidebar__inner { padding: 0 0 1.25rem; min-height: 0; }
  .avatar { width: 3.2rem; height: 3.8rem; }
  .identity { display: flex; gap: 1rem; align-items: center; }
  .identity__name span { display: inline; }
  .identity__name span + span::before { content: " "; }
  .identity__role,
  .identity__org,
  .contacts a,
  .entry__sub,
  .entry__meta time,
  .skills__label,
  .page-footer { color: #4a463f; }
  .entry__title,
  .card__title,
  .section__title,
  .intro__body,
  .statement,
  .bullets li,
  .card__text,
  .tags li { color: #1c1b17; }
  .statement { border-left-color: #6b4f38; }
  .section__head,
  .entry,
  .card,
  .skills__group,
  .contacts,
  .page-footer { border-color: #d9d4cb; }
  a { text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
