/*
 * GlobeCounter — Base Dashboard Stylesheet v2.0
 * ===============================================
 * PILLAR: Shared logic in base files.
 * PILLAR: One job per file — this file ONLY handles visual styling.
 * All colors come from CSS variables set by config.js.
 * This file NEVER contains hardcoded country colors.
 *
 * Design direction: Newspaper front page meets Bloomberg terminal.
 * White base, bold red accents, clean typography, premium card shadows.
 */

/* ── RESET ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }

/* ── CSS VARIABLES (overridden by config.js per country) ────────────────── */
:root {
    /* Base palette */
    --base:           #ffffff;
    --base-off:       #f7f7f8;
    --base-subtle:    #f0f0f2;
    --base-mid:       #e8e8ec;

    /* Accent — set by country config */
    --accent:         #D0021B;
    --accent-dim:     #a80015;
    --accent-light:   #fff0f2;
    --accent-glow:    rgba(208,2,27,0.12);
    --accent-border:  rgba(208,2,27,0.25);

    /* Secondary */
    --secondary:      #e07b00;
    --secondary-light:#fff8ee;
    --secondary-glow: rgba(224,123,0,0.12);

    /* Teal */
    --teal:           #00897b;
    --teal-light:     #e8f5f3;
    --teal-glow:      rgba(0,137,123,0.12);

    /* Blue */
    --blue:           #1565c0;
    --blue-light:     #e8f0fb;
    --blue-glow:      rgba(21,101,192,0.12);

    /* Purple */
    --purple:         #6a1b9a;
    --purple-light:   #f3e5f5;

    /* Text */
    --text-primary:   #0a0a0a;
    --text-secondary: #444444;
    --text-muted:     #888888;
    --text-faint:     #bbbbbb;

    /* Borders & shadows */
    --border:         #e2e2e6;
    --border-strong:  #cccccc;
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:      0 8px 24px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.04);
    --shadow-accent:  0 4px 16px rgba(208,2,27,0.15);
}

/* ── BODY ──────────────────────────────────────────────────────────────── */
body {
    background: var(--base-off);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── COUNTRY WATERMARK ─────────────────────────────────────────────────── */
#country-watermark {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 75vw; height: 75vw;
    max-width: 800px; max-height: 800px;
    opacity: 0.035;
    pointer-events: none;
    z-index: 0;
    fill: var(--accent);
}

/* ── HEADER ────────────────────────────────────────────────────────────── */
#site-header {
    position: sticky; top: 0; z-index: 1000;
    background: var(--accent);
    height: 52px;
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 12px rgba(208,2,27,0.3);
}

.logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 24px; letter-spacing: 3px;
    color: #ffffff;
    display: flex; align-items: center; gap: 8px;
}
.logo .logo-maple { font-size: 20px; }
.logo-accent { color: rgba(255,255,255,0.85); }

.header-right { display:flex; align-items:center; gap:14px; }

.hdate {
    font-family: 'DM Mono', monospace;
    font-size: 9px; color: rgba(255,255,255,0.7);
    letter-spacing: 1px;
}

.live-pill {
    display: flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    padding: 3px 10px; border-radius: 2px;
}
.live-dot {
    width: 6px; height: 6px;
    background: #fff; border-radius: 50%;
    animation: blink 1.4s infinite;
    box-shadow: 0 0 6px rgba(255,255,255,0.8);
}
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0.2;} }
.live-text {
    font-family: 'DM Mono', monospace;
    font-size: 9px; color: #fff; letter-spacing: 2px;
}

/* Mode toggle in header */
.mode-toggle {
    display: flex; gap: 0;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 2px; overflow: hidden;
}
.mode-btn {
    font-family: 'DM Mono', monospace;
    font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
    padding: 4px 12px; cursor: pointer; border: none;
    background: transparent; color: rgba(255,255,255,0.7);
    transition: all 0.2s;
}
.mode-btn.active {
    background: rgba(255,255,255,0.25);
    color: #ffffff;
    font-weight: 500;
}
.mode-btn:hover:not(.active) { color: #ffffff; }

/* ── TICKER ────────────────────────────────────────────────────────────── */
#ticker-bar {
    background: var(--text-primary);
    height: 28px;
    display: flex; align-items: center; overflow: hidden;
    position: sticky; top: 52px; z-index: 999;
}
.ticker-badge {
    background: var(--accent);
    height: 100%; padding: 0 14px;
    display: flex; align-items: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 11px; letter-spacing: 2px;
    color: #fff;
    white-space: nowrap; flex-shrink: 0;
}
.ticker-scroll {
    display: flex;
    animation: ticker-anim 50s linear infinite;
    white-space: nowrap;
}
.ticker-scroll span {
    font-family: 'DM Mono', monospace;
    font-size: 10px; padding: 0 28px;
    letter-spacing: 1px; color: rgba(255,255,255,0.8);
}
.ticker-scroll span::before { content:'◆ '; opacity:0.4; color: var(--accent); }
@keyframes ticker-anim {
    0%   { transform:translateX(0); }
    100% { transform:translateX(-50%); }
}

