/* ===========================
   DESIGN TOKENS
=========================== */
:root {
  --bg: #F9F7F4;
  --surface: #FFFFFF;
  --surface-alt: #F2EFE9;
  --border: #E5E0D8;
  --ink: #1A1714;
  --ink-2: #4A4540;
  --ink-3: #8A847C;
  --accent: #C8651A;
  --accent-light: #F5E8DB;
  --gold: #B8860B;
  --silver: #6B7280;
  --bronze: #92674A;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 2px 20px rgba(26,23,20,0.07);
  --shadow-lg: 0 8px 40px rgba(26,23,20,0.12);
  --nav-h: 64px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

/* ===========================
   RESET & BASE
=========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle, rgba(200,101,26,0.20) 1.5px, transparent 1.5px),
    radial-gradient(ellipse 65% 55% at 12% 18%, rgba(200,101,26,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 55% 65% at 88% 78%, rgba(184,134,11,0.10) 0%, transparent 70%),
    radial-gradient(ellipse 45% 45% at 55% 48%, rgba(200,101,26,0.08) 0%, transparent 70%);
  background-size: 28px 28px, 100% 100%, 100% 100%, 100% 100%;
  color: var(--ink);
  line-height: 1.7;
  overflow-x: hidden;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

section, nav, footer, .mobile-menu {
  position: relative;
  z-index: 1;
}

img { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ===========================
   NAVBAR
=========================== */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(249,247,244,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
}

#navbar.scrolled {
  border-color: var(--border);
  box-shadow: var(--shadow);
}

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

.nav-logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  gap: 36px;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
  position: relative;
  padding-bottom: 2px;
  transition: color 0.2s;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0;
  width: 0; height: 1.5px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active { color: var(--accent); }

.nav-links a.active::after,
.nav-links a:hover::after { width: 100%; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--ink);
  transition: 0.3s;
  border-radius: 2px;
}

/* ===========================
   MOBILE MENU
=========================== */
.mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-h); left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 99;
  box-shadow: var(--shadow-lg);
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-menu.open {
  transform: translateY(0);
  opacity: 1;
}

.mobile-menu ul { padding: 16px 0; }

.mobile-menu li a {
  display: block;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-2);
  transition: color 0.2s, background 0.2s;
}

.mobile-menu li a:hover {
  color: var(--accent);
  background: var(--accent-light);
}

/* ===========================
   SHARED SECTION LAYOUT
=========================== */
.section {
  padding: calc(var(--nav-h) + 60px) 24px 80px;
  min-height: 100vh;
}

.section-inner {
  max-width: 1000px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 56px;
}

.section-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

/* ===========================
   SHARED LINK BUTTON
=========================== */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  transition: all 0.2s ease;
}

.link-btn svg { width: 16px; height: 16px; }

.link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* ===========================
   PROJECT MODAL (global)
=========================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.6);
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: block;
  animation: fadeIn 0.2s ease;
}

.project-modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 201;
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 820px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
}

.project-modal.open {
  display: block;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  animation: modalIn 0.25s ease forwards;
}

@keyframes modalIn {
  from { transform: translate(-50%, -50%) scale(0.95); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
}

.modal-close {
  position: sticky;
  top: 16px;
  float: right;
  margin: 16px 16px 0 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  z-index: 10;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.modal-content {
  padding: 32px;
  clear: both;
}

.modal-hero {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
  background: var(--surface-alt);
}

.modal-hero img {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.modal-year {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  margin-top: 8px;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  width: fit-content;
}

.modal-tab {
  padding: 7px 20px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.modal-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(26,23,20,0.08);
}

.modal-tab:not(.active):hover { color: var(--ink-2); }

.modal-tab-panel { animation: tabFade 0.2s ease; }
.modal-tab-panel.hidden { display: none; }

@keyframes tabFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-story {
  font-size: 0.925rem;
  color: var(--ink-2);
  line-height: 1.75;
}

.modal-story p { margin-bottom: 12px; }

.modal-tech-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-tech-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: var(--ink-2);
  padding: 8px 12px;
  background: var(--surface-alt);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.modal-images {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.modal-images img {
  border-radius: var(--radius);
  width: 100%;
  object-fit: cover;
  aspect-ratio: 4/3;
}

.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 10px 22px;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s;
}

.modal-link:hover {
  background: var(--accent);
  transform: translateY(-2px);
}

/* ===========================
   SCROLL REVEAL
=========================== */
.reveal,
.reveal-delay-1,
.reveal-delay-2,
.reveal-delay-3,
.reveal-delay-4,
.reveal-delay-5 {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition: opacity 0.65s ease, transform 0.65s ease, filter 0.65s ease;
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.35s; }
.reveal-delay-4 { transition-delay: 0.5s; }
.reveal-delay-5 { transition-delay: 0.65s; }

.reveal.visible,
.reveal-delay-1.visible,
.reveal-delay-2.visible,
.reveal-delay-3.visible,
.reveal-delay-4.visible,
.reveal-delay-5.visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0px);
}

/* ===========================
   FOOTER
=========================== */
footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  font-size: 0.825rem;
  color: var(--ink-3);
  position: relative;
  z-index: 1;
}

/* ===========================
   ANIMATIONS
=========================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 700px) {
  .nav-links  { display: none; }
  .hamburger  { display: flex; }
  .mobile-menu { display: block; }

  .section-title { font-size: 1.8rem; }
}