/* ==========================================================================
   Will Jordan-Cooley, portfolio
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #f7f8fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eef1f7;
  --text: #0e1320;
  --text-muted: #5a6478;
  --text-faint: #8b94a7;
  --border: #e2e6ef;
  --border-strong: #cdd4e2;

  --accent: #2f7df6;
  --accent-2: #12b3a6;
  --accent-soft: rgba(47, 125, 246, 0.1);
  --on-accent: #ffffff;

  --shadow-sm: 0 1px 2px rgba(14, 19, 32, 0.05), 0 1px 3px rgba(14, 19, 32, 0.06);
  --shadow-md: 0 4px 12px rgba(14, 19, 32, 0.07), 0 12px 28px rgba(14, 19, 32, 0.07);
  --shadow-lg: 0 8px 20px rgba(14, 19, 32, 0.09), 0 24px 56px rgba(14, 19, 32, 0.1);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --maxw: 1140px;
  --gutter: clamp(20px, 5vw, 48px);
  --section-y: clamp(72px, 11vw, 132px);

  --nav-h: 66px;
  --font: "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0d14;
    --bg-elev: #121826;
    --bg-sunken: #0d121c;
    --text: #e9edf6;
    --text-muted: #9aa5bb;
    --text-faint: #6c7691;
    --border: #1e2637;
    --border-strong: #2c364b;

    --accent: #6aa6ff;
    --accent-2: #2fd4c4;
    --accent-soft: rgba(106, 166, 255, 0.14);
    --on-accent: #07101f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.36);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.45), 0 24px 56px rgba(0, 0, 0, 0.45);
  }
}

/* Explicit overrides. The theme toggle stamps data-theme on <html>. */
:root[data-theme="light"] {
  --bg: #f7f8fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eef1f7;
  --text: #0e1320;
  --text-muted: #5a6478;
  --text-faint: #8b94a7;
  --border: #e2e6ef;
  --border-strong: #cdd4e2;
  --accent: #2f7df6;
  --accent-2: #12b3a6;
  --accent-soft: rgba(47, 125, 246, 0.1);
  --on-accent: #ffffff;
  --shadow-sm: 0 1px 2px rgba(14, 19, 32, 0.05), 0 1px 3px rgba(14, 19, 32, 0.06);
  --shadow-md: 0 4px 12px rgba(14, 19, 32, 0.07), 0 12px 28px rgba(14, 19, 32, 0.07);
  --shadow-lg: 0 8px 20px rgba(14, 19, 32, 0.09), 0 24px 56px rgba(14, 19, 32, 0.1);
}