/* ── DASHBOARD CONTAINER ───────────────────────────────────────────────── */
#dashboard {
    padding: 12px;
    max-width: 1600px;
    margin: 0 auto;
    position: relative; z-index: 1;
    display: flex; flex-direction: column; gap: 10px;
}

/* ── TILE BASE ─────────────────────────────────────────────────────────── */
.tile {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px 18px 14px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.tile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Top accent bar */
.tile::before {
    content: '';
    position: absolute; top: 0; left: 0;
    width: 100%; height: 3px;
    background: var(--border);
    transition: background 0.2s;
}
.tile.t-accent::before    { background: var(--accent); }
.tile.t-secondary::before { background: var(--secondary); }
.tile.t-teal::before      { background: var(--teal); }
.tile.t-blue::before      { background: var(--blue); }
.tile.t-purple::before    { background: var(--purple); }
.tile.t-white::before     { background: var(--border-strong); }

/* ── TILE LABELS ───────────────────────────────────────────────────────── */
.tile-label {
    font-family: 'DM Mono', monospace;
    font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 4px;
    display: flex; align-items: center; gap: 6px;
}
.tile-label.l-accent    { color: var(--accent); }
.tile-label.l-secondary { color: var(--secondary); }
.tile-label.l-teal      { color: var(--teal); }
.tile-label.l-blue      { color: var(--blue); }
.tile-label.l-purple    { color: var(--purple); }

/* ── TREND ARROW ───────────────────────────────────────────────────────── */
.trend {
    display: inline-flex; align-items: center; gap: 3px;
    font-family: 'DM Mono', monospace;
    font-size: 9px; font-weight: 600;
    padding: 2px 6px; border-radius: 2px;
    letter-spacing: 0.5px;
}
.trend.up-bad  { color: var(--accent);    background: var(--accent-light); }
.trend.up-good { color: var(--teal);      background: var(--teal-light); }
.trend.dn-bad  { color: var(--accent);    background: var(--accent-light); }
.trend.dn-good { color: var(--teal);      background: var(--teal-light); }
.trend.flat    { color: var(--text-muted); background: var(--base-subtle); }

/* ── TILE TITLE ────────────────────────────────────────────────────────── */
.tile-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px; letter-spacing: 2px;
    color: var(--text-primary); margin-bottom: 8px; line-height: 1.1;
    display: flex; align-items: center; justify-content: space-between;
}

.tile-logo {
    height: 22px; width: auto; opacity: 0.7;
    filter: grayscale(30%);
}

/* ── KPI NUMBER ────────────────────────────────────────────────────────── */
.tile-kpi {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 58px; letter-spacing: -1px;
    line-height: 0.85; margin-bottom: 6px;
}
.tile-kpi.k-accent    { color: var(--accent); }
.tile-kpi.k-secondary { color: var(--secondary); }
.tile-kpi.k-teal      { color: var(--teal); }
.tile-kpi.k-blue      { color: var(--blue); }
.tile-kpi.k-purple    { color: var(--purple); }
.tile-kpi.k-dark      { color: var(--text-primary); }

/* ── CONTEXT TEXT ──────────────────────────────────────────────────────── */
.tile-ctx {
    font-size: 11px; color: var(--text-secondary);
    line-height: 1.5; margin-bottom: 8px;
}

/* ── CHART WRAPPER ─────────────────────────────────────────────────────── */
.tile-chart {
    position: relative; display: block;
    overflow: hidden; margin: 10px 0 6px;
}
.tile-chart canvas { display:block; width:100% !important; }

/* ── TILE FOOTER ───────────────────────────────────────────────────────── */
.tile-foot {
    display: flex; align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px; gap: 8px;
}
.tile-source {
    font-family: 'DM Mono', monospace;
    font-size: 8px; color: var(--text-faint); letter-spacing: 1px;
}
.tile-source a { color: var(--text-muted); text-decoration: none; }
.tile-source a:hover { color: var(--accent); }

