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

:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #181818;
  --fg: #f0ece4;
  --fg2: #9a9590;
  --fg3: #4a4845;
  --accent: #c8f04a;
  --accent2: #f0c060;
  --border: rgba(240,236,228,0.08);
  --border-hover: rgba(240,236,228,0.18);
  --font-display: 'Syne', sans-serif;
  --font-serif: 'Instrument Serif', serif;
  --font-mono: 'DM Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease2: cubic-bezier(0.4, 0, 0.2, 1);
  --px: 2.5rem;
}

html {
  scroll-behavior: smooth;
  /* Prevent horizontal overflow at root */
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  cursor: none;
  /* Hard clamp — nothing bleeds past viewport */
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

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

/* ─── Grain ─── */
.grain {
  position: fixed; inset: 0; z-index: 9999;
  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='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.5;
}

/* ─── Custom Cursor (desktop only) ─── */
.cursor {
  position: fixed; z-index: 9998;
  width: 40px; height: 40px;
  border: 1px solid rgba(200,240,74,0.5);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: width 0.3s var(--ease), height 0.3s var(--ease), border-color 0.3s, background 0.3s;
  mix-blend-mode: difference;
}
.cursor-dot {
  position: fixed; z-index: 9998;
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: transform 0.1s;
}
body.cursor-hover .cursor {
  width: 60px; height: 60px;
  background: rgba(200,240,74,0.08);
  border-color: var(--accent);
}

/* ─── Nav ─── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 6px;
  padding: 1.2rem var(--px);
  font-family: var(--font-mono);
  font-size: 12px;
  border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  background: rgba(10,10,10,0.6);
  transition: border-color 0.3s;
  /* Prevent nav from causing overflow */
  width: 100%;
  max-width: 100vw;
}
.nav.scrolled { border-bottom-color: var(--border); }
.nav-home { color: var(--fg); opacity: 0.7; transition: opacity 0.2s; white-space: nowrap; }
.nav-home:hover { opacity: 1; }
.nav-label { color: var(--accent); white-space: nowrap; }
.nav-count { margin-left: auto; color: var(--fg3); white-space: nowrap; }

/* ─── Reveal animations ─── */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal.visible { opacity: 1; transform: none; }
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.45s; }
.delay-5 { transition-delay: 0.6s; }

/* ─── Hero ─── */
.hero {
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 80px var(--px) 5rem;
  position: relative;
  /* Contain children — no bleed */
  overflow: hidden;
  width: 100%;
}

.hero::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 50vw; height: 60vh;
  background: radial-gradient(ellipse at 80% 20%, rgba(200,240,74,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.hero-title {
  font-family: var(--font-display);
  /* clamp: min 2.8rem on tiny phones, fluid, max 9rem on desktop */
  font-size: clamp(2.8rem, 9vw, 9rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin-bottom: 2rem;
  display: flex; flex-wrap: wrap; gap: 0.2em;
  /* Stop text from forcing horizontal scroll */
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}
.hero-title em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg2);
  line-height: 1.8;
  margin-bottom: 3rem;
  max-width: 100%;
}

.hero-scroll {
  display: flex; align-items: center; gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg3);
}
.scroll-line {
  width: 60px; height: 1px;
  background: var(--fg3);
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.scroll-line::after {
  content: '';
  position: absolute; top: 0; left: -100%;
  width: 100%; height: 100%;
  background: var(--accent);
  animation: scanline 2s ease-in-out infinite;
}
@keyframes scanline {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ─── Filter bar ─── */
.filter-bar {
  padding: 1rem var(--px);
  display: flex; align-items: center; gap: 0.75rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 52px; z-index: 90;
  background: rgba(10,10,10,0.85);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  /* Allow horizontal scroll inside filter bar only if tags overflow */
  overflow-x: auto;
  width: 100%;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  flex-shrink: 0;
}
.filters { display: flex; gap: 8px; flex-shrink: 0; }
.filter-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--fg2);
  cursor: none;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-btn:hover { border-color: var(--border-hover); color: var(--fg); }
.filter-btn.active {
  background: var(--accent);
  color: #0a0a0a;
  border-color: var(--accent);
  font-weight: 700;
}

/* ─── Projects Grid ─── */
.projects {
  padding: 4rem var(--px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 1px;
  background: var(--border);
  width: 100%;
}

/* ─── Project Card ─── */
.project-card {
  background: var(--bg);
  padding: 0;
  cursor: none;
  overflow: hidden;
  position: relative;
  transition: background 0.3s;
  /* Card never exceeds grid cell */
  min-width: 0;
  width: 100%;
}
.project-card:hover { background: var(--bg2); }

.card-preview {
  width: 100%; aspect-ratio: 16/9;
  overflow: hidden;
  position: relative;
  background: var(--bg3);
}
.card-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease), filter 0.4s;
  filter: grayscale(20%);
}
.project-card:hover .card-preview img {
  transform: scale(1.05);
  filter: grayscale(0%);
}
.card-preview-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg3);
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, var(--bg3) 0%, #1a1a18 100%);
  position: relative;
}
.card-preview-placeholder .placeholder-num {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 800;
  color: rgba(240,236,228,0.04);
  position: absolute;
}

