/* ============================================================
   DKMV TechX — UI/UX enhancement layer
   Loaded AFTER each page's inline <style> so it can refine it.
   Scope: accessibility, contrast, touch targets, motion safety,
          accent-token consistency, responsive fixes, new components.
   ============================================================ */

/* ── 1. TOKENS ─────────────────────────────────────────────── */
:root {
  /* Raised from 0.30 → 0.58. The old value put small mono text at
     roughly 2.4:1 on the dark ground, well under the AA 4.5:1 floor. */
  --tx3: rgba(237,250,247,0.58);
  /* Genuinely decorative hairlines keep the old weight. */
  --tx-faint: rgba(237,250,247,0.28);

  --ring: var(--em);
  --tap:  44px;              /* minimum touch target */

  /* 4/8px spacing rhythm */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-6: 24px; --sp-8: 32px; --sp-12: 48px; --sp-16: 64px;

  /* Motion tokens — one rhythm for the whole site */
  --dur-fast: 150ms;
  --dur-base: 220ms;
  --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in:  cubic-bezier(0.4, 0, 1, 1);

  /* Layered z-index scale — replaces the ad-hoc 5/10/200/9999 values */
  --z-base: 0; --z-raised: 10; --z-nav: 200; --z-scrim: 900;
  --z-drawer: 950; --z-toast: 1000;
}
[data-theme="light"] {
  /* 0.62 measured at 4.45:1 against the light ground — just under AA.
     0.68 clears 4.5:1 on both --bg and the slightly darker --bg2. */
  --tx3: rgba(11,41,34,0.68);
  /* --tx6 carries most of the body copy and had the same problem
     (0.60 -> 4.45:1). Raised for the light theme only; the dark
     theme already passes at 6.89:1 and is left alone. */
  --tx6: rgba(11,41,34,0.68);
  --tx-faint: rgba(11,41,34,0.32);
}

/* ── 2. FOCUS VISIBILITY (WCAG 2.4.7) ──────────────────────── */
/* The base sheet defined no focus styles at all, so keyboard users
   had no indication of position anywhere on the site. */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
  border-radius: 6px;
}
.btn:focus-visible { outline-offset: 4px; }
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute; left: 50%; top: 0;
  transform: translate(-50%, -140%);
  z-index: var(--z-toast);
  padding: 12px 22px;
  background: var(--em); color: #041210;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  border-radius: 0 0 10px 10px;
  transition: transform var(--dur-base) var(--ease-out);
}
.skip-link:focus-visible { transform: translate(-50%, 0); outline-offset: -4px; }

/* Anchor targets must clear the fixed navbar. */
:where(section, footer)[id] { scroll-margin-top: 96px; }

/* ── 3. TOUCH TARGETS (>=44px) ─────────────────────────────── */
.btn { min-height: var(--tap); }
.btn-outline { padding-inline: 20px; }
.nav-links a {
  display: inline-flex; align-items: center;
  min-height: var(--tap); padding-inline: 2px;
}
.footer-links a, .footer-legal a {
  display: inline-flex; align-items: center; min-height: var(--tap);
}
.svc-link { min-height: var(--tap); }
/* Nothing should look tappable without being tappable. */
button:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed;
}

/* ── 4. ACCENT-TOKEN CONSISTENCY ───────────────────────────── */
/* These were hard-coded emerald and stayed green even after the
   accent switched to amber or indigo. */
