/* =========================================================
   Portfolio — shared stylesheet
   Every page links this one file. Change colours, spacing
   and fonts in the :root block below and the whole site follows.
   ========================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Accent — identical in light and dark mode */
  --accent: #e25a12;          /* "safety orange" */
  --accent-strong: #c24a0b;   /* hover / pressed */
  --accent-soft: rgba(226, 90, 18, 0.12);
  --on-accent: #ffffff;       /* text sitting on the accent */

  /* Light theme (default) */
  --bg: #f5f2ec;              /* off-white */
  --surface: #fffdf9;
  --surface-2: #ece7de;
  --text: #1c1915;
  --text-muted: #5f584e;
  --border: #d9d2c5;
  --guide: rgba(28, 25, 21, 0.18); /* the two thin margin lines */
  --shadow: 0 1px 2px rgba(28, 25, 21, 0.06), 0 8px 24px rgba(28, 25, 21, 0.08);

  /* Layout */
  --nav-h: 64px;
  --guide-x: 48px;            /* ~half an inch from the left */
  --guide-y: 48px;            /* ~half an inch below the nav */
  --content-max: 1120px;
  --radius: 10px;

  /* Type */
  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

/* Dark theme — follows the OS unless the visitor picks light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f;            /* off-black (warm) */
    --surface: #1f1b16;
    --surface-2: #2a251f;
    --text: #ede8df;
    --text-muted: #a39c90;
    --border: #39332b;
    --guide: rgba(237, 232, 223, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

/* Dark theme — chosen with the toggle */
:root[data-theme="dark"] {
  --bg: #16130f;
  --surface: #1f1b16;
  --surface-2: #2a251f;
  --text: #ede8df;
  --text-muted: #a39c90;
  --border: #39332b;
  --guide: rgba(237, 232, 223, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ---------- 2. Reset & base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

img { max-width: 100%; display: block; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }
p  { margin: 0 0 1em; }

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

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

.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 0.5rem 1rem; border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }

/* ---------- 3. The two guide lines ----------
   A vertical line ~half an inch in from the left and a
   horizontal line ~half an inch below the nav bar. */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  background: var(--guide);
  z-index: 0;
}
body::before {               /* vertical */
  top: var(--nav-h); bottom: 0;
  left: var(--guide-x);
  width: 1px;
}
body::after {                /* horizontal */
  left: 0; right: 0;
  top: calc(var(--nav-h) + var(--guide-y));
  height: 1px;
}

/* ---------- 4. Nav bar ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.nav {
  height: 100%;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem 0 calc(var(--guide-x) + 1.25rem);
}

.brand {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--on-accent); text-decoration: none;
  font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em;
}
.brand:hover { color: var(--on-accent); }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--on-accent); color: var(--accent);
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700;
}

.nav-links {
  display: flex; gap: 0.25rem;
  margin: 0 0 0 auto; padding: 0; list-style: none;
}
.nav-links a {
  display: block; padding: 0.45rem 0.9rem; border-radius: 6px;
  color: var(--on-accent); text-decoration: none; font-weight: 500;
  transition: background-color 0.2s var(--ease);
}
.nav-links a:hover { background: rgba(255, 255, 255, 0.16); }
.nav-links a[aria-current="page"] { background: rgba(0, 0, 0, 0.18); }

/* Theme toggle switch */
.theme-toggle {
  display: flex; align-items: center; gap: 0.5rem;
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--on-accent); font: inherit;
}
.theme-toggle .track {
  position: relative;
  width: 52px; height: 28px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: background-color 0.25s var(--ease);
}
.theme-toggle .thumb {
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--on-accent); color: var(--accent);
  display: grid; place-items: center;
  transition: transform 0.25s var(--ease);
}
.theme-toggle svg { width: 14px; height: 14px; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle[aria-checked="true"] .thumb { transform: translateX(24px); }
.theme-toggle[aria-checked="true"] .icon-sun { display: none; }
.theme-toggle[aria-checked="true"] .icon-moon { display: block; }

.menu-btn {
  display: none;
  background: none; border: 1px solid rgba(255, 255, 255, 0.4);
  color: var(--on-accent); border-radius: 6px;
  width: 40px; height: 36px; cursor: pointer;
}
.menu-btn svg { width: 20px; height: 20px; margin: auto; }

/* ---------- 5. Page layout ---------- */
main {
  position: relative; z-index: 1;
  flex: 1;
  width: 100%;
  max-width: calc(var(--content-max) + var(--guide-x) * 2);
  padding: calc(var(--guide-y) + 2.5rem) 1.5rem 4rem calc(var(--guide-x) + 2rem);
}

.page-head { margin-bottom: 2.5rem; }

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono); font-size: 0.8rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 0.75rem;
}

