/* =========================
   Theme variables
========================= */

:root,
[data-theme="light"] {
  --bg: #efefef;
  --surface: #f4f4f4;
  --surface-2: #e9e9e9;
  --line: rgba(55, 55, 55, 0.12);
  --line-strong: rgba(55, 55, 55, 0.20);
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #8a8a8a;
  --accent-strong: #6b6b6b;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.32);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.32);
  --radius-xs: 2px;
  --w: 1360px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-2: #222222;
  --line: rgba(100, 100, 100, 0.10);
  --line-strong: rgba(100, 100, 100, 0.16);
  --text: #e5e5e5;
  --muted: #b0b0b0;
  --accent: #9a9a9a;
  --accent-strong: #b0b0b0;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.32);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.32);
}

/* =========================
   Base
========================= */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
  text-size-adjust: none;
  -webkit-text-size-adjust: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.72 var(--sans);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

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

.container {
  width: min(calc(100% - 2rem), var(--w));
  margin-inline: auto;
}

.section {
  padding: 48px;
}

p {
  margin: 0;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(3.35rem, 7vw, 7.2rem);
  font-weight: 600;
  max-width: 10.5ch;
}

h2 {
  font-family: var(--serif);
  font-size: clamp(2.15rem, 2.9vw, 3.35rem);
  font-weight: 600;
}

h3 {
  font-size: clamp(1.14rem, 1.02rem + 0.34vw, 1.45rem);
  font-weight: 600;
}

/* =========================
   Header
========================= */

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.skip-link:focus {
  top: 16px;
}

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

.footer-inner,
.hero-grid,
.split-layout {
  display: grid;
  gap: 24px;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  gap: 22px;
  flex: 1;
}

.main-nav a {
  position: relative;
  display: inline-block;
  padding: 4px 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.main-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease;
}

.main-nav a:hover,
.main-nav a[aria-current="true"] {
  color: var(--text);
}

.main-nav a:hover::after,
.main-nav a[aria-current="true"]::after {
  transform: scaleX(1);
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

/* =========================
   Shared cards / buttons
========================= */

.hero-panel,
.content-card,
.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-lg);
}

