/* ═══════════════════════════════════════════════════════════════════════════
   AXIOM — THE OBSERVATORY  ·  app-layer design system (2026-06-11)
   ═══════════════════════════════════════════════════════════════════════════
   The landing page promises "Peer-Reviewed Predictive Intelligence."
   This system makes the app feel like the instrument behind that promise:
   a precision analytical console — part observatory control room, part
   Swiss-printed scientific journal. Ink on deep space. Hairlines, not boxes.
   Every number is set in a measuring instrument's hand (mono, tabular).
   Indigo is earned, never decorative.

   LOAD ORDER: this sheet loads LAST, after Tailwind 2.x and legacy CSS.
   It deliberately remaps the legacy utility classes the app's JS renderers
   emit (bg-gray-800 etc.) so dynamically-injected content inherits the new
   aesthetic with ZERO JavaScript changes.

   Fonts (Google, CSP-allowed):
     Fraunces        — display serif, optical sizing, journal gravitas
     Archivo         — UI grotesque (never Inter)
     IBM Plex Mono   — all data, timestamps, figures
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 0 · TOKENS ──────────────────────────────────────────────────────────── */
:root {
    /* ink + space */
    --ax-bg:           #07070B;
    --ax-bg-deep:      #050508;
    --ax-surface:      #0D0D14;
    --ax-surface-2:    #12121B;
    --ax-surface-3:    #181826;
    --ax-line:         rgba(226, 229, 255, 0.08);
    --ax-line-strong:  rgba(226, 229, 255, 0.16);
    --ax-grid-line:    rgba(140, 150, 255, 0.05);

    /* text */
    --ax-text:         #EDEEF7;
    --ax-text-dim:     #A0A3B8;
    --ax-text-faint:   #62657A;

    /* brand + signals (match landing: indigo 6366F1 · emerald 10B981) */
    --ax-indigo:       #6366F1;
    --ax-indigo-bright:#818CF8;
    --ax-indigo-soft:  rgba(99, 102, 241, 0.13);
    --ax-live:         #FF4D5E;
    --ax-up:           #10B981;
    --ax-down:         #F87171;
    --ax-warn:         #FBBF24;

    /* type */
    --ax-font-display: 'Fraunces', Georgia, serif;
    --ax-font-ui:      'Archivo', 'Helvetica Neue', sans-serif;
    --ax-font-data:    'IBM Plex Mono', 'Consolas', monospace;

    /* rhythm */
    --ax-radius:       6px;
    --ax-radius-lg:    10px;
    --ax-gutter:       clamp(16px, 2.5vw, 32px);
    --ax-ease:         cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── 1 · CANVAS · the blueprint field ────────────────────────────────────── */
body {
    background-color: var(--ax-bg) !important;
    color: var(--ax-text) !important;
    font-family: var(--ax-font-ui) !important;
    font-feature-settings: 'ss01' on;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* graph-paper field: data feels PLOTTED, not floated on cards */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(var(--ax-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--ax-grid-line) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, black 35%, transparent 78%);
    -webkit-mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, black 35%, transparent 78%);
}

::selection { background: var(--ax-indigo); color: #fff; }

* { scrollbar-width: thin; scrollbar-color: var(--ax-surface-3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--ax-surface-3); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
    outline: 2px solid var(--ax-indigo) !important;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── 2 · TYPOGRAPHY ──────────────────────────────────────────────────────── */
h1, h2 {
    font-family: var(--ax-font-display) !important;
    font-weight: 550;
    font-optical-sizing: auto;
    letter-spacing: -0.01em;
    color: var(--ax-text);
}
h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); line-height: 1.08; }
h2 { font-size: clamp(1.3rem, 2vw, 1.7rem); line-height: 1.15; }
h3, h4 { font-family: var(--ax-font-ui) !important; font-weight: 600; letter-spacing: -0.005em; }

/* every figure reads like an instrument — opt-in via element, auto on tables */
.ax-num, td.ax-num, .ax-stat-value, .ax-table td {
    font-family: var(--ax-font-data);
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' on;
}

.ax-kicker {
    font-family: var(--ax-font-data);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--ax-text-faint);
}

.ax-display-accent { font-family: var(--ax-font-display); font-style: italic; font-weight: 400; color: var(--ax-indigo-bright); }

/* ── 3 · THE FIG. CAPTION · signature motif ─────────────────────────────────
   Every data module is captioned like a figure in a journal:
   <div class="ax-fig"><span class="ax-fig-no">FIG. 03</span>
        <span class="ax-fig-label">Live Feed</span>
        <span class="ax-fig-meta">60s cadence · Mongo</span></div>            */
