/*
 * Rymdlägesportalen – Omvärldsbevakning
 *
 * Komplett stilmall för:
 * - sidhuvud,
 * - rapportmetadata,
 * - samlad bedömning,
 * - prioriterade händelser,
 * - rymdväder,
 * - metodbeskrivning,
 * - rapportarkiv,
 * - mobil och Safari.
 */


/* =========================================================
   Grundvariabler
   ========================================================= */

:root {
    color-scheme: dark;

    --background: #07111f;
    --background-secondary: #0a1728;

    --surface: rgba(17, 34, 55, 0.92);
    --surface-elevated: rgba(22, 43, 68, 0.96);
    --surface-soft: rgba(255, 255, 255, 0.035);

    --border: rgba(148, 182, 216, 0.18);
    --border-strong: rgba(148, 182, 216, 0.32);

    --text: #f1f6fb;
    --text-muted: #aabbd0;
    --text-subtle: #7f95ad;

    --accent: #5eb6d9;
    --accent-soft: rgba(94, 182, 217, 0.12);
    --accent-border: rgba(94, 182, 217, 0.35);

    --success: #74d4a1;
    --success-soft: rgba(116, 212, 161, 0.12);
    --success-border: rgba(116, 212, 161, 0.36);

    --warning: #f1c56c;
    --warning-soft: rgba(241, 197, 108, 0.12);
    --warning-border: rgba(241, 197, 108, 0.38);

    --danger: #ef9a8e;
    --danger-soft: rgba(239, 154, 142, 0.12);
    --danger-border: rgba(239, 154, 142, 0.4);

    --critical: #ff7d7d;
    --critical-soft: rgba(255, 100, 100, 0.14);
    --critical-border: rgba(255, 100, 100, 0.5);

    --shadow:
        0 18px 45px rgba(0, 0, 0, 0.22);

    --shadow-soft:
        0 8px 24px rgba(0, 0, 0, 0.16);

    --radius-large: 22px;
    --radius-medium: 16px;
    --radius-small: 10px;

    --content-width: 1180px;
}


/* =========================================================
   Återställning och bas
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    overflow-x: hidden;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.6;

    color: var(--text);

    background:
        radial-gradient(
            circle at 12% 0%,
            rgba(43, 116, 154, 0.19),
            transparent 35%
        ),
        radial-gradient(
            circle at 88% 12%,
            rgba(73, 77, 150, 0.14),
            transparent 32%
        ),
        linear-gradient(
            180deg,
            var(--background-secondary) 0%,
            var(--background) 55%,
            #050d18 100%
        );
}

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

a {
    color: inherit;
}

img,
svg {
    display: block;
    max-width: 100%;
}

p,
h1,
h2,
h3,
h4 {
    overflow-wrap: anywhere;
}

p {
    margin-top: 0;
}

h1,
h2,
h3,
h4 {
    margin-top: 0;
    line-height: 1.2;
}

h1 {
    margin-bottom: 18px;
    font-size: clamp(2.35rem, 5vw, 4.4rem);
    font-weight: 750;
    letter-spacing: -0.045em;
}

h2 {
    margin-bottom: 0;
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    letter-spacing: -0.025em;
}

h3 {
    margin-bottom: 10px;
    font-size: 1.25rem;
    letter-spacing: -0.015em;
}

h4 {
    margin-bottom: 14px;
    font-size: 0.96rem;
    color: var(--text-muted);
}


/* =========================================================
   Sidlayout
   ========================================================= */

.page-container {
    width: min(
        calc(100% - 40px),
        var(--content-width)
    );

    min-width: 0;
    margin: 0 auto;
    padding:
        max(34px, env(safe-area-inset-top))
        0
        max(48px, env(safe-area-inset-bottom));
}


/* =========================================================
   Sidhuvud
   ========================================================= */

.page-header {
    position: relative;
    margin-bottom: 36px;
    padding: 8px 2px 12px;
}

