@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&family=JetBrains+Mono:wght@300&display=swap');

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

:root {
  --bg-home: #0a0a0c;
  --bg-about: #f5f0e8;
  --bg-work: #0d2b45;
  --bg-contact: #1a3a2a;
  --accent: #e8532e;
  --flip-duration: 1.4s;
}

html, body {
  width: 100%; min-height: 100vh;
  overflow-x: hidden;
  font-family: 'DM Sans', sans-serif;
}

/* Initial background driven by data-page so each file loads with the right colour */
body[data-page="home"]    { background: var(--bg-home); }
body[data-page="about"]   { background: var(--bg-about); }
body[data-page="work"]    { background: var(--bg-work); }
body[data-page="contact"] { background: var(--bg-contact); }

/* ── NAV ── */
.page-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 48px;
  mix-blend-mode: difference;
  transition: opacity 0.4s ease;
}
.page-nav.nav-hidden { opacity: 0; pointer-events: none; }
.page-nav .logo {
  font-family: 'Instrument Serif', serif;
  font-size: 24px; color: #fff; letter-spacing: -0.5px;
  text-decoration: none;
}
.page-nav .links { display: flex; gap: 32px; }
.page-nav .links a {
  color: #fff; text-decoration: none; font-size: 14px;
  font-weight: 400; letter-spacing: 0.5px; text-transform: uppercase;
  cursor: pointer; transition: opacity 0.3s;
  position: relative;
}
.page-nav .links a::after {
  content: ''; position: absolute; bottom: -4px; left: 0;
  width: 0; height: 1px; background: #fff; transition: width 0.3s;
}
.page-nav .links a:hover::after { width: 100%; }
.page-nav .links a:hover { opacity: 0.7; }
.page-nav .links a.active { opacity: 0.5; pointer-events: none; }

/* ── PAGES ── */
.page { display: none; width: 100%; min-height: 100vh; }
.page.active { display: block; }

/* ── HOME PAGE ── */
#page-home { background: var(--bg-home); color: #fff; }
.home-hero {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; padding: 120px 48px 80px;
}
.home-hero h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(56px, 9vw, 140px); line-height: 0.95;
  letter-spacing: -3px; font-weight: 400; max-width: 900px;
}
.home-hero h1 em { font-style: italic; color: var(--accent); }
.home-hero .subtitle {
  margin-top: 32px; font-size: 16px; color: #888;
  max-width: 420px; line-height: 1.6; font-weight: 300;
}
.home-section {
  padding: 120px 48px; border-top: 1px solid #1a1a1e;
}
.home-section .label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 3px; color: #555; margin-bottom: 40px;
}
.home-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px;
}
.home-card {
  border: 1px solid #1e1e22; padding: 36px; border-radius: 2px;
  transition: border-color 0.3s;
}
.home-card:hover { border-color: var(--accent); }
.home-card .num {
  font-family: 'Instrument Serif', serif;
  font-size: 42px; color: var(--accent); margin-bottom: 16px;
}
.home-card h3 { font-size: 18px; margin-bottom: 12px; font-weight: 400; }
.home-card p { font-size: 14px; color: #777; line-height: 1.6; font-weight: 300; }
.home-marquee {
  padding: 80px 0; border-top: 1px solid #1a1a1e;
  overflow: hidden; white-space: nowrap;
}
.home-marquee .track {
  display: inline-flex; gap: 48px;
  animation: marquee 20s linear infinite;
  font-family: 'Instrument Serif', serif;
  font-size: 72px; color: #1a1a1e;
}
.home-marquee .track span.highlight { color: var(--accent); }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ── ABOUT PAGE ── */
#page-about { background: var(--bg-about); color: #1a1a1a; }
.about-hero {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; padding: 120px 48px 80px;
}
.about-hero .eyebrow {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 4px; color: #999; margin-bottom: 24px;
}
.about-hero h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(48px, 7vw, 110px); line-height: 1;
  letter-spacing: -2px; font-weight: 400; max-width: 800px;
}
.about-hero h1 em { font-style: italic; color: var(--accent); }
.about-content {
  padding: 0 48px 120px; display: grid;
  grid-template-columns: 1fr 1fr; gap: 80px;
}
.about-content .col h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 32px; font-weight: 400; margin-bottom: 24px;
}
.about-content .col p {
  font-size: 15px; line-height: 1.8; color: #555; font-weight: 300;
  margin-bottom: 20px;
}
.about-stats {
  padding: 80px 48px; border-top: 1px solid #ddd8ce;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 40px;
}
.about-stat .number {
  font-family: 'Instrument Serif', serif;
  font-size: 56px; color: var(--accent);
}
.about-stat .desc {
  font-size: 13px; color: #888; margin-top: 8px;
  text-transform: uppercase; letter-spacing: 1px;
}

