/* ==========================================================
   FYDELIA — CORE DESIGN SYSTEM
   Product-led, Linear-style, red-first
   ========================================================== */

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

:root {
  /* Type */
  --sans: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Radii */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Layout */
  --wrap: 1240px;
  --wrap-wide: 1400px;
  --gutter: 28px;

  /* Accents */
  --green: #00D47E;
  --amber: #FFB020;
  --violet: #9A6CFF;
}

:root, body[data-theme="dark"] {
  /* Reds */
  --red: #FF2B2B;
  --red-500: #FF2B2B;
  --red-600: #E91E1E;
  --red-700: #C41010;
  --red-900: #3A0A0A;
  --red-glow: rgba(255, 43, 43, 0.35);
  --red-glow-soft: rgba(255, 43, 43, 0.12);

  /* Surfaces (dark linear-style) */
  --bg: #0A0A0C;
  --bg-1: #0F0F12;
  --bg-2: #141419;
  --bg-3: #1C1C22;
  --bg-4: #25252D;

  /* Lines */
  --line: rgba(255,255,255,0.06);
  --line-2: rgba(255,255,255,0.09);
  --line-strong: rgba(255,255,255,0.14);

  /* Text */
  --fg: #F5F5F7;
  --fg-2: #C8C8CE;
  --fg-3: #8B8B94;
  --fg-4: #5E5E66;
}

body[data-theme="light-disabled"] {
  /* Reds */
  --red: #FF2B2B;
  --red-500: #FF2B2B;
  --red-600: #E91E1E;
  --red-700: #C41010;
  --red-900: #3A0A0A;
  --red-glow: rgba(255, 43, 43, 0.35);
  --red-glow-soft: rgba(255, 43, 43, 0.12);

  /* Surfaces (dark linear-style) */
  --bg: #0A0A0C;
  --bg-1: #0F0F12;
  --bg-2: #141419;
  --bg-3: #1C1C22;
  --bg-4: #25252D;

  /* Lines */
  --line: rgba(255,255,255,0.06);
  --line-2: rgba(255,255,255,0.09);
  --line-strong: rgba(255,255,255,0.14);

  /* Text */
  --fg: #F5F5F7;
  --fg-2: #C8C8CE;
  --fg-3: #8B8B94;
  --fg-4: #5E5E66;
}

html {
  scroll-behavior: smooth;
  /* Prevent horizontal scroll/overflow at the viewport level. Only overflow on
     the root element propagates to the viewport, so this is what actually stops
     the page scrolling sideways on mobile. `clip` (not `hidden`) is used so the
     sticky nav keeps working. */
  overflow-x: clip;
  max-width: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  max-width: 100%;
  font-feature-settings: "ss01", "cv11";
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

/* body[data-theme="light-disabled"] .grain { mix-blend-mode: multiply; opacity: 0.04; } */

body[data-density="compact"] .section { padding: 80px 0; }

::selection { background: var(--red); color: white; }

/* Grain overlay */
.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
body[data-grain="off"] .grain { display: none; }

/* Media should never force the page wider than the viewport. */
img, video, iframe, svg, canvas {
  max-width: 100%;
}

/* ---------- Layout ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-wide { max-width: var(--wrap-wide); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: 120px 0; position: relative; }
.section--tight { padding: 80px 0; }

/* ---------- Type utilities ---------- */
.mono { font-family: var(--mono); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 7px 14px 7px 11px;
  background: rgba(255, 43, 43, 0.08);
  border: 1px solid rgba(255, 43, 43, 0.22);
  border-radius: 100px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--red);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.eyebrow-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
  animation: pulse-red 2s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.8); }
}

.kicker {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-3);
}

