/* DPM Affiliates · custom CSS (things Tailwind utilities do not cover).
   Tokens mirror the @theme block in each HTML page. Keep both in sync.
   Rules live in the same cascade layers as Tailwind, so Tailwind utilities
   (hidden, bg-*, text-*...) always win over these base and component styles. */

@layer theme, base, components, utilities;

@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink-950: #131416;
  --ink-900: #1B1D20;
  --ink-800: #2A2D30;
  --ink-700: #3A3E42;
  --ink-600: #4C5156;
  --ink-500: #63676C;
  --ink-400: #9A9EA3;
  --ink-300: #B9BCC0;
  --paper: #F4F3EF;
  --paper-2: #ECEAE4;
  --line: #DDDBD4;
  --accent: #D4FF3F;
  --accent-hover: #E1FF72;
  --accent-ink: #4F6B00;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}

@layer base {
  /* Base (also acts as fallback before Tailwind has compiled) */
  html { background: var(--ink-900); -webkit-text-size-adjust: 100%; }
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink-800);
    font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "ss01" on;
  }
  ::selection { background: var(--accent); color: var(--ink-900); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
}

@layer components {
  .on-light :focus-visible { outline-color: var(--ink-800); }
  .mono { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-feature-settings: "zero" off; }
  .tabular { font-variant-numeric: tabular-nums; }

  /* Grain overlay for dark sections */
  .grain { position: relative; isolation: isolate; }
  .grain::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .07;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }
  .grain-light::after { opacity: .5; mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .16 0 0 0 0 .17 0 0 0 0 .18 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  /* Hero backdrop: faint grid + accent glow */
  .hero-grid {
    background-image:
      linear-gradient(to right, rgb(255 255 255 / .045) 1px, transparent 1px),
      linear-gradient(to bottom, rgb(255 255 255 / .045) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 60% 0%, #000 25%, transparent 75%);
            mask-image: radial-gradient(ellipse 80% 60% at 60% 0%, #000 25%, transparent 75%);
  }
  .hero-glow {
    background:
      radial-gradient(45% 40% at 85% 12%, rgb(212 255 63 / .11), transparent 70%),
      radial-gradient(40% 35% at 10% 100%, rgb(212 255 63 / .05), transparent 70%);
  }

  /* Circuit arcs (echo of the logo symbol) */
  .circuit path { fill: none; stroke: rgb(244 243 239 / .11); stroke-width: 1.5; stroke-linecap: round; }
  .circuit circle { fill: var(--ink-900); stroke: rgb(244 243 239 / .22); stroke-width: 1.5; }
  .circuit circle.lit { stroke: var(--accent); fill: rgb(212 255 63 / .15); }
  .js .circuit path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.4s var(--ease-out) .2s forwards; }
  .js .circuit path:nth-child(2) { animation-delay: .35s; }
  .js .circuit path:nth-child(3) { animation-delay: .5s; }
  .js .circuit path:nth-child(4) { animation-delay: .65s; }
  .js .circuit circle { opacity: 0; animation: fade .6s ease 1.6s forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes fade { to { opacity: 1; } }

  /* Live dot */
  .live-dot { position: relative; width: 7px; height: 7px; border-radius: 999px; background: var(--accent); }
  .live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; background: var(--accent); opacity: .25; animation: pulse 2.4s ease-out infinite; }
  @keyframes pulse { 0% { transform: scale(.6); opacity: .45; } 100% { transform: scale(1.8); opacity: 0; } }

  /* Nav */
  .nav-bg { transition: background-color .3s ease, border-color .3s ease, backdrop-filter .3s ease; border-bottom: 1px solid transparent; }
  [data-scrolled] .nav-bg {
    background: rgb(27 29 32 / .78);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
            backdrop-filter: saturate(140%) blur(14px);
    border-bottom-color: rgb(58 62 66 / .7);
  }
  .nav-link { position: relative; transition: color .2s ease; }
  .nav-link::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease-out); }
  .nav-link:hover::after, .nav-link[aria-current="true"]::after { transform: scaleX(1); }

  /* Buttons */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    height: 48px; padding: 0 1.3rem; border-radius: 999px;
    font-size: 15px; font-weight: 500; letter-spacing: -.005em; white-space: nowrap;
    text-decoration: none; cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .25s ease, color .2s ease, transform .2s ease;
  }
  .btn:active { transform: translateY(1px); }
  .btn-sm { height: 38px; padding: 0 1rem; font-size: 14px; }
  .btn-primary { background: var(--accent); color: var(--ink-900); border: 1px solid var(--accent); }
  .btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 0 5px rgb(212 255 63 / .16); }
  .btn-ghost { background: transparent; color: var(--paper); border: 1px solid var(--ink-700); }
  .btn-ghost:hover { border-color: var(--ink-500); background: rgb(255 255 255 / .04); }
  .btn-ink { background: var(--ink-800); color: var(--paper); border: 1px solid var(--ink-800); }
  .btn-ink:hover { background: var(--ink-900); }
  .btn .arrow { transition: transform .25s var(--ease-out); }
  .btn:hover .arrow { transform: translateX(3px); }
  .btn:hover .arrow-ur { transform: translate(2px, -2px); }

  /* Cards with cursor spotlight */
  .card { position: relative; overflow: hidden; transition: border-color .25s ease, transform .35s var(--ease-out), box-shadow .35s ease; }
  .card::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgb(212 255 63 / .14), transparent 45%);
  }

  /* Test / Validate / Scale ladder */
  .ladder-cell { transition: background-color .5s ease, border-color .5s ease, opacity .5s ease; transition-delay: calc(var(--i, 0) * 70ms + 200ms); }
  .js .ladder .scale-bar { transform: scaleX(.08); transform-origin: left; transition: transform 1.1s var(--ease-out) .9s; }
  .js .ladder[data-in] .scale-bar { transform: none; }
  .js .ladder .ladder-cell.win { background: var(--paper); border-color: var(--line); }
  .js .ladder[data-in] .ladder-cell.win { background: var(--ink-800); border-color: var(--ink-800); }

  /* Process line */
  .js .process-fill { transform: scaleX(0); transform-origin: left; transition: transform 1.6s var(--ease-out) .2s; }
  .js .process-fill-v { transform: scaleY(0); transform-origin: top; transition: transform 1.6s var(--ease-out) .2s; }
  .js .process[data-in] .process-fill, .js .process[data-in] .process-fill-v { transform: none; }
  .process-node { transition: background-color .4s ease, box-shadow .4s ease; transition-delay: calc(var(--i, 0) * 350ms + 300ms); }
  .process-node { background: var(--paper); }

  /* Signal flow (compliance card) */
  .flow-line { position: relative; height: 1px; background: var(--line); overflow: hidden; }
  .flow-line::after { content: ""; position: absolute; top: 0; left: -30%; width: 30%; height: 100%; background: linear-gradient(90deg, transparent, var(--accent-ink), transparent); animation: flow 2.6s linear infinite; }
  @keyframes flow { to { left: 100%; } }

  /* Reveal on scroll */
  .js:not(.reveal-fallback) [data-reveal] {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
    transition: opacity .8s var(--ease-out), transform .8s var(--ease-out);
    transition-delay: calc(var(--i, 0) * 90ms);
  }
  .js:not(.reveal-fallback) [data-reveal][data-in] { opacity: 1; transform: none; }

  /* Form */
  .field-input {
    width: 100%;
    background: var(--ink-900);
    border: 1px solid var(--ink-700);
    border-radius: 12px;
    color: var(--paper);
    font: inherit; font-size: 16px;
    padding: 13px 14px;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
  }
  .field-input::placeholder { color: var(--ink-500); }
  .field-input:hover { border-color: var(--ink-600); }
  .field-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgb(212 255 63 / .14); background: var(--ink-950); }
  .field-input[aria-invalid="true"] { border-color: #FF8A7A; }
  textarea.field-input { resize: vertical; min-height: 140px; }

  /* Legal pages prose */
  .prose-legal h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; margin: 2.5rem 0 .75rem; color: var(--ink-800); }
  .prose-legal h3 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 .5rem; color: var(--ink-800); }
  .prose-legal p, .prose-legal li { color: var(--ink-600); line-height: 1.7; font-size: 15.5px; }
  .prose-legal p + p { margin-top: .9rem; }
  .prose-legal ul { margin: .75rem 0; padding-left: 1.1rem; list-style: disc; }
  .prose-legal li + li { margin-top: .35rem; }
  .prose-legal a { color: var(--ink-800); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-400); }
  .prose-legal a:hover { text-decoration-color: var(--ink-800); }
  .prose-legal table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 14.5px; }
  .prose-legal th, .prose-legal td { text-align: left; vertical-align: top; padding: .7rem .8rem; border-top: 1px solid var(--line); color: var(--ink-600); }
  .prose-legal th { color: var(--ink-800); font-weight: 500; width: 34%; }

  /* Reduced motion: no animation, everything visible */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
    .js [data-reveal] { opacity: 1 !important; transform: none !important; }
    .js .circuit path { stroke-dashoffset: 0; }
    .js .circuit circle { opacity: 1; }
    .live-dot::after, .flow-line::after { display: none; }
  }

  /* Layout container */
  .wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 16px; }
  @media (min-width: 640px) { .wrap { padding-inline: 24px; } }
  @media (min-width: 1024px) { .wrap { padding-inline: 32px; } }

  /* Burger */
  .burger { position: relative; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--ink-700); background: transparent; cursor: pointer; }
  .burger span { position: absolute; left: 12px; right: 12px; height: 1.5px; background: var(--paper); border-radius: 2px; transition: transform .3s var(--ease-out), top .3s var(--ease-out); }
  .burger span:nth-child(1) { top: 16px; }
  .burger span:nth-child(2) { top: 22px; }
  .burger[aria-expanded="true"] span:nth-child(1) { top: 19px; transform: rotate(45deg); }
  .burger[aria-expanded="true"] span:nth-child(2) { top: 19px; transform: rotate(-45deg); }
  [data-menu-open] .nav-bg { background: var(--ink-900); border-bottom-color: var(--ink-700); }

  /* Form status */
  [data-form-status][data-kind="success"] { color: var(--accent); }
  [data-form-status][data-kind="error"] { color: #FF8A7A; }

  /* Image cells in the Biocalma bento */
  .shot img { transition: transform .8s var(--ease-out); }
  @media (hover: hover) { .shot:hover img { transform: scale(1.04); } }
}

/* State rules kept outside the layers on purpose: they must win over the
   Tailwind utilities set on the same elements (border-line, bg-*). */
@media (hover: hover) {
  .card:hover { border-color: var(--ink-300); transform: translateY(-2px); box-shadow: 0 18px 40px -24px rgb(42 45 48 / .35); }
  .card:hover::before { opacity: 1; }
  .card-dark:hover { border-color: var(--ink-600); box-shadow: 0 18px 40px -24px rgb(0 0 0 / .6); }
}
.process[data-in] .process-node { background: var(--accent); box-shadow: 0 0 0 5px rgb(212 255 63 / .25); }
@media (prefers-reduced-motion: reduce) {
  .card:hover { transform: none; }
}