.page-header::after {
    display: block;
    width: 100%;
    height: 1px;
    margin-top: 34px;

    content: "";

    background:
        linear-gradient(
            90deg,
            transparent,
            var(--border-strong),
            transparent
        );
}

.page-header__navigation {
    margin-bottom: 46px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    min-height: 42px;
    padding: 8px 12px;

    font-size: 0.9rem;
    font-weight: 650;
    text-decoration: none;

    color: var(--text-muted);

    border: 1px solid transparent;
    border-radius: var(--radius-small);

    transition:
        color 150ms ease,
        background-color 150ms ease,
        border-color 150ms ease;
}

.back-link:hover {
    color: var(--text);
    background: var(--surface-soft);
    border-color: var(--border);
}

.back-link:focus-visible {
    outline: 3px solid var(--accent-border);
    outline-offset: 3px;
}

.page-header__content {
    max-width: 900px;
}

.page-eyebrow,
.section-eyebrow {
    margin-bottom: 8px;

    font-size: 0.73rem;
    font-weight: 750;
    line-height: 1.3;
    letter-spacing: 0.15em;
    text-transform: uppercase;

    color: var(--accent);
}

.page-introduction {
    max-width: 790px;
    margin-bottom: 0;

    font-size: clamp(1rem, 2vw, 1.18rem);
    line-height: 1.75;

    color: var(--text-muted);
}


/* =========================================================
   Gemensamma kort
   ========================================================= */

.card {
    min-width: 0;
    padding: 30px;

    background:
        linear-gradient(
            145deg,
            rgba(24, 46, 72, 0.96),
            rgba(13, 29, 48, 0.94)
        );

    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;

    min-width: 0;
    margin-bottom: 22px;
}

.card-header > div {
    min-width: 0;
}

.card-header h2,
.card-header h3 {
    margin-bottom: 0;
}

.lead {
    margin-bottom: 0;

    font-size: clamp(1.02rem, 2vw, 1.18rem);
    line-height: 1.75;

    color: #d7e3ef;
}


/* =========================================================
   Rapportmetadata
   ========================================================= */

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

    min-width: 0;
    margin-bottom: 22px;
}

.report-meta__item {
    min-width: 0;
    padding: 18px 20px;

    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-soft);
}

.report-meta__item span {
    display: block;
    margin-bottom: 7px;

    font-size: 0.76rem;
    font-weight: 650;
    letter-spacing: 0.055em;
    text-transform: uppercase;

    color: var(--text-subtle);
}

.report-meta__item strong {
    display: block;

    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.4;

    color: var(--text);
}


/* =========================================================
   Samlad bedömning
   ========================================================= */

.assessment-card {
    position: relative;
    overflow: hidden;
    margin-bottom: 54px;
}

.assessment-card::before {
    position: absolute;
    top: 0;
    left: 0;

    width: 5px;
    height: 100%;

    content: "";

    background:
        linear-gradient(
            180deg,
            var(--accent),
            rgba(94, 182, 217, 0.18)
        );
}

.assessment {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;

    min-height: 36px;
    padding: 7px 13px;

    font-size: 0.76rem;
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: 0.045em;
    text-align: center;
    text-transform: uppercase;

    border-radius: 999px;
}

.assessment--stable {
    color: var(--success);
    background: var(--success-soft);
    border: 1px solid var(--success-border);
}

.assessment--heightened {
    color: var(--warning);
    background: var(--warning-soft);
    border: 1px solid var(--warning-border);
}

.assessment--significant {
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid var(--danger-border);
}

.assessment--critical {
    color: var(--critical);
    background: var(--critical-soft);
    border: 1px solid var(--critical-border);
}

.archive-message {
    min-height: 22px;
    margin: 20px 0 0;
    padding-top: 17px;

    font-size: 0.82rem;
    color: var(--text-subtle);

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

.archive-message:empty {
    display: none;
}


/* =========================================================
   Innehållssektioner
   ========================================================= */

.content-section {
    min-width: 0;
    margin-bottom: 58px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 40px;

    min-width: 0;
    margin-bottom: 22px;
    padding: 0 2px;
}

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

.section-heading > p {
    max-width: 510px;
    margin-bottom: 2px;

    font-size: 0.93rem;
    line-height: 1.65;

    color: var(--text-muted);
}


/* =========================================================
   Händelser
   ========================================================= */

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

    min-width: 0;
}

