/* ---------- Theme ---------- */
:root {
  --bg: #0c0a09;
  --surface: #1c1917;
  --text: #f5f5f4;
  --muted: #a8a29e;
  --border: #292524;
  --accent: #60a5fa;
  --accent-text: #0c0a09;
  --radius: 12px;
  --max: 960px;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

/* Make sure anything marked hidden (e.g. filtered-out projects) really hides */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

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

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding-inline: 20px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h2 { font-size: 1.75rem; }

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

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo { font-weight: 700; font-size: 1.2rem; color: var(--text); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  position: relative;
  color: var(--muted);
  transition: color 0.2s;
}

/* Blue underline that sweeps in from the right on hover,
   and stays under the section you're currently reading */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.25s ease-out;
}
.nav-links a:hover,
.nav-links a:focus-visible,
.nav-links a.active { color: var(--accent); text-decoration: none; }
.nav-links a:hover::after,
.nav-links a:focus-visible::after,
.nav-links a.active::after { transform: scaleX(1); }

/* Dropdowns (Projects, Skills) */
.has-dropdown { position: relative; }
.has-dropdown::after {
  content: "▾";
  margin-left: 4px;
  font-size: 0.75em;
  color: var(--muted);
}

.dropdown {
  position: absolute;
  top: 100%;
  left: -16px;
  min-width: 200px;
  margin-top: 16px;
  padding: 8px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
/* Invisible bridge so the menu doesn't close while the mouse moves down to it */
.dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -18px;
  height: 18px;
}
.has-dropdown:hover .dropdown,
.has-dropdown:focus-within .dropdown {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.dropdown li { padding: 7px 16px; }
.dropdown a { white-space: nowrap; }
.dropdown a::after { bottom: -3px; }

.nav-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 4px 10px;
  cursor: pointer;
}

.nav-toggle { display: none; }

/* ---------- Hero ---------- */
.hero {
  min-height: min(680px, 85vh);
  display: flex;
  align-items: center;
  padding-block: 80px;
  background: var(--bg) url("../assets/images/hero-bg.svg") center / cover no-repeat;
}
.hero > .container { width: 100%; }

.eyebrow { color: var(--accent); font-weight: 600; margin: 0; }

.hero h1 { font-size: clamp(2.5rem, 7vw, 4rem); margin: 0.1em 0 0.3em; }

.tagline { font-size: 1.25rem; color: var(--muted); max-width: 60ch; }

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

.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  border: 1px solid var(--accent);
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { color: var(--accent); }

/* ---------- Sections ---------- */
.section { padding-block: 72px; border-top: 1px solid var(--border); }
/* Tighter spacing so About and Contact both fit on screen at the bottom of the page */
#about, #contact { padding-block: 48px; }

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 32px;
  align-items: center;
}

.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  font-weight: 700;
  object-fit: cover;
}

.about-grid p { color: var(--muted); margin-top: 0; max-width: 60ch; }