.lead { font-size: 1.2rem; color: var(--text-muted); max-width: 60ch; }

.section { margin-top: 4rem; }
.section-title {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.section-title::before {
  content: ""; width: 14px; height: 14px; flex: none;
  background: var(--accent); border-radius: 3px;
}
.section-title .count {
  font-family: var(--font-mono); font-size: 0.85rem;
  font-weight: 400; color: var(--text-muted);
}

.site-footer {
  position: relative; z-index: 1;
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.5rem 1.5rem calc(var(--guide-x) + 2rem);
  font-family: var(--font-mono); font-size: 0.85rem;
  color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------- 6. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.8rem 1.3rem; border-radius: var(--radius);
  border: 1.5px solid var(--accent);
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color 0.2s var(--ease), transform 0.15s var(--ease), color 0.2s var(--ease);
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn:active { transform: translateY(1px); }
.btn + .btn { margin-left: 0.5rem; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

/* Quick-link tiles under the carousel */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
}
.quick-link {
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text); text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.quick-link:hover { transform: translateY(-3px); box-shadow: var(--shadow); color: var(--text); }
.quick-link .ql-title { font-weight: 600; font-size: 1.1rem; display: flex; justify-content: space-between; }
.quick-link .ql-title::after { content: "→"; color: var(--accent); transition: transform 0.2s var(--ease); }
.quick-link:hover .ql-title::after { transform: translateX(4px); }
.quick-link .ql-desc { color: var(--text-muted); font-size: 0.95rem; }

/* ---------- 7. Carousel ---------- */
.carousel {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.carousel-track {
  display: flex;
  transition: transform 0.6s var(--ease);
}
.slide {
  position: relative;
  flex: 0 0 100%;
  margin: 0;
  aspect-ratio: 16 / 7;
  min-height: 320px;
}
.slide img {
  width: 100%; height: 100%; object-fit: cover;
}
.slide-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3rem 2rem 2rem;
  background: linear-gradient(to top, rgba(10, 8, 6, 0.88), rgba(10, 8, 6, 0));
  color: #f5f2ec;
}
.slide-caption .tag {
  display: inline-block;
  font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--accent); color: var(--on-accent);
  padding: 0.2rem 0.55rem; border-radius: 4px; margin-bottom: 0.6rem;
}
.slide-caption h2 { margin-bottom: 0.3rem; }
.slide-caption p { margin: 0; max-width: 60ch; color: #d8d2c7; }
.slide-caption a { color: #ffb48a; }

.carousel-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: rgba(20, 17, 13, 0.55);
  color: #fff;
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
  transition: background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.carousel-arrow:hover { background: var(--accent); }
.carousel-arrow:active { transform: translateY(-50%) scale(0.94); }
.carousel-arrow svg { width: 22px; height: 22px; }
.carousel-arrow.prev { left: 1rem; }
.carousel-arrow.next { right: 1rem; }

.carousel-dots {
  display: flex; justify-content: center; gap: 0.6rem;
  margin-top: 1.1rem;
}
.carousel-dots button {
  width: 11px; height: 11px; padding: 0;
  border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--text-muted);
  background: transparent;
  transition: width 0.3s var(--ease), background-color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.carousel-dots button:hover { border-color: var(--accent); }
.carousel-dots button[aria-current="true"] {
  width: 32px; background: var(--accent); border-color: var(--accent);
}

/* ---------- 8. About page ---------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 3rem;
  align-items: start;
}
.headshot {
  position: relative;
  margin: 0;
}
.headshot img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: var(--radius);
  position: relative; z-index: 1;
}
.headshot::after {             /* offset accent frame */
  content: "";
  position: absolute; inset: 14px -14px -14px 14px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 2rem 0; padding: 0; list-style: none;
}
.facts li {
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.facts .label {
  display: block;
  font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.facts .value { font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0; list-style: none; }
.chips li {
  font-family: var(--font-mono); font-size: 0.85rem;
  padding: 0.3rem 0.75rem; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.chips li.hot { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 1.75rem 1.5rem; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 0.45rem;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.timeline .when { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); }
.timeline h3 { margin: 0.1rem 0 0.25rem; }
.timeline p { margin: 0; color: var(--text-muted); }

/* ---------- 9. Projects page ---------- */
.project-nav {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 1rem; padding: 0; list-style: none;
}
.project-nav a {
  display: block;
  padding: 0.4rem 0.9rem; border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 0.95rem;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.project-nav a:hover { border-color: var(--accent); background: var(--accent-soft); }

.project-section { scroll-margin-top: calc(var(--nav-h) + 1.5rem); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.25rem;
}

.card {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; padding: 0;
  text-align: left; font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.card-icon {
  position: relative;
  display: grid; place-items: center;
  height: 140px;
  background:
    linear-gradient(135deg, var(--accent-soft), transparent 70%),
    var(--surface-2);
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}
.card-icon svg { width: 54px; height: 54px; transition: transform 0.35s var(--ease); }
.card:hover .card-icon svg { transform: scale(1.1) rotate(-4deg); }

.card-body { padding: 1rem 1.15rem 1.2rem; flex: 1; }
.card-body h3 { margin-bottom: 0.3rem; }
.card-body p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

.card-tags {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  margin-top: 0.8rem;
}
.card-tags span {
  font-family: var(--font-mono); font-size: 0.72rem;
  padding: 0.15rem 0.5rem; border-radius: 4px;
  background: var(--surface-2); color: var(--text-muted);
}

/* "See more" — revealed on hover / keyboard focus */
.see-more {
  position: absolute; left: 0; right: 0; top: 0; height: 140px;
  display: grid; place-items: center;
  background: rgba(226, 90, 18, 0.9);
  color: var(--on-accent);
  font-weight: 600; letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 2;
}
.see-more span::after { content: " →"; }
.card:hover .see-more,
.card:focus-visible .see-more { opacity: 1; transform: translateY(0); }

/* Click effect: ripple + press */
.card.is-pressed { animation: card-press 0.35s var(--ease); }
@keyframes card-press {
  0%   { transform: translateY(-4px) scale(1); }
  40%  { transform: translateY(-1px) scale(0.97); }
  100% { transform: translateY(-4px) scale(1); }
}
.ripple {
  position: absolute; z-index: 3;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  pointer-events: none;
  animation: ripple 0.6s var(--ease) forwards;
}
@keyframes ripple {
  to { transform: scale(40); opacity: 0; }
}

.card-details { display: none; } /* content copied into the dialog */

/* Project detail dialog */
.project-dialog {
  width: min(680px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  padding: 0;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.project-dialog::backdrop { background: rgba(10, 8, 6, 0.6); backdrop-filter: blur(3px); }
.project-dialog[open] { animation: dialog-in 0.3s var(--ease); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.dialog-inner { padding: 2rem; }
.dialog-close {
  position: absolute; top: 0.9rem; right: 0.9rem;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer; font-size: 1.2rem; line-height: 1;
}
.dialog-close:hover { border-color: var(--accent); color: var(--accent); }
.dialog-inner ul { padding-left: 1.2rem; }
.dialog-inner .dialog-links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* ---------- 10. Responsive ---------- */
@media (max-width: 820px) {
  :root { --guide-x: 20px; --guide-y: 24px; }

  .menu-btn { display: grid; margin-left: auto; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--accent-strong);
    padding: 0.5rem 1rem 1rem calc(var(--guide-x) + 1rem);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.75rem 0.5rem; }
  .theme-toggle .toggle-label { display: none; }

  main { padding-left: calc(var(--guide-x) + 1rem); padding-right: 1rem; }
  .site-footer { padding-left: calc(var(--guide-x) + 1rem); }

  .about-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .headshot { max-width: 300px; }

  .slide { aspect-ratio: auto; min-height: 0; height: 380px; }
  .slide-caption h2 { font-size: 1.3rem; }
  .slide-caption { padding: 2rem 1.25rem 1.25rem; }
  .carousel-arrow { width: 40px; height: 40px; }
  .carousel-arrow.prev { left: 0.5rem; }
  .carousel-arrow.next { right: 0.5rem; }
}

/* Respect "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
