/* ============================================================
   DomanskiAI — v2 motion + atmospheric + mobile refinement
   Loaded after site.css. Additive only — no overrides of v1 tokens.
   ============================================================ */

/* ----- TYPOGRAPHY: variable font + optical sizing ----- */
html, body {
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 16;
  -webkit-text-size-adjust: 100%;
}

/* display headlines pick up larger optical size and tighter tracking */
h1 {
  font-variation-settings: "opsz" 32;
  letter-spacing: -0.038em;
}
h2 {
  font-variation-settings: "opsz" 28;
  letter-spacing: -0.03em;
}
h3 {
  font-variation-settings: "opsz" 22;
}

/* ----- SKIP LINK (a11y) ----- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 999;
  padding: 12px 18px;
  background: var(--green);
  color: var(--charcoal);
  font-weight: 700;
  font-size: 14px;
  border-radius: 8px;
  transition: top .15s ease;
}
.skip-link:focus-visible {
  top: 12px;
  outline: 2px solid var(--offwhite);
  outline-offset: 2px;
}

/* ----- SMOOTH SCROLL (native, gated on reduced motion) ----- */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ----- HEADER scroll state ----- */
.site-header {
  transition: background .25s ease, border-color .25s ease, box-shadow .35s ease;
}
.site-header.is-scrolled {
  background: rgba(11, 14, 18, 0.82);
  border-bottom-color: var(--line-2);
  box-shadow: 0 1px 0 0 rgba(182, 255, 0, 0.08), 0 8px 32px -16px rgba(0, 0, 0, 0.6);
}
.site-header.is-scrolled .brand-lockup .mark {
  border-color: rgba(182, 255, 0, 0.35);
}

/* ----- ATMOSPHERIC GRADIENT BLOBS ----- */
.atmos {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}
.atmos .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.6;
  will-change: transform;
}
.atmos .blob.b1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(182, 255, 0, 0.22), transparent 70%);
  top: -120px; right: -80px;
  animation: drift-1 42s ease-in-out infinite alternate;
}
.atmos .blob.b2 {
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(102, 112, 133, 0.18), transparent 70%);
  top: 30%; left: -180px;
  animation: drift-2 56s ease-in-out infinite alternate;
}
.atmos .blob.b3 {
  width: 460px; height: 460px;
  background: radial-gradient(circle, rgba(182, 255, 0, 0.10), transparent 70%);
  bottom: -120px; left: 40%;
  animation: drift-3 64s ease-in-out infinite alternate;
}
@keyframes drift-1 {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-80px, 60px, 0) scale(1.12); }
}
@keyframes drift-2 {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(120px, -40px, 0) scale(0.92); }
}
@keyframes drift-3 {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-60px, -80px, 0) scale(1.18); }
}
@media (prefers-reduced-motion: reduce) {
  .atmos .blob { animation: none; }
}

/* ----- REVEAL-ON-SCROLL (richer than v1) ----- */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  transition: opacity .55s cubic-bezier(0.22, 1, 0.36, 1),
              transform .55s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
[data-reveal="up"]   { transform: translate3d(0, 24px, 0); }
[data-reveal="fade"] { transform: none; }
[data-reveal].is-in {
  opacity: 1;
  transform: none;
}
[data-reveal][data-delay="1"].is-in { transition-delay: 60ms; }
[data-reveal][data-delay="2"].is-in { transition-delay: 120ms; }
[data-reveal][data-delay="3"].is-in { transition-delay: 180ms; }
[data-reveal][data-delay="4"].is-in { transition-delay: 240ms; }
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ----- MAGNETIC CTA (subtle pull, applied via JS to .btn-primary) ----- */
.btn-primary.magnetic {
  position: relative;
  transition: transform .2s cubic-bezier(0.22, 1, 0.36, 1),
              background .15s,
              border-color .15s,
              box-shadow .25s;
}
@media (prefers-reduced-motion: reduce) {
  .btn-primary.magnetic { transition: background .15s, border-color .15s; }
}

