:root {
  --ink: #121110;
  --ink-muted: #5c5a56;
  --paper: #faf8f5;
  --paper-warm: #f0ebe3;
  --surface: #ffffff;
  --accent: #9a8b6f;
  --accent-hover: #7d6f58;
  --deep: #1c1b19;
  --line: rgba(28, 27, 25, 0.08);
  --header-glass: rgba(18, 17, 16, 0.82);
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Manrope", system-ui, sans-serif;
  background-color: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
.font-display {
  font-family: "Cormorant Garamond", "Georgia", serif;
  font-weight: 500;
  letter-spacing: -0.02em;
}

::selection {
  background: var(--accent);
  color: var(--surface);
}

/* Hero subtle grain */
.hero-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* Header */
#main-header {
  transition:
    background-color 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.45s ease,
    padding 0.35s ease,
    border-color 0.35s ease;
}

#main-header.header-scrolled {
  background-color: var(--header-glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Nav link underline */
.nav-link {
  position: relative;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Mobile menu */
#mobile-menu {
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  background: var(--deep);
}
.menu-open {
  transform: translateX(0) !important;
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 {
  transition-delay: 0.08s;
}
.reveal-delay-2 {
  transition-delay: 0.16s;
}
.reveal-delay-3 {
  transition-delay: 0.24s;
}

/* Service cards */
.service-card {
  transition:
    box-shadow 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.service-card:hover {
  box-shadow: 0 32px 64px -16px rgba(18, 17, 16, 0.12);
}

/* Button primary */
.btn-primary {
  background: var(--ink);
  color: var(--surface);
  transition:
    background 0.3s ease,
    transform 0.2s ease,
    box-shadow 0.3s ease;
}
.btn-primary:hover {
  background: var(--deep);
  box-shadow: 0 20px 40px -12px rgba(18, 17, 16, 0.35);
}
.btn-primary:active {
  transform: scale(0.98);
}

/* Focus visible */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Portfolio tiles as buttons */
button.portfolio-tile {
  padding: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
}

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

/* Lightbox */
body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(18, 17, 16, 0.88);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-figure {
  margin: 0;
  max-width: min(1100px, 100%);
  max-height: calc(100vh - 2.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.lightbox-figure img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 5.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
}

.lightbox-caption {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  z-index: 2;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

@media (max-width: 640px) {
  .lightbox-nav {
    display: none;
  }

  .lightbox-figure img {
    max-height: calc(100vh - 4.5rem);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .service-card:hover {
    transform: none;
  }
  .lightbox {
    transition: none;
  }
}