/* Headings */
h1, h2, h3, h4 { font-family: var(--sans); font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; color: var(--fg); }
h1 { font-size: clamp(40px, 5.6vw, 82px); font-weight: 500; letter-spacing: -0.035em; }
h2 { font-size: clamp(32px, 3.8vw, 56px); font-weight: 500; letter-spacing: -0.03em; line-height: 1.08; }
h3 { font-size: clamp(22px, 2.2vw, 30px); font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
h4 { font-size: 18px; font-weight: 600; }

p { color: var(--fg-2); font-size: 16.5px; line-height: 1.65; }
.lead { font-size: clamp(17px, 1.3vw, 20px); color: var(--fg-2); line-height: 1.55; max-width: 640px; }

em { font-style: italic; color: var(--red); font-weight: 500; }

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

/* ---------- Buttons ---------- */
.btn-solid, .btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-solid {
  background: var(--red);
  color: white;
  border-color: var(--red-600);
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 8px 24px -6px var(--red-glow), 0 0 0 1px rgba(255,255,255,0.04);
}
.btn-solid:hover {
  background: #ff4040;
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 12px 32px -6px var(--red-glow), 0 0 0 1px rgba(255,255,255,0.08);
}
.btn-solid:active { transform: translateY(0); }
.btn-solid svg { width: 14px; height: 14px; }

.btn-ghost {
  color: var(--fg-2);
  background: transparent;
}
.btn-ghost:hover { color: var(--fg); background: var(--bg-2); }

.btn-lg { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn-xl { padding: 16px 26px; font-size: 16px; border-radius: 14px; }

/* ---------- NAV ---------- */
nav#nav {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  background: var(--nav-bg, rgba(10,10,12,0.7));
  border-bottom: 1px solid var(--line);
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}
/* body[data-theme="light-disabled"] nav#nav { --nav-bg: rgba(250,250,247,0.75); } */

/* Nav over a light-band section — flip to light mode */
nav#nav.nav--over-light {
  --nav-bg: rgba(255, 255, 255, 0.93);
  border-bottom-color: rgba(10, 10, 12, 0.09);
}
nav#nav.nav--over-light .nav-links a {
  color: rgba(10, 10, 12, 0.65);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
nav#nav.nav--over-light .nav-links a:hover {
  color: #0A0A0C;
  background: rgba(10, 10, 12, 0.05);
}
nav#nav.nav--over-light .btn-ghost {
  color: #2A2A30;
}
nav#nav.nav--over-light .btn-ghost:hover {
  background: rgba(10, 10, 12, 0.06);
  color: #0A0A0C;
}
nav#nav.nav--over-light .menu-toggle-label { color: #0A0A0C; }
nav#nav.nav--over-light .menu-toggle-icon span { background-color: #0A0A0C; }

/* Theme switch in nav */
.theme-switch {
  display: none !important;
}
.theme-switch:hover { border-color: var(--line-strong); }
.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line-2);
  transition: transform 0.35s var(--ease), background 0.3s var(--ease);
  display: grid; place-items: center;
  overflow: hidden;
}
body[data-theme="light-disabled"] .theme-switch-thumb { transform: translateX(24px); background: white; }
.theme-switch-thumb svg {
  width: 12px; height: 12px;
  color: var(--fg-2);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  position: absolute;
}
.theme-switch-thumb .ts-moon { opacity: 1; }
.theme-switch-thumb .ts-sun { opacity: 0; transform: scale(0.5) rotate(-90deg); color: var(--red); }
body[data-theme="light-disabled"] .theme-switch-thumb .ts-moon { opacity: 0; transform: scale(0.5) rotate(90deg); }
body[data-theme="light-disabled"] .theme-switch-thumb .ts-sun { opacity: 1; transform: scale(1) rotate(0); }
.nav-inner {
  max-width: var(--wrap-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
  height: 72px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  flex-shrink: 0;
  font-family: var(--sans); font-weight: 600; font-size: 20px; letter-spacing: -0.04em;
  color: var(--fg);
}
.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}
nav#nav .brand-logo {
  height: 34px;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
  flex-wrap: nowrap;
}
.nav-links li { flex-shrink: 0; }
.nav-links a {
  padding: 8px 14px;
  font-size: 16px;
  color: var(--fg-3);
  border-radius: 8px;
  transition: all 0.2s var(--ease);
  font-weight: 500;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--fg); background: var(--bg-2); }

.nav-cta { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.nav-cta .btn-ghost,
.nav-cta .btn-solid {
  font-size: 15px;
  padding: 10px 16px;
  white-space: nowrap;
}

/* ---------- Mobile menu toggle (hidden on desktop) ---------- */
.menu-toggle { display: none; }

@media (max-width: 1040px) {
  .nav-links { display: none; }
  .nav-cta   { display: none; }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 2px;
    -webkit-tap-highlight-color: transparent;
  }
  .menu-toggle-label {
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 500;
    color: var(--fg-2);
    transition: color 0.2s var(--ease);
  }
  .menu-toggle:hover .menu-toggle-label { color: var(--fg); }
  .menu-toggle-icon {
    width: 20px;
    height: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
  }
  .menu-toggle-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--fg-2);
    border-radius: 2px;
    transition: all 0.35s var(--ease);
  }
  .menu-toggle:hover .menu-toggle-icon span { background: var(--fg); }

  /* Animate burger → X when open */
  .menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(2) {
    opacity: 0; transform: scaleX(0);
  }
  .menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

