/* ==========================================================================
   AB Digital — Global Design System (V2.2, Milestone 01)
   --------------------------------------------------------------------------
   Additive foundation only. Not loaded by any page yet.

   SCOPING
   - Tokens are declared on `.ab-ds` (not :root), so nothing applies until a
     page opts in by adding class="ab-ds" to its outer wrapper. The admin and
     client portal never receive this class, so they are unaffected even if
     this file is loaded site-wide later.
   - Every component class is prefixed `ab-` and only matches inside `.ab-ds`.
   - No element selectors (body, a, button, h1…) are styled. No resets.

   ACCESSIBILITY
   - Text colours on cream meet WCAG AA at the sizes noted.
   - Visible :focus-visible ring on all interactive components.
   - prefers-reduced-motion collapses all durations and movement.
   - Hover effects only apply on devices that actually hover.
   ========================================================================== */

.ab-ds {
  /* ---- Colour: surfaces ---- */
  --ab-cream: #fdfbf8;
  --ab-cream-2: #f6f1ea;
  --ab-cream-3: #f0e9df;
  --ab-white: #ffffff;

  /* ---- Colour: ink / text ---- */
  --ab-ink: #241f1a;
  --ab-ink-2: #3a342d;
  --ab-ink-3: #1e1a16;
  --ab-mute: #5c5348;
  --ab-mute-2: #8a8074;
  --ab-on-dark: #f6f1ea;
  --ab-on-dark-mute: #b8afa3;

  /* ---- Colour: lines ---- */
  --ab-line: #e7dfd5;
  --ab-line-2: #d8d0c4;
  --ab-line-dark: rgba(246, 241, 234, 0.12);

  /* ---- Colour: brand ---- */
  --ab-orange: #e4572e;
  --ab-orange-dark: #c2451e;
  --ab-coral: #ff8a5c;
  --ab-peach: #ffb59a;
  --ab-orange-tint: #fce6dd;
  --ab-orange-ring: rgba(228, 87, 46, 0.35);

  /* ---- Typography (Inter) ---- */
  --ab-font:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif;
  --ab-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ab-fs-12: 12px;
  --ab-fs-13: 13px;
  --ab-fs-14: 14px;
  --ab-fs-15: 15px;
  --ab-fs-16: 16px;
  --ab-fs-18: 18px;
  --ab-fs-20: 20px;
  --ab-fs-24: 24px;
  --ab-fs-h3: clamp(20px, 2.2vw, 26px);
  --ab-fs-h2: clamp(28px, 4vw, 44px);
  --ab-fs-h1: clamp(36px, 6vw, 68px);
  --ab-lh-tight: 1.08;
  --ab-lh-snug: 1.25;
  --ab-lh-body: 1.6;
  --ab-track-display: -0.025em;
  --ab-track-eyebrow: 0.12em;

  /* ---- Spacing ---- */
  --ab-sp-1: 4px;
  --ab-sp-2: 8px;
  --ab-sp-3: 12px;
  --ab-sp-4: 16px;
  --ab-sp-5: 24px;
  --ab-sp-6: 32px;
  --ab-sp-7: 48px;
  --ab-sp-8: 64px;
  --ab-sp-9: 96px;
  --ab-sp-10: 128px;
  --ab-section-y: var(--ab-sp-9);
  --ab-gutter: clamp(20px, 5vw, 40px);
  --ab-container: 1200px;

  /* ---- Radius ---- */
  --ab-r-xs: 6px;
  --ab-r-sm: 10px;
  --ab-r-md: 14px;
  --ab-r-lg: 20px;
  --ab-r-xl: 28px;
  --ab-r-pill: 999px;

  /* ---- Elevation (warm-tinted) ---- */
  --ab-sh-1: 0 1px 2px rgba(36, 31, 26, 0.06), 0 2px 6px rgba(36, 31, 26, 0.04);
  --ab-sh-2:
    0 4px 12px rgba(36, 31, 26, 0.07), 0 12px 28px -12px rgba(36, 31, 26, 0.12);
  --ab-sh-3:
    0 10px 30px -10px rgba(36, 31, 26, 0.18),
    0 24px 48px -24px rgba(36, 31, 26, 0.16);
  --ab-sh-glow: 0 14px 34px -12px rgba(228, 87, 46, 0.45);

  /* ---- Motion ---- */
  --ab-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ab-ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --ab-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ab-dur-1: 0.15s;
  --ab-dur-2: 0.25s;
  --ab-dur-3: 0.45s;
  --ab-dur-4: 0.65s;
  --ab-stagger: 70ms;
  --ab-reveal-y: 18px;
  --ab-lift: -4px;

  /* ---- Focus ---- */
  --ab-focus: 0 0 0 3px var(--ab-cream), 0 0 0 5px var(--ab-orange);
}

