/* ==========================================================================
   JR Buckley portfolio
   Single stylesheet. Light and dark themes follow prefers-color-scheme.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-alt: #f4f7fb;
  --surface: #ffffff;
  --border: #dde4ee;
  --border-strong: #c7d2e1;
  --text: #0f1f3a;
  --muted: #4a5a74;
  --accent: #1f5fbf;
  --accent-hover: #174a96;
  --accent-soft: #e9f1fc;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(15, 31, 58, 0.05), 0 4px 16px rgba(15, 31, 58, 0.05);

  --radius: 12px;
  --radius-sm: 8px;
  --container: 1120px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-alt: #0f182a;
    --surface: #121d32;
    --border: #22314c;
    --border-strong: #2f4166;
    --text: #e6edf7;
    --muted: #a6b3c8;
    --accent: #6ea8ff;
    --accent-hover: #9cc3ff;
    --accent-soft: #15264a;
    --on-accent: #0b1220;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

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

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

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

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
svg { flex-shrink: 0; }

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

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 16px; top: -48px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--on-accent); }

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

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

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.brand:hover { color: var(--text); }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.site-nav ul {
  display: flex;
  gap: 4px;
  list-style: none;
}

.site-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}
.site-nav a:hover,
.site-nav a[aria-current="true"] {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

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

.hero {
  padding: 88px 0 72px;
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 56px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(2.75rem, 6vw, 4.25rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  margin-bottom: 14px;
}

.hero-tagline {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 22px;
}
.hero-tagline span { color: var(--border-strong); padding: 0 4px; }

.hero-lede {
  font-size: 1.1875rem;
  max-width: 60ch;
  margin-bottom: 32px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
}

.panel-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #2f9e6b;
  box-shadow: 0 0 0 3px color-mix(in srgb, #2f9e6b 22%, transparent);
}

.focus-list { list-style: none; padding: 8px 0; }
.focus-list li {
  display: flex;
  gap: 14px;
  padding: 14px 20px;
}
.focus-list li + li { border-top: 1px solid var(--border); }
.focus-list svg {
  width: 22px; height: 22px;
  margin-top: 2px;
  color: var(--accent);
}
.focus-list strong { display: block; font-size: 0.9875rem; }
.focus-list span { display: block; font-size: 0.875rem; color: var(--muted); line-height: 1.5; }

/* ---------- Metrics ---------- */

.metrics {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 32px 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  list-style: none;
}

.metric {
  padding: 8px 20px;
  border-left: 1px solid var(--border-strong);
}
.metric:first-child { border-left: 0; padding-left: 0; }

