/* Midvinterveckan 2627 – ljust tema är standard, mörkt läge via data-theme="dark" */

/* Mörkt tema */
:root {
    color-scheme: dark;
    --bg: #03262c;
    --bg-elev: #06333b;
    --bg-elev-2: #084049;
    --primary: #02434e;
    --accent: #e8a558;
    --accent-strong: #f2b878;
    --text: #eaf3f4;
    --muted: #97aeb5;
    --plum: #b06a8a;
    --teal-light: #6fc3cb;
    --green: #7fc98f;
    --btn-active: rgba(255, 255, 255, 0.12);
    /* Färger på mörka ytor (header, bottom-nav, hero) – samma i båda teman */
    --on-dark: #eaf3f4;
    --on-dark-muted: #97aeb5;
    --accent-strong-on-dark: #f2b878;
    --line: rgba(151, 174, 181, 0.25);
    --radius: 14px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* Ljust tema*/
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eef4f5;
    --bg-elev: #ffffff;
    --bg-elev-2: #dce8eb;
    --accent-strong: #9a5a12;
    --text: #14333b;
    --muted: #587178;
    --plum: #9c5578;
    --teal-light: #1f7f8a;
    --green: #3e8e57;
    --btn-active: rgba(18, 51, 58, 0.1);
}

* { box-sizing: border-box; }

/* [hidden] måste vinna över klassregler som sätter display (t.ex. .icon-btn, .btn) */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
}

/* ---------- Header ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--primary);
    color: var(--on-dark);
    border-bottom: 1px solid var(--line);
}
.app-icon { width: 44px; height: 44px; flex: none; border-radius: 10px; }
.app-title h1 { margin: 0; font-size: 1.15rem; line-height: 1.2; }
.app-title .subtitle { margin: 0; font-size: 0.78rem; color: var(--on-dark-muted); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.app-header .icon-btn { color: var(--on-dark); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
}
.icon-btn:active { background: var(--btn-active); }

/* Temaväxlaren: måne i ljust läge, sol i mörkt läge */
#theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* ---------- Main / views ---------- */
#main {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}
.view[hidden] { display: none; }
.view-title { margin: 4px 10px 14px; font-size: 1.4rem; }
.view {
    margin-bottom: 5em;
}
/* ---------- Hero ---------- */
.hero {
    position: relative;
    aspect-ratio: 4 / 3;
    margin-bottom: 16px;
    overflow: hidden;
}
.hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-img2 { width: 100%; height: 100%; object-fit: scale-down; display: block; }
.hero-overlay {
    width: 100%;
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    color: var(--on-dark);
    background: linear-gradient(to top, rgba(3, 38, 44, 0.92), rgba(3, 38, 44, 0.35) 55%, transparent);
}
.hero-overlay h2 { margin-left: auto; margin-right: auto; font-size: 2rem; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); }
.hero-dates { margin: 4px 0 0; font-weight: 600; color: var(--accent-strong-on-dark); }
.hero-place { margin: 2px 0 0; font-size: 0.9rem; color: var(--on-dark); }

/* ---------- Kort och händelser (delad ruta) ---------- */
.card, .event {
    background: var(--bg-elev);
    border: 1px solid var(--line);
}
.card { padding: 16px; margin-bottom: 16px; }
.card h3, .modal h3 { margin: 0 0 8px; color: var(--accent-strong); }
.card h3 { font-size: 1.05rem; }
.card p, .modal p { margin: 0 0 12px; }
.card p:last-child { margin-bottom: 0; }
.news-item { padding: 8px 0; }
.news-item:first-child { padding-top: 0; }
.news-item + .news-item { border-top: 1px solid var(--line); }
.news-item:last-child { padding-bottom: 0; }
.news-item h4 { margin: 0 0 4px; font-size: 0.95rem; }
.news-item p { margin: 0; }

