/* DERMS Simulation — OpenDSS Case Study Stylesheet */

:root {
    color-scheme: dark;
    --bg: #091018;
    --bg-deep: #060b11;
    --surface: rgba(14, 23, 34, 0.88);
    --surface-strong: rgba(19, 31, 45, 0.96);
    --surface-soft: rgba(255, 255, 255, 0.04);
    --line: rgba(173, 196, 220, 0.12);
    --line-strong: rgba(255, 255, 255, 0.24);
    --text: #edf3ff;
    --text-soft: #9fb0c9;
    --text-muted: #7d8ca4;
    --accent: #ff7a3d;
    --accent-soft: #ffb088;
    --accent-glow: rgba(255, 122, 61, 0.22);
    --teal: #44d3c5;
    --green: #4ade80;
    --blue: #6ab8ff;
    --yellow: #fbbf24;
    --danger: #f87171;
    --radius: 24px;
    --radius-sm: 16px;
    --shadow: 0 30px 60px rgba(0, 0, 0, 0.28);
    --focus-ring: 0 0 0 3px rgba(106, 184, 255, 0.35);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Manrope", sans-serif;
    background:
        radial-gradient(1000px 700px at 10% -10%, rgba(68, 211, 197, 0.16), transparent 60%),
        radial-gradient(1200px 680px at 100% -5%, rgba(255, 122, 61, 0.18), transparent 55%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 80%);
    opacity: 0.18;
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

/* ── Skip link ─────────────────────────────────────────────── */

.skip-link {
    position: absolute;
    left: 16px;
    top: 16px;
    transform: translateY(-160%);
    z-index: 1000;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg-deep);
    font-weight: 700;
    text-decoration: none;
    transition: transform 180ms ease;
}

.skip-link:focus-visible {
    transform: translateY(0);
}

/* ── Page layout ───────────────────────────────────────────── */

.page {
    width: min(1480px, 94vw);
    margin: 18px auto 42px;
    position: relative;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
}

.span-12 { grid-column: span 12; }
.span-8  { grid-column: span 8; }
.span-6  { grid-column: span 6; }
.span-4  { grid-column: span 4; }

/* ── Panel / card base ─────────────────────────────────────── */

.panel,
.kpi-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
        var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    position: relative;
    overflow: hidden;
    animation: rise 420ms ease both;
}

.panel::after,
.kpi-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255, 122, 61, 0.10), transparent 38%);
    opacity: 0.9;
}

.panel > *,
.kpi-card > * {
    position: relative;
    z-index: 1;
}

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

/* ── Site header ───────────────────────────────────────────── */

.site-header {
    grid-column: span 12;
    padding: 18px 22px;
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

/* ── Brand ─────────────────────────────────────────────────── */

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--bg-deep);
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.7), transparent 40%),
        linear-gradient(135deg, var(--teal), var(--accent));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand-title {
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    color: var(--text-soft);
    font-size: 12px;
}

/* ── Nav ───────────────────────────────────────────────────── */

.nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-link,
.button,
.mode-button,
.footer a {
    transition:
        transform 180ms ease,
        border-color 180ms ease,
        background-color 180ms ease,
        color 180ms ease,
        box-shadow 180ms ease,
        opacity 180ms ease;
}

.nav-link {
    text-decoration: none;
    color: var(--text);
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    font-size: 13px;
    font-weight: 700;
}

.nav-link:hover {
    border-color: rgba(255, 122, 61, 0.55);
    transform: translateY(-1px);
}

/* ── Buttons ───────────────────────────────────────────────── */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, rgba(255, 122, 61, 0.95), rgba(255, 156, 92, 0.95));
    color: var(--bg-deep);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.button.secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--line);
    color: var(--text);
}

.button:hover,
.button.secondary:hover {
    transform: translateY(-1px);
}

/* ── Hero ──────────────────────────────────────────────────── */

.panel-hero {
    grid-column: span 12;
    padding: 28px;
    min-height: 360px;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
    gap: 22px;
    align-items: stretch;
}

.hero-copy {
    display: grid;
    align-content: start;
    gap: 18px;
}

.hero-eyebrow,
.eyebrow,
.metric-label,
.plot-label,
.kpi-title,
.modes-copy {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-soft);
}

.hero h1 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(34px, 4vw, 62px);
    line-height: 0.98;
    letter-spacing: -0.03em;
    max-width: 13ch;
    text-wrap: balance;
}