@media (max-width: 640px) {
  .ab-ds {
    --ab-section-y: var(--ab-sp-8);
    --ab-reveal-y: 10px;
    --ab-lift: -2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ab-ds {
    --ab-dur-1: 0.01ms;
    --ab-dur-2: 0.01ms;
    --ab-dur-3: 0.01ms;
    --ab-dur-4: 0.01ms;
    --ab-stagger: 0ms;
    --ab-reveal-y: 0px;
    --ab-lift: 0px;
  }
}

/* ==========================================================================
   Layout
   ========================================================================== */

.ab-ds .ab-container {
  width: 100%;
  max-width: var(--ab-container);
  margin-inline: auto;
  padding-inline: var(--ab-gutter);
  box-sizing: border-box;
}

.ab-ds .ab-section {
  padding-block: var(--ab-section-y);
  position: relative;
}

.ab-ds .ab-section-dark {
  background: var(--ab-ink);
  color: var(--ab-on-dark);
}

/* ==========================================================================
   Typography helpers
   ========================================================================== */

.ab-ds .ab-eyebrow {
  font-family: var(--ab-font);
  font-size: var(--ab-fs-12);
  font-weight: 700;
  letter-spacing: var(--ab-track-eyebrow);
  text-transform: uppercase;
  color: var(--ab-orange);
}

.ab-ds .ab-h1,
.ab-ds .ab-h2,
.ab-ds .ab-h3 {
  font-family: var(--ab-font);
  font-weight: 800;
  letter-spacing: var(--ab-track-display);
  color: inherit;
  margin: 0;
  text-wrap: balance;
}

.ab-ds .ab-h1 {
  font-size: var(--ab-fs-h1);
  line-height: var(--ab-lh-tight);
}

.ab-ds .ab-h2 {
  font-size: var(--ab-fs-h2);
  line-height: var(--ab-lh-tight);
}

.ab-ds .ab-h3 {
  font-size: var(--ab-fs-h3);
  line-height: var(--ab-lh-snug);
}

.ab-ds .ab-body {
  font-size: var(--ab-fs-15);
  line-height: var(--ab-lh-body);
  color: var(--ab-mute);
  text-wrap: pretty;
}

.ab-ds .ab-section-dark .ab-body {
  color: var(--ab-on-dark-mute);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.ab-ds .ab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ab-sp-2);
  min-height: 46px;
  padding: 0 var(--ab-sp-5);
  border-radius: var(--ab-r-sm);
  border: 1.5px solid transparent;
  font-family: var(--ab-font);
  font-size: var(--ab-fs-15);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--ab-dur-2) var(--ab-ease-out),
    box-shadow var(--ab-dur-2) var(--ab-ease-out),
    background-color var(--ab-dur-2) ease,
    border-color var(--ab-dur-2) ease,
    color var(--ab-dur-2) ease;
}

.ab-ds .ab-btn-primary {
  background: var(--ab-orange);
  color: #fff;
  box-shadow: var(--ab-sh-1);
}

.ab-ds .ab-btn-secondary {
  background: var(--ab-white);
  color: var(--ab-ink);
  border-color: var(--ab-line-2);
}

.ab-ds .ab-btn-ghost {
  background: transparent;
  color: var(--ab-ink);
  padding-inline: var(--ab-sp-2);
}

.ab-ds .ab-btn-on-dark {
  background: transparent;
  color: var(--ab-on-dark);
  border-color: var(--ab-line-dark);
}

@media (hover: hover) and (pointer: fine) {
  .ab-ds .ab-btn-primary:hover {
    background: var(--ab-orange-dark);
    transform: translateY(-2px);
    box-shadow: var(--ab-sh-glow);
  }

  .ab-ds .ab-btn-secondary:hover {
    border-color: var(--ab-orange);
    color: var(--ab-orange-dark);
    transform: translateY(-2px);
    box-shadow: var(--ab-sh-2);
  }

  .ab-ds .ab-btn-ghost:hover {
    color: var(--ab-orange-dark);
  }

  .ab-ds .ab-btn-on-dark:hover {
    border-color: var(--ab-coral);
    color: #fff;
    transform: translateY(-2px);
  }
}