.metric-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1.15;
}
.metric-label {
  display: block;
  margin-top: 4px;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

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

.section { padding: 88px 0; }
.section-alt {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-head h2 {
  font-size: clamp(1.75rem, 3.2vw, 2.375rem);
  font-weight: 750;
}
.section-head-wide { max-width: 720px; margin-bottom: 40px; }
.section-intro { margin-top: 14px; color: var(--muted); font-size: 1.0625rem; }

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  grid-template-areas:
    "head prose"
    "facts prose";
  gap: 24px 64px;
  align-items: start;
}
.about-grid .section-head { grid-area: head; }
.about-grid .prose { grid-area: prose; }
.about-grid .fact-list { grid-area: facts; }

.prose p { font-size: 1.0625rem; }
.prose p:last-child { margin-bottom: 0; }

.fact-list {
  margin: 8px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
}
.fact-list div { padding: 14px 18px; }
.fact-list div + div { border-top: 1px solid var(--border); }
.fact-list dt {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.fact-list dd { margin: 2px 0 0; font-size: 0.9375rem; font-weight: 500; }

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

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.project {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s ease;
}
.project:hover,
.project[open] { border-color: var(--border-strong); }
.project[open] { grid-column: 1 / -1; }

.project summary {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 22px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.project summary::-webkit-details-marker { display: none; }

.project-icon {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.project-icon svg { width: 22px; height: 22px; }

.project-summary { flex: 1; min-width: 0; }
.project-title {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.project-line {
  display: block;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--muted);
}

.chevron {
  width: 10px; height: 10px;
  margin-top: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s ease;
}
.project[open] .chevron { transform: rotate(225deg); margin-top: 12px; }

.case {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  grid-template-areas:
    "ch ap" "c1 ap" "oh ap" "o1 ap" "th ap" "t1 ap";
  grid-template-rows: auto auto auto auto auto 1fr;
  column-gap: 48px;
  padding: 4px 22px 26px 82px;
  border-top: 1px solid var(--border);
}
.case > :nth-child(1) { grid-area: ch; }
.case > :nth-child(2) { grid-area: c1; }
.case > :nth-child(3) { grid-area: ap; }
.case > :nth-child(4) { grid-area: oh; }
.case > :nth-child(5) { grid-area: o1; }
.case > :nth-child(6) { grid-area: th; }
.case > :nth-child(7) { grid-area: t1; align-self: start; }
.case-approach h3 { margin-top: 20px; }
.case h3 {
  margin: 20px 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.case p, .case li { font-size: 0.9625rem; line-height: 1.6; }
.case p { margin: 0; }
.case-approach ul { padding-left: 1.1em; }
.case-approach li + li { margin-top: 6px; }

.tags, .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}
.tags li, .chips li {
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  background: var(--surface);
}

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

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.skill-group {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
}
.skill-group h3 { font-size: 1rem; margin-bottom: 14px; }
.skill-group .chips li { background: var(--surface); }

/* ---------- Approach ---------- */

.approach-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  list-style: none;
}
.approach-grid li {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.step {
  display: inline-block;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
}
.approach-grid h3 { font-size: 1.0625rem; margin-bottom: 8px; }
.approach-grid p { margin: 0; font-size: 0.9375rem; color: var(--muted); }

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

.edu-list {
  list-style: none;
  border-left: 2px solid var(--border-strong);
  max-width: 760px;
}
.edu-list li {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 16px;
  padding: 0 0 28px 28px;
}
.edu-list li:last-child { padding-bottom: 0; }
.edu-list li::before {
  content: "";
  position: absolute;
  left: -7px; top: 7px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.edu-year {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
  padding-top: 1px;
}
.edu-list h3 { font-size: 1.0625rem; margin-bottom: 2px; }
.edu-list p { margin: 0; color: var(--muted); font-size: 0.9375rem; }

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

.contact {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}
.contact-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: center;
}
.contact h2 { font-size: clamp(1.75rem, 3.2vw, 2.375rem); }
.contact-actions { display: grid; gap: 12px; }

.contact-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s ease;
}
.contact-card:hover { border-color: var(--accent); color: var(--text); }
.contact-card svg { width: 24px; height: 24px; color: var(--accent); }
.contact-card strong { display: block; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.contact-card span span { display: block; font-size: 1.0625rem; font-weight: 600; }

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

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-inner p { margin: 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------- 404 ---------- */

.not-found {
  min-height: 70vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 80px 24px;
}
.not-found h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 12px; }
.not-found p { color: var(--muted); margin-bottom: 28px; }

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

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 20px; }
  .metric:nth-child(4) { border-left: 0; padding-left: 0; }
  .approach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "head" "prose" "facts";
  }
}

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    position: absolute;
    top: 64px; left: 0; right: 0;
    display: none;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; padding: 8px 16px 16px; gap: 2px; }
  .site-nav a { padding: 12px; font-size: 1rem; }

  .project-grid { grid-template-columns: 1fr; }
  .case {
    grid-template-columns: 1fr;
    grid-template-areas: "ch" "c1" "ap" "oh" "o1" "th" "t1";
    grid-template-rows: none;
    padding-left: 22px;
  }
  .contact-inner { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  body { font-size: 1rem; }
  .container { padding: 0 20px; }
  .hero { padding: 56px 0 48px; }
  .hero-lede { font-size: 1.0625rem; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; }
  .section { padding: 64px 0; }

  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric, .metric:nth-child(4) { border-left: 0; padding: 0; }
  .metric:last-child { grid-column: 1 / -1; }

  .approach-grid { grid-template-columns: 1fr; }
  .skill-grid { grid-template-columns: 1fr; }

  .project summary { padding: 18px; gap: 14px; }
  .project-icon { width: 38px; height: 38px; }
  .case { padding: 4px 18px 20px; }
  .edu-list li { grid-template-columns: 1fr; gap: 2px; }
}

@media print {
  .site-header, .nav-toggle, .hero-actions, .skip-link { display: none; }
  .project .case { display: block; }
  body { background: #fff; color: #000; }
}
