:root {
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Space Grotesk', sans-serif;

  --color-base: rgb(var(--eg-color-carbon));
  --color-base-light: rgb(var(--eg-color-graphite));
  --color-brand-gold: rgb(var(--eg-color-copper));
  --color-brand-gold-dark: rgb(var(--eg-color-copper-strong));
  --color-brand-blue: rgb(var(--eg-color-ultramarine));
  --color-brand-blue-deep: rgb(var(--eg-color-ultramarine-deep));
  --color-brand-slate: rgb(var(--eg-color-muted));

  /* Legacy aliases (consumed by other pages) */
  --color-brand-primary: rgb(var(--eg-color-copper));
  --color-brand-amber: rgb(var(--eg-color-copper));
  --color-brand-amber-dark: rgb(var(--eg-color-copper-strong));
  /* brand-rose / brand-teal removed — Atelier uses copper + ultramarine only */
  --color-brand-violet: rgb(var(--eg-color-ultramarine));
}

* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
}

/* Sanitized editorial HTML must remain within the article viewport. */
.article-body {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.article-body :where(a, code) {
  overflow-wrap: anywhere;
}

.article-body :where(figure, img) {
  max-width: 100%;
}

.article-body img {
  height: auto;
}

.article-body :where(pre, table) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* Custom scrollbar — noble dark */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-base);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--color-brand-blue) 0%, var(--color-brand-slate) 100%);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--color-brand-gold) 0%, var(--color-brand-blue) 100%);
}

/* ─── Animations ─── */

/* Fade in up */
.fade-in {
  animation: fadeIn 0.8s ease-out both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hover lift (cards) */
.hover-lift {
  transition: all 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3),
    0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* Progressive enhancement: SSR content stays visible when JavaScript is absent. */
html.reveal-ready .reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

html.reveal-ready .reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children delay classes */
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* Legacy decoration hooks kept non-animated for older templates. */
.gradient-shimmer {
  background-size: 100% auto;
}

.glow-border {
  position: relative;
}

/* Pulse ring (for status dots) */
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  70% { transform: scale(2.5); opacity: 0; }
  100% { transform: scale(2.5); opacity: 0; }
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: pulse-ring 2s ease-out infinite;
}

/* Counter number animation helper */
.counter-value {
  font-variant-numeric: tabular-nums;
}

/* Footer compliance row: fixed badge geometry prevents wrap/alignment drift across EN/FR. */
.footer-compliance {
  border-top: 1px solid rgba(var(--eg-color-line), 0.95);
  padding-top: 2rem;
  color: var(--eg-muted);
  font-size: 0.875rem;
}

.footer-compliance-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 0.75rem;
  text-align: center;
}

@media (min-width: 640px) {
  .footer-compliance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .footer-compliance-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.footer-compliance-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 1.5rem;
  padding: 0;
  line-height: 1;
  white-space: nowrap;
}

.footer-compliance-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  min-width: 1.25rem;
  text-align: center;
}

.footer-compliance-flag {
  height: 1rem;
}

.footer-copyright {
  margin-top: 1.25rem;
  text-align: center;
  line-height: 1;
}

/* Particle grid background — DISABLED. Causes visible squares on 4K displays.
   Re-enable only with lower opacity (e.g. 0.01) and smaller grid (40px). */
.bg-grid {
  background-image: none;
}

/* Legacy radial hooks: intentionally restrained under the atelier system. */
.glow-amber {
  background: none;
}

.glow-blue {
  background: none;
}

.glow-rose {
  background: none;
}

.glow-teal {
  background: none;
}

/* AI Portal button glow — noble dark */
.ai-portal-btn {
  animation: ai-glow 3s ease-in-out infinite;
}
@keyframes ai-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(99,102,241,0.2), 0 0 2px rgba(129,140,248,0.15); }
  50%      { box-shadow: 0 0 16px rgba(99,102,241,0.35), 0 0 6px rgba(129,140,248,0.25); }
}

/* HTMX loading indicator */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

/* Trinity chat spinner */
.trinity-spinner {
  animation: trinity-spin 0.8s linear infinite;
}
@keyframes trinity-spin {
  to { transform: rotate(360deg); }
}

/* Trinity phase text transitions */
.trinity-phase.hidden {
  display: none;
}

/* Trinity step dot active state */
.trinity-step-dot.active {
  background-color: rgba(99, 102, 241, 0.5);
}

/* Trinity public chat popup */
#trinity-public-chat-widget {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
}

.trinity-public-chat-dialog {
  position: absolute;
  right: 0;
  bottom: 4rem;
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(70vh, 42rem);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.trinity-public-chat-dialog > #trinity-public-chat-panel {
  max-height: inherit;
  overflow-y: auto;
}
.trinity-public-chat-dialog.hidden {
  display: none;
  opacity: 0;
  transform: translateY(0.75rem);
}

@media (max-width: 639px) {
  #trinity-public-chat-widget {
    right: 1rem;
    bottom: 1rem;
  }

  .trinity-public-chat-dialog {
    position: fixed;
    inset: 4.5rem 1rem 1rem 1rem;
    width: auto;
    max-height: none;
  }
}

/* Hero background film — single continuous scene under copy */
[data-hero-media] {
  isolation: isolate;
}
[data-hero-video] {
  opacity: 1;
}
[data-hero-root] [data-hero-video-toggle]:not([hidden]) {
  cursor: pointer;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ai-portal-btn { animation: none; }
  .trinity-spinner { animation: none; }
  .trinity-public-chat-dialog { transition: none; transform: none; }
  html.reveal-ready .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .fade-in {
    animation: none;
    opacity: 1;
    transform: none;
  }
  /* Poster only — never autoplay motion for reduced-motion users */
  [data-hero-video] {
    display: none !important;
  }
}
