/* =====================================================================
   Atronet design system — one source of truth for every customer-facing
   page (homepage, demo, signup, login, reset-password, setup, dashboard,
   refer, legal). Load it BEFORE a page's own <style> block so a page can
   still specialise, and so any page that hasn't converged yet keeps
   rendering exactly as before.

   Identity: a pale, near-white ground lit by soft blue light. The glow
   means "Atronet is here and working" — strongest where Atronet acts
   (hero, demo, setup's learning moment, success), quietest where the
   owner reads (dashboard).
   ===================================================================== */

:root {
  /* ---- Colour ---- */
  --at-ground:        #FAFBFD;
  --at-ground-2:      #EFF3F9;
  --at-ground-3:      #E9EEF6;
  --at-surface:       #FFFFFF;
  --at-ink:           #0B0D14;
  --at-ink-2:         #565C6E;
  --at-ink-3:         #8A90A0;
  --at-hairline:      rgba(11,13,20,0.08);
  --at-hairline-2:    rgba(11,13,20,0.05);
  --at-accent:        #3E7BFA;
  --at-accent-2:      #5096FF;
  --at-accent-ink:    #2B63DB;
  /* Accessible companions to the brand blue (same hue, a step deeper).
     --at-accent stays the brand: glows, rules, logo, large type. Use these
     wherever small text sits on, or is, a blue surface. */
  --at-accent-strong:       #336EEE;  /* white text on it: 4.6:1 (lightest blue that passes AA) */
  --at-accent-strong-hover: #2B63DB;  /* white text on it: 5.4:1 */
  --at-accent-text:         #2858D2;  /* blue text on white or pale glow: 5.0:1+ */
  --at-ink-muted:           #5B6172;  /* quiet text on white or pale glow: 4.6:1+ */
  --at-accent-tint:   rgba(62,123,250,0.08);
  --at-accent-tint-2: rgba(62,123,250,0.14);
  --at-accent-glow:   rgba(62,123,250,0.40);
  --at-good:          #22B36B;
  --at-good-tint:     rgba(34,179,107,0.12);
  --at-attention:     #D9891F;
  --at-attention-tint:rgba(232,163,61,0.14);
  --at-problem:       #E5484D;
  --at-problem-tint:  rgba(229,72,77,0.10);

  /* ---- Type ---- */
  --at-font:      "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --at-font-mark: "Fredoka", "Inter", system-ui, sans-serif;
  --at-fs-xs: 12px; --at-fs-sm: 13px; --at-fs-md: 15px; --at-fs-lg: 17px;
  --at-fs-xl: 20px; --at-fs-2xl: 28px; --at-fs-3xl: 40px; --at-fs-4xl: 56px;
  --at-track-tight: -0.02em;

  /* ---- Space (4px base) ---- */
  --at-s1: 4px; --at-s2: 8px; --at-s3: 12px; --at-s4: 16px;
  --at-s5: 24px; --at-s6: 32px; --at-s7: 48px; --at-s8: 72px;

  /* ---- Radius ---- */
  --at-r-input: 12px; --at-r-btn: 14px; --at-r-card: 20px; --at-r-window: 28px; --at-r-pill: 100px;

  /* ---- Shadow (blue-tinted, never grey-black) ---- */
  --at-shadow-1: 0 1px 2px rgba(11,13,20,0.04), 0 8px 24px -14px rgba(30,60,140,0.18);
  --at-shadow-2: 0 1px 0 rgba(11,13,20,0.03) inset, 0 30px 70px -26px rgba(30,60,140,0.24);
  --at-shadow-cta: 0 10px 28px -10px var(--at-accent-glow);

  /* ---- Glow intensities ---- */
  --at-glow-hero:    0.30;
  --at-glow-working: 0.20;
  --at-glow-quiet:   0.10;

  /* ---- Motion ---- */
  --at-ease: cubic-bezier(.2,.7,.2,1);
  --at-t-press: 160ms; --at-t-state: 240ms; --at-t-enter: 480ms;
}

/* Never let decorative light push the page sideways on a phone. `clip`
   (not `hidden`) keeps position:sticky working. */
html { overflow-x: hidden; }
@supports (overflow: clip) { html { overflow-x: clip; } body { overflow-x: clip; } }