/* ---------- Knappar ---------- */
.btn {
    display: inline-block;
    padding: 12px 18px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary, .btn-secondary { border: 1px solid var(--line); }
.btn-primary { background: var(--primary); color: var(--on-dark); }
.btn-accent { background: var(--accent); color: #2b1a08; }
.btn-accent:active { background: var(--accent-strong); }
.btn-secondary { background: var(--bg-elev-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-small { padding: 8px 14px; font-size: 0.9rem; }

/* ---------- Karta (Leaflet) ---------- */
.map {
    position: relative;
    z-index: 0; /* håller kartans panes under header/bottom-nav */
    height: 260px;
    margin-top: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-elev-2);
}
.leaflet-popup-content { margin: 10px 14px; }
.leaflet-popup-content a { color: var(--accent-strong); }

/* ---------- Schema ---------- */
.day-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-left: 5px;
    padding-right: 5px;
    margin-bottom: 6px;
    padding-bottom: 10px;
    scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
    flex: none;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-elev);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.day-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #2b1a08; }

.events { display: flex; flex-direction: column; gap: 12px; }
.event { padding: 12px 14px; border-left: 4px solid var(--tc, var(--muted)); }

/* Eventtyp: --tc = kantfärg på händelsen, --tc-text = textfärg på chip */
.type-möte { --tc: var(--accent); --tc-text: var(--accent-strong); }
.type-workshop { --tc: var(--plum); --tc-text: var(--plum); }
.type-måltid { --tc: var(--green); --tc-text: var(--green); }
.type-samling { --tc: var(--teal-light); --tc-text: var(--teal-light); }
.type-info { --tc: var(--muted); }

.event-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.event-time { font-weight: 700; color: var(--accent-strong); font-variant-numeric: tabular-nums; white-space: nowrap; }
.event-title { font-weight: 600; font-size: 1.02rem; }
.event-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}
.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--bg-elev-2);
    color: var(--tc-text, var(--text));
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.event-desc { margin: 8px 0 0; font-size: 0.92rem; }
.error { color: var(--accent-strong); }
.schedule-note { margin: 14px 10px 0; font-size: 0.85rem; color: var(--muted); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed;
    left: 50%;
    right: 0;
    bottom: 0;
    width: 100vw;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    padding-bottom: var(--safe-bottom);
    background: rgba(2, 67, 78, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 10px;
    color: var(--on-dark-muted);
    font-size: 0.72rem;
    text-decoration: none;
}
.nav-item.active { color: var(--accent-strong-on-dark); }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(1, 18, 21, 0.7);
}
.modal-backdrop[hidden] { display: none; }
.modal {
    position: relative;
    width: 100%;
    max-width: 480px;
    padding: 24px 20px calc(20px + var(--safe-bottom));
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    text-align: center;
    animation: sheet-up 0.25s ease-out;
}
@keyframes sheet-up {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
/* Stängning: samma rörelse som vid öppning, fast omvänt */
.modal.closing {
    animation: sheet-down 0.25s ease-in forwards;
}
@keyframes sheet-down {
    from { transform: translateY(0);    opacity: 1; }
    to   { transform: translateY(30px); opacity: 0; }
}
.modal-icon { border-radius: 16px; margin-bottom: 10px; }
.modal-hint { font-size: 0.88rem; color: var(--muted); margin-top: 10px; }
.modal h3 { font-size: 1.2rem; }
.modal-close { position: absolute; top: 10px; right: 10px; }
.ios-steps { margin: 0 0 12px; padding-left: 22px; text-align: left; }
.ios-steps li { margin-bottom: 8px; }

@media (min-width: 870px) {
    .modal-backdrop { align-items: center; }
    .modal { border-bottom: 1px solid var(--line); border-radius: 18px; }
    .bottom-nav { width: 870px}
}

/* Bilder */
.edited-img {
    align-items: center;
    justify-content: center;
    flex-direction: column;
    width: 80vw;
    max-width: 480px;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
}

.margin-x {
    margin-left: 1em;
    margin-right: 1em;
}