/**
 * Global layout invariants — Phase A safety net + root-cause helpers.
 * Load after tokens.css, before page CSS.
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  overflow-x: clip;
  margin: 0;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}
/* Three.js canvas must keep layout box from absolute fill, not intrinsic height:auto */
.loop-3d canvas {
  max-width: none;
  height: 100%;
}

input,
select,
textarea,
button {
  max-width: 100%;
  font: inherit;
}

.flex > *,
.grid > *,
[class*="grid-cols-"] > *,
[class*="flex"] > * {
  min-width: 0;
}

table {
  width: 100%;
}

.table-wrap,
.to-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.to-container {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

/* Aurora Shard — strict light surface */
.aurora {
  position: relative;
  isolation: isolate;
  overflow-x: clip;
  overflow-y: visible;
  background-color: var(--aurora-base, #ffffff);
  color: var(--aurora-fg, #0f172a);
}
/* Sections that host the free-floating 3D loop must not clip the bleed canvas */
.aurora:has(.loop-3d),
.brand.aurora {
  overflow: visible;
}
.aurora::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(40% 50% at 15% 40%, var(--aurora-glow-blue), transparent 70%),
    radial-gradient(35% 45% at 85% 20%, var(--aurora-glow-teal), transparent 70%),
    radial-gradient(30% 40% at 55% 100%, var(--aurora-glow-violet), transparent 70%);
  filter: blur(20px);
}
.aurora::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -10%;
  bottom: -10%;
  left: 38%;
  width: 42%;
  transform: skewX(-24deg);
  pointer-events: none;
  background: linear-gradient(180deg, var(--aurora-shard-fill), rgba(255, 255, 255, 0) 70%);
  border-inline: 1px solid var(--aurora-shard-border);
}
@media (max-width: 768px) {
  .aurora::before { filter: none; inset: -10%; }
  .aurora::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .aurora::before,
  .aurora::after { animation: none; }
}

.loop-3d--landing {
  width: min(100%, 720px);
  min-width: min(100%, 560px);
  margin-inline: auto;
  aspect-ratio: 16 / 10;
  border: 0;
  background: transparent;
  overflow: visible;
}
@media (max-width: 640px) {
  .loop-3d--landing { aspect-ratio: 1 / 1; min-width: 0; }
}
.loop-3d--auth {
  width: min(100%, 420px);
  aspect-ratio: 16 / 10;
  min-height: 220px;
  height: auto;
  margin-inline: auto;
  flex-shrink: 1;
  border: 0;
  background: transparent;
  overflow: visible;
}
.loop-3d--off {
  display: none !important;
}
@media (max-height: 780px) and (min-width: 961px) {
  .loop-3d--auth { min-height: 206px; }
}

/* Landing root — Aurora Light marketing only */
html.landing,
body.landing,
body.landing-premium {
  background: #F7F9FD;
  color: #0B1220;
  color-scheme: light;
}

/* Light aurora only on marketing pages; auth .brand.aurora keeps dark panel CSS */
html.landing .aurora,
body.landing-premium .aurora {
  background-color: var(--aurora-base, #F7F9FD);
  color: var(--ink, #0B1220);
  overflow: clip;
}
html.landing .aurora::before,
body.landing-premium .aurora::before {
  filter: blur(24px);
  background:
    radial-gradient(40% 50% at 12% 30%, var(--aurora-glow-blue), transparent 70%),
    radial-gradient(35% 45% at 88% 15%, var(--aurora-glow-teal), transparent 70%),
    radial-gradient(30% 40% at 55% 100%, var(--aurora-glow-violet), transparent 70%);
}
html.landing .aurora::after,
body.landing-premium .aurora::after {
  left: 40%;
  width: 40%;
  background: linear-gradient(180deg, var(--aurora-shard-fill), rgba(37, 99, 235, 0) 70%);
  border-inline: 1px solid var(--aurora-shard-border);
}
html.landing .aurora:has(.loop-3d),
body.landing-premium .aurora:has(.loop-3d) {
  overflow: visible;
}

.glass {
  background: var(--surface-glass, rgba(255, 255, 255, 0.82));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), var(--shadow-1);
}