/* Projects */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s, opacity 0.2s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
/* Skill selected: matching projects are outlined, the rest fade until hovered */
.card.match { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.dimmed:not(.reveal) { opacity: 0.4; }
.card.dimmed:hover { opacity: 1; }
.card p { color: var(--muted); flex: 1; }

/* Project image, or an empty spot until there is one */
.card-media {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 16px;
  background: var(--bg);
}
.card-media-link { display: block; }
/* Real images: show the whole picture on a light panel (suits CAD screenshots) */
img.card-media { object-fit: contain; background: #f4f4f5; }
.card h3 a { color: var(--text); }
.card h3 a:hover { color: var(--accent); text-decoration: none; }
/* A card with a title link is clickable anywhere: the link stretches over the whole card */
.card { position: relative; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card:has(h3 a):hover h3 a { color: var(--accent); }
.card-link { font-weight: 600; margin-top: 14px; align-self: flex-start; }

/* Empty spot shown until an image is added (cards and project pages) */
.card-media.placeholder,
.page-media.placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 8%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 8%, transparent) 1px, transparent 1px);
  background-size: 20px 20px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.tags button {
  font: inherit;
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  position: relative; /* sits above the card-wide link so tags still filter */
  z-index: 1;
}
.tags button:hover, .tags button.active { border-color: var(--accent); color: var(--accent); }

/* ---------- Project pages ---------- */
.project-page { padding-block: 40px 72px; }

.back-link { display: inline-block; color: var(--muted); margin-bottom: 32px; }
.back-link:hover { color: var(--accent); text-decoration: none; }

.project-header h1 { font-size: clamp(2.25rem, 6vw, 3.25rem); margin-bottom: 0.2em; }
.project-summary { font-size: 1.2rem; color: var(--muted); max-width: 60ch; margin-top: 0; }

.project-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  margin: 28px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.project-facts dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.project-facts dd { margin: 2px 0 0; }

.page-media {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  background: var(--bg);
}
.page-media.placeholder { aspect-ratio: 4 / 3; }

/* Main image sits on a light panel so CAD screenshots (light backgrounds) look intentional */
.project-hero { margin: 40px 0 0; }
.project-hero .page-media:not(.placeholder) {
  max-height: 560px;
  object-fit: contain;
  background: #f4f4f5;
  padding: 24px;
  border: 1px solid var(--border);
}
.project-hero .page-media.placeholder { aspect-ratio: 16 / 9; }
/* A smaller image, for a supporting photo */
.project-hero.compact { max-width: 480px; }
.project-hero.compact .page-media:not(.placeholder) { max-height: 360px; }
.project-hero.compact .page-media.placeholder { aspect-ratio: 4 / 3; }
/* "photo": a real photo, shown edge to edge without the light CAD panel */
.project-hero.photo .page-media:not(.placeholder) {
  width: auto;
  max-width: 100%;
  padding: 0;
  background: none;
}

figcaption { margin-top: 10px; font-size: 0.85rem; color: var(--muted); }

.project-section { margin-top: 56px; }
.project-section p { color: var(--muted); max-width: 70ch; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 20px;
}
.gallery figure { margin: 0; }
/* Keep gallery images the same shape so the row lines up */
.gallery img.page-media { aspect-ratio: 4 / 3; object-fit: cover; }
/* "portrait": for tall photos, so they aren't cut off at the top and bottom */
.gallery.portrait img.page-media { aspect-ratio: 3 / 4; }

/* "photo-row": photos side by side at the same height, even when one is tall and one is wide.
   Set --ratio on each figure to the photo's width ÷ height (tall 3:4 = 0.75, wide 4:3 = 1.333). */
.photo-row { display: flex; gap: 20px; max-width: 760px; margin-top: 24px; }
.photo-row figure { margin: 0; flex: var(--ratio, 1) 1 0; min-width: 0; }
.photo-row .page-media { aspect-ratio: var(--ratio, 1); object-fit: cover; border: 1px solid var(--border); }
@media (max-width: 560px) {
  .photo-row { flex-direction: column; }
}

.project-nav {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* Filter bar + empty message */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--muted);
}
.filter-bar strong { color: var(--accent); }
.filter-clear {
  font: inherit;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.filter-clear:hover { border-color: var(--accent); }

.no-projects { color: var(--muted); }
.no-projects strong { color: var(--text); }

/* Skills */
.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.skill-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.skill-group h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 16px;
}

.section-hint { color: var(--muted); margin-top: -4px; }

.skill {
  font: inherit;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.skill:hover, .skill.active {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* Contact */
.contact p { color: var(--muted); }
.contact-email { font-size: 1.4rem; font-weight: 600; }
.contact-email a { color: var(--text); }
.contact-email a:hover { color: var(--accent); }
.socials { display: flex; gap: 20px; list-style: none; padding: 0; }

/* Footer */
.site-footer {
  padding-block: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}
.site-footer p { margin: 0; }

/* Fade-in on scroll */
.reveal { opacity: 0; transform: translateX(60px); transition: opacity 0.7s ease-out, transform 0.7s ease-out; }
.reveal.visible { opacity: 1; transform: none; }

/* Stop items waiting off to the right from making the page scroll sideways */
main { overflow-x: clip; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .nav-toggle { display: block; }

  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .nav-links.open { display: flex; }
  .nav-links {
    align-items: flex-start;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }

  /* On phones the dropdown items are always listed, indented under their section */
  .has-dropdown::after { display: none; }
  .dropdown {
    position: static;
    min-width: 0;
    margin: 6px 0 0;
    padding: 0 0 0 12px;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: none;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .dropdown::before { display: none; }
  .dropdown li { padding: 5px 0; font-size: 0.9rem; }

  .hero { padding-block: 72px 48px; }

  .about-grid { grid-template-columns: 1fr; gap: 20px; }
  .avatar { width: 100px; height: 100px; font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .nav-links a::after, .dropdown { transition: none; }
}