.event-card {
    position: relative;

    min-width: 0;
    min-height: 235px;
    padding: 24px;

    background:
        linear-gradient(
            150deg,
            rgba(22, 43, 68, 0.92),
            rgba(12, 27, 45, 0.94)
        );

    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-soft);

    transition:
        transform 160ms ease,
        border-color 160ms ease,
        background-color 160ms ease;
}

.event-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border);
}

.event-card__category {
    margin-bottom: 13px;

    font-size: 0.71rem;
    font-weight: 750;
    letter-spacing: 0.11em;
    text-transform: uppercase;

    color: var(--accent);
}

.event-card h3 {
    margin-bottom: 12px;
}

.event-card p:last-child {
    margin-bottom: 0;

    font-size: 0.93rem;
    line-height: 1.7;

    color: var(--text-muted);
}

.event-card--empty {
    grid-column: 1 / -1;

    min-height: 150px;

    background:
        linear-gradient(
            145deg,
            rgba(18, 36, 58, 0.82),
            rgba(10, 24, 40, 0.86)
        );

    border-style: dashed;
}


/* =========================================================
   Rymdväder
   ========================================================= */

.space-weather-card {
    min-width: 0;
}

.space-weather-columns {
    display: grid;
    grid-template-columns:
        minmax(0, 1.05fr)
        minmax(0, 0.95fr);
    gap: 30px;

    min-width: 0;
    margin-top: 30px;
    padding-top: 26px;

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

.space-weather-columns > div {
    min-width: 0;
}

.impact-list {
    margin: 0;
    padding-left: 20px;

    color: var(--text-muted);
}

.impact-list li {
    margin-bottom: 10px;
    padding-left: 4px;
}

.impact-list li:last-child {
    margin-bottom: 0;
}

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

.source-list {
    display: grid;
    gap: 10px;
}

.source-list a {
    display: block;
    padding: 12px 14px;

    font-size: 0.89rem;
    line-height: 1.5;
    text-decoration: none;

    color: var(--text-muted);

    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    transition:
        color 150ms ease,
        border-color 150ms ease,
        background-color 150ms ease;
}

.source-list a:hover {
    color: var(--text);
    background: var(--accent-soft);
    border-color: var(--accent-border);
}

.source-list__empty {
    margin: 0;

    font-size: 0.9rem;
    color: var(--text-subtle);
}


/* =========================================================
   Metod
   ========================================================= */

.method-grid {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 14px;

    min-width: 0;
}

.method-card {
    min-width: 0;
    padding: 23px;

    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
}

.method-card__number {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;
    margin-bottom: 20px;

    font-size: 0.8rem;
    font-weight: 750;

    color: var(--accent);

    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: 50%;
}

.method-card h3 {
    font-size: 1.04rem;
}

.method-card p {
    margin-bottom: 0;

    font-size: 0.88rem;
    line-height: 1.68;

    color: var(--text-muted);
}


/* =========================================================
   Arkiv och information
   ========================================================= */

.archive-card {
    margin-bottom: 24px;
}

.archive-card p:last-child {
    max-width: 780px;
    margin-bottom: 0;

    color: var(--text-muted);
}

.information-panel {
    margin-bottom: 44px;
    padding: 24px 26px;

    background: rgba(94, 182, 217, 0.055);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-medium);
}

.information-panel h2 {
    margin-bottom: 12px;
    font-size: 1rem;
}

.information-panel p {
    max-width: 900px;
    margin-bottom: 0;

    font-size: 0.9rem;
    line-height: 1.7;

    color: var(--text-muted);
}


/* =========================================================
   Sidfot
   ========================================================= */

