/*
 * mattsin.se – återskapad design från 2006 (glaspaneler över himmel och äng),
 * byggd mobile first. Brytpunkter: 768px (surfplatta), 1024px (originalets
 * tvåkolumnslayout), 1440px (maxbredd).
 */

:root {
    /* Färger (uppmätta från originalet) */
    --text: #000;
    --muted: #2b2b2b;
    --glass: rgba(255, 255, 255, .58);
    --glass-strong: rgba(255, 255, 255, .78);
    --glass-edge: rgba(255, 255, 255, .8);
    --sky: #4f8fd6;
    --focus: #0b3d91;
    --error-bg: #fde8e8;
    --error-text: #8a1111;
    --ok-bg: #e6f4e8;

    /* Typografi – systemtypsnitt som originalet, inga webbfonter att ladda */
    --font: Tahoma, Verdana, "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-menu: Verdana, Tahoma, "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, Consolas, "Courier New", monospace;

    /* Avstånd */
    --s1: .25rem;
    --s2: .5rem;
    --s3: .75rem;
    --s4: 1rem;
    --s5: 1.5rem;
    --s6: 2rem;
    --radius: 12px;
}

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

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
    background: var(--sky);
}

/* ------------------------------------------------------------------ Bakgrund */

.bg img {
    position: fixed;
    inset: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Håll det rosa trädet (nere till höger) i bild även på smala skärmar. */
    object-position: 78% 100%;
}

/* ------------------------------------------------------------------ Glas */

.glass {
    background: var(--glass);
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0, 40, 90, .12), inset 0 1px 0 rgba(255, 255, 255, .7);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .glass {
        -webkit-backdrop-filter: blur(3px) saturate(1.1);
        backdrop-filter: blur(3px) saturate(1.1);
    }
}

/* ------------------------------------------------------------------ Grundlayout (mobil) */

.shell {
    display: flex;
    flex-direction: column;
    gap: var(--s4);
    max-width: 90rem;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: var(--s4);
}

.skip-link {
    position: absolute;
    left: var(--s4);
    top: -100px;
    z-index: 10;
    padding: var(--s2) var(--s4);
    background: #fff;
    color: var(--text);
    font-weight: bold;
    border-radius: 6px;
}

.skip-link:focus { top: var(--s4); }

/* ------------------------------------------------------------------ Meny */

.menu {
    padding: var(--s2) var(--s4);
    font-family: var(--font-menu);
}

.menu-title {
    margin: var(--s1) 0 var(--s2);
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
}

.menu-list {
    margin: 0 0 var(--s2);
    padding: 0;
    list-style: none;
}

.menu-list li + li { margin-top: 2px; }

.menu-list a {
    display: block;
    padding: .45rem var(--s2);
    color: var(--text);
    font-weight: bold;
    font-size: .95rem;
    text-decoration: none;
    border-radius: 6px;
}

.menu-list a:hover { text-decoration: underline; }

.menu-list a[aria-current="page"] {
    background: var(--glass-strong);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* Knapp som fäller ut menyn på små skärmar. */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    width: 100%;
    min-height: 44px;
    padding: var(--s2);
    font: bold 1.1rem var(--font);
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.menu-toggle:hover { background: var(--glass-strong); }

.menu-toggle-icon,
.menu-toggle-icon::before,
.menu-toggle-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}

.menu-toggle-icon { position: relative; }
.menu-toggle-icon::before,
.menu-toggle-icon::after { content: ""; position: absolute; left: 0; }
.menu-toggle-icon::before { top: -6px; }
.menu-toggle-icon::after { top: 6px; }

/*
 * Mobil: menyn är hopfälld från första ritningen – styrt av CSS, inte av JS. Om JS fällde
 * ihop den efteråt skulle innehållet hoppa upp (layoutskift, CLS). JS öppnar/stänger bara.
 * Utan JS visar nojs.css (i <noscript>) hela listan i stället.
 */
.menu-title { display: none; }
.menu-list { display: none; }
.menu.is-open .menu-list { display: block; margin-top: var(--s2); }

/* ------------------------------------------------------------------ Innehåll */

.content {
    flex: 1;
    min-width: 0;
}

.content:focus { outline: none; }

.tab {
    display: inline-block;
    max-width: 100%;
    margin: 0 0 -1px var(--s4);
    padding: var(--s2) var(--s4);
    font-size: 1.2rem;
    line-height: 1.3;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
    position: relative;
    z-index: 1;
}

.panel {
    padding: var(--s4);
    overflow-wrap: anywhere;
}

.section + .section {
    margin-top: var(--s5);
    padding-top: var(--s4);
    border-top: 1px solid rgba(0, 0, 0, .15);
}

h2 {
    margin: 0 0 var(--s3);
    font-size: 1.15rem;
    line-height: 1.3;
}

h3 { margin: var(--s4) 0 var(--s2); font-size: 1rem; }

p { margin: 0 0 var(--s3); }

a {
    color: var(--text);
    font-weight: bold;
}

/* Länkar i löptext är understrukna (färg är inte ensam skillnad mot vanlig text). */
.panel a { text-decoration: underline; text-underline-offset: 2px; }
.panel a:hover { text-decoration-thickness: 2px; }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 3px;
}

.prose > :last-child { margin-bottom: 0; }

.muted { color: var(--muted); font-weight: normal; }

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

/* ------------------------------------------------------------------ Listor */

.link-list,
.episode-list {
    margin: 0;
    padding-left: 1.25rem;
}

.link-list li,
.episode-list li { margin-bottom: var(--s2); }

.link-description { margin: var(--s1) 0 0; font-size: .95rem; }

