/*
 * web/css/app.css
 *
 * Streaming Sweet Spot
 *
 * Reuses the established PALAK visual language:
 *   - dark application background
 *   - dark elevated cards
 *   - system / Segoe UI / Roboto font stack
 *   - blue primary accent
 *   - light-blue secondary accent
 *   - muted supporting copy
 *   - restrained borders, shadows and radii
 *
 * PALAK-specific dashboard/report components are intentionally excluded.
 */


/* ========================================================================
   Brand / design tokens
   ======================================================================== */

:root {
    --bg: #121212;
    --card: #1e1e1e;
    --card-elevated: #242424;
    --surface: #2b2b2b;

    --text: #f5f5f5;
    --muted: #c7c7c7;
    --muted-strong: #dddddd;

    --accent: #1976D2;
    --accent-hover: #1565C0;
    --accent-muted: #90CAF9;

    --success: #2ecc71;
    --warning: #f1c40f;
    --danger: #D32F2F;

    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);

    --shadow: 0 4px 12px rgba(0, 0, 0, 0.60);

    --radius: 8px;
    --radius-small: 4px;
    --radius-pill: 999px;

    --content-width: 1180px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;
}


/* ========================================================================
   Global
   ======================================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;

    background:
        radial-gradient(
            circle at top right,
            rgba(25, 118, 210, 0.08),
            transparent 34rem
        ),
        var(--bg);

    color: var(--text);

    font-family:
        system-ui,
        "Segoe UI",
        Roboto,
        sans-serif;

    font-size: 16px;
    line-height: 1.45;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: var(--accent-muted);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

[hidden] {
    display: none !important;
}


/* ========================================================================
   App shell
   ======================================================================== */

.app-shell {
    width: calc(100% - 32px);
    max-width: var(--content-width);

    margin:
        var(--space-6)
        auto
        48px;

    display: grid;
    gap: var(--space-4);
}


/* ========================================================================
   Header
   ======================================================================== */

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: var(--space-6);

    padding:
        var(--space-4)
        2px
        var(--space-2);
}

.app-header > div:first-child {
    min-width: 0;
    max-width: 780px;
}

