/* ========================================
   BASE — Global Styles
   ======================================== */

html {
  background: var(--bg);
}

/* Disable text selection + iOS long-press callout site-wide.
   Form fields re-enable selection via the rule below so inputs stay usable. */
html, body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 300;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  overflow-x: clip;
  cursor: none;
  transition: background 0.4s ease, color 0.4s ease;
}

/* Noise Grain Overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: var(--noise-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Selection */
::selection {
  background: var(--blue);
  color: var(--white);
}

::-moz-selection {
  background: var(--blue);
  color: var(--white);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

/* Skip to content */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 10010;
  padding: 0.75rem 1.25rem;
  background: var(--blue);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-decoration: none;
  transition: top 180ms ease;
}
.skip-link:focus { top: 1rem; }

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--black);
}
::-webkit-scrollbar-thumb {
  background: var(--gray-700);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-600);
}

/* Typography Base */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

p {
  line-height: var(--leading-normal);
  color: var(--text-dim);
}

/* Links */
a {
  transition: color var(--duration-fast) ease;
}
a:hover {
  color: var(--accent-text);
}

/* Monospace Labels */
.label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--text-muted);
}

.label--accent {
  color: var(--accent-text);
}

/* Custom Cursor */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--white);
  border-radius: 50%;
  pointer-events: none;
  z-index: 99999;
  transform: translate(-50%, -50%);
  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),
              border-color var(--duration-normal) var(--ease-out-expo);
  mix-blend-mode: difference;
  will-change: transform;
}

.cursor.is-active {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--blue-bright);
}

.cursor.is-hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
}

/* Grab states for the hero graph. The graph used to set a native `grab`
   cursor, which overrides the `cursor: none` on body and draws a second
   pointer on top of this one — two cursors at once. Grabbability is expressed
   here instead, so there is still only ever one. */
.cursor.is-grab {
  width: 36px;
  height: 36px;
  border-color: var(--accent);
  border-width: 2px;
}

.cursor.is-grabbing {
  width: 22px;
  height: 22px;
  border-color: var(--accent);
  border-width: 2px;
  background: hsla(var(--accent-hue), 100%, 55%, 0.22);
}

/* A text field is the one place the native cursor is worth more than this one:
   the I-beam shows where the caret will land. So this one stands down rather
   than doubling up. */
.cursor.is-text {
  opacity: 0;
}

/* The custom cursor is the only pointer on fine-pointer devices. The UA
   stylesheet gives every <a> and <summary> a native `pointer`, which draws a
   second cursor on top of the custom one — so it is cleared here once rather
   than class by class, which is how several links slipped through before.
   Text fields deliberately keep their native I-beam (it shows where the caret
   lands); .cursor.is-text hides the custom dot over those instead. */
@media (hover: hover) and (pointer: fine) {
  a, summary, label, select, [role="button"] { cursor: none; }
}


[data-theme="light"] .cursor.is-grabbing {
  background: hsla(var(--accent-hue), 100%, 55%, 0.18);
}

/* Hide custom cursor on touch */
@media (hover: none), (pointer: coarse) {
  .cursor { display: none !important; }
  body { cursor: auto; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Light mode adjustments */
[data-theme="light"] .nav.is-scrolled {
  background: rgba(250, 250, 250, 0.85);
}
[data-theme="light"] .nav__mobile {
  background: rgba(250, 250, 250, 0.97);
}
[data-theme="light"] .page-loader {
  background: #FAFAFA;
}
[data-theme="light"] .cursor {
  border-color: #1A1A1A;
  mix-blend-mode: normal;
}
[data-theme="light"] .cursor.is-active {
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] ::-webkit-scrollbar-track {
  background: #F0F0F0;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #CCCCCC;
}

/* Floating Icons */
.floating-icons {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.floating-icon {
  position: absolute;
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 0.6rem + 1vw, 1.4rem);
  color: var(--accent-text);
  opacity: 0;
  animation: floatIcon 12s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

@keyframes floatIcon {
  0%   { opacity: 0; transform: translateY(20px) rotate(0deg); }
  15%  { opacity: 0.15; }
  50%  { opacity: 0.08; transform: translateY(-30px) rotate(5deg); }
  85%  { opacity: 0.15; }
  100% { opacity: 0; transform: translateY(20px) rotate(-3deg); }
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--text-sm);
  cursor: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

[data-theme="light"] .theme-toggle {
  border-color: rgba(0, 0, 0, 0.12);
}

/* GSAP visibility helper */
.gs-reveal {
  visibility: hidden;
}
