/* ═══════════════════════════════════════════════════════════
   DEREKSHREDS.DEV — design system
   dark terminal-brutalist / acid accent / mono details
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0b;
  --bg-2: #121216;
  --ink: #e8e8e3;
  --ink-dim: #94948c;
  /* main.js cycles --accent through purple → acid → orange → cyan */
  --accent: #a855ff;   /* neon purple — the opener */
  --accent-rgb: 168, 85, 255;
  --accent-2: #ccff00; /* acid */
  --accent-3: #ff8a00; /* electric orange */
  --accent-4: #4df3ff; /* electric cyan */
  --line: rgba(232, 232, 227, 0.14);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-title: "Clash Display", "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --pad: clamp(1.25rem, 4vw, 4rem);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #000; }

.mono { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em; }

a { color: inherit; text-decoration: none; }

/* ── grain ─────────────────────────────────────────────── */
.grain {
  /* -15% bleed is enough for the ±8% keyframe jitter; anything bigger
     multiplies the composited layer area and tanks Safari */
  position: fixed; inset: -15%;
  pointer-events: none;
  z-index: 200;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(10) infinite;
  will-change: transform;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); } 10% { transform: translate(-3%,-5%); }
  20% { transform: translate(-7%,3%); } 30% { transform: translate(4%,-8%); }
  40% { transform: translate(-3%,8%); } 50% { transform: translate(-8%,2%); }
  60% { transform: translate(6%,0%); } 70% { transform: translate(0%,6%); }
  80% { transform: translate(2%,9%); } 90% { transform: translate(-5%,4%); }
}

/* ── scroll progress line ──────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.5);
  transform: scaleX(0);
  transform-origin: left;
  z-index: 150;
  pointer-events: none;
}

/* ── custom cursor ─────────────────────────────────────── */
.cursor, .cursor-ring {
  position: fixed; top: 0; left: 0;
  pointer-events: none;
  z-index: 300;
  border-radius: 50%;
  will-change: transform;
}
.cursor {
  width: 8px; height: 8px;
  background: var(--accent);
  transform: translate3d(-100px, -100px, 0) translate(-50%, -50%);
}
.cursor-ring {
  width: 36px; height: 36px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  transform: translate3d(-100px, -100px, 0) translate(-50%, -50%);
  transition: width 0.25s var(--ease-out), height 0.25s var(--ease-out),
              border-color 0.25s, background 0.25s;
}
.cursor-ring.is-hover {
  width: 64px; height: 64px;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}
@media (hover: none), (pointer: coarse) {
  .cursor, .cursor-ring { display: none; }
}

/* ── nav ───────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem var(--pad);
  border-bottom: 1px solid transparent;
  transition: background 0.4s, border-color 0.4s, backdrop-filter 0.4s;
}
.nav.is-scrolled {
  background: rgba(10, 10, 11, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-color: var(--line);
}

/* WebKit repaints fixed SVG grain and backdrop-filter layers during pointer
   and scroll updates. Keep the texture, but make both layers static/opaque
   enough that the interaction lane can hold the display refresh rate. */