.content-card {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.btn {
  min-height: 44px;
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn-primary:hover {
  background: var(--accent-strong);
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
}

/* =========================
   Home page
========================= */

.hero {
  padding-top: 64px;
}

.hero-grid {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.76rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.elastic-headline {
  display: block;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 0.98;
  white-space: nowrap;
  letter-spacing: -0.04em;
}

.elastic-headline .word {
  font-size: inherit;
}

.hero-text {
  margin-top: 24px;
  max-width: 64ch;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-actions,
.project-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions {
  margin-top: 30px;
}

.profile-panel {
  min-height: auto;
  display: flex;
  justify-content: flex-end;
  padding: 0;
}

.profile-photo {
  width: 360px;
  height: auto;
}

.section-intro {
  display: grid;
  gap: 12px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.project-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.project-image {
  aspect-ratio: 16 / 9;
  position: relative;
  display: grid;
  place-items: end start;
  overflow: hidden;
  padding: 16px;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.project-body {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.project-topline {
  justify-content: space-between;
}

.project-year,
.project-role {
  color: var(--muted);
  font-size: 0.78rem;
}

.project-cta {
  margin-top: 4px;
  color: var(--accent);
  font-size: 0.92rem;
}

.project-link {
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.project-link:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.project-link:hover .project-cta {
  text-decoration: underline;
}

.split-layout {
  grid-template-columns: 0.72fr 1.28fr;
  align-items: start;
}

.cv-panel {
  gap: 16px;
}

.cv-box {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.cv-frame {
  width: 100%;
  min-height: 520px;
  border: 0;
  display: block;
}

.cv-box .cv-frame {
  min-height: 560px;
}

.cv-mobile-link {
  display: none;
}

.cv-actions {
  display: flex;
  justify-content: flex-end;
}

.contact-panel-box {
  padding: 28px;
}

.contact-links {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 16px;
}

.contact-links a {
  color: var(--accent-strong);
}

.site-footer {
  padding: 32px 0 48px;
  border-top: 1px solid var(--line);
}

.footer-inner {
  grid-template-columns: 1fr auto;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

/* =========================
   Project page
========================= */

.project-hero {
  padding-top: clamp(72px, 10vw, 128px);
  padding-bottom: 4px;
}

.project-hero + .section {
  padding-top: 8px;
}

.project-shell {
  display: grid;
  gap: 28px;
}

.project-header {
  display: grid;
  gap: 18px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.project-kicker {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
}

.project-title {
  font-family: var(--serif);
  font-size: clamp(3.1rem, 7vw, 6.7rem);
  line-height: 0.94;
  letter-spacing: -0.05em;
  max-width: 15ch;
}

.project-summary {
  max-width: 70ch;
  color: var(--muted);
  font-size: 1.06rem;
}

/* =========================
   Meta cards
========================= */

.project-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.project-meta-stacked {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.meta-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

.meta-card .stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meta-card .stat-value {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
}

.project-hero-image {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  color: var(--text);
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  background: var(--surface-2);
}

.project-hero-image span {
  position: relative;
  z-index: 1;
  font-weight: 700;
}

.project-hero + .section,
.section + .section {
  padding-top: 16px;
  padding-bottom: 16px;
}

.project-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

.project-copy {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

.project-copy p {
  margin-bottom: 16px;
}

.hero-slot {
  min-height: 320px;
}

.project-note {
  color: var(--muted);
  font-size: 0.96rem;
}

/* =========================
   Media
========================= */

.case-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 0;
}

/* =========================
   Thumbnail grid
========================= */

.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  width: 100%;
}

.thumbnail-grid-3col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.thumbnail-grid-4col {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.thumbnail-grid-5col {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.thumbnail-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.thumbnail-link:hover {
  transform: translateY(-4px);
  opacity: 0.9;
}

.thumbnail-link .project-hero-image {
  aspect-ratio: 16 / 9;
  padding: 0;
  min-height: 0;
}

.thumbnail-link .case-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =========================
   Video thumbnails
========================= */

.video-thumb {
  position: relative;
}

.play-icon {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 200ms ease;
  border-radius: var(--radius-xs);
}

.thumbnail-link:hover .play-icon {
  opacity: 1;
}

.thumb-caption {
  display: grid;
  gap: 4px;
  padding: 12px 4px 4px;
}

.thumb-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.thumb-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

/* =========================
   Lightbox
========================= */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.92);
  cursor: zoom-out;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-xs);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 160ms ease;
}

.lightbox-close:hover {
  background: var(--surface-2);
}

.lightbox-video {
  display: none;
  width: min(90vw, 1280px);
  aspect-ratio: 16 / 9;
}

.lightbox-video.is-active {
  display: block;
}

.lightbox-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--radius-xs);
}

.lightbox.video-mode .lightbox-img {
  display: none;
}

/* =========================
   Reveal animation
========================= */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.delay-1 {
  transition-delay: 90ms;
}

.delay-2 {
  transition-delay: 160ms;
}

/* =========================
   Responsive
========================= */

@media (max-width: 980px) {
  .hero-grid,
  .split-layout,
  .footer-inner,
  .project-meta-grid,
  .project-section {
    grid-template-columns: 1fr;
  }

  .hero-slot {
    min-height: 220px;
  }

  .project-title {
    max-width: 11ch;
  }

  .elastic-headline {
    white-space: normal;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(calc(100% - 1rem), var(--w));
  }

  h1 {
    max-width: 11ch;
  }

  .hero-text {
    font-size: 1rem;
  }

  .thumbnail-grid,
  .projects-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

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

  .reveal {
    opacity: 1;
    transform: none;
  }
}

/* =========================
   Hero split layout
========================= */

.hero-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

/* =========================
   Mobile (<=768px)
========================= */

@media (max-width: 768px) {
  .section {
    padding: 20px 0;
  }

  .container {
    width: min(calc(100% - 1rem), var(--w));
  }

  .header-inner {
    gap: 8px;
    min-height: auto;
    padding: 8px 0;
  }

  .brand {
    font-size: 0.82rem;
  }

  .main-nav {
    gap: 10px;
    overflow-x: auto;
  }

  .main-nav a {
    font-size: 0.82rem;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }

  h1 {
    font-size: clamp(2.2rem, 10vw, 3.8rem);
    max-width: none;
  }

  h2 {
    font-size: clamp(1.8rem, 7vw, 2.4rem);
  }

  .hero-text,
  .project-summary,
  .thumb-desc,
  .project-copy p {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .hero-actions,
  .project-topline {
    gap: 10px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .hero-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    text-align: center;
  }

  .profile-panel {
    order: -1;
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 8px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .profile-photo {
    width: 160px;
    height: 160px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 10%;
  }

  .hero-actions {
    justify-content: center;
    width: 100%;
    margin-top: 16px;
  }

  .project-meta-stacked {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .meta-card {
    padding: 10px 12px;
  }

  .meta-card .stat-label {
    font-size: 0.68rem;
    margin-bottom: 2px;
  }

  .meta-card .stat-value {
    font-size: 0.84rem;
  }

  .hero-split {
    grid-template-columns: 1fr;
  }

  .project-copy,
  .content-card,
  .cv-box,
  .contact-panel-box,
  .meta-card {
    padding: 16px;
  }

  .project-hero {
    padding-top: 32px;
    padding-bottom: 8px;
  }

  .hero-slot {
    min-height: 180px;
  }

  .thumbnail-grid,
  .projects-grid,
  .project-meta-grid,
  .project-section,
  .split-layout,
  .footer-inner {
    grid-template-columns: 1fr;
  }

  .thumbnail-grid-3col,
  .thumbnail-grid-4col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .thumb-caption {
    padding: 10px 2px 2px;
  }

  .lightbox {
    padding: 12px;
  }

  .lightbox-close {
    top: 12px;
    right: 12px;
  }

  .cv-frame {
    display: none;
  }

  .cv-desktop-only {
    display: none;
  }

  .cv-mobile-link {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 56px;
    padding: 14px 16px;
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text);
    text-align: center;
    box-sizing: border-box;
    text-decoration: none;
    font-weight: 500;
  }
}

/* =========================
   Small phones (<=480px)
========================= */

@media (max-width: 480px) {
  .cv-box {
    padding: 10px;
  }

  .thumbnail-grid-3col,
  .thumbnail-grid-4col {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Video Embeds
========================= */

.video-embed {
  width: 100%;
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}