/* =========================================================
   ConferenceDemo - DealerCon Market Intelligence Dashboard
   Design tokens, grid shell, cards, responsive rules.
   Target: WCAG 2.2 AA
   ========================================================= */

:root {
    /* Surfaces */
    --bg-app: #07090F;
    --bg-panel: #0D1118;
    --bg-panel-alt: #111722;
    --border-panel: #1E2733;
    /* Brand */
    --brand-green: #2EAE4E;
    --brand-green-deep: #1F8A3D; /* verify AA (4.5:1) behind white text */
    --brand-green-text: #4ADE80; /* small-text accent, focus rings, icons */
    --pos-green: #2DD4A7; /* teal-green, distinct from brand green */
    --neg-red: #FF4D52; /* semantic negative, not brand */
    /* Text */
    --text-hi: #FFFFFF;
    --text-mid: #B7C0CC;
    --text-lo: #7C8899;
    /* Metrics */
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 72px;
    --rail-w: 200px;
    --gutter: 12px;
    --radius: 10px;
    --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    /* Fluid type scale (tuned to keep full dashboard above the fold) */
    --fs-hero: clamp(1.8rem, 3.1vw, 3rem);
    --fs-hero-sub: clamp(0.95rem, 1.05vw, 1.45rem);
    --fs-section: clamp(1rem, 1.2vw, 1.6rem);
    --fs-kpi-value: clamp(1.35rem, 1.8vw, 2.4rem);
    --fs-kpi-label: clamp(0.75rem, 0.85vw, 0.95rem);
    --fs-card-title: clamp(0.68rem, 0.75vw, 0.82rem);
    --fs-nav: clamp(0.5rem, 1vw, 0.8rem);
    --fs-meta: clamp(0.68rem, 0.75vw, 0.82rem);
}

/* ---------- Base ---------- */

body.dash-body {
    background: var(--bg-app);
    color: var(--text-hi);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

.dash-body a {
    color: var(--text-mid);
    text-decoration: none;
}

.dash-body :focus-visible {
    outline: 2px solid var(--brand-green-text);
    outline-offset: 2px;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    z-index: 100;
    background: var(--brand-green-deep);
    color: #fff;
    padding: 8px 16px;
    border-radius: 0 0 var(--radius) 0;
}

    .skip-link:focus {
        left: 0;
    }

/* ---------- Grid shell ---------- */

.dash-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rail-w);
    grid-template-areas: "nav main rail";
    gap: var(--gutter);
    align-items: start;
    padding: var(--gutter);
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns .18s ease;
}

/* Shared two-column variant for pages that do not render a right rail. */
.dash-shell-no-rail {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-areas: "nav main";
}

    .dash-shell[data-collapsed="true"] {
        --sidebar-w: var(--sidebar-w-collapsed);
    }

.dash-nav {
    grid-area: nav;
    position: sticky;
    top: var(--gutter);
    align-self: start;
}

.dash-main {
    grid-area: main;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    padding-right: 4px;
}

.dash-rail {
    grid-area: rail;
    position: sticky;
    top: var(--gutter);
    align-self: start;
}

/* ---------- Panel primitive ---------- */

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius);
    padding: 16px;
}

.panel-title {
    font-size: var(--fs-card-title);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-hi);
    margin: 0 0 4px;
}

.panel-sub {
    font-size: var(--fs-meta);
    color: var(--text-lo);
    margin: 0 0 12px;
}

/* ---------- Sidebar ---------- */

.sidebar {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 12px;
}

.sidebar-logo {
    background: #fff;
    padding: 12px;
    display: flex;
    justify-content: center;
}

    .sidebar-logo img {
        max-width: 100%;
        height: auto;
    }

.sidebar-toggle {
    margin: 8px 12px 0;
    background: transparent;
    border: 1px solid var(--border-panel);
    color: var(--text-mid);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

    .sidebar-toggle:hover {
        color: var(--text-hi);
        border-color: var(--brand-green);
    }

.sidebar-eyebrow {
    font-size: var(--fs-meta);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-lo);
    padding: 4px 16px;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--text-mid);
    font-size: var(--fs-nav);
    font-weight: 500;
    white-space: nowrap;
}

    .sidebar-link:hover {
        background: var(--bg-panel-alt);
        color: var(--text-hi);
    }

    .sidebar-link[aria-current="page"] {
        background: var(--brand-green-deep);
        color: #fff;
    }

.sidebar-icon {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
}

.sidebar-cta {
    margin: auto 12px 0;
    background: var(--bg-panel-alt);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

    .sidebar-cta p {
        margin: 0;
        font-size: var(--fs-kpi-label);
        color: var(--text-mid);
        line-height: 1.35;
    }

.sidebar-cta-accent {
    color: var(--brand-green-text);
    font-weight: 600;
}

.sidebar-cta-arrow {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--brand-green);
    color: var(--brand-green-text);
    display: grid;
    place-items: center;
}

    .sidebar-cta-arrow:hover {
        background: var(--brand-green-deep);
        color: #fff;
    }
/* Collapsed sidebar: icons only */
.dash-shell[data-collapsed="true"] .sidebar-eyebrow,
.dash-shell[data-collapsed="true"] .sidebar-link-text,
.dash-shell[data-collapsed="true"] .sidebar-cta p {
    display: none;
}

.dash-shell[data-collapsed="true"] .sidebar-link {
    justify-content: center;
    padding: 10px 0;
}

