/* Variables are defined in theme.css — do not redeclare here */

/*
 * ─── App Shell (Full-Screen Pages) ─────────────────────────────────────────
 * Add class to <html> (document.documentElement) for pages that want a true
 * full-screen layout. Set on the html element so it works in <head> scripts
 * before <body> is parsed. dvh = dynamic viewport height.
 */
html.page-fullscreen,
html.page-fullscreen body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

html.page-fullscreen main.container {
    min-height: 0;
    overflow: hidden;
}

html.page-fullscreen .site-footer {
    display: none;
}

html {
    max-width: 100%;
    overflow-x: hidden;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Outfit', 'Inter', sans-serif;
    margin: 0;
    line-height: 1.65;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Base size — 16px is the browser default and a comfortable reading floor */
    font-size: 16px;
}

/* ── Page Transition ──────────────────────────────────────────────────────────────── */
/* NOTE: transform on body breaks position:fixed for mobile-nav, modals, etc.
   on mobile browsers (Safari, Chrome iOS).  Use opacity-only on body and
   push the slide-up effect into main content via a separate keyframe. */
@keyframes pageEnterOpacity {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

body.page-ready {
    animation: pageEnterOpacity 0.22s ease both;
}

/* Slide-up only on main content — keeps position:fixed children unaffected */
body.page-ready > main,
body.page-ready > .container:not(nav):not(.mobile-nav):not(.site-footer) {
    animation: pageEnterSlide 0.22s ease both;
}

body.page-leaving {
    pointer-events: none;
    opacity: 0 !important;
    transition: opacity 0.18s ease !important;
}

/* ── Modal fade-in via @starting-style (Chrome 117+, FF 129+, Safari 17.5+) ─── */
.modal-overlay {
    transition: opacity 0.15s ease;
}

@starting-style {
    .modal-overlay {
        opacity: 0;
    }
}


/* Scale up proportionally at larger screen sizes */
@media (min-width: 1440px) {
    body {
        font-size: 17px;
    }
}

@media (min-width: 1920px) {
    body {
        font-size: 18px;
    }
}

@media (min-width: 2560px) {
    body {
        font-size: 19px;
    }
}

main.container,
.container {
    flex: 1;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--text);
}

/* ── External-link indicator ────────────────────────────────────────────────
 * Automatically appends ↗ to any link that opens in a new tab,
 * excluding buttons, tabs, nav links, and data-cards (which have their own
 * positioned ::after rule).
 */
a[target="_blank"]:not(.btn):not(.tab-btn):not(.data-card):not([class*="nav-"])::after {
    content: '\202F\2197'; /* thin-space + ↗ */
    font-size: 0.85em;
    opacity: 0.85;
    vertical-align: 0.1em;
    transition: opacity 0.15s ease;
}

a[target="_blank"]:not(.btn):not(.tab-btn):not(.data-card):not([class*="nav-"]):hover::after {
    opacity: 1;
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
    color: var(--text);
}

h1 span {
    color: var(--primary);
}

.page-title {
    font-size: 1.8rem;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    line-height: 1.1;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-dim);
    max-width: 600px;
    margin: 0 auto 12px auto;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-dim);
    max-width: 650px;
    margin: 0 auto;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thin-thumb);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeInUp 0.6s ease forwards;
}

/* Typography Utilities */
.text-dim {
    color: var(--text-dim) !important;
}

.text-accent {
    color: var(--accent) !important;
}

.text-success {
    color: #4ade80 !important;
}

.text-danger {
    color: #ef4444 !important;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.fw-bold {
    font-weight: bold !important;
}

.fw-normal {
    font-weight: normal !important;
}

.empty-state-text {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    padding: 15px 0;
}

/* Margin Overrides */
.mb-0 {
    margin-bottom: 0 !important;
}

.mb-2 {
    margin-bottom: 8px !important;
}

.mb-3 {
    margin-bottom: 12px !important;
}

.mb-4 {
    margin-bottom: 20px !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.mt-2 {
    margin-top: 8px !important;
}

.mt-3 {
    margin-top: 12px !important;
}

.mt-4 {
    margin-top: 20px !important;
}

/* Markdown AI Outputs */
.markdown-body {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text);
}

.markdown-body h1 {
    font-size: 1.2rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.markdown-body h2 {
    font-size: 1.1rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.markdown-body h3,
.markdown-body h4 {
    font-size: 0.95rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.markdown-body p {
    margin-bottom: 0.5rem;
}

.markdown-body p:last-child {
    margin-bottom: 0;
}

.markdown-body ul {
    list-style: disc;
    padding-left: 1.2rem;
    margin-bottom: 0.5rem;
}

.markdown-body ol {
    list-style: decimal;
    padding-left: 1.2rem;
    margin-bottom: 0.5rem;
}

.markdown-body li {
    display: list-item;
    margin-bottom: 0.1rem;
    font-size: 0.85rem;
    color: var(--text);
}

.markdown-body pre {
    background: var(--code-bg);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--glass-border);
    margin-bottom: 1rem;
}

.markdown-body code {
    background: var(--code-inline-bg);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
    color: var(--accent);
}

.markdown-body strong {
    color: var(--text);
}

/* ══ Global Ticker Marquee ══ */
.ticker-marquee {
    background: var(--ticker-marquee-bg);
    border-bottom: 1px solid var(--border-subtle);
    overflow: hidden;
    white-space: nowrap;
    padding: 5px 0;
    position: relative;
}

.ticker-marquee::before,
.ticker-marquee::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    z-index: 2;
    pointer-events: none;
}

.ticker-marquee::before {
    left: 0;
    background: linear-gradient(90deg, var(--marquee-fade-color) 0%, transparent 100%);
}

.ticker-marquee::after {
    right: 0;
    background: linear-gradient(-90deg, var(--marquee-fade-color) 0%, transparent 100%);
}

.marquee-content {
    display: inline-flex;
    gap: 48px;
    animation: scroll-left 50s linear infinite;
}

.marquee-content:hover {
    animation-play-state: paused;
}

@keyframes scroll-left {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .marquee-content {
        animation: none;
        transform: none;
    }
}

.marquee-item {
    display: flex;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    align-items: center;
    cursor: default;
    transition: opacity 0.2s;
}

.marquee-item:hover {
    opacity: 0.7;
}

.marquee-item a {
    display: flex;
    gap: 8px;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.ticker-sym {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.ticker-val {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.ticker-pct {
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
}

.ticker-pct.pos {
    color: #34d399;
}

.ticker-pct.neg {
    color: #f87171;
}