:root[data-theme="dark"] {
  --bg: #0a0d14;
  --bg-elev: #121826;
  --bg-sunken: #0d121c;
  --text: #e9edf6;
  --text-muted: #9aa5bb;
  --text-faint: #6c7691;
  --border: #1e2637;
  --border-strong: #2c364b;
  --accent: #6aa6ff;
  --accent-2: #2fd4c4;
  --accent-soft: rgba(106, 166, 255, 0.14);
  --on-accent: #07101f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.45), 0 24px 56px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* height:auto so the width/height attributes (which prevent layout shift) don't
   override CSS sizing. Without it, aspect-ratio loses to the height attribute. */
img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.022em;
  font-weight: 640;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

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

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

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: var(--on-accent);
  padding: 12px 18px;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.nav.is-stuck {
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.nav__brand {
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--text);
  font-size: 1.02rem;
  white-space: nowrap;
  margin-right: auto;
}
.nav__brand:hover { text-decoration: none; }

.nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__links a {
  color: var(--text-muted);
  font-size: 0.94rem;
  font-weight: 520;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.18s ease, background 0.18s ease;
}
.nav__links a:hover,
.nav__links a.is-active {
  color: var(--text);
  background: var(--bg-sunken);
  text-decoration: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.icon-btn svg { width: 18px; height: 18px; }

/* Theme toggle shows the sun in dark mode and the moon in light mode. */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

.nav__menu { display: none; }

@media (max-width: 720px) {
  .nav__links {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px var(--gutter) 20px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .nav__links.is-open { opacity: 1; transform: none; pointer-events: auto; }
  .nav__links a { padding: 12px 14px; font-size: 1rem; }
  .nav__menu { display: inline-grid; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-block: clamp(64px, 12vw, 128px) clamp(56px, 9vw, 104px);
  overflow: hidden;
}

.hero__glow {
  position: absolute;
  inset: -30% -10% auto -10%;
  height: 720px;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(46% 44% at 22% 32%, color-mix(in srgb, var(--accent) 26%, transparent) 0%, transparent 68%),
    radial-gradient(40% 40% at 78% 24%, color-mix(in srgb, var(--accent-2) 22%, transparent) 0%, transparent 66%);
  filter: blur(18px);
  opacity: 0.75;
}

.hero__inner { position: relative; z-index: 1; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 7px 15px 7px 11px;
  border-radius: 999px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-sm);
}
.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent);
}

.hero h1 {
  font-size: clamp(2.6rem, 7.2vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 22px;
}

.hero__lede {
  font-size: clamp(1.12rem, 2.3vw, 1.42rem);
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 30ch;
  margin-bottom: 14px;
  text-wrap: pretty;
}

.grad {
  background: linear-gradient(100deg, var(--accent) 8%, var(--accent-2) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__sub {
  font-size: 1.03rem;
  color: var(--text-faint);
  max-width: 54ch;
  margin-bottom: 34px;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.96rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    background 0.18s ease, border-color 0.18s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn svg { width: 17px; height: 17px; }

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn--primary:hover {
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 40%, transparent);
}

.btn--ghost {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn--ghost:hover { box-shadow: var(--shadow-md); }

/* Hero stats */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(24px, 5vw, 56px);
  margin-top: 54px;
  padding-top: 34px;
  border-top: 1px solid var(--border);
}
.stat__n {
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  font-weight: 680;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat__l {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ---------- Sections ---------- */
.section { padding-block: var(--section-y); }
.section--sunken {
  background: var(--bg-sunken);
  border-block: 1px solid var(--border);
}

.section__head { max-width: 60ch; margin-bottom: clamp(36px, 5vw, 56px); }

.section__kicker {
  display: block;
  font-size: 0.79rem;
  font-weight: 640;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.section__title {
  font-size: clamp(1.9rem, 4.4vw, 2.7rem);
  letter-spacing: -0.032em;
  margin-bottom: 14px;
}

.section__sub { color: var(--text-muted); font-size: 1.05rem; }

/* ---------- Project grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: clamp(18px, 2.4vw, 26px);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.3, 1),
    box-shadow 0.28s ease, border-color 0.28s ease;
}
.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
}
.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.card:hover .card__media img { transform: scale(1.045); }

.card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 22px 24px 24px;
}

.card__title {
  font-size: 1.22rem;
  letter-spacing: -0.025em;
  margin-bottom: 10px;
}

.card__text {
  color: var(--text-muted);
  font-size: 0.955rem;
  line-height: 1.62;
  margin-bottom: 20px;
  flex: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}
.tag {
  font-size: 0.74rem;
  font-weight: 580;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.tag--now {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.card__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 0.93rem;
  align-self: flex-start;
}
.card__link svg {
  width: 15px;
  height: 15px;
  transition: transform 0.22s ease;
}
.card:hover .card__link svg { transform: translate(2px, -2px); }

/* Featured card spans two columns on wide screens */
.card--featured { grid-column: span 2; }
.card--featured .card__media { aspect-ratio: 16 / 8.2; }
.card--featured .card__title { font-size: 1.55rem; }
.card--featured .card__text { font-size: 1.02rem; max-width: 62ch; }

@media (max-width: 719px) {
  .card--featured { grid-column: span 1; }
}

/* ---------- Writing ---------- */
.posts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: clamp(18px, 2.4vw, 26px);
}

.post-card {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 20px;
  align-items: center;
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: inherit;
  transition: transform 0.26s ease, box-shadow 0.26s ease, border-color 0.26s ease;
}
.post-card:hover {
  text-decoration: none;
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}
.post-card__thumb {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunken);
}
.post-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-card__date {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 7px;
}
.post-card__title {
  font-size: 1.12rem;
  letter-spacing: -0.022em;
  margin-bottom: 8px;
}
.post-card__excerpt {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.56;
}

@media (max-width: 460px) {
  .post-card { grid-template-columns: 1fr; }
  .post-card__thumb { aspect-ratio: 16 / 9; }
}

/* ---------- Timeline ---------- */
.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: clamp(36px, 6vw, 72px);
}

.col__label {
  font-size: 0.79rem;
  font-weight: 640;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding-bottom: 14px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.tl { list-style: none; margin: 0; padding: 0; }

.tl__item {
  position: relative;
  padding-left: 30px;
  padding-bottom: 34px;
}
.tl__item:last-child { padding-bottom: 0; }

.tl__item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  z-index: 1;
}
.tl__item::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 20px;
  bottom: 2px;
  width: 1px;
  background: var(--border);
}
.tl__item:last-child::after { display: none; }

.tl__role {
  font-size: 1.06rem;
  font-weight: 620;
  letter-spacing: -0.018em;
  margin-bottom: 4px;
}
.tl__meta {
  font-size: 0.83rem;
  font-weight: 560;
  color: var(--accent);
  margin-bottom: 10px;
}
.tl__desc {
  font-size: 0.94rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 68px);
  align-items: start;
}
@media (max-width: 760px) {
  .about { grid-template-columns: 1fr; }
}

.about__photo {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  max-width: 300px;
}
.about__photo img { width: 100%; aspect-ratio: 1; object-fit: cover; }

.about__quote {
  font-size: clamp(1.25rem, 2.7vw, 1.65rem);
  line-height: 1.42;
  letter-spacing: -0.024em;
  font-weight: 560;
  margin-bottom: 22px;
  text-wrap: pretty;
}
.about__body { color: var(--text-muted); font-size: 1.03rem; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding-block: 40px;
  background: var(--bg-sunken);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}
.footer p { font-size: 0.9rem; color: var(--text-faint); margin: 0; }
.footer__social { display: flex; gap: 8px; }

/* ---------- Article pages ---------- */
.article { padding-block: clamp(48px, 8vw, 88px) var(--section-y); }
.article__wrap { max-width: 760px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 560;
  color: var(--text-muted);
  margin-bottom: 30px;
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.back-link svg { width: 15px; height: 15px; }

.article__date {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.article__title {
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.036em;
  margin-bottom: 18px;
}
.article__standfirst {
  font-size: 1.16rem;
  color: var(--text-muted);
  line-height: 1.6;
  padding-bottom: 32px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.prose { font-size: 1.06rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.25em; }
.prose h2 {
  font-size: 1.55rem;
  letter-spacing: -0.028em;
  margin-top: 2.2em;
  margin-bottom: 0.1em;
}
.prose h3 {
  font-size: 1.18rem;
  margin-top: 1.9em;
  margin-bottom: 0.1em;
}
.prose figure { margin: 2.2em 0; }
.prose figure img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.prose figcaption {
  font-size: 0.86rem;
  color: var(--text-faint);
  text-align: center;
  margin-top: 12px;
}
.prose .byline {
  color: var(--text-muted);
  font-size: 0.97rem;
  line-height: 1.5;
}
.prose .refs {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.prose .refs p { text-indent: -1.4em; padding-left: 1.4em; }
.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.6em 0;
}

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s cubic-bezier(0.2, 0.7, 0.3, 1),
    transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
  will-change: opacity, transform;
}
.reveal.is-in { opacity: 1; transform: none; }

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