body { font-family: var(--at-font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* ---------------------------------------------------------------------
   Glow — one contained layer. Put <div class="at-glow" data-level="hero">
   as the first child of a positioned section; it can never overflow.
   --------------------------------------------------------------------- */
.at-glow { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.at-glow::before, .at-glow::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(10px);
  background: radial-gradient(closest-side, rgba(62,123,250,var(--at-g, var(--at-glow-working))), transparent);
}
.at-glow::before { width: 900px; height: 700px; top: -360px; right: -260px; }
.at-glow::after  { width: 760px; height: 560px; top: -200px; left: -320px; opacity: .75; }
.at-glow[data-level="hero"]  { --at-g: var(--at-glow-hero); }
.at-glow[data-level="quiet"] { --at-g: var(--at-glow-quiet); }

/* A soft "working" breathe for elements that represent Atronet acting. */
@keyframes at-breathe { 0%,100% { box-shadow: 0 0 0 0 rgba(62,123,250,0.0); } 50% { box-shadow: 0 0 0 6px rgba(62,123,250,0.12); } }
@keyframes at-dot     { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.82); } }
@keyframes at-shimmer { from { background-position: -320px 0; } to { background-position: 320px 0; } }
@keyframes at-enter   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes at-success { 0% { box-shadow: 0 0 0 0 rgba(62,123,250,.35); } 100% { box-shadow: 0 0 0 22px rgba(62,123,250,0); } }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.at-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px; border-radius: var(--at-r-pill);
  font: 600 var(--at-fs-sm)/1 var(--at-font); letter-spacing: -0.005em; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform var(--at-t-press) var(--at-ease), box-shadow var(--at-t-state) var(--at-ease), background var(--at-t-state) var(--at-ease), color var(--at-t-state);
}
.at-btn:active { transform: scale(.98); }
.at-btn:focus-visible { outline: 3px solid var(--at-accent-tint-2); outline-offset: 2px; }
.at-btn[disabled] { opacity: .55; cursor: default; transform: none; }
.at-btn--primary { background: linear-gradient(180deg, var(--at-accent-2), var(--at-accent)); color: #fff; box-shadow: var(--at-shadow-cta); }
.at-btn--primary:hover { box-shadow: 0 14px 34px -10px var(--at-accent-glow); }
.at-btn--secondary { background: var(--at-surface); color: var(--at-ink); border-color: var(--at-hairline); box-shadow: 0 1px 2px rgba(11,13,20,0.04); }
.at-btn--secondary:hover { border-color: rgba(11,13,20,0.16); }
.at-btn--quiet { background: transparent; color: var(--at-ink-2); }
.at-btn--quiet:hover { color: var(--at-ink); background: var(--at-ground-2); }
.at-btn--sm { min-height: 32px; padding: 0 14px; font-size: var(--at-fs-xs); }

/* ---------------------------------------------------------------------
   Inputs
   --------------------------------------------------------------------- */
.at-input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--at-r-input);
  background: var(--at-surface); color: var(--at-ink); border: 1px solid var(--at-hairline);
  font: 400 var(--at-fs-md)/1.4 var(--at-font);
  transition: border-color var(--at-t-state), box-shadow var(--at-t-state);
}
.at-input::placeholder { color: var(--at-ink-3); }
.at-input:focus { outline: none; border-color: var(--at-accent); box-shadow: 0 0 0 4px var(--at-accent-tint); }

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */
.at-card { background: var(--at-surface); border: 1px solid var(--at-hairline); border-radius: var(--at-r-card); box-shadow: var(--at-shadow-1); }

/* ---------------------------------------------------------------------
   Status pills — the one vocabulary for trust states.
     data-state = working | you | needs | ok | warn | off
   --------------------------------------------------------------------- */
.at-status {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 9px;
  border-radius: var(--at-r-pill); font: 500 var(--at-fs-xs)/1.3 var(--at-font); white-space: nowrap;
  background: var(--at-ground-2); color: var(--at-ink-2);
}
.at-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.at-status[data-state="working"] { background: var(--at-accent-tint); color: var(--at-accent-ink); }
.at-status[data-state="working"]::before { background: var(--at-accent); animation: at-dot 2.2s var(--at-ease) infinite; }
.at-status[data-state="you"]     { background: var(--at-ground-2); color: var(--at-ink-2); }
.at-status[data-state="you"]::before { background: var(--at-ink-3); }
.at-status[data-state="needs"],
.at-status[data-state="warn"]    { background: var(--at-attention-tint); color: #9A5B07; }
.at-status[data-state="needs"]::before,
.at-status[data-state="warn"]::before { background: var(--at-attention); }
.at-status[data-state="ok"]      { background: var(--at-good-tint); color: #11804A; }
.at-status[data-state="ok"]::before { background: var(--at-good); }
.at-status[data-state="off"]     { background: var(--at-ground-2); color: var(--at-ink-3); }
.at-status[data-state="off"]::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--at-ink-3); }