.is-safari .grain {
  inset: 0;
  animation: none;
  will-change: auto;
}
.is-safari .nav.is-scrolled {
  background: rgba(10, 10, 11, 0.94);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.nav-logo {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.nav-logo-mark { color: var(--ink); }
.nav-logo-tld { color: var(--accent); }
.nav-links { display: flex; gap: 2rem; }
.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-dim);
  transition: color 0.25s;
}
.nav-links a:hover { color: var(--accent); }
.nav-num { color: var(--accent); margin-right: 0.35em; }
.nav-cta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.25s, background 0.25s, color 0.25s;
}
.nav-cta:hover { border-color: var(--accent); background: var(--accent); color: #000; }
@media (max-width: 640px) { .nav-links { display: none; } }

/* ── hero ──────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 7rem var(--pad) 0;
  overflow: hidden;
  contain: paint;
}
#field {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}
.hero-inner { position: relative; z-index: 1; }
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-dim);
  display: flex; align-items: center; gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}
.hero-title {
  font-family: var(--font-title);
  font-size: clamp(3.5rem, 13vw, 11.5rem);
  line-height: 0.92;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  user-select: none;
}
.hero-line { display: block; overflow: hidden; }
.hero-word { display: inline-block; will-change: transform; }
.hero-word .char { display: inline-block; will-change: transform; }
.hero-word-outline {
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
}
/* free-roaming 3d wireframe icosahedron — physics in main.js:
   lazily chases the cursor and bounces off the hero edges */
.hero-glyph {
  position: absolute;
  top: 0; left: 0;
  width: clamp(64px, 7vw, 110px);
  height: clamp(64px, 7vw, 110px);
  z-index: 1;
  pointer-events: none;
  transform: translate3d(62vw, 48svh, 0); /* start / reduced-motion resting spot */
  will-change: transform;
  /* no CSS drop-shadow here: the canvas repaints every frame, and Safari
     re-renders the filter with it. The glow is painted in-canvas instead. */
}
#glyph {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.hero-sub {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 1.5rem;
  margin-top: 2.5rem;
}
.hero-tag {
  max-width: 34ch;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  color: var(--ink-dim);
}
.hero-tag em { color: var(--ink); font-style: normal; border-bottom: 1px solid var(--accent); }
.hero-actions { display: flex; gap: 0.75rem; }
.btn {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.9rem 1.6rem;
  border-radius: 999px;
  transition: transform 0.2s var(--ease-out), background 0.25s, color 0.25s, border-color 0.25s;
  will-change: transform;
  display: inline-block;
}
.btn-solid { background: var(--accent); color: #000; font-weight: 500; }
.btn-solid:hover { filter: brightness(1.12); box-shadow: 0 0 28px rgba(var(--accent-rgb), 0.35); }
.btn-ghost { border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.hero-meta {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 1.5rem 3rem;
  padding: 2rem 0;
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
}
.hero-meta .mono { color: var(--ink-dim); }
.hero-scroll { margin-left: auto; color: var(--accent) !important; animation: nudge 2s infinite; }
@keyframes nudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* ── marquee ───────────────────────────────────────────── */
.marquee {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  padding: 1rem 0;
  background: var(--accent);
  color: #000;
}
.marquee-track {
  display: flex;
  width: max-content;
  will-change: transform;
  /* position driven by main.js — clones spans to cover any viewport
     and wraps modulo one span width, so the strip can never gap */
}
.marquee-track span {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: clamp(0.85rem, 1.9vw, 1.2rem);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ── sections shared ───────────────────────────────────── */
section { padding: clamp(5rem, 12vh, 9rem) var(--pad); }
.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 2rem;
  align-items: start;
  margin-bottom: clamp(3rem, 7vh, 5rem);
}
.section-index { color: var(--accent); padding-top: 0.6em; }
.section-title {
  font-family: var(--font-title);
  font-size: clamp(2.6rem, 7.5vw, 6rem);
  line-height: 0.92;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.outline { color: transparent; -webkit-text-stroke: 1.5px var(--ink); }
.section-note { grid-column: 2; color: var(--ink-dim); }

/* ── work list ─────────────────────────────────────────── */
.work { padding-left: 0; padding-right: 0; }
.work .section-head { padding: 0 var(--pad); }
.work-list { border-top: 1px solid var(--line); }
.project {
  display: block;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.project::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--accent, var(--accent));
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.45s var(--ease-out);
  z-index: 0;
}
.project:hover::before { transform: scaleY(1); transform-origin: top; }
.project-row {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 4ch 1fr auto auto 3rem;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem var(--pad);
  transition: color 0.3s;
}
.project:hover .project-row { color: #000; }
.project:hover .project-tag,
.project:hover .project-desc,
.project:hover .project-index { color: rgba(0,0,0,0.65); }
.project-index { color: var(--ink-dim); }
.project-name {
  font-family: var(--font-title);
  font-size: clamp(1.7rem, 4.5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  line-height: 1;
  transition: transform 0.45s var(--ease-out);
}
.project:hover .project-name { transform: translateX(0.5rem) skewX(-4deg); }
.project-tag { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-dim); }
.project-desc { font-size: 0.9rem; color: var(--ink-dim); max-width: 30ch; text-align: right; }
.project-arrow {
  font-size: 1.6rem;
  justify-self: end;
  transition: transform 0.45s var(--ease-out);
}
.project:hover .project-arrow { transform: translate(4px, -4px) rotate(45deg); }
@media (max-width: 900px) {
  .project-row { grid-template-columns: 4ch 1fr 3rem; grid-template-rows: auto auto; }
  .project-tag { grid-column: 2; }
  .project-desc { display: none; }
  .project-arrow { grid-row: 1 / 3; grid-column: 3; }
}

/* preview bar that chases the cursor over the work list */
.preview-bar {
  position: fixed;
  top: 0; left: 0;
  width: 3px; height: 0;
  background: var(--accent);
  z-index: 50;
  pointer-events: none;
  will-change: transform, height;
}

/* ── services ──────────────────────────────────────────── */
.services { background: var(--bg-2); }
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.service-card {
  background: var(--bg-2);
  padding: clamp(1.75rem, 4vw, 3rem);
  position: relative;
  transition: background 0.35s;
}
.service-card:hover { background: #18181d; }
.service-card::after {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}
.service-card:hover::after { transform: scaleX(1); }
.service-num { color: var(--accent); }
.service-title {
  font-family: var(--font-title);
  font-size: clamp(1.5rem, 3.2vw, 2.4rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 1rem 0 1.25rem;
}
.service-desc { color: var(--ink-dim); max-width: 46ch; margin-bottom: 1.75rem; }
.service-list { list-style: none; }
.service-list li {
  padding: 0.6rem 0;
  border-top: 1px dashed var(--line);
  color: var(--ink-dim);
  transition: color 0.25s, padding-left 0.25s;
}
.service-list li::before { content: "→ "; color: var(--accent); }
.service-card:hover .service-list li { color: var(--ink); }
.service-list li:hover { padding-left: 0.4rem; }
.process {
  margin-top: 3rem;
  display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; align-items: baseline;
}
.process-label { color: var(--accent); }
.process-steps { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: baseline; }
.process-steps i { color: var(--accent); font-style: normal; }
.process-steps span { color: var(--ink-dim); }

/* ── about ─────────────────────────────────────────────── */
.about-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: clamp(2rem, 6vw, 5rem);
}
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }
.about-big {
  font-size: clamp(1.5rem, 3.2vw, 2.4rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 500;
}
.about-facts a { color: var(--accent); border-bottom: 1px solid transparent; transition: border-color 0.25s; }
.about-facts a:hover { border-color: var(--accent); }
.about-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: 2rem;
}
.stat {
  background: var(--bg);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.stat-num {
  font-family: var(--font-title);
  font-size: clamp(1.9rem, 3.8vw, 2.9rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-label { color: var(--ink-dim); }

/* ── contact ───────────────────────────────────────────── */
.contact {
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  text-align: center;
  padding-top: clamp(6rem, 16vh, 11rem);
  padding-bottom: clamp(6rem, 16vh, 11rem);
}
.contact-eyebrow { color: var(--accent); margin-bottom: 1.5rem; }
.contact-title {
  font-family: var(--font-title);
  font-size: clamp(2.8rem, 10vw, 8rem);
  line-height: 0.92;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}
.contact-mail {
  display: inline-block;
  font-size: clamp(1.2rem, 3.5vw, 2.2rem);
  font-weight: 500;
  padding: 1rem 2.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.3s, color 0.3s, border-color 0.3s, transform 0.2s var(--ease-out);
  will-change: transform;
}
.contact-mail:hover {
  background: var(--accent); color: #000; border-color: var(--accent);
  box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.3);
}
.contact-links {
  display: flex; justify-content: center; gap: 2rem;
  margin-top: 3rem;
  color: var(--ink-dim);
}
.contact-links a { transition: color 0.25s; }
.contact-links a:hover { color: var(--accent); }

/* ── footer ────────────────────────────────────────────── */
.footer {
  display: flex; flex-wrap: wrap; gap: 1rem;
  justify-content: space-between;
  padding: 1.5rem var(--pad);
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
}
.footer-time { color: var(--accent); }

/* ── reveal animation ──────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