/* ----- 3D D-MARK (hero centerpiece) ----- */
.mark3d {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --idle-x: 0deg;
  --idle-y: 0deg;
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  margin-inline: auto;
  perspective: 1100px;
  perspective-origin: 50% 50%;
  cursor: grab;
}
.mark3d:active { cursor: grabbing; }
.mark3d__stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(calc(var(--tilt-y) + var(--idle-y))) rotateY(calc(var(--tilt-x) + var(--idle-x)));
  transition: transform .12s linear;
}
.mark3d__plate {
  position: absolute;
  inset: 12%;
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(34, 40, 48, 0.85), rgba(11, 14, 18, 0.95));
  border: 1px solid var(--line-2);
  transform: translateZ(-30px);
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.04);
}
.mark3d__glow {
  position: absolute;
  inset: 8%;
  border-radius: 30px;
  background: radial-gradient(circle at 60% 30%, rgba(182, 255, 0, 0.32), transparent 60%);
  filter: blur(28px);
  transform: translateZ(-50px);
  opacity: 0.85;
}
.mark3d__d, .mark3d__slash, .mark3d__grid {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.mark3d__grid {
  transform: translateZ(4px);
  opacity: 0.4;
}
.mark3d__grid svg { width: 78%; height: 78%; }
.mark3d__d {
  transform: translateZ(28px);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
}
.mark3d__d svg { width: 72%; height: 72%; }
.mark3d__slash {
  transform: translateZ(56px);
  filter: drop-shadow(0 10px 22px rgba(182, 255, 0, 0.4));
}
.mark3d__slash svg { width: 72%; height: 72%; }
.mark3d__corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform: translateZ(70px);
}
.mark3d__corners span {
  position: absolute;
  width: 22px; height: 22px;
  border: 1.5px solid var(--green);
  opacity: 0.7;
}
.mark3d__corners span:nth-child(1) { top: 6%; left: 6%; border-right: 0; border-bottom: 0; }
.mark3d__corners span:nth-child(2) { top: 6%; right: 6%; border-left: 0; border-bottom: 0; }
.mark3d__corners span:nth-child(3) { bottom: 6%; left: 6%; border-right: 0; border-top: 0; }
.mark3d__corners span:nth-child(4) { bottom: 6%; right: 6%; border-left: 0; border-top: 0; }
.mark3d__caption {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--slate);
  white-space: nowrap;
}
.mark3d__caption b { color: var(--green); font-weight: 600; }