/* ── SHARE BUTTON ──────────────────────────────────────────────────────── */
.share-btn {
    font-family: 'DM Mono', monospace;
    font-size: 8px; letter-spacing: 1px;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid var(--accent-border);
    padding: 4px 12px; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
    text-transform: uppercase; white-space: nowrap; flex-shrink: 0;
    border-radius: 2px;
}
.share-btn:hover {
    background: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow-accent);
}

/* ── DEBT HERO TILE ────────────────────────────────────────────────────── */
.debt-tile {
    background: var(--accent);
    border: none;
    border-radius: 4px;
    padding: 24px 24px 18px;
    position: relative; overflow: hidden;
    text-align: center;
    box-shadow: var(--shadow-accent), var(--shadow-lg);
    color: #ffffff;
}

/* Decorative diagonal stripe */
.debt-tile::after {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    background: rgba(255,255,255,0.05);
    transform: rotate(45deg);
    border-radius: 4px;
    pointer-events: none;
}

/* Animated rings */
.debt-ring {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    animation: ring-pulse 4s ease-in-out infinite;
    pointer-events: none;
}
.debt-ring:nth-child(1) { width:260px; height:260px; }
.debt-ring:nth-child(2) { width:340px; height:340px; animation-delay:1.3s; opacity:0.6; }
.debt-ring:nth-child(3) { width:420px; height:420px; animation-delay:2.6s; opacity:0.3; }
@keyframes ring-pulse {
    0%,100% { transform:translate(-50%,-50%) scale(1); }
    50%     { transform:translate(-50%,-50%) scale(1.04); }
}

.debt-eyebrow {
    font-family: 'DM Mono', monospace; font-size: 9px;
    color: rgba(255,255,255,0.7); letter-spacing: 4px;
    margin-bottom: 4px; position: relative; z-index: 1;
}
.debt-sub {
    font-family: 'Bebas Neue', sans-serif; font-size: 14px;
    letter-spacing: 5px; color: rgba(255,255,255,0.85);
    margin-bottom: 6px; position: relative; z-index: 1;
}
.debt-num {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(44px, 6.5vw, 90px);
    color: #ffffff; letter-spacing: -2px; line-height: 0.9;
    text-shadow: 0 2px 20px rgba(0,0,0,0.2);
    animation: debt-glow 3s ease-in-out infinite;
    position: relative; z-index: 1;
}
@keyframes debt-glow {
    0%,100% { text-shadow: 0 2px 20px rgba(0,0,0,0.2); }
    50%     { text-shadow: 0 2px 30px rgba(0,0,0,0.3), 0 0 60px rgba(255,255,255,0.1); }
}

.debt-rate {
    margin-top: 6px; font-family: 'DM Mono', monospace;
    font-size: 11px; color: rgba(255,255,255,0.75); letter-spacing: 1px;
    position: relative; z-index: 1;
}
.pulse-num {
    color: #ffffff; display: inline-block; font-weight: 600;
    animation: num-pulse 1s ease-in-out infinite;
    background: rgba(255,255,255,0.2);
    padding: 1px 6px; border-radius: 2px;
}
@keyframes num-pulse {
    0%,100% { background: rgba(255,255,255,0.2); transform:scale(1); }
    50%     { background: rgba(255,255,255,0.35); transform:scale(1.06); }
}

/* Debt sub-stats */
.debt-substats {
    display: flex; gap: 8px; margin-top: 14px;
    justify-content: center; flex-wrap: wrap;
    position: relative; z-index: 1;
}
.dss-item {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
    padding: 8px 14px; text-align: center; flex: 1; min-width: 90px;
    backdrop-filter: blur(4px);
}
.dss-val {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 24px; color: #ffffff; letter-spacing: 1px;
}
.dss-label {
    font-family: 'DM Mono', monospace; font-size: 7px;
    color: rgba(255,255,255,0.7); letter-spacing: 1px;
    text-transform: uppercase; margin-top: 2px;
}

