/* cameronbasham.com: single page, no build step. */

:root {
  /* Raw tokens, one per scheme */
  --bg-l: #fafaf7;        --bg-d: #0b0d10;
  --surface-l: #ffffff;   --surface-d: #12161b;
  --raised-l: #f1f1ec;    --raised-d: #181d24;
  --border-l: #dcdfe3;    --border-d: #252c36;
  --text-l: #14171b;      --text-d: #e9edf2;
  --muted-l: #56606b;     --muted-d: #9ba7b4;
  --accent-l: #c8322c;    --accent-d: #ff6a61;
  --accent2-l: #8a5600;   --accent2-d: #ffb454;
  --on-accent-l: #ffffff; --on-accent-d: #1a0605;

  /* Fallback for browsers without light-dark(): follow the system setting */
  --bg: var(--bg-l);
  --surface: var(--surface-l);
  --raised: var(--raised-l);
  --border: var(--border-l);
  --text: var(--text-l);
  --muted: var(--muted-l);
  --accent: var(--accent-l);
  --accent2: var(--accent2-l);
  --on-accent: var(--on-accent-l);

  @media (prefers-color-scheme: dark) {
    --bg: var(--bg-d);
    --surface: var(--surface-d);
    --raised: var(--raised-d);
    --border: var(--border-d);
    --text: var(--text-d);
    --muted: var(--muted-d);
    --accent: var(--accent-d);
    --accent2: var(--accent2-d);
    --on-accent: var(--on-accent-d);
  }

  @supports (color: light-dark(white, black)) {
    --bg: light-dark(var(--bg-l), var(--bg-d));
    --surface: light-dark(var(--surface-l), var(--surface-d));
    --raised: light-dark(var(--raised-l), var(--raised-d));
    --border: light-dark(var(--border-l), var(--border-d));
    --text: light-dark(var(--text-l), var(--text-d));
    --muted: light-dark(var(--muted-l), var(--muted-d));
    --accent: light-dark(var(--accent-l), var(--accent-d));
    --accent2: light-dark(var(--accent2-l), var(--accent2-d));
    --on-accent: light-dark(var(--on-accent-l), var(--on-accent-d));
  }

  color-scheme: light dark;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --wrap: 68rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --nav-h: 3.5rem;
  --radius: 0.75rem;
}

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

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  /* faint measurement grid */
  background-image:
    linear-gradient(to right, color-mix(in oklab, var(--border) 45%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in oklab, var(--border) 45%, transparent) 1px, transparent 1px);
  background-size: 3rem 3rem;
  background-attachment: fixed;
}

img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration-color: color-mix(in oklab, currentColor 40%, transparent); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 20;
  background: var(--accent); color: var(--on-accent); padding: 0.5rem 0.9rem; border-radius: 0.5rem; font-weight: 600;
  &:focus { top: 0.6rem; }
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);

  .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: var(--nav-h); }
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; text-decoration: none;
  .mark {
    display: grid; place-items: center; inline-size: 2rem; block-size: 2rem; border-radius: 0.45rem;
    background: var(--accent); color: var(--on-accent); font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.02em;
  }
}
.links {
  display: flex; align-items: center; gap: clamp(0.25rem, 1.5vw, 1rem);
  scroll-target-group: auto;

  a {
    font-size: 0.9rem; color: var(--muted); text-decoration: none; padding: 0.4rem 0.55rem; border-radius: 0.4rem;
    border-bottom: 2px solid transparent;
    &:hover { color: var(--text); }
  }
  /* :is() keeps the rule valid where :target-current is unknown */
  a:is(:target-current, .\:target-current) { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
  a.cta { color: var(--text); border: 1px solid var(--border); background: var(--surface); }
}
@media (max-width: 40rem) {
  .links a:not(.cta) { display: none; }
}

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: clip;
  padding-block: clamp(3rem, 9vw, 6.5rem) clamp(6.5rem, 12vw, 8rem);

  .wrap { display: grid; gap: clamp(1.5rem, 5vw, 4rem); grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}
.trace {
  position: absolute; inset-inline: 0; bottom: 0; inline-size: 100%; block-size: 5rem; z-index: -1;
  color: var(--accent); opacity: 0.35;
}
.pill {
  display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--mono); font-size: 0.78rem; color: var(--muted);
  border: 1px solid var(--border); background: var(--surface); padding: 0.3rem 0.7rem; border-radius: 999px;
  &::before { content: ""; inline-size: 0.5rem; block-size: 0.5rem; border-radius: 50%; background: var(--accent2); }
}
h1 { font-size: clamp(2.4rem, 7vw, 4.25rem); line-height: 1.05; letter-spacing: -0.02em; margin-block: 1rem 0.4rem; text-wrap: balance; }
.role { font-size: clamp(1.1rem, 2.6vw, 1.5rem); font-weight: 600; color: var(--accent); }
.lede { margin-top: 1.1rem; max-width: 38rem; font-size: 1.08rem; color: var(--muted); text-wrap: pretty; }
.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.6rem; }
.btn {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0.55rem 1.1rem; border-radius: 0.6rem;
  font-weight: 600; text-decoration: none; border: 1px solid var(--border); background: var(--surface);
  &:hover { border-color: var(--muted); }
  &.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
  &.primary:hover { filter: brightness(1.08); }
}
.portrait {
  inline-size: clamp(8rem, 22vw, 13rem); aspect-ratio: 1; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--surface); outline: 1px solid var(--border);
}
.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 2.2rem; max-width: 38rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);

  > div { padding: 0.9rem 1.1rem; }
  > div + div { border-inline-start: 1px solid var(--border); }
  dt { font-size: 0.8rem; color: var(--muted); }
  dd { margin: 0; font-family: var(--mono); font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 700; color: var(--accent2); line-height: 1.2; }
  /* number first visually, label second, while keeping dt/dd order in the DOM */
  > div { display: flex; flex-direction: column-reverse; justify-content: flex-end; }
}
@media (max-width: 40rem) {
  .hero .wrap { grid-template-columns: 1fr; }
  .portrait { order: -1; }
}