.dash-shell[data-collapsed="true"] .sidebar-cta {
    justify-content: center;
    padding: 10px;
}

.dash-shell[data-collapsed="true"] .sidebar-logo {
    padding: 8px 4px;
}

/* ---------- Hero ---------- */

.hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border-panel);
    background: linear-gradient(120deg, #0A0D14 0%, #061F10 60%, #072B14 100%);
    padding: 18px;
    margin-bottom: var(--gutter);
}

.hero-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 62ch;
}

.hero-title {
    font-size: var(--fs-hero);
    font-weight: 700;
    line-height: 1.04;
    margin: 0 0 8px;
    letter-spacing: -.01em;
}

.hero-accent {
    color: var(--brand-green-text);
    font-weight: 700;
}

.hero-sub {
    font-size: var(--fs-hero-sub);
    color: var(--text-mid);
    margin: 0;
}

/* ---------- Section heading ---------- */

.section-head {
    margin: 0 0 10px;
}

.section-title {
    font-size: var(--fs-section);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 0;
}

.section-meta {
    font-size: var(--fs-kpi-label);
    color: var(--text-lo);
    margin: 2px 0 0;
}

/* ---------- KPI cards ---------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--gutter);
    margin-bottom: var(--gutter);
}

.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kpi-icon {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-green-deep);
    color: #fff;
    display: grid;
    place-items: center;
}

.kpi-label {
    font-size: var(--fs-kpi-label);
    color: var(--text-mid);
    line-height: 1.25;
}

.kpi-value {
    font-size: var(--fs-kpi-value);
    font-weight: 600;
    line-height: 1.05;
    font-variant-numeric: tabular-nums lining-nums;
}

.kpi-delta {
    font-size: clamp(0.85rem, 1vw, 1.25rem);
    font-weight: 500;
    font-variant-numeric: tabular-nums lining-nums;
}

.kpi-delta-up {
    color: var(--pos-green);
}

.kpi-delta-down {
    color: var(--neg-red);
}

.kpi-compare {
    font-size: var(--fs-meta);
    color: var(--text-lo);
    margin-top: auto;
}

/* ---------- Chart cards ---------- */

.chart-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--gutter);
}

.chart-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius);
    padding: 12px;
}

.chart-surface {
    width: 100%;
    height: clamp(150px, 22vh, 220px);
}

.chart-legend {
    display: flex;
    gap: 16px;
    font-size: var(--fs-meta);
    color: var(--text-mid);
    margin-bottom: 8px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: middle;
}

.swatch-new {
    background: var(--brand-green);
}

.swatch-used {
    background: #8A94A3;
}

/* ---------- Source footer ---------- */

.dash-source {
    font-size: var(--fs-meta);
    color: var(--text-lo);
    border-top: 1px solid var(--border-panel);
    margin-top: 10px;
    padding-top: 8px;
}

/* ---------- Sponsor rail ---------- */

.rail-stack {
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
}

.rail-sponsor {
    text-align: center;
}

    .rail-sponsor img {
        max-width: 100%;
        height: auto;
        border-radius: 6px;
    }

.rail-sponsor-caption {
    font-size: var(--fs-meta);
    color: var(--text-mid);
    margin: 8px 0 0;
}

.rail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

    .rail-list li {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: var(--fs-meta);
        color: var(--text-mid);
    }

.rail-check {
    flex: 0 0 16px;
    color: var(--brand-green-text);
}

.rail-map {
    text-align: center;
}

    .rail-map svg,
    .rail-map .rail-map-img {
        width: 100%;
        max-width: 170px;
        height: auto;
        display: block;
        margin-inline: auto;
    }

.rail-map-text {
    font-size: var(--fs-kpi-label);
    color: var(--text-hi);
    margin: 12px 0 0;
    line-height: 1.35;
}

/* ---------- Unavailable state ---------- */

#unavailable-state {
    padding: 64px 16px;
    text-align: center;
    color: var(--text-mid);
}

/* =========================================================
   Breakpoints
   ========================================================= */

/* Tablet landscape and below: rail becomes a horizontal strip */
@media (max-width: 1279px) {
    .dash-shell {
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
        grid-template-areas:
            "nav main"
            "nav rail";
    }

    .dash-shell.dash-shell-no-rail {
        grid-template-areas: "nav main";
    }

    .dash-rail {
        position: static;
    }

    .rail-stack {
        flex-direction: row;
        align-items: stretch;
    }

    .rail-stack > * {
        flex: 1 1 0;
    }

    .kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .chart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Tablet portrait and below */
@media (max-width: 1023px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .rail-stack {
        flex-direction: column;
    }

    .hero {
        padding: 14px;
    }
}

/* Low-height displays: additional compaction to keep all cards visible */
@media (max-height: 920px) {
    :root {
        --gutter: 10px;
        --fs-hero: clamp(1.5rem, 2.8vw, 2.3rem);
        --fs-hero-sub: clamp(0.85rem, 1vw, 1.1rem);
        --fs-kpi-value: clamp(1.15rem, 1.4vw, 1.8rem);
    }

    .hero {
        padding: 12px;
    }

    .kpi-card,
    .chart-card,
    .panel {
        padding: 10px;
    }

    .chart-surface {
        height: clamp(130px, 18vh, 170px);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .dash-shell {
        transition: none;
    }
}
