/* ============================================================
   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(21, 18, 16, 0.82);
  border-bottom-color: var(--line-2);
  box-shadow: 0 1px 0 0 rgba(200, 117, 85, 0.08), 0 8px 32px -16px rgba(0, 0, 0, 0.6);
}
.site-header.is-scrolled .brand-lockup .mark {
  border-color: rgba(200, 117, 85, 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(200, 117, 85, 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(230, 210, 186, 0.10), 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(200, 117, 85, 0.12), transparent 70%);
  bottom: -120px; left: 40%;
  animation: drift-3 64s ease-in-out infinite alternate;
}
/* Sand-tinted atmospheric blob — gives the warm parchment register
   presence in dark territory without ever flipping a section. */
.atmos .blob.b4 {
  width: 540px; height: 540px;
  background: radial-gradient(circle, rgba(230, 210, 186, 0.10), transparent 70%);
  top: 55%; right: -160px;
  animation: drift-4 70s ease-in-out infinite alternate;
}
@keyframes drift-4 {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-100px, -50px, 0) scale(1.10); }
}
@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) -----
   Softened 13 May 2026 evening: longer ease + smaller y-translate so
   reveals feel like paper sliding into place, not terminal output. */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity .85s cubic-bezier(0.16, 0.84, 0.32, 1),
              transform .85s cubic-bezier(0.16, 0.84, 0.32, 1);
  will-change: opacity, transform;
}
[data-reveal="up"]   { transform: translate3d(0, 16px, 0); }
[data-reveal="fade"] { transform: none; }
[data-reveal].is-in {
  opacity: 1;
  transform: none;
}
[data-reveal][data-delay="1"].is-in { transition-delay: 100ms; }
[data-reveal][data-delay="2"].is-in { transition-delay: 200ms; }
[data-reveal][data-delay="3"].is-in { transition-delay: 300ms; }
[data-reveal][data-delay="4"].is-in { transition-delay: 400ms; }
@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; }

/* Canonical artwork variant — three layers in the 3D stage:
   plate (back), D.AI wordmark (middle), terracotta L-brackets (front).
   The brackets lift forward with translateZ so they read as a
   viewfinder hovering in front of the typeset wordmark. */
.mark3d--canonical .mark3d__plate {
  inset: 0;
  border-radius: 22px;
  background:
    /* faint construction-line grid like the master artwork */
    radial-gradient(circle at 26% 18%, rgba(255,255,255,0.018), transparent 40%),
    linear-gradient(160deg, #1F1A16 0%, #17120F 60%, #110E0C 100%);
  border: 1px solid #2C251F;
  transform: translateZ(-30px);
}
.mark3d--canonical .mark3d__wordmark {
  position: absolute;
  inset: 28% 14%;
  width: 72%;
  height: 44%;
  object-fit: contain;
  transform: translateZ(8px);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45));
}
/* The four terracotta brackets float forward of the wordmark — same
   geometry as the master artwork, but lifted in Z for parallax. */
.mark3d--canonical .mark3d__corners { transform: translateZ(64px); }
.mark3d--canonical .mark3d__corners span {
  width: 22%; height: 22%;
}
.mark3d--canonical .mark3d__corners span::before,
.mark3d--canonical .mark3d__corners span::after {
  background: #d17655;
  border-radius: 2px;
  box-shadow: 0 6px 18px rgba(209, 118, 85, 0.35);
}
.mark3d--canonical .mark3d__corners span::before { height: 4px; }
.mark3d--canonical .mark3d__corners span::after  { width: 4px; }
.mark3d--canonical .mark3d__corners span:nth-child(1) { top: 14%; left: 10%; }
.mark3d--canonical .mark3d__corners span:nth-child(2) { top: 14%; right: 10%; transform: scaleX(-1); }
.mark3d--canonical .mark3d__corners span:nth-child(3) { bottom: 14%; left: 10%; transform: scaleY(-1); }
.mark3d--canonical .mark3d__corners span:nth-child(4) { bottom: 14%; right: 10%; transform: scale(-1, -1); }
.mark3d--canonical .mark3d__glow {
  inset: 8%;
  background:
    radial-gradient(circle at 50% 50%, rgba(209, 118, 85, 0.28), transparent 65%);
  filter: blur(28px);
  transform: translateZ(-40px);
  border-radius: 50%;
}
.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: 8%;
  border-radius: 36px;
  /* Warm dark plate, slightly lifted from the page ink. */
  background: linear-gradient(160deg, #25201B 0%, #1A1612 60%, #14110F 100%);
  border: 1px solid #38302A;
  transform: translateZ(-30px);
  box-shadow:
    0 40px 80px -28px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.04);
}
.mark3d__glow {
  position: absolute;
  inset: 6%;
  border-radius: 40px;
  background:
    radial-gradient(circle at 70% 25%, rgba(200, 117, 85, 0.38), transparent 60%),
    radial-gradient(circle at 25% 80%, rgba(230, 210, 186, 0.10), transparent 60%);
  filter: blur(32px);
  transform: translateZ(-50px);
  opacity: 0.95;
}
/* D.AI lettermark — text-as-mark, layered at depth 40px so it floats
   above the plate. D in canvas, . in clay, AI in sand. Tightened with
   negative margins per the brand pack's dx offsets. */