/* ---------- Menu backdrop (blur overlay) ---------- */
.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease), visibility 0.4s;
}
/* body[data-theme="light-disabled"] .menu-backdrop {
  background: rgba(250, 250, 247, 0.5);
} */
.menu-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* ---------- Menu drawer (slides from right) ---------- */
.menu-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 85vw);
  z-index: 999;
  background: var(--bg-1);
  border-left: 1px solid var(--line-2);
  box-shadow: -20px 0 60px -20px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.45s var(--ease-out), visibility 0.45s;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.menu-drawer.active {
  transform: translateX(0);
  visibility: visible;
}

.menu-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.menu-drawer-title {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.menu-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  padding: 0;
}
.menu-close svg { width: 18px; height: 18px; color: var(--fg-2); }
.menu-close:hover { background: var(--bg-4); border-color: var(--line-strong); }
.menu-close:hover svg { color: var(--fg); }

.menu-drawer-nav {
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 2px;
  flex: 1;
}
.menu-drawer-nav a {
  display: block;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg-2);
  border-radius: var(--r-sm);
  transition: all 0.2s var(--ease);
}
.menu-drawer-nav a:hover {
  color: var(--fg);
  background: var(--bg-2);
}

.menu-drawer-foot {
  padding: 20px 24px 28px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.menu-drawer-theme {
  display: none !important;
}
.menu-drawer-theme-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-3);
}
.menu-drawer-signin {
  text-align: center;
  justify-content: center;
  border: 1px solid var(--line-2);
}
.menu-drawer-cta {
  text-align: center;
  justify-content: center;
}

/* Lock body scroll when menu is open */
body.menu-open { overflow: hidden; }

/* ---------- Global decorative grid ---------- */
.bg-grid {
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
}

/* ---------- Tweaks panel ---------- */
.tweaks-panel {
  position: fixed; right: 22px; bottom: 22px;
  width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.03);
  z-index: 999;
  overflow: hidden;
  transform: translateY(8px);
  opacity: 0;
  transition: all 0.3s var(--ease);
}
.tweaks-panel:not(.hidden) { opacity: 1; transform: translateY(0); }
.tweaks-panel.hidden { pointer-events: none; }

.tp-head {
  padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--bg-3);
}
.tp-title { font-weight: 600; font-size: 14px; }
.tp-hint { font-family: var(--mono); font-size: 10.5px; color: var(--fg-4); text-transform: uppercase; letter-spacing: 0.1em; }

.tp-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.tp-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tp-label {
  font-family: var(--mono); font-size: 11px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.tp-swatches { display: flex; gap: 6px; }
.tp-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--s); border: 2px solid transparent;
  cursor: pointer; padding: 0;
  transition: all 0.2s var(--ease);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.tp-swatch:hover { transform: scale(1.1); }
.tp-swatch.active { border-color: var(--fg); }
.tp-toggle {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  padding: 4px 10px; border-radius: 6px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  color: var(--fg-2); cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.08em;
  transition: all 0.2s var(--ease);
}
.tp-toggle.active { background: var(--red); color: white; border-color: var(--red); }

.tp-seg { display: inline-flex; background: var(--bg-3); border-radius: 8px; padding: 2px; gap: 2px; border: 1px solid var(--line); }
.tp-seg button {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  padding: 4px 9px; border-radius: 6px;
  background: transparent; border: none;
  color: var(--fg-3); cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.tp-seg button.active { background: var(--bg-4); color: var(--fg); }

/* ---------- Reveals ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}
.reveal.reveal-left {
  transform: translateX(calc(-1 * var(--reveal-x, 72px)));
}
.reveal.reveal-right {
  transform: translateX(var(--reveal-x, 72px));
}
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: 0.08s; }
.reveal.d2 { transition-delay: 0.16s; }
.reveal.d3 { transition-delay: 0.24s; }
.reveal.d4 { transition-delay: 0.32s; }

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal.reveal-left,
  .reveal.reveal-right { opacity: 1; transform: none; transition: none; }
}

/* ---------- Hide Case Studies ---------- */
a[href*="case-studies"],
li:has(> a[href*="case-studies"]) {
  display: none !important;
}

/* YouTube click-to-load facade (blog .art-video) */
.art-video .yt-facade {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  cursor: pointer;
  background: var(--bg-2, #1a1a1a);
}

.art-video .yt-facade img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.art-video .yt-facade-play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68px;
  height: 48px;
  margin: -24px 0 0 -34px;
  border-radius: 12px;
  background: rgba(255, 43, 43, 0.92);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.art-video .yt-facade-play::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -10px 0 0 -5px;
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent #fff;
}

.art-video iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}