/* ---------- sections ---------- */
section { padding-block: clamp(2.75rem, 7vw, 5rem); }
.eyebrow { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent2); }
h2 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; letter-spacing: -0.015em; margin-block: 0.35rem 1.6rem; text-wrap: balance; }
h3 { font-size: 1.12rem; line-height: 1.3; }

.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
/* four project cards read better two-up than three plus an orphan */
#projects .cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1.3rem 1.3rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.75rem;

  p { color: var(--muted); font-size: 0.96rem; }
  .tags { margin-top: auto; padding-top: 0.4rem; }
}
.facts { display: grid; gap: 0.45rem; font-size: 0.95rem;
  li { padding-inline-start: 1.1rem; position: relative; }
  li::before { content: ""; position: absolute; inset-inline-start: 0; top: 0.62em; inline-size: 0.4rem; block-size: 0.4rem; border-radius: 50%; background: var(--accent); }
}
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem;
  li { font-family: var(--mono); font-size: 0.74rem; padding: 0.18rem 0.55rem; border-radius: 999px; background: var(--raised); border: 1px solid var(--border); color: var(--muted); }
}

/* ---------- timeline ---------- */
.timeline { display: grid; gap: 1rem; counter-reset: job; }
.job {
  counter-increment: job;
  display: grid; grid-template-columns: 3.2rem minmax(0, 1fr); gap: 0 1rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1.3rem;

  &::before { content: counter(job, decimal-leading-zero); font-family: var(--mono); font-size: 1.3rem; font-weight: 700; color: var(--accent); line-height: 1.3; }
  > div { display: grid; gap: 0.7rem; }
  header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.2rem 1rem; align-items: baseline; }
  .org { color: var(--muted); font-size: 0.95rem; }
  .when { font-family: var(--mono); font-size: 0.8rem; color: var(--accent2); white-space: nowrap; }
  .note { color: var(--muted); font-size: 0.95rem; }
}
@media (max-width: 40rem) {
  .job { grid-template-columns: 1fr; }
  .job::before { margin-bottom: 0.3rem; }
}

/* ---------- skills ---------- */
.skills { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  > div { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1.1rem 1.2rem; display: grid; gap: 0.7rem; align-content: start; }
  h3 { font-size: 0.78rem; font-family: var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
}

/* ---------- contact ---------- */
.contact { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.contact a {
  display: grid; gap: 0.1rem; align-content: start; min-width: min(100%, 15rem); flex: 1; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1rem 1.2rem;
  &:hover { border-color: var(--accent); }
  span { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
  strong { font-weight: 600; overflow-wrap: anywhere; }
}

footer {
  border-top: 1px solid var(--border); padding-block: 1.5rem 2rem; color: var(--muted); font-size: 0.88rem;
  .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; }
}

/* ---------- decorative entry effect (progressive enhancement, no fallback needed) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes rise { from { opacity: 0; translate: 0 1.25rem; } }
    .card, .job, .skills > div, .contact a {
      animation: rise auto ease-out backwards;
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
  }
}

@media print {
  .nav, .trace, .actions, .skip { display: none; }
  body { background: none; }
  section { padding-block: 1rem; }
}
