/* ==========================================================================
   Adam Schapekahm, personal resume site
   Plain CSS. Tokens first, then layout, then components, then print.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
  color-scheme: light;

  --bg:        #faf9f7;
  --surface:   #ffffff;
  --surface-2: #f3f0eb;
  --ink:       #15191f;
  --ink-2:     #4c5563;
  --ink-3:     #626b78;
  --line:      #e3ded6;
  --accent:    #1a56c4;
  --accent-2:  #14418f;
  --accent-soft: #e9effc;
  --shadow:    0 1px 2px rgb(21 25 31 / 6%), 0 8px 24px -12px rgb(21 25 31 / 14%);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;

  --step--1: clamp(0.82rem, 0.8rem + 0.1vw, 0.88rem);
  --step-0:  clamp(1rem, 0.96rem + 0.18vw, 1.08rem);
  --step-1:  clamp(1.13rem, 1.05rem + 0.35vw, 1.3rem);
  --step-2:  clamp(1.35rem, 1.2rem + 0.7vw, 1.75rem);
  --step-3:  clamp(1.7rem, 1.4rem + 1.4vw, 2.5rem);
  --step-4:  clamp(2.2rem, 1.6rem + 2.8vw, 4rem);

  --gutter: clamp(1.15rem, 4vw, 2.5rem);
  --wrap: 68rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #0e1116;
    --surface:   #161b22;
    --surface-2: #1b212a;
    --ink:       #e9edf3;
    --ink-2:     #aab4c2;
    --ink-3:     #828d9c;
    --line:      #2a313b;
    --accent:    #7aa7ff;
    --accent-2:  #9dbcff;
    --accent-soft: #18233a;
    --shadow:    0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0e1116;
  --surface:   #161b22;
  --surface-2: #1b212a;
  --ink:       #e9edf3;
  --ink-2:     #aab4c2;
  --ink-3:     #828d9c;
  --line:      #2a313b;
  --accent:    #7aa7ff;
  --accent-2:  #9dbcff;
  --accent-soft: #18233a;
  --shadow:    0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
}

/* --- Base ----------------------------------------------------------------- */

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

html {
  scroll-behavior: smooth;
  /* Sticky header would otherwise cover the top of a linked section. */
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-2); }

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; color: #fff; }

/* --- Header --------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.75rem;
  flex-wrap: wrap;
}

.wordmark {
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

.site-nav ul { display: flex; gap: clamp(0.75rem, 2vw, 1.5rem); flex-wrap: wrap; }

.site-nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--step--1);
  font-weight: 550;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--step--1);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.theme-toggle__icon {
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  border: 2px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
/* Narrow screens: wordmark and toggle share the first row, nav drops to its own. */
@media (max-width: 40rem) {
  .theme-toggle__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .theme-toggle { padding: 0.4rem; order: 1; }
  .site-nav { order: 2; flex-basis: 100%; padding-bottom: 0.5rem; }
  .header-inner { row-gap: 0; padding-block: 0.5rem; }
}

/* --- Hero ----------------------------------------------------------------- */

.hero { padding-block: clamp(2.5rem, 7vw, 5.5rem) clamp(2rem, 5vw, 3.5rem); }

.hero-grid {
  display: grid;
  gap: clamp(1.75rem, 5vw, 3.5rem);
  align-items: center;
}
@media (min-width: 48rem) {
  .hero-grid { grid-template-columns: 1.35fr 1fr; }
}

.eyebrow {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.9rem;
}

.hero h1 {
  font-size: var(--step-4);
  font-weight: 700;
  letter-spacing: -0.035em;
  margin-bottom: 0.5rem;
}