.card-status {
  position: absolute; top: 12px; right: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 100px;
  letter-spacing: 0.08em;
}
.status-live { background: rgba(200,240,74,0.15); color: var(--accent); border: 1px solid rgba(200,240,74,0.3); }
.status-wip { background: rgba(240,192,96,0.15); color: var(--accent2); border: 1px solid rgba(240,192,96,0.3); }
.status-archived { background: rgba(74,72,69,0.4); color: var(--fg3); border: 1px solid rgba(74,72,69,0.6); }

.card-body { padding: 1.25rem; }

.card-meta {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.card-year {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg3);
  flex-shrink: 0;
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg3);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  white-space: nowrap;
}

.card-title {
  font-size: clamp(1.1rem, 3vw, 1.3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  line-height: 1.2;
  word-break: break-word;
}

.card-desc {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg2);
  line-height: 1.7;
  margin-bottom: 1.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.card-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--fg2);
  cursor: none;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.card-btn:hover { border-color: var(--fg); color: var(--fg); }
.card-btn.primary {
  background: var(--accent);
  color: #0a0a0a;
  border-color: var(--accent);
  font-weight: 700;
}
.card-btn.primary:hover { background: #d8ff55; }
.card-btn svg { width: 10px; height: 10px; flex-shrink: 0; }

/* Featured card */
.project-card.featured { grid-column: span 2; }
.project-card.featured .card-title { font-size: clamp(1.3rem, 3.5vw, 1.8rem); }
.project-card.featured .card-preview { aspect-ratio: 21/9; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  /* Padding ensures modal never touches screen edges */
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
  overflow-y: auto;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: 12px;
  max-width: 700px; width: 100%;
  max-height: calc(100svh - 2rem);
  overflow-y: auto;
  transform: translateY(30px) scale(0.97);
  transition: transform 0.4s var(--ease);
  /* Prevent modal content from overflowing */
  overflow-x: hidden;
}
.modal-overlay.open .modal { transform: none; }

.modal-close {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg3);
  background: transparent; border: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  display: block; width: 100%; text-align: right;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--fg); }

.modal-inner { padding: 0 1.5rem 2rem; }

.modal-image {
  width: calc(100% + 3rem);
  margin-left: -1.5rem;
  aspect-ratio: 16/9;
  object-fit: cover;
  margin-bottom: 1.5rem;
  border-radius: 8px 8px 0 0;
  display: block;
}

