/**
 * Engineering portfolio – modern theme
 * Uses CSS custom properties for easy theming.
 */

:root {
  --bg: #0c0d0f;
  --bg-elevated: #14161a;
  --surface: #1a1c22;
  --border: #2a2d36;
  --text: #e8eaed;
  --text-muted: #9aa0a8;
  --accent: #7dd3fc;
  --accent-dim: rgba(125, 211, 252, 0.15);
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: #bae6fd;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 13, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
}

.nav-logo:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--text);
}

/* Hero */
.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  align-items: center;
}

@media (min-width: 800px) {
  .hero {
    grid-template-columns: 1fr 1fr;
    min-height: 70vh;
  }
}

.hero-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.hero-headshot {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent);
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hero-headshot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-text {
  flex: 1;
}

.hero-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

@media (max-width: 600px) {
  .hero-header {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .hero-headshot {
    width: 100px;
    height: 100px;
  }
}

.hero-title .accent {
  color: var(--accent);
}

.hero-desc {
  color: var(--text-muted);
  font-size: 1.0625rem;
  max-width: 480px;
  margin: 0 0 0.75rem;
}

.hero-contact {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.hero-contact a {
  color: var(--accent);
}

.hero-contact-sep {
  margin: 0 0.5rem;
  color: var(--border);
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius);
  transition: background var(--transition), transform var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: #bae6fd;
  color: var(--bg);
  transform: translateY(-1px);
}

.hero-visual {
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.hero-visual.placeholder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* Section common */
.section-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.section-title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.section-subtitle {
  color: var(--text-muted);
  margin: 0 0 2.5rem;
}

/* Skills carousel under project cards – seamless infinite loop */
.skills-carousel-wrap {
  margin-top: 0.75rem;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent 0, black 2em, black calc(100% - 2em), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 2em, black calc(100% - 2em), transparent 100%);
}

.skills-carousel {
  display: flex;
  gap: 0.5rem;
  width: max-content;
  will-change: transform;
}

.skills-carousel-set {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.skills-carousel .skill-pill {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 6px;
  white-space: nowrap;
}

/* Project grid */
.projects-section {
  padding: 3rem 0 4rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
  display: block;
  color: inherit;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.project-card-image {
  aspect-ratio: 16 / 10;
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
}

.project-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.project-card:hover .project-card-image img {
  transform: scale(1.03);
}

.project-card-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.project-card-body {
  padding: 1.25rem;
}

.project-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.project-card-desc {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin: 0;
  line-height: 1.5;
}

.project-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 6px;
}

/* Contact */
.contact-section {
  padding: 4rem 0 5rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

.contact-inner {
  text-align: center;
}

.contact-text {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
}

.contact-link {
  font-weight: 500;
  padding: 0.5rem 0;
}

/* Footer */
.site-footer {
  padding: 1.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
}

/* Project detail page */
.project-page {
  padding: 2rem 0 4rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--accent);
}

.project-article h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin: 0 0 0.5rem;
}

.project-meta {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}

.project-date {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.project-article .project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0;
}

.project-article .long-desc {
  color: var(--text-muted);
  max-width: 65ch;
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

.project-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (min-width: 700px) {
  .project-gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }
}

.project-gallery figure {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  aspect-ratio: 4 / 3;
  min-height: 0;
}

.project-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  vertical-align: bottom;
}

.project-gallery.placeholder figure {
  min-height: 180px;
  aspect-ratio: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.project-article .project-links {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.project-article .project-links li {
  margin-bottom: 0.5rem;
}

.project-article .project-links a {
  font-weight: 500;
}

/* Placeholder image block (detail page) */
.project-hero-image {
  width: 100%;
  aspect-ratio: 21 / 9;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  overflow: hidden;
}

.project-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-hero-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.project-hero-image.gallery-item-hero {
  cursor: pointer;
  transition: opacity var(--transition);
}

.project-hero-image.gallery-item-hero:hover {
  opacity: 0.9;
}

.project-gallery figure.gallery-item {
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
}

.project-gallery figure.gallery-item:hover {
  transform: scale(1.02);
  opacity: 0.9;
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 95vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  font-size: 2rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
  z-index: 1001;
  line-height: 1;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  font-size: 2.5rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
  z-index: 1001;
  padding: 0;
  line-height: 1;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.lightbox-prev {
  left: 1.5rem;
}

.lightbox-next {
  right: 1.5rem;
}

@media (max-width: 768px) {
  .lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.5rem;
  }

  .lightbox-nav {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 2rem;
  }

  .lightbox-prev {
    left: 0.75rem;
  }

  .lightbox-next {
    right: 0.75rem;
  }
}