.ab-ds .ab-btn:active {
  transform: translateY(0) scale(0.98);
  transition-duration: var(--ab-dur-1);
}

.ab-ds .ab-btn:focus-visible {
  outline: none;
  box-shadow: var(--ab-focus);
}

.ab-ds .ab-btn[disabled],
.ab-ds .ab-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Arrow that nudges on hover. */

.ab-ds .ab-btn-arrow {
  display: inline-block;
  transition: transform var(--ab-dur-2) var(--ab-ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .ab-ds .ab-btn:hover .ab-btn-arrow {
    transform: translateX(4px);
  }
}

/* ==========================================================================
   Cards
   ========================================================================== */

.ab-ds .ab-ui-card {
  position: relative;
  background: var(--ab-white);
  border: 1px solid var(--ab-line);
  border-radius: var(--ab-r-md);
  box-shadow: var(--ab-sh-1);
  box-sizing: border-box;
  min-width: 0;
}

.ab-ds .ab-ui-card-dark {
  background: var(--ab-ink-2);
  border-color: var(--ab-line-dark);
  color: var(--ab-on-dark);
}

/* Interactive card: lift + pre-rendered shadow layer. */

.ab-ds .ab-ui-card-hover {
  transition:
    transform var(--ab-dur-2) var(--ab-ease-out),
    border-color var(--ab-dur-2) ease;
}

.ab-ds .ab-ui-card-hover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--ab-sh-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ab-dur-2) var(--ab-ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .ab-ds .ab-ui-card-hover:hover {
    transform: translateY(var(--ab-lift));
    border-color: var(--ab-orange-ring);
  }

  .ab-ds .ab-ui-card-hover:hover::after {
    opacity: 1;
  }
}

.ab-ds .ab-ui-card-hover:focus-visible {
  outline: none;
  box-shadow: var(--ab-focus);
}

.ab-ds .ab-ui-card-hover:focus-visible::after {
  opacity: 1;
}

/* ==========================================================================
   Pills / badges
   ========================================================================== */

.ab-ds .ab-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 var(--ab-sp-3);
  border-radius: var(--ab-r-pill);
  background: var(--ab-cream-2);
  border: 1px solid var(--ab-line);
  color: var(--ab-mute);
  font-size: var(--ab-fs-12);
  font-weight: 700;
  white-space: nowrap;
}

.ab-ds .ab-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--ab-r-pill);
  background: var(--ab-orange);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ab-ds .ab-badge-soft {
  background: var(--ab-orange-tint);
  color: var(--ab-orange-dark);
}

/* ==========================================================================
   Focus utility (for custom controls)
   ========================================================================== */

.ab-ds .ab-focus:focus-visible {
  outline: none;
  box-shadow: var(--ab-focus);
  border-radius: var(--ab-r-xs);
}

/* ==========================================================================
   Motion utilities — inert until ab-motion.js is explicitly started.

   Content stays fully visible by default. The hidden state only applies when
   BOTH are true: the container has data-ab-motion="ready" AND the item
   has not yet received data-ab-in.

   MIGRATING FROM reveal.js
   Put data-abr-skip on sections driven by ABMotion.reveal() before
   reveal.js scans them, to avoid double animations.
   ========================================================================== */

.ab-ds[data-ab-motion="ready"] .ab-reveal:not([data-ab-in]),
.ab-ds [data-ab-motion="ready"] .ab-reveal:not([data-ab-in]) {
  opacity: 0;
  transform: translateY(var(--ab-reveal-y));
}

.ab-ds .ab-reveal {
  transition:
    opacity var(--ab-dur-4) var(--ab-ease-out),
    transform var(--ab-dur-4) var(--ab-ease-out);
  transition-delay: calc(var(--ab-i, 0) * var(--ab-stagger));
}

/* Ambient loops pause automatically when marked out of view. */

.ab-ds .ab-ambient[data-ab-paused="true"],
.ab-ds .ab-ambient[data-ab-paused="true"] * {
  animation-play-state: paused !important;
}

@media (prefers-reduced-motion: reduce) {
  .ab-ds .ab-reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .ab-ds .ab-ambient,
  .ab-ds .ab-ambient * {
    animation: none !important;
  }
}