/* Toggle buttons */
.debt-toggle {
    display: flex; gap: 0; margin: 10px auto 0;
    border: 1px solid rgba(255,255,255,0.3);
    overflow: hidden; width: fit-content;
    border-radius: 2px; position: relative; z-index: 1;
}
.dtbtn {
    font-family: 'DM Mono', monospace; font-size: 9px;
    letter-spacing: 1px; text-transform: uppercase;
    padding: 5px 16px; cursor: pointer; border: none;
    background: transparent; color: rgba(255,255,255,0.7);
    transition: all 0.2s;
}
.dtbtn.active {
    background: rgba(255,255,255,0.25);
    color: #ffffff; font-weight: 500;
}
.dtbtn:hover:not(.active) { color: #ffffff; }

.debt-definition {
    font-family: 'DM Mono', monospace; font-size: 8px;
    color: rgba(255,255,255,0.55); margin-top: 5px; letter-spacing: 1px;
    min-height: 14px; position: relative; z-index: 1;
}
.debt-src {
    margin-top: 12px; font-family: 'DM Mono', monospace;
    font-size: 9px; color: rgba(255,255,255,0.6);
    display: flex; align-items: center; justify-content: center;
    gap: 12px; flex-wrap: wrap; position: relative; z-index: 1;
}
.debt-src a { color: rgba(255,255,255,0.8); text-decoration: none; }
.debt-src a:hover { color: #ffffff; }
.debt-src .share-btn {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    color: #ffffff;
}
.debt-src .share-btn:hover {
    background: rgba(255,255,255,0.35);
    color: #ffffff;
}

/* ── ROW LAYOUTS ───────────────────────────────────────────────────────── */
.row { display: grid; gap: 10px; }
.r-2   { grid-template-columns: 1fr 1fr; }
.r-3   { grid-template-columns: 1fr 1fr 1fr; }
.r-4   { grid-template-columns: 1fr 1fr 1fr 1fr; }
.r-1-2 { grid-template-columns: 1fr 2fr; }
.r-2-1 { grid-template-columns: 2fr 1fr; }

/* ── SIMPLE MODE ───────────────────────────────────────────────────────── */
.advanced-only { display: block; }
body.simple-mode .advanced-only { display: none !important; }

/* Simple mode hero — bigger, more centered */
body.simple-mode .debt-num { font-size: clamp(56px, 9vw, 110px); }
body.simple-mode #dashboard { max-width: 1200px; }

/* ── AD ZONE ───────────────────────────────────────────────────────────── */
.ad-zone {
    border: 1px dashed var(--border);
    background: var(--base-off);
    text-align: center; padding: 10px;
    font-family: 'DM Mono', monospace; font-size: 8px;
    color: var(--text-faint); letter-spacing: 2px; text-transform: uppercase;
    border-radius: 2px;
}

/* ── BOTTOM TICKER ─────────────────────────────────────────────────────── */
#source-ticker {
    background: var(--base-subtle);
    border-top: 1px solid var(--border);
    height: 28px; display: flex; align-items: center;
    overflow: hidden; margin-top: 4px;
}
.src-label {
    padding: 0 14px; height: 100%; display: flex; align-items: center;
    font-family: 'DM Mono', monospace; font-size: 8px;
    color: var(--text-muted); border-right: 1px solid var(--border);
    white-space: nowrap; flex-shrink: 0;
    letter-spacing: 2px; text-transform: uppercase;
    background: var(--base-mid);
}
.src-scroll { display: flex; animation: ticker-anim 70s linear infinite; white-space: nowrap; }
.src-scroll span {
    font-family: 'DM Mono', monospace; font-size: 8px;
    color: var(--text-muted); padding: 0 20px; letter-spacing: 1px;
}

/* ── FOOTER ────────────────────────────────────────────────────────────── */
#site-footer {
    padding: 24px 16px; text-align: center;
    border-top: 2px solid var(--accent);
    background: var(--text-primary);
}
.footer-logo {
    font-family: 'Bebas Neue', sans-serif; font-size: 20px;
    letter-spacing: 4px; color: rgba(255,255,255,0.3); margin-bottom: 6px;
}
.footer-logo .logo-accent { color: var(--accent); opacity: 0.6; }
.footer-tag {
    font-family: 'DM Mono', monospace; font-size: 9px;
    color: rgba(255,255,255,0.3); letter-spacing: 2px; margin-bottom: 10px;
}
.footer-disc {
    font-family: 'DM Mono', monospace; font-size: 8px;
    color: rgba(255,255,255,0.2); max-width: 640px;
    margin: 0 auto; line-height: 1.8;
}
.footer-disc a { color: rgba(255,255,255,0.3); text-decoration: none; }

/* ── SECTION DIVIDER ───────────────────────────────────────────────────── */
.section-head {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 0 2px;
}
.section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 13px; letter-spacing: 4px;
    color: var(--text-muted); white-space: nowrap;
}
.section-rule {
    flex: 1; height: 1px;
    background: var(--border);
}

/* ── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .r-3 { grid-template-columns: 1fr 1fr; }
    .r-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .r-2, .r-3, .r-4, .r-1-2, .r-2-1 { grid-template-columns: 1fr; }
    .debt-num { font-size: 42px !important; }
    .dss-val  { font-size: 18px; }
    #site-header { padding: 0 12px; }
    .mode-toggle { display: none; }
}
