/* ═══════════════════════════════════════════════
   PORTFOLIO — Base Design System v2.0
   Inspired by charnphivnil.com + framer.website
   ═══════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,400&family=Instrument+Serif:ital@0;1&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Roboto+Mono:wght@300;400;500;600;700&display=swap');

/* ── Custom Properties ── */
:root {
  /* ─── Colors ─── */
  --bg:             #08080d;
  --surface-1:      #0f0f16;
  --surface-2:      #15151f;
  --surface-3:      #1c1c28;

  --text-primary:   #f0ede8;
  --text-secondary: rgba(240, 237, 232, 0.6);
  --text-tertiary:  rgba(240, 237, 232, 0.35);

  --accent-gold:    #C8A96E;
  --accent-cyan:    #4DFFDB;
  --muted:          #3A3A4A;

  /* ─── Borders & Cards ─── */
  --border-subtle:      rgba(255, 255, 255, 0.06);
  --border-hover:       rgba(255, 255, 255, 0.12);
  --border-gold:        rgba(200, 169, 110, 0.25);
  --card-bg:            rgba(255, 255, 255, 0.02);
  --card-border:        rgba(255, 255, 255, 0.06);
  --watermark-color:    rgba(255, 255, 255, 0.015);
  --vortex-opacity:     0.8;

  /* ─── Typography ─── */
  --font-display: 'Bebas Neue', 'Arial Black', sans-serif;
  --font-heading: 'Inter', 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-mono:    'Roboto Mono', 'DM Mono', 'Courier New', monospace;
  --font-accent:  'Instrument Serif', Georgia, serif;

  /* Fluid Type Scale */
  --text-xs:   clamp(0.65rem, 0.6rem + 0.25vw, 0.75rem);
  --text-sm:   clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.8rem + 0.4vw, 1rem);
  --text-lg:   clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  --text-xl:   clamp(1.25rem, 1rem + 1vw, 1.75rem);
  --text-2xl:  clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  --text-3xl:  clamp(2rem, 1.5rem + 2.5vw, 3.5rem);
  --text-4xl:  clamp(2.5rem, 2rem + 3vw, 4.5rem);
  --text-5xl:  clamp(3rem, 2rem + 5vw, 6rem);
  --text-hero: clamp(3.5rem, 2rem + 8vw, 8rem);

  /* ─── Spacing (8px grid) ─── */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Legacy spacing aliases (for backward compat) */
  --space-xs:  var(--space-1);
  --space-sm:  var(--space-2);
  --space-md:  var(--space-4);
  --space-lg:  var(--space-8);
  --space-xl:  var(--space-16);
  --space-2xl: var(--space-32);

  /* ─── Radii ─── */
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-bento: 20px;
  --radius-xl:    24px;
  --radius-pill:  999px;
  --radius:       12px; /* legacy alias */

  /* ─── Motion ─── */
  --ease-out-expo:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quint:   cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-quad: cubic-bezier(0.45, 0, 0.55, 1);
  --duration-fast:    150ms;
  --duration-normal:  300ms;
  --duration-slow:    600ms;
  --transition:       0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-slow:  0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* ─── Layout ─── */
  --content-max: 1200px;
  --bento-gap:   var(--space-4);
  --bento-pad:   var(--space-8);

  /* ─── Z-Index ─── */
  --z-cursor:  9999;
  --z-loader:  9998;
  --z-nav:     9000;
  --z-grain:   8000;
  --z-content: 100;
  --z-canvas:  1;
}

/* ── Desktop Cursor Hiding ── */
@media (min-width: 769px) {
  body, a, button, [data-cursor], .nav__link {
    cursor: none !important;
  }
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: auto; /* Lenis handles smooth scroll */
}

html.lenis, html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

body {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg);
  overflow-x: hidden;
  line-height: 1.6;
}

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

button {
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

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

ul, ol {
  list-style: none;
}

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

/* ── Grain / Noise Overlay ── */
.grain-overlay {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.03;
  animation: grainShift 0.5s steps(6) infinite;
}

.grain-overlay svg {
  width: 100%;
  height: 100%;
}

@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -10%); }
  20% { transform: translate(-15%, 5%); }
  30% { transform: translate(7%, -25%); }
  40% { transform: translate(-5%, 25%); }
  50% { transform: translate(-15%, 10%); }
  60% { transform: translate(15%, 0%); }
  70% { transform: translate(0%, 15%); }
  80% { transform: translate(3%, 35%); }
  90% { transform: translate(-10%, 10%); }
}

/* ── Custom Cursor ── */
.cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  pointer-events: none;
  z-index: var(--z-cursor);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px var(--accent-cyan), 0 0 20px rgba(77, 255, 219, 0.3);
  transition: width var(--duration-normal) var(--ease-out-expo),
              height var(--duration-normal) var(--ease-out-expo),
              background var(--duration-normal) var(--ease-out-expo);
}

.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  border: 1.5px solid rgba(240, 237, 232, 0.25);
  border-radius: 50%;
  pointer-events: none;
  z-index: var(--z-cursor);
  transform: translate(-50%, -50%);
  transition: width 0.4s var(--ease-out-expo),
              height 0.4s var(--ease-out-expo),
              border-color var(--duration-normal) ease,
              background var(--duration-normal) ease;
}

.cursor-label {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: var(--z-cursor);
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--bg);
  opacity: 0;
  transition: opacity var(--duration-normal) ease;
  white-space: nowrap;
}