.hero-title {
  font-size: var(--step-2);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.hero-roles {
  margin-top: 0.5rem;
  color: var(--ink-3);
  font-size: var(--step--1);
  font-weight: 550;
}
.hero-roles span { margin-inline: 0.4rem; }

.hero-summary {
  margin-top: 1.4rem;
  color: var(--ink-2);
  max-width: 46ch;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 1.2rem;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.btn:hover { border-color: var(--ink-3); color: var(--ink); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.hero-photo { margin: 0; }
.hero-photo img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 5;
  object-fit: cover;
}
@media (max-width: 47.99rem) {
  /* On phones the portrait is a supporting detail, not the headline. */
  .hero-photo { max-width: 16rem; }
  .hero-grid { grid-template-areas: "photo" "text"; }
  .hero-text { grid-area: text; }
  .hero-photo { grid-area: photo; }
}

/* --- Stat row ------------------------------------------------------------- */

.stats { padding-block: clamp(1rem, 3vw, 2rem); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (min-width: 46rem) {
  .stat-row { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--surface);
  padding: clamp(1.1rem, 3vw, 1.6rem) clamp(1rem, 2.5vw, 1.4rem);
}

.stat__value {
  font-size: var(--step-3);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}
.stat__plus { color: var(--accent); }

.stat__label {
  margin-top: 0.35rem;
  font-size: var(--step--1);
  color: var(--ink-3);
  line-height: 1.4;
}

/* --- Sections ------------------------------------------------------------- */

.section { padding-block: clamp(3rem, 8vw, 5.5rem); }
.section--alt { background: var(--surface-2); border-block: 1px solid var(--line); }

.section-title {
  font-size: var(--step-3);
  font-weight: 650;
  letter-spacing: -0.03em;
}

.section-intro {
  margin-top: 0.9rem;
  color: var(--ink-2);
  max-width: 58ch;
}

/* --- Timeline ------------------------------------------------------------- */

.timeline {
  margin-top: clamp(2rem, 5vw, 3rem);
  position: relative;
  padding-left: 1.75rem;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 2px;
  background: var(--line);
}

.role { position: relative; padding-bottom: clamp(2.25rem, 5vw, 3rem); }
.role:last-child { padding-bottom: 0; }

.role::before {
  content: "";
  position: absolute;
  left: -1.75rem;
  top: 0.55rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--ink-3);
}
.section--alt .role::before { background: var(--surface-2); }
.role:first-child::before { background: var(--accent); border-color: var(--accent); }

.role__title {
  font-size: var(--step-1);
  font-weight: 650;
}

.role__org { margin-top: 0.3rem; color: var(--ink-2); font-weight: 550; }
.role__loc { color: var(--ink-3); font-weight: 400; }

.role__dates {
  margin-top: 0.2rem;
  font-size: var(--step--1);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Cap the measure: full-width bullets run past a comfortable reading line. */
.role__points { margin-top: 1.1rem; display: grid; gap: 0.7rem; max-width: 70ch; }

.role__points li {
  position: relative;
  padding-left: 1.1rem;
  color: var(--ink-2);
}
.role__points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
}

/* --- Project cards -------------------------------------------------------- */

.cards {
  margin-top: clamp(2rem, 5vw, 3rem);
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 1.75rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--ink-3); transform: translateY(-2px); }

.card__kicker {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.card__title { font-size: var(--step-1); font-weight: 650; }
.card__body { color: var(--ink-2); font-size: var(--step--1); line-height: 1.6; }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 0.5rem; }
.tags li {
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

/* --- Skills --------------------------------------------------------------- */

.skill-grid {
  margin-top: clamp(2rem, 5vw, 3rem);
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}

.skill-group h3 {
  font-size: var(--step-0);
  font-weight: 650;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-soft);
}
.skill-group p { margin-top: 0.6rem; color: var(--ink-2); font-size: var(--step--1); }

/* --- Education ------------------------------------------------------------ */

.edu-grid {
  margin-top: clamp(2rem, 5vw, 3rem);
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.edu h3 { font-size: var(--step-1); font-weight: 650; margin-bottom: 0.6rem; }
.edu__detail { color: var(--ink-2); }
.edu__meta { margin-top: 0.5rem; font-size: var(--step--1); color: var(--ink-3); }
.edu__list { margin-top: 0.3rem; display: grid; gap: 0.35rem; color: var(--ink-2); }
.edu__list li { position: relative; padding-left: 1.1rem; }
.edu__list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.7em;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
}

/* --- Contact & footer ----------------------------------------------------- */

/* .contact-inner is also a .wrap, so capping it here would center the whole
   block away from the page's left edge. Cap the prose instead. */
.contact-lede { margin-top: 0.9rem; color: var(--ink-2); max-width: 52ch; }

.contact-links {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.6rem;
  font-weight: 550;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2rem;
  color: var(--ink-3);
  font-size: var(--step--1);
}

/* --- Blog: index --------------------------------------------------------- */

.tag-filter {
  margin-top: clamp(1.5rem, 4vw, 2.25rem);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.tag-filter__label {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-3);
}

.tag-filter__buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag-filter button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.tag-filter button:hover { color: var(--ink); border-color: var(--ink-3); }
.tag-filter button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.post-list {
  margin-top: clamp(1.75rem, 4vw, 2.5rem);
  display: grid;
  gap: clamp(1.25rem, 3vw, 1.75rem);
}

.post-card {
  border-top: 1px solid var(--line);
  padding-top: clamp(1.25rem, 3vw, 1.75rem);
}
.post-card[hidden] { display: none; }

.post-card__meta {
  font-size: var(--step--1);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.post-card__title {
  margin-top: 0.35rem;
  font-size: var(--step-2);
  font-weight: 650;
  letter-spacing: -0.025em;
}
.post-card__title a { color: var(--ink); text-decoration: none; }
.post-card__title a:hover { color: var(--accent); }

.post-card__excerpt {
  margin-top: 0.6rem;
  color: var(--ink-2);
  max-width: 62ch;
}

.post-card .tags { margin-top: 0.9rem; }

.post-list__empty { margin-top: 2rem; color: var(--ink-3); }

/* --- Blog: post ---------------------------------------------------------- */

.post__inner { max-width: 44rem; margin-inline: auto; }

.post__back { font-size: var(--step--1); font-weight: 550; }
.post__back a { text-decoration: none; }
.post__back a:hover { text-decoration: underline; }

.post__header {
  margin-top: 1.5rem;
  padding-bottom: clamp(1.25rem, 3vw, 1.75rem);
  border-bottom: 1px solid var(--line);
}

.post__title {
  font-size: var(--step-3);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.post__meta {
  margin-top: 0.7rem;
  font-size: var(--step--1);
  color: var(--ink-3);
}
.post__meta span[aria-hidden] { margin-inline: 0.4rem; }

.post__header .tags { margin-top: 0.9rem; }

/* Long-form measure: prose reads at a narrower column than the page grid. */
.post__body { margin-top: clamp(1.75rem, 4vw, 2.5rem); }
.post__body > * + * { margin-top: 1.15rem; }
.post__body p { color: var(--ink-2); }

.post__lede {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--ink) !important;
}

.post__body h2 {
  margin-top: 2.25rem;
  font-size: var(--step-1);
  font-weight: 650;
  color: var(--ink);
}

.post__body ul { display: grid; gap: 0.7rem; }
.post__body li { position: relative; padding-left: 1.1rem; color: var(--ink-2); }
.post__body li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
}
.post__body strong { color: var(--ink); font-weight: 650; }

.post__footer {
  margin-top: clamp(2.25rem, 5vw, 3rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

/* --- Home page: writing teaser ------------------------------------------- */

.writing-teaser { margin-top: clamp(1.75rem, 4vw, 2.5rem); display: grid; gap: 1.25rem; }
.writing-teaser .post-card:first-child { border-top: 0; padding-top: 0; }

/* --- Motion --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card:hover { transform: none; }
}

/* --- Print ---------------------------------------------------------------- */

@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --ink: #000; --ink-2: #222; --ink-3: #555;
    --line: #bbb; --accent: #000; --accent-2: #000; --accent-soft: #fff;
    --shadow: none;
  }
  /* The fluid clamp() scale keys off viewport width, which is meaningless on
     paper, so pin the whole scale to points instead. */
  :root {
    --step--1: 8.5pt; --step-0: 10pt; --step-1: 11.5pt;
    --step-2: 13pt;   --step-3: 15pt; --step-4: 24pt;
    --gutter: 0; --wrap: 100%;
  }
  body { font-size: 10pt; line-height: 1.45; }
  .hero-grid { grid-template-columns: 1fr 1.4in; gap: 1rem; align-items: start; }
  .hero-summary, .role__points, .contact-lede { max-width: none; }
  .stat__value { font-size: 14pt; }
  .site-header, .skip-link, .hero-actions, .site-footer, .theme-toggle,
  .tag-filter, .post__back { display: none; }
  .section, .hero { padding-block: 0.9rem; }
  .section--alt { background: none; border: 0; }
  .hero-photo { max-width: 9rem; }
  .card, .stat { break-inside: avoid; box-shadow: none; }
  .role { break-inside: avoid; padding-bottom: 1rem; }
  a { text-decoration: none; }
  /* Spell out destinations that a printed page would otherwise lose. */
  .contact-links a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}
