/* ============================================
   Portfolio — Design System & Global Styles
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #0c0f12;
  --bg-secondary: #12161a;
  --bg-tertiary: #181d22;

  --text-primary: #eef1f4;
  --text-secondary: #c0c7cf;
  --text-muted: #87909a;

  --accent: #5f738a;
  /* dusty steel blue */
  --accent-hover: #758aa3;

  --border: #26303a;
  --card-shadow: rgba(0, 0, 0, .46);



  /* extras */
  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  --header-height: 64px;
  --max-width: 1280px;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
}

h3 {
  font-size: clamp(1.125rem, 2.5vw, 1.5rem);
}

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

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

/* ============================================
   Header / Navigation
   ============================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 1000;
  background: rgba(10, 10, 11, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: transform var(--transition-base);
}

.site-header.hidden {
  display: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  white-space: nowrap;
}

.site-logo span {
  color: var(--accent);
}

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

.nav-link {
  position: relative;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-link.active {
  color: var(--accent);
}

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

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform var(--transition-base), opacity var(--transition-fast);
}

.menu-toggle.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   Main Content
   ============================================ */
main {
  padding-top: calc(var(--header-height) + 32px);
  min-height: 100vh;
}

/* ---------- Page transitions ---------- */
.page {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Gallery Grid (Home)
   ============================================ */
/* Masonry Grid for Home */
.gallery-grid {
  column-count: 3;
  column-gap: 24px;
  padding-bottom: 80px;
}

.gallery-card {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--transition-base),
    box-shadow var(--transition-base),
    border-color var(--transition-base);
  /* Masonry fix */
  break-inside: avoid;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
}

.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px var(--card-shadow);
  border-color: var(--accent);
}

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

/* Thumbnail - Natural Aspect Ratio */
.card-thumb {
  position: relative;
  width: 100%;
  /* Removed fixed aspect-ratio to allow natural image height */
  overflow: hidden;
  background: var(--bg-tertiary);
  display: block;
}

.card-thumb img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform var(--transition-slow), opacity 0.3s ease-out;
  opacity: 0;
}

.card-thumb img.loaded {
  opacity: 1;
}

/* View overlay */
.card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.gallery-card:hover .card-overlay {
  opacity: 1;
}

.card-overlay .view-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Card body */
.card-body {
  padding: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 9999px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.card-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 120px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 1.125rem;
}

/* ============================================
   Gallery Detail Page
   ============================================ */
.detail-header {
  margin-bottom: 32px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 24px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

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

.detail-title {
  margin-bottom: 12px;
}

.detail-divider {
  height: 2px;
  width: 60px;
  background: var(--accent);
  border: none;
  margin-bottom: 16px;
  border-radius: 1px;
}

.detail-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin-bottom: 16px;
  line-height: 1.7;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 40px;
}

/* Image grid — Masonry */
.image-grid {
  column-count: 3;
  column-gap: 16px;
  padding-bottom: 80px;
}

.image-grid-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-tertiary);
  /* Masonry fix */
  break-inside: avoid;
  margin-bottom: 16px;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.image-grid-item:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 32px var(--card-shadow);
  z-index: 2;
  /* Bring to front on hover */
}

.image-grid-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.image-grid-item img {
  display: block;
  width: 100%;
  height: auto;
  /* Natural */
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.image-grid-item img.loaded {
  opacity: 1;
}

.image-grid-item .expand-icon {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.image-grid-item:hover .expand-icon {
  opacity: 1;
}

.expand-icon svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
}

/* ============================================
   Contact Section
   ============================================ */
.contact-section {
  padding-bottom: 80px;
}

.contact-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 40px;
  max-width: 560px;
}

.contact-title {
  margin-bottom: 8px;
}

.contact-divider {
  height: 2px;
  width: 60px;
  background: var(--accent);
  border: none;
  margin-bottom: 28px;
  border-radius: 1px;
}

.contact-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.contact-row a {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.contact-row a:hover {
  color: var(--accent);
}

.contact-row svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: var(--text-muted);
}

.social-links {
  display: flex;
  gap: 12px;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.social-btn:hover {
  background: var(--bg-primary);
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.social-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   Lightbox Modal
   ============================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox-img-wrapper {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lbZoomIn 0.3s ease forwards;
}

@keyframes lbZoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.lightbox-img-wrapper img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  user-select: none;
}

/* Controls */
.lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2010;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.lb-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lb-close svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
}

.lb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2010;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.lb-arrow:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lb-arrow svg {
  width: 24px;
  height: 24px;
  stroke: #fff;
}

.lb-prev {
  left: 16px;
}

.lb-next {
  right: 16px;
}

.lb-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.05em;
  user-select: none;
}

/* ============================================
   Error / Loading States
   ============================================ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120px 24px;
  color: var(--text-muted);
  gap: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-state {
  text-align: center;
  padding: 120px 24px;
}

.error-state h2 {
  color: var(--text-primary);
  margin-bottom: 8px;
}

.error-state p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  padding: 32px 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .menu-toggle {
    display: flex;
  }

  .site-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    flex-direction: column;
    background: rgba(10, 10, 11, 0.96);
    backdrop-filter: blur(16px);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--transition-base), opacity var(--transition-base);
  }

  .site-nav.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  .nav-link {
    width: 100%;
    padding: 12px 16px;
  }

  .gallery-grid {
    column-count: 1;
    column-gap: 16px;
  }

  .image-grid {
    column-count: 2;
    /* 2 cols on mobile for images usually looks okay, or 1 */
    column-gap: 8px;
  }

  @media (max-width: 480px) {
    .image-grid {
      column-count: 1;
    }
  }

  .contact-card {
    padding: 24px;
  }

  .social-links {
    flex-direction: column;
  }

  .lb-arrow {
    width: 40px;
    height: 40px;
  }

  .lb-prev {
    left: 8px;
  }

  .lb-next {
    right: 8px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {

  .gallery-grid,
  .image-grid {
    column-count: 2;
  }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
  position: relative;
  width: 100vw;
  height: 45vh;
  min-height: 300px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  margin-bottom: 60px;
  color: #fff;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 2;
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 40px;
  animation: fadeUp 1s ease forwards;
  text-align: center;
}

.hero-image {
  width: 50%;
  height: 100%;
  background-size: auto 100%;
  background-position: center;
  background-repeat: no-repeat;
}

.hero-title {
  font-size: clamp(2.5rem, 4vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  letter-spacing: -0.04em;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hero-subtitle {
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  font-weight: 400;
  margin-bottom: 32px;
  opacity: 0.95;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  padding: .4rem .6rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: transform var(--transition-base), background var(--transition-base), box-shadow var(--transition-base);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.hero-cta:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.hero-scroll-indicator {
  display: none;
  /* Hide scroll indicator for shorter hero */
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {

  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translate(-50%, 0);
  }

  40% {
    transform: translate(-50%, -10px);
  }

  60% {
    transform: translate(-50%, -5px);
  }
}

/* Adjust gallery grid when hero is present */
.gallery-grid.with-hero {
  padding-top: 0;
}