/* =========================================================================
   Chris Edwards — spcmky.net
   Tokens, then components. Every value comes from the scale.
   ========================================================================= */

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

:root {
  /* Spacing — 4px base */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Type */
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.75rem;
  --text-3xl: clamp(2rem, 1.4rem + 2.6vw, 3rem);
  --text-display: clamp(2.5rem, 1.4rem + 4.6vw, 4.5rem);

  /* Shape */
  --radius-sm: 0.375rem;
  --radius: 0.625rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  --shell: 68rem;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Dark is the default and the design's home base. */
[data-theme="dark"] {
  --bg: #0b0d10;
  --bg-elevated: #101319;
  --surface: #14181f;
  --surface-hover: #1a1f27;
  --border: #232833;
  --border-strong: #333a47;

  --text: #e8ebef;
  --text-muted: #9aa4b2;
  /* Tuned to clear 4.5:1 on --surface, the lightest thing it sits on. */
  --text-faint: #798290;

  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-contrast: #04211d;
  --accent-soft: rgba(45, 212, 191, 0.12);

  --glow-a: rgba(45, 212, 191, 0.16);
  --glow-b: rgba(56, 128, 255, 0.10);
  --grid-line: rgba(255, 255, 255, 0.035);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg: #fbfbfa;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f6f7f8;
  --border: #e3e5e9;
  --border-strong: #cfd3da;

  --text: #14171b;
  --text-muted: #55606d;
  /* Tuned to clear 4.5:1 on --bg, the darkest thing it sits on. */
  --text-faint: #69737f;

  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(15, 118, 110, 0.09);

  --glow-a: rgba(15, 118, 110, 0.10);
  --glow-b: rgba(56, 128, 255, 0.08);
  --grid-line: rgba(15, 23, 42, 0.045);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lift: 0 12px 28px rgba(15, 23, 42, 0.10);
}

/* ---------- Reset ------------------------------------------------------- */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
/* Theme switching is deliberately instant: easing only the body background makes
   it drift out of step with the section surfaces, which snap. */

img, svg { display: block; max-width: 100%; }
ul { list-style: none; padding: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

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

/* ---------- Layout primitives ------------------------------------------- */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus { transform: translateY(0); }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background-color 0.3s var(--ease);
}

.site-header[data-scrolled="true"] { border-bottom-color: var(--border); }

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-height: 4rem;
}

/* Keeps the nav from forcing page-level overflow on very narrow screens. */
.site-header__inner > .site-nav { min-width: 0; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  margin-right: auto;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.wordmark__mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
}

.site-nav {
  display: flex;
  gap: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.site-nav a {
  position: relative;
  padding-block: var(--space-1);
  transition: color 0.2s var(--ease);
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease);
}

.site-nav a:hover { color: var(--text); }
.site-nav a:hover::after { transform: scaleX(1); }

.theme-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.theme-toggle__icon {
  grid-area: 1 / 1;
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .theme-toggle__icon--sun,
[data-theme="light"] .theme-toggle__icon--moon { display: none; }

/* ---------- Buttons ----------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease),
    border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn--primary:hover { background: var(--accent-hover); }

.btn--ghost {
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn__arrow {
  width: 0.875rem;
  height: 0.875rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s var(--ease);
}

.btn:hover .btn__arrow { transform: translate(2px, -2px); }

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

.hero {
  position: relative;
  padding-block: var(--space-24) var(--space-16);
  overflow: hidden;
}

.hero__backdrop {
  position: absolute;
  inset: -20% -10% auto;
  height: 46rem;
  z-index: 0;
  background:
    radial-gradient(42rem 26rem at 22% 18%, var(--glow-a), transparent 65%),
    radial-gradient(34rem 22rem at 82% 8%, var(--glow-b), transparent 62%);
  pointer-events: none;
}

.hero__backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 4.5rem 4.5rem;
  mask-image: radial-gradient(60% 50% at 50% 30%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(60% 50% at 50% 30%, #000 20%, transparent 75%);
}

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

.eyebrow {
  display: inline-block;
  margin-bottom: var(--space-6);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
}

.hero__title {
  max-width: 18ch;
  font-size: var(--text-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.hero__lede {
  max-width: 60ch;
  margin-top: var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: 1.7;
  text-wrap: pretty;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-16);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
}

.stat dt {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stat dd {
  margin-top: var(--space-2);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat--text { font-size: var(--text-xl); }
.stat__unit { color: var(--accent); }

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

.section { padding-block: var(--space-24); }

.section--alt {
  background: var(--bg-elevated);
  border-block: 1px solid var(--border);
}

.section__head {
  max-width: 46rem;
  margin-bottom: var(--space-12);
}

.section__kicker {
  margin-bottom: var(--space-4);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section__title {
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.section__lede {
  max-width: 56ch;
  margin-top: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-lg);
  text-wrap: pretty;
}

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

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

/* ---------- Focus cards ------------------------------------------------- */

/* Four cards, so an explicit 2x2 — auto-fit would strand one on its own row. */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 40rem) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