/* Cursor hover states */
body.cursor-hover .cursor-dot {
  width: 60px;
  height: 60px;
  background: rgba(77, 255, 219, 0.12);
  box-shadow: none;
  mix-blend-mode: difference;
}

body.cursor-hover .cursor-ring {
  width: 60px;
  height: 60px;
  border-color: var(--accent-cyan);
  background: rgba(77, 255, 219, 0.08);
}

body.cursor-hover .cursor-label {
  opacity: 1;
}

body.cursor-hover-gold .cursor-dot {
  background: rgba(200, 169, 110, 0.15);
  box-shadow: 0 0 15px rgba(200, 169, 110, 0.3);
}

body.cursor-hover-gold .cursor-ring {
  border-color: var(--accent-gold);
  background: rgba(200, 169, 110, 0.08);
}

/* ── Navigation ── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: var(--space-5) var(--space-10);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-nav);
  transition: background var(--duration-normal) var(--ease-out-quint),
              backdrop-filter var(--duration-normal) var(--ease-out-quint);
}

.nav--scrolled {
  background: rgba(8, 8, 13, 0.7);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-bottom: 1px solid var(--border-subtle);
}

.nav__links {
  display: flex;
  gap: var(--space-10);
  align-items: center;
}

.nav__link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  position: relative;
  padding: var(--space-1) 0;
  transition: color var(--duration-normal) var(--ease-out-quint);
}

.nav__link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent-cyan);
  transition: width var(--duration-normal) var(--ease-out-expo);
}

.nav__link:hover,
.nav__link--active {
  color: var(--text-primary);
}

.nav__link:hover::after,
.nav__link--active::after {
  width: 100%;
}

/* Mobile nav toggle */
.nav__toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  cursor: pointer;
  background: transparent;
  border: none;
  z-index: 110;
}

.nav__toggle span {
  width: 24px;
  height: 1.5px;
  background: var(--text-primary);
  transition: transform var(--duration-normal) var(--ease-out-expo),
              opacity var(--duration-normal) var(--ease-out-expo);
  transform-origin: center;
}

.nav__toggle--active span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}

.nav__toggle--active span:nth-child(2) {
  opacity: 0;
}

.nav__toggle--active span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ── Loader ── */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: var(--z-loader);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
}

.loader__counter {
  font-family: var(--font-mono);
  font-size: var(--text-5xl);
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: 0.1em;
  opacity: 0.4;
}

.loader__text {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  letter-spacing: 0.15em;
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
}

.loader__char {
  display: inline-block;
  min-width: 0.6em;
  text-align: center;
}

.loader__bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-gold));
  width: 0%;
  transition: width 0.05s linear;
}

/* ── Typography Utilities ── */
.font-display { font-family: var(--font-display); }
.font-heading { font-family: var(--font-heading); }
.font-mono    { font-family: var(--font-mono); }
.font-accent  { font-family: var(--font-accent); }

.text-gold    { color: var(--accent-gold); }
.text-cyan    { color: var(--accent-cyan); }
.text-muted   { color: var(--muted); }
.text-secondary { color: var(--text-secondary); }

/* ── Layout Container ── */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-8);
}

/* ── Section Base ── */
.section {
  position: relative;
  width: 100%;
  min-height: 100vh;
  padding: var(--space-32) var(--space-16);
  overflow: hidden;
  scroll-margin-top: 6.5rem;
}

.section__header {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  letter-spacing: 0.12em;
  margin-bottom: var(--space-4);
  text-align: center;
  color: var(--text-primary);
}

.section__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: center;
  margin-bottom: var(--space-3);
}

.section__divider {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-hover), transparent);
  margin: var(--space-4) auto var(--space-12);
}

/* ── Bento Grid Utility ── */
.bento-grid {
  display: grid;
  gap: var(--bento-gap);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

.bento-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-bento);
  padding: var(--bento-pad);
  transition: border-color var(--duration-normal) var(--ease-out-quint),
              transform var(--duration-normal) var(--ease-out-expo),
              box-shadow var(--duration-slow) var(--ease-out-expo);
}

.bento-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* ── CTA Button (modernized) ── */
.cta-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: var(--space-4) var(--space-8);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  background: transparent;
  transition: all var(--duration-normal) var(--ease-out-quint);
  text-decoration: none;
}

.cta-button:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}

.cta-button--gold {
  border-color: var(--border-gold);
  color: var(--accent-gold);
}

.cta-button--gold:hover {
  background: rgba(200, 169, 110, 0.08);
  border-color: var(--accent-gold);
  box-shadow: 0 0 30px rgba(200, 169, 110, 0.1);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* ── Canvas Backgrounds ── */
.ambient-canvas,
.vectors-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-canvas);
  pointer-events: none;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  body {
    cursor: auto;
  }

  .cursor-dot,
  .cursor-ring,
  .cursor-label {
    display: none !important;
  }

  .nav {
    padding: var(--space-4) var(--space-6);
  }

  .nav__links {
    position: fixed;
    top: 0;
    right: -100%;
    width: 70%;
    height: 100vh;
    background: rgba(8, 8, 13, 0.95);
    backdrop-filter: blur(24px);
    flex-direction: column;
    justify-content: center;
    gap: var(--space-8);
    transition: right 0.5s var(--ease-out-expo);
  }

  .nav__links--open {
    right: 0;
  }

  .nav__toggle {
    display: flex;
  }

  .section {
    padding: var(--space-16) var(--space-8);
  }
}

@media (max-width: 480px) {
  .section {
    padding: var(--space-16) var(--space-4);
  }
}