/* ── WORK PAGE ── */
#page-work { background: var(--bg-work); color: #e0eaf5; }
.work-hero { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 120px 48px 80px; }
.work-hero h1 { font-family: 'Instrument Serif', serif; font-size: clamp(52px, 8vw, 120px); line-height: 0.95; letter-spacing: -3px; font-weight: 400; max-width: 860px; }
.work-hero h1 em { font-style: italic; color: #5eb8ff; }
.work-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; padding: 0 0 120px; }
.work-item { background: #0a2035; padding: 56px 48px; transition: background 0.3s; }
.work-item:hover { background: #112a42; }
.work-item .tag { font-size: 10px; text-transform: uppercase; letter-spacing: 3px; color: #5eb8ff; margin-bottom: 20px; }
.work-item h3 { font-family: 'Instrument Serif', serif; font-size: 36px; font-weight: 400; margin-bottom: 12px; }
.work-item p { font-size: 14px; color: #6a8aaa; line-height: 1.6; font-weight: 300; }
.work-item .year { margin-top: 32px; font-size: 12px; color: #3a5a7a; }

/* ── CONTACT PAGE ── */
#page-contact { background: var(--bg-contact); color: #d4ead8; }
.contact-hero { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 120px 48px 80px; }
.contact-hero h1 { font-family: 'Instrument Serif', serif; font-size: clamp(52px, 8vw, 120px); line-height: 0.95; letter-spacing: -3px; font-weight: 400; max-width: 860px; }
.contact-hero h1 em { font-style: italic; color: #6fcf8a; }
.contact-body { padding: 0 48px 120px; display: grid; grid-template-columns: 1fr 1fr; gap: 80px; }
.contact-body .col h2 { font-family: 'Instrument Serif', serif; font-size: 32px; font-weight: 400; margin-bottom: 24px; }
.contact-body .col p { font-size: 15px; line-height: 1.8; color: #7aaa80; font-weight: 300; margin-bottom: 20px; }
.contact-body .col a { color: #6fcf8a; text-decoration: none; border-bottom: 1px solid #6fcf8a44; padding-bottom: 2px; }
.contact-offices { padding: 80px 48px; border-top: 1px solid #1e4030; display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; }
.contact-office .city { font-family: 'Instrument Serif', serif; font-size: 28px; margin-bottom: 12px; }
.contact-office .addr { font-size: 13px; color: #4a7a50; line-height: 1.8; }

/* ── TRANSITION OVERLAY ── */
#transition-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 1000; pointer-events: none; display: none;
}
#transition-overlay.active { display: block; pointer-events: all; }

.flip-cell {
  position: absolute;
  perspective: 1200px;
}
.flip-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration) cubic-bezier(0.4, 0.0, 0.2, 1);
}
.flip-inner.flipped { transform: rotateX(180deg); }
.flip-front, .flip-back {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  backface-visibility: hidden;
  overflow: hidden;
}
.flip-back { transform: rotateX(180deg); }
.flip-front canvas, .flip-back canvas {
  position: absolute; display: block;
}

/* ── CONTROLS ── */
.controls {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 50; display: flex; gap: 12px; align-items: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(16px);
  padding: 12px 24px; border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: #aaa;
}
.controls label { white-space: nowrap; }
.controls input[type=number] {
  width: 42px; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff; padding: 4px 8px; border-radius: 6px;
  font-size: 12px; text-align: center;
  font-family: 'DM Sans', sans-serif;
}
.controls input[type=number]:focus { outline: 1px solid var(--accent); }
.controls .sep {
  width: 1px; height: 20px; background: rgba(255,255,255,0.15);
}
.controls .hint { color: #666; font-size: 11px; }

/* ── SOLACE BADGE ── */
.solace-badge {
  position: fixed; bottom: 22px; left: 22px; z-index: 50;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 300;
  letter-spacing: 0.1em; text-transform: uppercase;
  line-height: 1.75;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  transition: color 0.3s;
}
.solace-badge:hover { color: rgba(255,255,255,0.7); }

@media (max-width: 768px) {
  .page-nav { padding: 16px 20px; }
  .page-nav .links { gap: 20px; }
  .page-nav .links a { font-size: 12px; }
  .home-hero, .about-hero { padding: 100px 20px 60px; }
  .home-section, .about-content, .about-stats { padding-left: 20px; padding-right: 20px; }
  .home-grid { grid-template-columns: 1fr; }
  .about-content { grid-template-columns: 1fr; gap: 40px; }
  .about-stats { grid-template-columns: repeat(2, 1fr); }
  .controls { bottom: 12px; padding: 10px 16px; font-size: 11px; }
}