.card {
  position: relative;
  padding: var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}

.card__index {
  display: block;
  margin-bottom: var(--space-6);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
}

.card__title {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.card__body {
  margin-top: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.7;
  text-wrap: pretty;
}

/* ---------- Projects ---------------------------------------------------- */

.projects {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 40rem) {
  .projects { grid-template-columns: repeat(2, 1fr); }
}

/* Five projects into three columns: the lead one spans two, so both rows fill. */
@media (min-width: 60rem) {
  .projects { grid-template-columns: repeat(3, 1fr); }
  .projects > :first-child { grid-column: span 2; }
}

.project { display: flex; }

.project__link {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.project__link:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}

.project__lang {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  align-self: flex-start;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.03em;
}

.project__lang::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--text-faint);
}

.project__lang[data-lang="TypeScript"]::before { background: #3178c6; }
.project__lang[data-lang="Python"]::before { background: #f2c14e; }
.project__lang[data-lang="Groovy"]::before { background: #4298b8; }
.project__lang[data-lang="HTML"]::before { background: #e34c26; }

.project__title {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.project__body {
  flex: 1;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.7;
  text-wrap: pretty;
}

.project__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 600;
}

.project__link:hover .btn__arrow { transform: translate(2px, -2px); }

/* ---------- Stack ------------------------------------------------------- */

/* Four groups — explicit columns so the last one never strands on its own row. */
.stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8) var(--space-12);
}

@media (min-width: 34rem) {
  .stack { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 60rem) {
  .stack { grid-template-columns: repeat(4, 1fr); }
}

.stack__label {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.tags li {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.tags li:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ---------- Contact ----------------------------------------------------- */

.section--contact {
  border-top: 1px solid var(--border);
  background:
    radial-gradient(38rem 20rem at 50% 0%, var(--glow-a), transparent 70%),
    var(--bg);
}

.contact {
  max-width: 46rem;
  margin-inline: auto;
  text-align: center;
}

.contact__title {
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.contact__lede {
  max-width: 52ch;
  margin: var(--space-4) auto 0;
  color: var(--text-muted);
  font-size: var(--text-lg);
  text-wrap: pretty;
}

.contact__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

/* ---------- Footer ------------------------------------------------------ */

.site-footer {
  padding-block: var(--space-8);
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
}

.site-footer__meta { font-family: var(--font-mono); font-size: var(--text-xs); }

/* ---------- Reveal on scroll -------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Responsive -------------------------------------------------- */

@media (max-width: 46rem) {
  :root { --space-24: 4.5rem; }

  .shell { padding-inline: var(--space-4); }

  /* The mark alone carries the identity; the name is already the <h1> below. */
  .wordmark__text { display: none; }

  .site-header__inner { gap: var(--space-4); }

  /* Nav stays reachable on small screens — it scrolls rather than disappearing. */
  .site-nav {
    gap: var(--space-4);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { white-space: nowrap; }

  .hero { padding-block: var(--space-16) var(--space-12); }
  .hero__title { max-width: none; }
  .stats { margin-top: var(--space-12); }
  .site-footer__inner { flex-direction: column; }
}

/* Touch devices need a 44px minimum hit area, without a 44px visual box. */
@media (pointer: coarse) {
  .theme-toggle { position: relative; }

  .theme-toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.75rem;
    height: 2.75rem;
    transform: translate(-50%, -50%);
  }

  .site-nav a { padding-block: var(--space-3); }
}

/* ---------- Motion & print ---------------------------------------------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .theme-toggle, .hero__backdrop { display: none; }
  body { background: #fff; color: #000; }
  .section { padding-block: var(--space-8); }
  .reveal { opacity: 1; transform: none; }
}