/* idle drift when cursor isn't hovering */
@keyframes mark-idle {
  0%   { --idle-x: -3deg; --idle-y: 2deg; }
  50%  { --idle-x: 4deg;  --idle-y: -3deg; }
  100% { --idle-x: -3deg; --idle-y: 2deg; }
}
@property --idle-x { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@property --idle-y { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.mark3d.is-idle .mark3d__stage {
  animation: mark-idle 14s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .mark3d__stage { transform: none; transition: none; animation: none !important; }
}

/* ----- HERO LAYOUT REFINEMENT (when a 3D mark sits in the right column) ----- */
.hero-grid.has-3d {
  align-items: center;
  gap: 56px;
}
.hero-side {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ----- LAYER STACK reveal accent ----- */
.layer.is-in {
  animation: layer-pop .6s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes layer-pop {
  0%   { box-shadow: 0 0 0 0 rgba(182, 255, 0, 0); }
  40%  { box-shadow: 0 0 0 6px rgba(182, 255, 0, 0.08); }
  100% { box-shadow: 0 0 0 0 rgba(182, 255, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .layer.is-in { animation: none; }
}

/* ============================================================
   MOBILE BREAKPOINTS — finer than v1 (which jumped at 880px)
   ============================================================ */

/* tablet portrait & below */
@media (max-width: 1024px) {
  :root { --gutter: 28px; }
  section { padding: 80px 0; }
}

/* large mobile / small tablet */
@media (max-width: 768px) {
  :root { --gutter: 22px; }
  section { padding: 64px 0; }

  h1 { font-size: clamp(40px, 9vw, 64px); letter-spacing: -0.032em; }
  h2 { font-size: clamp(28px, 6vw, 44px); }
  h3 { font-size: clamp(20px, 4.4vw, 26px); }
  p.lede { font-size: clamp(15px, 4vw, 18px); }

  .hero { padding: 32px 0 56px !important; }
  .hero-h1 { font-size: clamp(40px, 11vw, 72px) !important; }
  .m-hero h1 { font-size: clamp(48px, 12vw, 96px) !important; }
  .cs-hero h1 { font-size: clamp(36px, 9vw, 60px) !important; }
  .m-hero { padding: 32px 0 56px !important; }
  .cs-hero { padding: 32px 0 40px !important; }

  /* tap targets ≥48px */
  .btn { min-height: 48px; padding: 14px 22px; }
  .btn-sm { min-height: 44px; padding: 11px 16px; font-size: 13px; }
  .nav-link { min-height: 44px; display: inline-flex; align-items: center; }

  /* drop the coordinate decorations on small screens */
  .coord { display: none; }

  /* atmospheric blobs scale down to keep paint cheap */
  .atmos .blob { filter: blur(80px); }
  .atmos .blob.b1 { width: 340px; height: 340px; }
  .atmos .blob.b2 { width: 380px; height: 380px; }
  .atmos .blob.b3 { width: 320px; height: 320px; }

  /* layered grids collapse */
  .hero-grid,
  .hero-grid.has-3d { grid-template-columns: 1fr !important; gap: 32px !important; }
  .wedge { grid-template-columns: 1fr !important; }
  .wedge-col.right { border-left: 0 !important; border-top: 1px solid var(--green) !important; }
  .wedge-col.right::before { display: none; }
  .shapes { grid-template-columns: 1fr !important; }
  .proof-grid { grid-template-columns: 1fr !important; }
  .about-grid { grid-template-columns: 1fr !important; gap: 28px !important; }
  .pipeline { grid-template-columns: 1fr 1fr !important; }

  /* methodology + case-study sticky markers collapse */
  .thesis-grid,
  .sb { grid-template-columns: 1fr !important; gap: 24px !important; }
  .thesis-grid .marker,
  .sb .marker { position: static !important; top: auto !important; }

  /* about headshot caps */
  .headshot { max-width: 320px; }

  /* econ + worked example */
  .econ, .we-grid { grid-template-columns: 1fr !important; }
  .replaced { grid-template-columns: repeat(2, 1fr) !important; }

  /* TOC on methodology */
  .m-hero .toc { grid-template-columns: 1fr 1fr !important; }
  .m-hero .toc a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

  /* case-study meta */
  .cs-meta { grid-template-columns: 1fr 1fr !important; }
  .cs-meta .cell { border-right: 0 !important; border-bottom: 1px solid var(--line-2); }
  .nums { grid-template-columns: 1fr !important; }
  .placeholder-banner { grid-template-columns: 1fr !important; }
  .hero-image { height: 240px !important; }

  /* final CTA tightening */
  .final { padding: 36px 22px !important; }

  /* footer */
  .site-footer .grid { grid-template-columns: 1fr !important; gap: 28px !important; }

  /* layer detail (methodology) condense */
  .layer-detail { padding: 22px !important; }
  .layer-detail .top { grid-template-columns: 56px 1fr !important; gap: 16px !important; padding-bottom: 18px !important; }
  .layer-detail .top .badge { grid-column: 1 / -1 !important; justify-self: start !important; }
  .layer-detail .top .num { font-size: 40px !important; }
  .layer-detail .top h3 { font-size: 26px !important; }

  /* layer stack on home */
  .layer { grid-template-columns: 50px 1fr !important; padding: 18px 20px !important; }
  .layer .bars { display: none !important; }
  .layer .body h3 { font-size: 18px !important; }

  /* spec sheet */
  .spec-sheet { padding: 20px !important; }
  .spec-row { grid-template-columns: 100px 1fr !important; padding: 9px 0 !important; }

  /* nav: hide methodology + case-studies text, keep CTA — already in v1 at 860px; refine */
  .site-header .nav-link:not(.btn) { display: none; }
  .nav { gap: 6px; }

  /* hero CTA stack vertical and full-width */
  .hero-cta { flex-direction: column; align-items: stretch; }
  .hero-cta .btn { justify-content: center; width: 100%; }

  /* eyebrow becomes more compact */
  .eyebrow { font-size: 10px; letter-spacing: 0.18em; }
}

/* phone portrait */
@media (max-width: 480px) {
  :root { --gutter: 18px; }
  section { padding: 56px 0; }
  .hero-h1 { font-size: clamp(36px, 13vw, 56px) !important; line-height: 1.02 !important; }
  .m-hero h1 { font-size: clamp(44px, 14vw, 80px) !important; }
  .cs-hero h1 { font-size: clamp(30px, 10vw, 48px) !important; }
  .brand-lockup .name { font-size: 16px; }
  .brand-lockup .mark { width: 32px; height: 32px; }
  .site-header .inner { padding: 12px var(--gutter); }
  .btn-sm { padding: 10px 12px; font-size: 12px; }
  .final { padding: 32px 18px !important; }
  .proof-main { padding: 24px !important; }
  .proof-main .name { font-size: 30px !important; gap: 8px !important; }
  .pipeline { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .pipe-chip { font-size: 10px !important; padding: 8px 6px !important; }
  .spec-row { grid-template-columns: 86px 1fr !important; }
  .spec-row .k { font-size: 10px !important; }
  .spec-row .v { font-size: 12px !important; }
  .stack-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stack-footer .dim { font-size: 11px; }
  .copy { flex-direction: column !important; gap: 8px !important; align-items: flex-start !important; }
}

/* iOS dynamic viewport — prevent rubber-band cutoff on full-screen sections */
@supports (height: 100dvh) {
  .hero-tall { min-height: 100dvh; }
}

/* respect reduced motion globally for any leftover transitions */
@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;
  }
}