.ax-fig {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--ax-line);
}
.ax-fig-no {
    font-family: var(--ax-font-data);
    font-size: 0.625rem;
    letter-spacing: 0.14em;
    color: var(--ax-indigo-bright);
    white-space: nowrap;
}
.ax-fig-label {
    font-family: var(--ax-font-ui);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ax-text);
}
.ax-fig-rule { flex: 1; height: 1px; background: var(--ax-line); align-self: center; }
.ax-fig-meta {
    font-family: var(--ax-font-data);
    font-size: 0.625rem;
    letter-spacing: 0.08em;
    color: var(--ax-text-faint);
    white-space: nowrap;
}

/* ── 4 · SURFACES · hairlines, not boxes ─────────────────────────────────── */
.ax-card, .premium-card {
    background: linear-gradient(180deg, var(--ax-surface-2), var(--ax-surface)) !important;
    border: 1px solid var(--ax-line) !important;
    border-radius: var(--ax-radius-lg) !important;
    box-shadow: none !important;
    position: relative;
    transition: border-color 0.35s var(--ax-ease);
}
.ax-card:hover, .premium-card:hover { border-color: var(--ax-line-strong) !important; }

/* corner tick — tiny plotted-chart registration mark, top-left of each card */
.ax-card::before, .premium-card::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px;
    width: 14px; height: 14px;
    border-top: 1px solid var(--ax-indigo);
    border-left: 1px solid var(--ax-indigo);
    border-top-left-radius: var(--ax-radius-lg);
    opacity: 0.55;
    pointer-events: none;
}

.stat-card {
    background: var(--ax-surface) !important;
    border: 1px solid var(--ax-line) !important;
    border-radius: var(--ax-radius) !important;
    padding: 18px 20px !important;
    box-shadow: none !important;
    position: relative;
    overflow: hidden;
}
.stat-card h3 {
    font-family: var(--ax-font-data) !important;
    font-size: 0.625rem !important;
    font-weight: 500 !important;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--ax-text-faint) !important;
    margin-bottom: 10px;
}
.stat-card .stat-value, .ax-stat-value {
    font-family: var(--ax-font-data) !important;
    font-size: clamp(1.6rem, 2.6vw, 2.2rem) !important;
    font-weight: 500;
    letter-spacing: -0.03em;
    color: var(--ax-text) !important;
    line-height: 1;
}
.stat-card::after {
    content: '';
    position: absolute;
    left: 20px; right: 20px; bottom: 12px;
    height: 1px;
    background: linear-gradient(90deg, var(--ax-indigo), transparent 60%);
    opacity: 0.4;
}

/* ── 5 · TABLES · dense, instrument-grade ────────────────────────────────── */
.ax-table, .premium-card table { width: 100%; border-collapse: collapse; }
.ax-table th, .premium-card thead th {
    font-family: var(--ax-font-data) !important;
    font-size: 0.625rem !important;
    font-weight: 500 !important;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ax-text-faint) !important;
    border-bottom: 1px solid var(--ax-line-strong) !important;
    padding: 6px 12px 8px 0 !important;
    text-align: left;
}
.ax-table td, .premium-card tbody td {
    font-size: 0.8125rem !important;
    padding: 9px 12px 9px 0 !important;
    border-bottom: 1px solid var(--ax-line) !important;
    color: var(--ax-text-dim) !important;
}
.ax-table tbody tr, .premium-card tbody tr { transition: background 0.2s var(--ax-ease); }
.ax-table tbody tr:hover, .premium-card tbody tr:hover { background: rgba(99, 102, 241, 0.05) !important; }
.ax-table td:first-child, .premium-card tbody td:first-child { color: var(--ax-text) !important; font-weight: 500; }

/* ── 6 · CONTROLS ────────────────────────────────────────────────────────── */
.ax-btn, .ax-pill {
    font-family: var(--ax-font-ui);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--ax-radius);
    border: 1px solid var(--ax-line);
    background: transparent;
    color: var(--ax-text-dim);
    padding: 7px 14px;
    cursor: pointer;
    transition: all 0.25s var(--ax-ease);
}
.ax-btn:hover, .ax-pill:hover { border-color: var(--ax-line-strong); color: var(--ax-text); }
.ax-btn--primary {
    background: var(--ax-indigo);
    border-color: var(--ax-indigo);
    color: #fff;
}
.ax-btn--primary:hover { background: var(--ax-indigo-bright); border-color: var(--ax-indigo-bright); color: #fff; }
.ax-pill--active, .ax-pill[aria-pressed="true"] {
    background: var(--ax-indigo-soft);
    border-color: var(--ax-indigo);
    color: var(--ax-indigo-bright);
}

.ax-input, input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
    background: var(--ax-bg-deep) !important;
    border: 1px solid var(--ax-line) !important;
    border-radius: var(--ax-radius) !important;
    color: var(--ax-text) !important;
    font-family: var(--ax-font-ui) !important;
    transition: border-color 0.25s var(--ax-ease);
}
.ax-input:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--ax-indigo) !important;
    box-shadow: 0 0 0 3px var(--ax-indigo-soft) !important;
}
input::placeholder, textarea::placeholder { color: var(--ax-text-faint) !important; }