.episode-list .muted { display: block; font-size: .9rem; }
.episode-list .muted a { font-weight: normal; }

.episode-list a[aria-current="true"] {
    background: var(--glass-strong);
    padding: 0 var(--s1);
    border-radius: 4px;
}

.value-list { margin: 0; padding: 0; list-style: none; }

.credits { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s4); margin: 0 0 var(--s4); }
.credits dt { font-weight: bold; }
.credits dd { margin: 0; }

/* ------------------------------------------------------------------ Formulär */

label { font-weight: bold; }

input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    min-height: 44px;
    padding: var(--s2) var(--s3);
    font: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid #5c6b7a;
    border-radius: 6px;
}

textarea { min-height: 8rem; resize: vertical; }

input[aria-invalid="true"],
textarea[aria-invalid="true"] { border: 2px solid var(--error-text); }

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: var(--s2) var(--s5);
    font: bold 1rem var(--font);
    color: #fff;
    background: #1f4f8a;
    border: 0;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
}

.panel .button { text-decoration: none; color: #fff; }

button:hover,
.button:hover { background: #163c6b; }

button.secondary { color: var(--text); background: #fff; border: 1px solid #5c6b7a; }
button.secondary:hover { background: #eef2f6; }

.inline-form {
    display: grid;
    gap: var(--s2);
    max-width: 36rem;
}

.stack-form {
    display: grid;
    gap: var(--s2);
    max-width: 36rem;
}

.stack-form button { justify-self: start; }

.help { margin: 0; font-size: .9rem; color: var(--muted); }

.field-error {
    margin: 0;
    color: var(--error-text);
    font-weight: bold;
    font-size: .95rem;
}

.alert {
    padding: var(--s3) var(--s4);
    background: var(--glass-strong);
    border-radius: 6px;
}

.alert-error { background: var(--error-bg); color: var(--error-text); font-weight: bold; }

/* Swish */
.swish-form { display: grid; gap: var(--s4); max-width: 36rem; }

.swish-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--s1) var(--s3);
    align-items: center;
}

.swish-row > label:first-child { grid-column: 1 / -1; }
.swish-row .help,
.swish-row .field-error { grid-column: 1 / -1; }

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    min-height: 44px;
    font-weight: normal;
    white-space: nowrap;
}

.checkbox input { width: 1.25rem; height: 1.25rem; }

.swish-form button { justify-self: start; }

.swish-result { margin-top: var(--s5); }

.code-output {
    font-family: var(--mono);
    font-size: .85rem;
    word-break: break-all;
}

.button-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s3) 0; }

.qr {
    display: block;
    width: 220px;
    height: 220px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
}

/* ------------------------------------------------------------------ Tabeller */

.table-wrap {
    overflow-x: auto;
    margin: 0 0 var(--s4);
    background: rgba(255, 255, 255, .45);
    border-radius: 6px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.data-table th,
.data-table td {
    padding: var(--s2) var(--s3);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(0, 0, 0, .15);
}

.data-table { overflow-wrap: normal; }
.data-table thead th,
.data-table td:first-child,
.data-table td:nth-child(2) { white-space: nowrap; }
.data-table .value { overflow-wrap: anywhere; min-width: 14rem; }
.data-table .value-list li { white-space: nowrap; }

.results-heading { margin-top: var(--s5); }

/* ------------------------------------------------------------------ Video / podd */

.video {
    display: block;
    width: 100%;
    max-height: 75vh;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
}

.player { margin-bottom: var(--s4); }
.player-now { margin-top: var(--s2); }
.feed-link { font-size: .95rem; }

/* ------------------------------------------------------------------ Sidfot */

.site-footer {
    display: flex;
    justify-content: center;
    padding-bottom: var(--s2);
}

.pill {
    display: inline-block;
    padding: var(--s1) var(--s4);
    font-size: .85rem;
    font-weight: normal;
    color: var(--text);
    text-decoration: none;
    border-radius: 999px;
}

.pill:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ 768px: surfplatta */

@media (min-width: 768px) {
    .shell { padding: var(--s6); gap: var(--s5); }
    .panel { padding: var(--s5) var(--s6); }
    .tab { font-size: 1.3rem; margin-left: var(--s5); }

    .inline-form {
        grid-template-columns: auto 1fr auto;
        align-items: center;
    }

    .swish-row { grid-template-columns: 9rem 1fr auto; }
    .swish-row > label:first-child { grid-column: auto; }
    .swish-row .help,
    .swish-row .field-error { grid-column: 2 / -1; }
}

/* ------------------------------------------------------------------ 1024px: originalets layout */

@media (min-width: 1024px) {
    body { font-size: .9375rem; }

    .shell {
        display: grid;
        grid-template-columns: 13.5rem minmax(0, 1fr);
        grid-template-rows: 1fr auto;
        column-gap: 4vw;
        padding: 10vh 4vw var(--s5);
    }

    /* Menyn alltid utfälld – knappen behövs inte. */
    .menu { align-self: start; position: sticky; top: var(--s5); }
    .menu-toggle { display: none; }
    .menu-title,
    .menu-list { display: block; }

    /* Innehållet börjar lite lägre än menyn och panelen är hög, som i originalet. */
    .content { margin-top: 10vh; }
    .panel { min-height: 55vh; }

    .site-footer { grid-column: 2; }
}

@media (min-width: 1440px) {
    .shell { column-gap: 5rem; }
    .content { max-width: 64rem; }
}

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

@media print {
    .bg, .menu, .site-footer, .skip-link { display: none; }
    .glass { background: none; border: 0; box-shadow: none; }
}