.btn-primary { box-shadow: 0 0 40px color-mix(in srgb, var(--em) 22%, transparent); }
.btn-primary:hover { box-shadow: 0 4px 60px color-mix(in srgb, var(--em) 40%, transparent); }
.svc-card:hover { box-shadow: 0 24px 64px color-mix(in srgb, var(--em) 10%, transparent); }
.svc-icon {
  background: var(--em-a);
  border-color: color-mix(in srgb, var(--em) 22%, transparent);
}
.svc-card:hover .svc-icon {
  background: color-mix(in srgb, var(--em) 22%, transparent);
  box-shadow: 0 0 20px color-mix(in srgb, var(--em) 24%, transparent);
}
.process-line {
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--em) 34%, transparent) 25%,
    color-mix(in srgb, var(--cy) 34%, transparent) 75%, transparent);
}
.hero-glow {
  background:
    radial-gradient(ellipse 70% 60% at 50% 40%, color-mix(in srgb, var(--em) 7%, transparent) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 60%, color-mix(in srgb, var(--cy) 5%, transparent) 0%, transparent 70%);
}
.contact-glow {
  background: radial-gradient(ellipse 50% 50% at 50% 50%,
    color-mix(in srgb, var(--em) 9%, transparent), transparent 70%);
}
.term-title, .footer-legal-sep { color: var(--tx-faint); }
.scroll-ln { background: linear-gradient(to bottom, var(--em), transparent); }

/* ── 5. HERO: STOP HIDING THE LCP ──────────────────────────── */
/* The base sheet held the headline at opacity:0 until 1.6s and the
   CTA until 2.0s — a deliberate ~2s LCP penalty, and if the animation
   never runs the page reads as blank. Same choreography, compressed. */
.badge        { animation-delay: 0.10s; }
.hero-h1      { animation-delay: 0.18s; }
.hero-p       { animation-delay: 0.30s; }
.hero-actions { animation-delay: 0.42s; }
.hero-scroll  { animation-delay: 0.70s; }
.shape        { animation-duration: 1.4s; }

.hero { min-height: 100vh; min-height: 100svh; }
@supports (height: 100dvh) { .hero { min-height: 100dvh; } }

/* ── 6. REDUCED MOTION (WCAG 2.3.3) ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .badge, .hero-h1, .hero-p, .hero-actions, .hero-scroll, .shape {
    opacity: 1 !important; transform: none !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
  .shapes { display: none; }   /* drifting blobs are pure decoration */
  .tcur { animation: none; opacity: 1; }
}
/* Safety net: if the reveal observer never runs (JS blocked or erroring),
   content must still be readable rather than permanently invisible. */
.no-js .reveal { opacity: 1; transform: none; }

/* ── 7. TYPOGRAPHY & READABILITY ───────────────────────────── */
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.hero-p, .svc-desc, .pstep-desc, .about-text p { text-wrap: pretty; }
.sec-title, .hero-h1 { text-wrap: balance; }
.svc-n, .pstep-num, .footer-copy, .contact-email {
  font-variant-numeric: tabular-nums;   /* stops digit-width jitter */
}
.about-text p { max-width: 62ch; }

/* ── 8. TERMINAL: MOBILE OVERFLOW ──────────────────────────── */
/* Fixed-width mono content used to force the whole page sideways. */
.terminal { max-width: 100%; }
.term-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.term-body > div { white-space: pre; }

/* ── 9. INTERACTION STATES ─────────────────────────────────── */
/* Press feedback inside 100ms, without shifting layout bounds. */
.btn, .svc-card, .pill, .swatch { touch-action: manipulation; }
.btn:active { transform: translateY(0) scale(0.98); transition-duration: var(--dur-fast); }
.svc-link, .nav-links a, .footer-links a { transition: color var(--dur-fast) var(--ease-out); }

/* ── 10. NEW: TRUST BAND ───────────────────────────────────── */
.trust-band { padding: 56px 0; border-block: 1px solid var(--br); background: var(--bg2); }
.trust-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-6); text-align: center;
}
.trust-item { padding: var(--sp-2) var(--sp-4); }
.trust-num {
  font-size: clamp(30px, 4vw, 44px); font-weight: 700;
  letter-spacing: -0.03em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--em), var(--cy));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.trust-label {
  display: block; margin-top: var(--sp-2);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--tx3); text-transform: uppercase;
}