.eyebrow,
.step-label {
    margin:
        0
        0
        var(--space-2);

    color: var(--accent-muted);

    font-size: 0.78rem;
    font-weight: 700;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-header h1 {
    margin:
        0
        0
        var(--space-3);

    max-width: 850px;

    color: var(--text);

    font-size:
        clamp(
            1.8rem,
            4vw,
            2.8rem
        );

    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.025em;
}

.lede {
    margin: 0;

    max-width: 760px;

    color: var(--muted);

    font-size: 1rem;
    line-height: 1.6;
}

.header-state {
    flex: 0 0 auto;

    min-width: 150px;

    padding:
        var(--space-3)
        var(--space-4);

    background: var(--card);

    border:
        1px
        solid
        var(--border);

    border-radius: var(--radius);

    box-shadow: var(--shadow);

    text-align: right;
}

.state-label {
    display: block;

    margin-bottom: var(--space-1);

    color: var(--muted);

    font-size: 0.78rem;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-state strong {
    display: block;

    color: var(--accent-muted);

    font-size: 0.98rem;
    font-weight: 700;
}


/* ========================================================================
   Cards
   ======================================================================== */

.card {
    width: 100%;
    min-width: 0;

    padding:
        var(--space-5)
        var(--space-5);

    background: var(--card);

    border:
        1px
        solid
        var(--border);

    border-radius: var(--radius);

    box-shadow: var(--shadow);
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: var(--space-6);

    margin-bottom: var(--space-5);
}

.section-heading > div {
    min-width: 0;
}

.section-heading h2 {
    margin: 0;

    color: var(--text);

    font-size: 1.15rem;
    font-weight: 800;

    line-height: 1.25;
}

.section-heading > p {
    margin: 0;

    max-width: 520px;

    color: var(--muted);

    font-size: 0.9rem;
    line-height: 1.5;
}


/* ========================================================================
   Forms
   ======================================================================== */

.form-grid {
    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );

    gap:
        var(--space-4)
        var(--space-4);
}

.field {
    display: flex;
    flex-direction: column;

    gap: 6px;

    margin: 0;

    color: var(--muted);

    font-size: 0.9rem;
}

.field-wide {
    grid-column: 1 / -1;
}

.field > span {
    color: var(--muted);

    font-size: 0.9rem;
    font-weight: 600;
}

.field small {
    color: var(--muted);

    font-size: 0.78rem;
    line-height: 1.45;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;

    padding:
        0.66rem
        0.78rem;

    background: var(--surface);

    color: var(--text);

    border:
        1px
        solid
        transparent;

    border-radius: var(--radius-small);

    outline: none;

    transition:
        border-color 120ms ease,
        background-color 120ms ease,
        box-shadow 120ms ease;
}

input[type="text"]:hover,
input[type="url"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
select:hover,
textarea:hover {
    background: #303030;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);

    box-shadow:
        0
        0
        0
        2px
        rgba(25, 118, 210, 0.18);
}

input[readonly] {
    color: var(--muted-strong);

    background: #252525;

    cursor: default;
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

select {
    cursor: pointer;
}


/* ========================================================================
   Buttons
   ======================================================================== */

.actions {
    display: flex;
    flex-wrap: wrap;

    gap: var(--space-3);

    margin-top: var(--space-5);
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;

    padding:
        0.58rem
        0.95rem;

    background: var(--accent);

    color: #ffffff;

    border: 0;
    border-radius: var(--radius-small);

    font-weight: 600;
    line-height: 1;

    cursor: pointer;

    transition:
        background-color 120ms ease,
        transform 80ms ease,
        opacity 120ms ease;
}

button:hover:not(:disabled),
.btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

button:active:not(:disabled),
.btn:active:not(:disabled) {
    transform: translateY(1px);
}

button:focus-visible,
.btn:focus-visible {
    outline:
        2px
        solid
        var(--accent-muted);

    outline-offset: 2px;
}

button.secondary,
.btn.secondary {
    background: transparent;

    color: var(--text);

    border:
        1px
        solid
        var(--border);
}

button.secondary:hover:not(:disabled),
.btn.secondary:hover:not(:disabled) {
    background:
        rgba(
            255,
            255,
            255,
            0.06
        );
}

button[disabled],
.btn[disabled] {
    opacity: 0.52;
    cursor: not-allowed;
    transform: none;
}


/* ========================================================================
   Guidance / state copy
   ======================================================================== */

.guidance {
    margin:
        var(--space-4)
        0
        0;

    padding:
        var(--space-3)
        var(--space-4);

    background:
        rgba(
            144,
            202,
            249,
            0.06
        );

    color: var(--accent-muted);

    border-left:
        3px
        solid
        var(--accent);

    border-radius:
        0
        var(--radius-small)
        var(--radius-small)
        0;

    font-size: 0.9rem;
}


/* ========================================================================
   Video
   ======================================================================== */

.video-stage {
    position: relative;

    width: 100%;

    overflow: hidden;

    background: #050505;

    border:
        1px
        solid
        var(--border);

    border-radius: var(--radius);
}

.video-stage::before {
    content: "";

    display: block;

    width: 100%;
    padding-top: 56.25%;
}

.video-stage video {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;

    background: #000;
}


/* ========================================================================
   Metrics
   ======================================================================== */

.metric-grid {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: var(--space-3);

    margin: 0;
}

.metric {
    min-width: 0;

    padding:
        var(--space-3)
        var(--space-4);

    background:
        rgba(
            255,
            255,
            255,
            0.035
        );

    border:
        1px
        solid
        var(--border);

    border-radius: var(--radius);
}

.metric dt {
    margin:
        0
        0
        var(--space-1);

    color: var(--muted);

    font-size: 0.78rem;
    font-weight: 600;
}

.metric dd {
    margin: 0;

    min-width: 0;

    color: var(--text);

    font-size: 1.05rem;
    font-weight: 700;

    overflow-wrap: anywhere;
}

#metric-test-id {
    font-size: 0.8rem;
    font-weight: 500;

    color: var(--muted-strong);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        monospace;
}


/* ========================================================================
   Assessment / result card
   ======================================================================== */

#result-card {
    border-color:
        rgba(
            144,
            202,
            249,
            0.18
        );
}

.finding {
    margin-top: var(--space-5);

    padding:
        var(--space-4)
        var(--space-4);

    background:
        rgba(
            255,
            255,
            255,
            0.035
        );

    border:
        1px
        solid
        var(--border);

    border-left:
        4px
        solid
        var(--accent);

    border-radius: var(--radius);
}

.finding strong {
    display: block;

    margin-bottom: var(--space-2);

    color: var(--accent-muted);

    font-size: 0.95rem;
}

.finding p {
    margin: 0;

    color: var(--muted);

    font-size: 0.92rem;
    line-height: 1.55;
}


/* ========================================================================
   Status chips
   ======================================================================== */

.status-chip {
    display: inline-block;

    padding:
        4px
        10px;

    border-radius: var(--radius-pill);

    font-size: 0.8rem;
    font-weight: 600;
}

.status-green {
    background:
        rgba(
            46,
            204,
            113,
            0.15
        );

    color: #7ee2a8;
}

.status-yellow {
    background:
        rgba(
            241,
            196,
            15,
            0.15
        );

    color: #f4d35e;
}

.status-red {
    background:
        rgba(
            231,
            76,
            60,
            0.15
        );

    color: #ff8a80;
}

.status-neutral {
    background:
        rgba(
            255,
            255,
            255,
            0.08
        );

    color: var(--muted);
}


/* ========================================================================
   Diagnostic section
   ======================================================================== */

.diagnostic-card {
    background:
        rgba(
            30,
            30,
            30,
            0.72
        );
}

.diagnostic-card details {
    width: 100%;
}

.diagnostic-card summary {
    cursor: pointer;

    color: var(--muted-strong);

    font-weight: 700;
}

.diagnostic-card summary:hover {
    color: var(--text);
}

.diagnostic-card details > p {
    margin:
        var(--space-3)
        0;

    color: var(--muted);

    font-size: 0.88rem;
}

pre {
    width: 100%;

    margin:
        var(--space-3)
        0
        0;

    padding:
        var(--space-3)
        var(--space-4);

    overflow: auto;

    background: #0f0f0f;

    color: var(--text);

    border:
        1px
        solid
        var(--border);

    border-radius: var(--radius);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.78rem;
    line-height: 1.5;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}


/* ========================================================================
   Shared utility styles
   ======================================================================== */

.small {
    color: var(--muted);
    font-size: 0.85rem;
}

.muted {
    color: var(--muted);
}

.hr {
    height: 1px;

    margin:
        var(--space-3)
        0;

    background: var(--border);
}


/* ========================================================================
   Optional health indicators
   ======================================================================== */

.health {
    display: flex;
    align-items: center;

    gap: 10px;

    margin-top: 6px;

    font-weight: 600;
}

.dot.ok {
    color: var(--success);
}

.tri.warn {
    color: var(--warning);
}

.tri.alarm {
    color: #e74c3c;
}


/* ========================================================================
   Loading indicator
   ======================================================================== */

.spinner {
    width: 16px;
    height: 16px;

    flex:
        0
        0
        16px;

    border-radius: 50%;

    border:
        2px
        solid
        rgba(
            255,
            255,
            255,
            0.20
        );

    border-top-color:
        var(--accent-muted);

    animation:
        sweetspot-spin
        0.9s
        linear
        infinite;
}

@keyframes sweetspot-spin {
    to {
        transform: rotate(360deg);
    }
}


/* ========================================================================
   Responsive layout
   ======================================================================== */

@media (
    max-width: 900px
) {
    .app-header {
        flex-direction: column;
    }

    .header-state {
        width: 100%;

        text-align: left;
    }

    .section-heading {
        flex-direction: column;

        gap: var(--space-2);
    }

    .section-heading > p {
        max-width: none;
    }

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


@media (
    max-width: 700px
) {
    .app-shell {
        width:
            calc(
                100% - 20px
            );

        margin:
            14px
            auto
            32px;

        gap: var(--space-3);
    }

    .app-header {
        gap: var(--space-4);

        padding-top: 4px;
    }

    .app-header h1 {
        font-size: 1.8rem;
    }

    .lede {
        font-size: 0.94rem;
    }

    .card {
        padding:
            var(--space-4)
            var(--space-4);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .field-wide {
        grid-column: auto;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    button,
    .btn {
        width: 100%;
    }
}


@media (
    max-width: 420px
) {
    .app-shell {
        width:
            calc(
                100% - 16px
            );
    }

    .card {
        padding:
            var(--space-3)
            var(--space-3);
    }

    .app-header h1 {
        font-size: 1.55rem;
    }

    .metric {
        padding:
            var(--space-3)
            var(--space-3);
    }
}


/* ========================================================================
   Reduced motion
   ======================================================================== */

@media (
    prefers-reduced-motion: reduce
) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;

        transition-duration:
            0.01ms !important;

        animation-duration:
            0.01ms !important;

        animation-iteration-count:
            1 !important;
    }
}
