/* Portfolio — clean, professional, content-first. */

:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-text: #1d4ed8;
  --radius: 12px;
  --container: 960px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111827;
    --border: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #60a5fa;
    --accent-text: #93c5fd;
    color-scheme: dark;
  }
}

/* Explicit choice from the header toggle always wins over the system. */
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --accent-text: #93c5fd;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* Keyboard focus ---------------------------------------------------------- */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  z-index: 100;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 0.4em;
}

h2 {
  font-size: 1.5rem;
  margin: 0;
}

h3 {
  font-size: 1.15rem;
  margin: 0;
}

p {
  margin: 0 0 1em;
}

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

.muted {
  color: var(--muted);
}

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

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

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

.brand {
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent-text);
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav a {
  color: var(--text);
  font-size: 0.95rem;
}

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

/* Theme toggle ----------------------------------------------------------- */

.theme-toggle {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Light mode: offer the moon (switch to dark). Dark mode: offer the sun. */
.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: inline;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun {
    display: inline;
  }
  :root:not([data-theme]) .theme-toggle .icon-moon {
    display: none;
  }
}

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

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.btn:hover {
  text-decoration: none;
  filter: brightness(1.05);
}

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

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  filter: none;
}

.btn-small {
  padding: 7px 15px;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn {
    color: #0b1120;
  }
  :root:not([data-theme="light"]) .btn-ghost {
    color: var(--text);
  }
}

:root[data-theme="dark"] .btn {
  color: #0b1120;
}

:root[data-theme="dark"] .btn-ghost {
  color: var(--text);
}

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

.hero {
  padding: 72px 0 40px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-text);
  margin-bottom: 0.75rem;
}

.location {
  margin-top: -0.4rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 62ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 1.75rem;
}

.hero-tags {
  margin-top: 2rem;
}

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

.section {
  padding: 40px 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.resume-heading {
  margin: 2rem 0 1rem;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Cards & grid ---------------------------------------------------------- */

.grid {
  display: grid;
  /* auto-fit collapses empty tracks so a lone featured card spans the row */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--accent);
}

.project-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.project-card-head a {
  color: var(--text);
}

.project-card-head a:hover {
  color: var(--accent-text);
  text-decoration: none;
}

.project-links {
  display: flex;
  gap: 16px;
  font-size: 0.92rem;
  margin-top: auto;
}

.project-links a {
  font-weight: 600;
}

/* Tags ------------------------------------------------------------------ */

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
}

.tag {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 999px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag {
    background: #0f172a;
  }
}

:root[data-theme="dark"] .tag {
  background: #0f172a;
}

/* Timeline -------------------------------------------------------------- */

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  border-left: 2px solid var(--border);
  padding-left: 18px;
}

.timeline-meta {
  font-size: 0.9rem;
}

.timeline-item p {
  margin: 0.3em 0 0;
  font-size: 0.95rem;
}

/* Project detail -------------------------------------------------------- */

.detail-links {
  margin: 1.5rem 0;
}

.case-study {
  display: grid;
  gap: 20px;
  max-width: 68ch;
  margin: 2rem 0;
}

/* Evidence gallery -------------------------------------------------------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 2rem 0;
}

.gallery-item {
  margin: 0;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.gallery-item figcaption {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}

.case-study section {
  border-left: 2px solid var(--border);
  padding-left: 18px;
}

.case-study h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

.case-study p {
  color: var(--muted);
  margin: 0;
}

.case-study ul,
.resume-highlights {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.case-study li,
.resume-highlights li {
  margin: 0.25rem 0;
}

.prose {
  max-width: 68ch;
  margin-top: 1.5rem;
  color: var(--text);
}

.prose p {
  margin-bottom: 1em;
}

.contact-line {
  margin-top: 2.5rem;
}

/* On-demand PDF preview --------------------------------------------------- */

.resume-live-preview iframe {
  display: block;
  width: 100%;
  min-height: 720px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Collapsible preview card ---------------------------------------------- */

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-head h2 {
  margin: 0;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.preview-toggle:hover {
  color: var(--accent-text);
}

.preview-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.preview-toggle[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

.preview-body {
  margin-top: 12px;
}

.preview-body .muted {
  margin-top: 0;
}

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

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--accent-text);
}

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

@media (max-width: 640px) {
  .hero {
    padding-top: 48px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .header-inner {
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 10px;
  }

  .brand {
    font-size: 0.98rem;
  }

  .nav {
    gap: 12px;
  }

  .nav a {
    font-size: 0.9rem;
  }

  .btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
}