/* ── 11. NEW: FAQ ACCORDION ────────────────────────────────── */
.faq-list { max-width: 780px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid var(--br); }
.faq-q {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: 22px 4px; min-height: var(--tap);
  background: none; border: none; cursor: pointer; text-align: left;
  font-family: var(--sans); font-size: 17px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--tx);
  transition: color var(--dur-fast) var(--ease-out);
}
.faq-q:hover { color: var(--em); }
.faq-icon {
  flex-shrink: 0; width: 20px; height: 20px; color: var(--em);
  transition: transform var(--dur-base) var(--ease-out);
}
.faq-q[aria-expanded="true"] .faq-icon { transform: rotate(45deg); }
.faq-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-slow) var(--ease-out); }
.faq-panel[data-open="true"] { grid-template-rows: 1fr; }
.faq-panel > div { overflow: hidden; }
.faq-a {
  font-size: 15px; font-weight: 300; line-height: 1.75;
  color: var(--tx6); padding: 0 4px 24px; max-width: 68ch;
}

/* ── 12. NEW: CONTACT FORM ─────────────────────────────────── */
.form-card {
  max-width: 560px; margin: 0 auto; text-align: left;
  background: var(--card); border: 1px solid var(--br);
  border-radius: var(--rad); padding: var(--sp-8);
  backdrop-filter: blur(12px);
}
[data-theme="light"] .form-card { box-shadow: 0 2px 24px rgba(0,0,0,0.06); }
.field { margin-bottom: var(--sp-6); }
.field-label {
  display: block; margin-bottom: var(--sp-2);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--tx3); text-transform: uppercase;
}
.field-req { color: var(--cy); margin-left: 4px; }
.field-input, .field-textarea {
  width: 100%; min-height: var(--tap);
  padding: 12px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--br); color: var(--tx);
  font-family: var(--sans); font-size: 16px; /* 16px prevents iOS auto-zoom */
  line-height: 1.5;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