.modal-title {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  word-break: break-word;
}
.modal-year {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 1rem;
}
.modal-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 1.5rem; }
.modal-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 12px;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  color: var(--fg2);
}
.modal-desc {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg2);
  line-height: 1.8;
  margin-bottom: 1.5rem;
}
.modal-links { display: flex; gap: 12px; flex-wrap: wrap; }
.modal-link {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid var(--border-hover);
  color: var(--fg);
  transition: all 0.2s;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.modal-link:hover { border-color: var(--fg); background: var(--bg3); }
.modal-link.primary-link {
  background: var(--accent); color: #0a0a0a;
  border-color: var(--accent); font-weight: 700;
}
.modal-link.primary-link:hover { background: #d8ff55; }

/* ─── Footer ─── */
.footer { padding: 0 var(--px) 3rem; }
.footer-line { height: 1px; background: var(--border); margin-bottom: 2rem; }
.footer-inner {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.75rem;
}
.footer-text { font-family: var(--font-mono); font-size: 12px; color: var(--fg3); }
.footer-text a { color: var(--accent); }
.footer-hint { font-family: var(--font-mono); font-size: 11px; color: var(--fg3); opacity: 0.5; }

/* ─── No results ─── */
.no-results {
  grid-column: 1/-1;
  text-align: center;
  padding: 6rem 2rem;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg3);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--fg3); border-radius: 2px; }

/* ═══════════════════════════════════
   TABLET  (481px – 768px)
═══════════════════════════════════ */
@media (max-width: 768px) {
  :root { --px: 1.5rem; }

  .hero { padding: 80px var(--px) 4rem; }

  .hero-title { font-size: clamp(2.5rem, 8vw, 4.5rem); }

  .projects {
    padding: 2rem var(--px);
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 1px;
  }

  /* Featured takes full width on tablet too if only 1 col fits */
  .project-card.featured { grid-column: span 1; }
  .project-card.featured .card-preview { aspect-ratio: 16/9; }

  .filter-bar { top: 48px; }
}

/* ═══════════════════════════════════
   MOBILE  (≤ 480px)
═══════════════════════════════════ */
@media (max-width: 480px) {
  :root { --px: 1.25rem; }

  /* Kill custom cursor on touch */
  body { cursor: auto; }
  .cursor, .cursor-dot { display: none; }
  .filter-btn, .card-btn { cursor: pointer; }

  .nav { padding: 1rem var(--px); font-size: 11px; }
  /* Hide count on very small screens to avoid overflow */
  .nav-count { display: none; }

  .hero {
    padding: 70px var(--px) 3.5rem;
    min-height: 100svh;
  }
  .hero-title {
    font-size: clamp(2.2rem, 11vw, 3.2rem);
    gap: 0.15em;
  }
  .hero-sub { font-size: 12px; }
  .hero-scroll { display: none; }

  .filter-bar {
    padding: 0.75rem var(--px);
    gap: 0.5rem;
    top: 44px;
  }
  .filter-label { display: none; }

  .projects {
    padding: 1.5rem var(--px);
    grid-template-columns: 1fr;
    background: transparent;
    gap: 1rem;
  }

  .project-card {
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .project-card.featured { grid-column: span 1; }
  .project-card.featured .card-preview { aspect-ratio: 16/9; }

  .card-body { padding: 1rem; }
  .card-title { font-size: 1.15rem; }
  .card-actions { gap: 6px; }
  .card-btn { padding: 6px 12px; font-size: 10px; }

  .modal-overlay { padding: 0.75rem; align-items: flex-end; }
  .modal {
    border-radius: 16px 16px 12px 12px;
    max-height: calc(100svh - 1.5rem);
  }
  .modal-inner { padding: 0 1rem 1.5rem; }
  .modal-image {
    width: calc(100% + 2rem);
    margin-left: -1rem;
  }
  .modal-title { font-size: 1.5rem; }
  .modal-links { flex-direction: column; }
  .modal-link { justify-content: center; }

  .footer { padding: 0 var(--px) 2rem; }
  .footer-hint { display: none; }
}

/* ═══════════════════════════════════
   TINY  (≤ 360px — small Androids)
═══════════════════════════════════ */
@media (max-width: 360px) {
  :root { --px: 1rem; }
  .hero-title { font-size: 2rem; }
  .card-btn { padding: 5px 10px; }
}