.mark3d__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateZ(40px);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: clamp(64px, 11vw, 120px);
  letter-spacing: -0.05em;
  line-height: 1;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.5));
  white-space: nowrap;
}
.mark3d__text .d   { color: #F5EFE6; }
.mark3d__text .dot { color: #C87555; margin-left: -0.012em; }
.mark3d__text .ai  { color: #E6D2BA; margin-left: -0.062em; }
/* The small clay dot below the lettermark was removed in the
   fixed-spacing brand pack — the bracket corners + tightened D.AI
   carry the mark on their own. */
/* Clay L-bracket corners — match the brand mark's framing device.
   Each corner is built from two thin clay segments meeting at 90°. */
.mark3d__corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform: translateZ(70px);
}
.mark3d__corners span {
  position: absolute;
  width: 34px; height: 34px;
  pointer-events: none;
}
.mark3d__corners span::before,
.mark3d__corners span::after {
  content: "";
  position: absolute;
  background: #C87555;
  opacity: 0.86;
  border-radius: 2px;
}
.mark3d__corners span::before {
  width: 100%; height: 2px;
  top: 0;
}
.mark3d__corners span::after {
  width: 2px; height: 100%;
  left: 0; top: 0;
}
/* Each corner positions the L bracket facing inward. */
.mark3d__corners span:nth-child(1) { top: 8%; left: 8%; }
.mark3d__corners span:nth-child(2) { top: 8%; right: 8%; transform: scaleX(-1); }
.mark3d__corners span:nth-child(3) { bottom: 8%; left: 8%; transform: scaleY(-1); }
.mark3d__corners span:nth-child(4) { bottom: 8%; right: 8%; transform: scale(-1, -1); }
.mark3d__caption {
  position: absolute;
  bottom: -32px;
  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(--clay); 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(200, 117, 85, 0); }
  40%  { box-shadow: 0 0 0 6px rgba(200, 117, 85, 0.08); }
  100% { box-shadow: 0 0 0 0 rgba(200, 117, 85, 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(30px, 5.6vw, 44px) !important; line-height: 1.08 !important; text-wrap: balance; }
  .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; }
  .atmos .blob.b4 { width: 360px; height: 360px; }

  /* 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(26px, 7.6vw, 36px) !important; line-height: 1.06 !important; text-wrap: balance; }
  .m-hero h1 { font-size: clamp(44px, 14vw, 80px) !important; }
  .cs-hero h1 { font-size: clamp(30px, 10vw, 48px) !important; }
  /* Cap the 3D D.AI mark on small phones so it doesn't dominate. */
  .mark3d { max-width: 240px !important; }
  /* Tighten the header lockup so wordmark + CTA all fit even at 320px. */
  .brand-lockup { gap: 8px !important; }
  .brand-wordmark-type { font-size: 16px !important; letter-spacing: -0.035em !important; }
  .brand-lockup .name { font-size: 15px !important; letter-spacing: -0.03em !important; }
  .brand-lockup .mark { width: 28px !important; height: 28px !important; }
  .site-header .inner { padding: 10px var(--gutter) !important; gap: 12px !important; }
  .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;
  }
}