[data-theme="light"] .field-input,
[data-theme="light"] .field-textarea { background: rgba(0,0,0,0.02); }
.field-textarea { resize: vertical; min-height: 120px; }
.field-input::placeholder, .field-textarea::placeholder { color: var(--tx-faint); }
.field-input:hover, .field-textarea:hover { border-color: color-mix(in srgb, var(--em) 30%, transparent); }
.field-input:focus-visible, .field-textarea:focus-visible {
  outline: none; border-color: var(--em);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--em) 22%, transparent);
}
.field-input[aria-invalid="true"], .field-textarea[aria-invalid="true"] { border-color: #f0616e; }
.field-hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--tx3); }
.field-error {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: 6px; font-size: 13px; color: #ff8a94; font-weight: 500;
}
[data-theme="light"] .field-error { color: #c02536; }
.field-error svg { flex-shrink: 0; width: 15px; height: 15px; margin-top: 2px; }
.form-status {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: var(--sp-4); padding: 12px 14px; border-radius: 10px;
  font-size: 14px; line-height: 1.5;
}
.form-status svg { flex-shrink: 0; width: 17px; height: 17px; margin-top: 2px; }
.form-status[data-tone="success"] {
  background: color-mix(in srgb, #22c55e 14%, transparent);
  border: 1px solid color-mix(in srgb, #22c55e 34%, transparent);
  color: #7ae0a0;
}
[data-theme="light"] .form-status[data-tone="success"] { color: #146c39; }
.form-status[data-tone="error"] {
  background: color-mix(in srgb, #ef4444 12%, transparent);
  border: 1px solid color-mix(in srgb, #ef4444 32%, transparent);
  color: #ff8a94;
}
[data-theme="light"] .form-status[data-tone="error"] { color: #b41f2f; }
.form-submit { width: 100%; justify-content: center; }
/* Icons inside buttons inherit the button's own foreground, never the accent. */
.btn-icon { width: 18px; height: 18px; flex-shrink: 0; color: currentColor; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.form-alt {
  margin-top: var(--sp-4); text-align: center;
  font-size: 13px; color: var(--tx3);
}
.form-alt a { color: var(--em); text-decoration: underline; text-underline-offset: 3px; }

/* ── 13. NEW: MOBILE NAV ───────────────────────────────────── */
.nav-toggle {
  display: none;
  width: var(--tap); height: var(--tap);
  margin-left: auto; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--br);
  border-radius: 10px; color: var(--tx); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.nav-toggle:hover { border-color: var(--br-g); background: var(--em-b); }
.nav-toggle svg { width: 20px; height: 20px; }

.nav-scrim {
  position: fixed; inset: 0; z-index: var(--z-scrim);
  background: rgba(2,8,7,0.62);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity var(--dur-base) var(--ease-out);
}
.nav-scrim[data-open="true"] { opacity: 1; }

.nav-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-drawer);
  width: min(84vw, 340px);
  display: flex; flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: var(--bg2);
  border-left: 1px solid var(--br);
  box-shadow: -24px 0 60px rgba(0,0,0,0.4);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  overflow-y: auto; overscroll-behavior: contain;
}
.nav-drawer[data-open="true"] { transform: translateX(0); }
.nav-drawer-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-8); }
.nav-drawer-eyebrow {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.14em; color: var(--tx3);
}
.nav-drawer-close {
  width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--br);
  border-radius: 10px; color: var(--tx); cursor: pointer;
}
.nav-drawer-close svg { width: 18px; height: 18px; }
.nav-drawer-links { display: flex; flex-direction: column; }
.nav-drawer-links a {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: 4px 2px;
  font-size: 18px; font-weight: 500; color: var(--tx);
  border-bottom: 1px solid var(--br);
}
.nav-drawer-links a span { color: var(--tx-faint); font-family: var(--mono); font-size: 11px; }
.nav-drawer-links a[aria-current="page"] { color: var(--em); }
.nav-drawer-cta { margin-top: auto; padding-top: var(--sp-8); }
.nav-drawer-cta .btn { width: 100%; justify-content: center; }
.nav-drawer-meta {
  margin-top: var(--sp-4); text-align: center;
  font-family: var(--mono); font-size: 11px; color: var(--tx3);
}
body[data-nav-open="true"] { overflow: hidden; }

@media (max-width: 600px) {
  .nav-toggle { display: inline-flex; }
  .btn-outline.nav-cta { display: none; }   /* it lives in the drawer instead */
}

/* ── 14. NEW: SCROLL PROGRESS + BACK TO TOP ────────────────── */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: calc(var(--z-nav) + 1);
  background: linear-gradient(90deg, var(--em), var(--cy));
  transform: scaleX(0); transform-origin: 0 50%;
  will-change: transform;
}
.to-top {
  position: fixed; right: 20px; z-index: var(--z-nav);
  bottom: max(20px, env(safe-area-inset-bottom));
  width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  background: var(--card); color: var(--tx);
  border: 1px solid var(--br);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  opacity: 0; transform: translateY(12px) scale(0.9); pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.to-top[data-show="true"] { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--br-g); color: var(--em); }
.to-top svg { width: 18px; height: 18px; }

/* ── 15. RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 960px) {
  .trust-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-8) var(--sp-4); }
}
@media (max-width: 600px) {
  :where(section, footer)[id] { scroll-margin-top: 76px; }
  .form-card { padding: var(--sp-6) var(--sp-4); }
  .faq-q { font-size: 16px; }
  .contact-details { gap: var(--sp-3); flex-direction: column; }
  .footer-row { justify-content: center; text-align: center; }
  .to-top { right: 14px; }
}
/* Landscape phones: 120px section padding eats the whole viewport. */
@media (max-height: 520px) and (orientation: landscape) {
  .hero { min-height: auto; padding: 120px 0 72px; }
  .section { padding: 64px 0; }
}