.lead {
    margin: 0;
    max-width: 60ch;
    color: #d5deef;
    font-size: 16px;
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.badge {
    border-radius: 999px;
    border: 1px solid rgba(255, 122, 61, 0.28);
    background: rgba(255, 122, 61, 0.10);
    color: var(--accent-soft);
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
}

/* ── Metric board (hero tiles) ─────────────────────────────── */

.metric-board {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.metric-tile {
    min-height: 150px;
    padding: 18px;
    border-radius: var(--radius-sm);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
        rgba(6, 11, 17, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    align-content: space-between;
    gap: 12px;
}

.metric-value {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 0.95;
}

.metric-unit {
    font-size: 0.38em;
    letter-spacing: 0;
    opacity: 0.7;
}

.metric-meta {
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.5;
}

/* ── Section header ────────────────────────────────────────── */

.section-header {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.section-title {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(26px, 3vw, 42px);
    line-height: 1.05;
    letter-spacing: -0.03em;
    text-wrap: balance;
}

/* ── What I Built cards ────────────────────────────────────── */

.built-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.built-card {
    padding: 24px;
    display: grid;
    gap: 14px;
    align-content: start;
}

.built-icon {
    font-size: 28px;
    line-height: 1;
}

.built-card h3 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 20px;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.built-card p {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.65;
}

.built-card strong {
    color: var(--text);
}

/* ── Case study section ────────────────────────────────────── */

.story-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.story-card {
    padding: 24px;
    display: grid;
    align-content: start;
    gap: 14px;
}

.story-card-wide {
    grid-column: span 2;
}

.story-card h3 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 21px;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.story-card p,
.story-note {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.68;
}

.story-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.story-tag {
    border-radius: 999px;
    border: 1px solid rgba(68, 211, 197, 0.34);
    background: rgba(68, 211, 197, 0.12);
    color: #baf4ee;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
}

.story-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 9px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

.story-list li::marker {
    color: var(--accent-soft);
}

.story-note {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
}

.story-code {
    margin: 0;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(106, 184, 255, 0.28);
    background: rgba(8, 16, 26, 0.78);
    color: #cde6ff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
}

.story-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.story-stat {
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    display: grid;
    gap: 8px;
}

.story-stat-label {
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 10px;
    font-weight: 800;
}

.story-stat-value {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(24px, 2.4vw, 34px);
    line-height: 1;
    letter-spacing: -0.02em;
}

.story-stat-meta {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.45;
}

/* ── Results section (card with padding) ───────────────────── */

.card {
    padding: 22px;
}

/* ── KPI grid ──────────────────────────────────────────────── */

.kpi-grid {
    grid-column: span 12;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.kpi-card {
    padding: 18px;
}

.kpi-value {
    margin-top: 12px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 32px;
    line-height: 1;
    letter-spacing: -0.03em;
}

.kpi-subtitle {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-soft);
}

.kpi-improvement {
    margin-top: 10px;
    min-height: 18px;
    font-size: 12px;
    font-weight: 700;
}

.kpi-improvement.positive { color: var(--green); }
.kpi-improvement.negative { color: var(--danger); }

/* ── Modes (scenario switcher) ─────────────────────────────── */

.modes {
    grid-column: span 12;
    padding: 22px;
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
}

.mode-toggle {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mode-button {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.mode-button:hover {
    border-color: rgba(255, 122, 61, 0.45);
    transform: translateY(-1px);
}

.mode-button.active,
.mode-button[aria-pressed="true"] {
    background: rgba(255, 122, 61, 0.18);
    border-color: rgba(255, 122, 61, 0.75);
    color: #ffe2d4;
}

/* ── Plot panels ───────────────────────────────────────────── */

.plot-card,
.plot-full {
    padding: 22px;
    display: grid;
    gap: 10px;
}

.plot-card { grid-column: span 6; }
.plot-full { grid-column: span 12; }

.plot-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    text-wrap: balance;
}

.plot-subtitle {
    margin-top: -4px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-soft);
}

.plot-container {
    min-height: 260px;
}

/* ── Comparison table ──────────────────────────────────────── */

.scroll-x {
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    color: #e0e8f7;
    font-size: 13px;
}

.comparison-table th,
.comparison-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.comparison-table th {
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.10em;
    font-size: 10px;
    font-weight: 800;
}

.comparison-table td:first-child {
    font-weight: 700;
}

.comparison-table tr:last-child td {
    border-bottom: none;
}

.comparison-table .better { color: var(--green); }
.comparison-table .worse  { color: var(--yellow); }

/* ── Footer ────────────────────────────────────────────────── */

.footer {
    grid-column: span 12;
    padding: 18px;
    text-align: center;
    font-size: 13px;
    color: var(--text-soft);
}

.footer p { margin: 0; }

.footer a {
    color: var(--accent-soft);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ── Text utilities ────────────────────────────────────────── */

.text-accent  { color: var(--accent-soft); }
.text-muted   { color: var(--text-muted); }
.text-green   { color: var(--green); }
.text-blue    { color: var(--blue); }
.text-yellow  { color: var(--yellow); }

.error-copy { color: var(--danger); }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Focus styles ──────────────────────────────────────────── */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ── Reduced motion ────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Responsive: tablet ────────────────────────────────────── */

@media (max-width: 1200px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .built-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .story-stats {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .span-8,
    .span-6,
    .span-4,
    .plot-card {
        grid-column: span 12;
    }
}

/* ── Responsive: mobile ────────────────────────────────────── */

@media (max-width: 760px) {
    .page {
        width: min(1480px, 96vw);
        margin: 10px auto 28px;
    }

    .grid { gap: 12px; }

    .site-header,
    .panel-hero,
    .card,
    .plot-card,
    .plot-full,
    .modes,
    .kpi-card {
        padding: 18px;
    }

    .built-grid,
    .story-grid,
    .metric-board,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .story-card-wide {
        grid-column: span 1;
    }

    .hero h1 {
        max-width: 12ch;
    }
}