.page-footer {
    padding: 22px 2px 0;

    font-size: 0.78rem;
    text-align: center;

    color: var(--text-subtle);

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

.page-footer p {
    margin: 0;
}


/* =========================================================
   Responsiv design
   ========================================================= */

@media (max-width: 1000px) {
    .report-meta {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

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

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


@media (max-width: 760px) {
    .page-container {
        width: min(
            calc(100% - 28px),
            var(--content-width)
        );
    }

    .page-header__navigation {
        margin-bottom: 34px;
    }

    .card {
        padding: 24px 20px;
        border-radius: 18px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .assessment {
        align-self: flex-start;
    }

    .section-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

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

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

    .space-weather-columns {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}


@media (max-width: 540px) {
    .page-container {
        width: min(
            calc(100% - 20px),
            var(--content-width)
        );

        padding-top:
            max(20px, env(safe-area-inset-top));
    }

    .page-header {
        margin-bottom: 24px;
    }

    .page-header__navigation {
        margin-bottom: 24px;
    }

    .back-link {
        margin-left: -8px;
    }

    .page-header::after {
        margin-top: 26px;
    }

    .page-introduction {
        font-size: 0.98rem;
        line-height: 1.65;
    }

    .report-meta {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .report-meta__item {
        padding: 15px 16px;
    }

    .card {
        padding: 20px 17px;
    }

    .assessment-card {
        margin-bottom: 44px;
    }

    .content-section {
        margin-bottom: 44px;
    }

    .event-card {
        min-height: 0;
        padding: 20px 18px;
    }

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

    .method-card {
        padding: 20px 18px;
    }

    .information-panel {
        padding: 20px 18px;
    }
}


/* =========================================================
   Tillgänglighet och reducerad rörelse
   ========================================================= */

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

    .back-link,
    .event-card,
    .source-list a {
        transition: none;
    }
}

/* =========================================================
   Dynamiska händelsekort
   ========================================================= */

.event-card__summary {
    margin-bottom: 18px;
}

.event-card__detail {
    margin-top: 18px;
    padding-top: 16px;

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

.event-card__detail h4,
.event-card__sources h4 {
    margin-bottom: 7px;

    font-size: 0.74rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;

    color: var(--text-subtle);
}

.event-card__detail p {
    margin-bottom: 0;
}

.event-card__sources {
    margin-top: 20px;
    padding-top: 16px;

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


/* =========================================================
   Dynamiska källänkar
   ========================================================= */

.source-link__title,
.source-link__provider,
.source-link__date {
    display: block;
}

.source-link__title {
    font-weight: 700;
    color: var(--text);
}

.source-link__provider {
    margin-top: 3px;

    font-size: 0.8rem;
    color: var(--text-muted);
}

.source-link__date {
    margin-top: 5px;

    font-size: 0.75rem;
    color: var(--text-subtle);
}

/* =========================================================
   Rapportarkiv
   ========================================================= */

.archive-introduction {
    margin-bottom: 20px;
    color: var(--text-muted);
}

.report-archive {
    min-width: 0;
}

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

.report-archive__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;

    min-width: 0;
    padding: 15px 16px;

    font: inherit;
    text-align: left;
    color: var(--text);

    cursor: pointer;

    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    transition:
        background-color 150ms ease,
        border-color 150ms ease,
        transform 150ms ease;
}

.report-archive__item:hover {
    transform: translateY(-1px);

    background: var(--accent-soft);
    border-color: var(--accent-border);
}

.report-archive__item:focus-visible {
    outline: 3px solid var(--accent-border);
    outline-offset: 3px;
}

.report-archive__item--selected {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.report-archive__date {
    font-size: 0.93rem;
}

.report-archive__details {
    font-size: 0.76rem;
    color: var(--text-subtle);
}

.report-archive__message {
    margin: 0;
    padding: 16px;

    color: var(--text-muted);

    background: var(--surface-soft);
    border: 1px dashed var(--border);
    border-radius: var(--radius-small);
}


@media (max-width: 850px) {
    .report-archive__list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}


@media (max-width: 540px) {
    .report-archive__list {
        grid-template-columns: 1fr;
    }
}