/* ---------------------------------------------------------------------
   Skeletons, toasts, entering
   --------------------------------------------------------------------- */
.at-skeleton {
  border-radius: 8px; min-height: 12px; color: transparent !important;
  background: linear-gradient(90deg, var(--at-ground-2) 0, var(--at-ground-3) 40%, var(--at-ground-2) 80%) 0 0 / 640px 100% var(--at-ground-2);
  animation: at-shimmer 1.4s linear infinite;
}
.at-enter { animation: at-enter var(--at-t-enter) var(--at-ease) both; }
.at-success-pulse { animation: at-success 900ms var(--at-ease) 1; }

/* Calm cross-page transitions (supporting browsers only; others just navigate). */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; animation-timing-function: var(--at-ease); }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .at-status[data-state="working"]::before, .at-skeleton, .at-enter, .at-success-pulse { animation: none !important; }
  .at-btn { transition: none; }
}

/* =====================================================================
   Polish layer. Additive and token-based: it refines the shared .at-*
   components and adds a few zero-specificity (:where) accessibility
   defaults that any page can still override. No page-specific selectors,
   no change to colour, glow or brand.
   ===================================================================== */

/* Keyboard focus: one visible ring everywhere, overridable by any page rule. */
:where(a, button, summary, select, textarea, input, [role="button"], [tabindex]):focus-visible {
  outline: 3px solid var(--at-accent-tint-2); outline-offset: 2px;
}
/* Type: balanced headings, no stranded last words. */
:where(h1, h2, h3) { text-wrap: balance; }
:where(p, li, figcaption, dd) { text-wrap: pretty; }
:where(button, a, summary, label) { -webkit-tap-highlight-color: transparent; }
/* Anchor jumps glide (and stop gliding for anyone who asks for less motion). */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Buttons: a physical press, a quiet hover, comfortable touch targets. */
.at-btn--primary:active { box-shadow: 0 6px 16px -8px var(--at-accent-glow); }
.at-btn--secondary:hover { box-shadow: 0 4px 14px -8px rgba(30,60,140,0.30); }
.at-btn--secondary:active { background: var(--at-ground-2); }
@media (pointer: coarse) {
  .at-btn { min-height: 44px; }
  .at-btn--sm { min-height: 40px; }
  .at-input { min-height: 48px; font-size: 16px; } /* 16px stops iOS zooming into the field */
}

/* Inputs: error and success state, one vocabulary. */
.at-input[aria-invalid="true"], .at-input.is-invalid { border-color: var(--at-problem); box-shadow: 0 0 0 4px var(--at-problem-tint); }
.at-input[disabled] { background: var(--at-ground-2); color: var(--at-ink-3); cursor: not-allowed; }
.at-field-error { margin-top: 6px; font-size: var(--at-fs-sm); line-height: 1.4; color: #B4282D; }
.at-field-hint  { margin-top: 6px; font-size: var(--at-fs-sm); line-height: 1.4; color: var(--at-ink-2); }

/* Notices: one shape for info, success, warning and error messages. */
.at-notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--at-r-input);
  font-size: var(--at-fs-sm); line-height: 1.5; background: var(--at-accent-tint); color: var(--at-accent-ink);
}
.at-notice[data-tone="ok"]    { background: var(--at-good-tint); color: #11804A; }
.at-notice[data-tone="warn"]  { background: var(--at-attention-tint); color: #8A4F06; }
.at-notice[data-tone="error"] { background: var(--at-problem-tint); color: #B4282D; }

/* Empty states: composed, not a stray sentence. */
.at-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--at-s6) var(--at-s5); text-align: center; color: var(--at-ink-2); font-size: var(--at-fs-md); }
.at-empty strong { color: var(--at-ink); font-weight: 650; }

/* Provider logos: one tile, one proportion, whatever the artwork's own shape. */
.at-provider-logo {
  display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px;
  background: var(--at-surface); border: 1px solid var(--at-hairline); box-shadow: 0 1px 2px rgba(11,13,20,0.04);
}
.at-provider-logo img { width: 26px; height: 26px; object-fit: contain; display: block; }

/* Skeletons stay the shape of what replaces them. */
.at-skeleton { display: block; }
span.at-skeleton, .at-skeleton.at-skeleton--inline { display: inline-block; }