/* ── 7 · LIVE SIGNAL ─────────────────────────────────────────────────────── */
.ax-live-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--ax-live);
    box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.5);
    animation: ax-pulse 2s var(--ax-ease) infinite;
    vertical-align: middle;
}
@keyframes ax-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.45); }
    70%  { box-shadow: 0 0 0 9px rgba(255, 77, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0); }
}
.text-red-400.animate-pulse { color: var(--ax-live) !important; }

/* ── 8 · TAB MECHANICS · behavioral CSS the page JS depends on (KEEP) ────── */
.dashboard-tab { display: none; }
.dashboard-tab.active { display: block; animation: ax-tab-in 0.28s var(--ax-ease); }
@keyframes ax-tab-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dashboard-tab-button {
    font-family: var(--ax-font-ui) !important;
    letter-spacing: 0.01em;
    border-left: 2px solid transparent !important;
    border-radius: 0 var(--ax-radius) var(--ax-radius) 0 !important;
    transition: all 0.22s var(--ax-ease) !important;
}
.dashboard-tab-button[aria-selected="true"] {
    border-left-color: var(--ax-indigo) !important;
    background: var(--ax-indigo-soft) !important;
    color: var(--ax-indigo-bright) !important;
}

/* ── 9 · LEGACY UTILITY REMAP ────────────────────────────────────────────────
   The app's JS renderers emit Tailwind 2.x utilities. Remap them so injected
   content speaks Observatory without a single JavaScript change.            */
.bg-gray-900 { background-color: var(--ax-bg) !important; }
.bg-gray-800 { background-color: var(--ax-surface) !important; }
.bg-gray-700 { background-color: var(--ax-surface-2) !important; }
.bg-gray-600 { background-color: var(--ax-surface-3) !important; }
.border-gray-700, .border-gray-600, .border-gray-800 { border-color: var(--ax-line) !important; }
.text-gray-300 { color: var(--ax-text-dim) !important; }
.text-gray-400 { color: var(--ax-text-dim) !important; }
.text-gray-500 { color: var(--ax-text-faint) !important; }
.text-gray-600 { color: var(--ax-text-faint) !important; }
.bg-blue-600, .bg-blue-700 { background-color: var(--ax-indigo) !important; }
.hover\:bg-blue-500:hover, .hover\:bg-blue-700:hover { background-color: var(--ax-indigo-bright) !important; }
.text-blue-500, .text-blue-400 { color: var(--ax-indigo-bright) !important; }
.bg-blue-900 { background-color: var(--ax-indigo-soft) !important; }
.text-blue-100 { color: var(--ax-indigo-bright) !important; }
.text-green-400 { color: var(--ax-up) !important; }
.text-red-400 { color: var(--ax-live) !important; }
.rounded-lg { border-radius: var(--ax-radius-lg) !important; }
.rounded { border-radius: var(--ax-radius) !important; }

/* sidebar + shell surfaces commonly used by the app pages */
#sidebar { background: var(--ax-bg-deep) !important; border-right: 1px solid var(--ax-line) !important; }
header, nav.navbar { background: rgba(7, 7, 11, 0.82) !important; backdrop-filter: blur(12px); border-bottom: 1px solid var(--ax-line) !important; }

/* ── 10 · PAGE REVEAL · one orchestrated entrance, CSS only ──────────────── */
.ax-reveal, .premium-card, .stat-card {
    animation: ax-reveal 0.6s var(--ax-ease) backwards;
}
.premium-card:nth-of-type(1), .stat-card:nth-of-type(1) { animation-delay: 0.04s; }
.premium-card:nth-of-type(2), .stat-card:nth-of-type(2) { animation-delay: 0.1s; }
.premium-card:nth-of-type(3), .stat-card:nth-of-type(3) { animation-delay: 0.16s; }
.premium-card:nth-of-type(4), .stat-card:nth-of-type(4) { animation-delay: 0.22s; }
@keyframes ax-reveal {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── 11 · AUTH / FOCUSED PAGES · centered instrument panel ───────────────── */
.ax-panel {
    max-width: 420px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--ax-surface-2), var(--ax-surface));
    border: 1px solid var(--ax-line);
    border-radius: var(--ax-radius-lg);
    padding: 36px 32px;
    position: relative;
}
.ax-panel::before {
    content: '';
    position: absolute;
    top: -1px; left: 24px; right: 24px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--ax-indigo), transparent);
    opacity: 0.6;
}

/* ── 12 · FOOTNOTES · journal-style page footer meta ─────────────────────── */
.ax-footnote {
    font-family: var(--ax-font-data);
    font-size: 0.625rem;
    letter-spacing: 0.1em;
    color: var(--ax-text-faint);
    text-transform: uppercase;
    border-top: 1px solid var(--ax-line);
    padding-top: 14px;
}
