/*
Theme Name: Fyrliv 2026
Description: Opslagsværk i Nørre Lyngvig Fyrs logbog og fyrmester Ejnar Nedergaards dagbog 1906–1965. Kræver mu-plugin'et "Fyrliv API".
Version: 1.5
Text Domain: fyrliv
*/

:root {
    --paper: #f6f2ea;
    --card: #fffdf9;
    --ink: #1f2933;
    --muted: #5f6b76;
    --line: #e4dccd;
    --navy: #14304a;
    --accent: #b3261e;
    --logbog: #2b5c8a;
    --logbog-bg: #e8f0f8;
    --dagbog: #9a4a1c;
    --dagbog-bg: #f8ece2;
    --mark: #ffe08a;
    --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --topbar-h: 64px;
    /* Graffarver (validerede for farveblindhed og kontrast mod --card) */
    --chart-logbog: #1f66b3;
    --chart-dagbog: #b0521c;
    --chart-word: #0b8a72;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #11161c;
        --card: #19212a;
        --ink: #e6e1d8;
        --muted: #9aa5b1;
        --line: #2a3440;
        --navy: #0b1a29;
        --accent: #ef6b5f;
        --logbog: #8cb8e6;
        --logbog-bg: #1c2b3b;
        --dagbog: #f0a774;
        --dagbog-bg: #33241a;
        --mark: #7a5c00;
        --chart-logbog: #4a8fd9;
        --chart-dagbog: #cc7636;
        --chart-word: #2aa58c;
    }
}

html { scroll-padding-top: calc(var(--topbar-h) + 16px); }
/* clip (ikke hidden) — hidden gør body til scroll-container og ødelægger sticky topbar */
body { overflow-x: clip; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
}

a { color: var(--logbog); }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--topbar-h);
    padding-top: 8px;
    padding-bottom: 8px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
}
.brand img {
    background: #fff;
    border-radius: 50%;
    padding: 3px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.brand-sub { font-size: .75rem; opacity: .75; }

.search {
    position: relative;
    flex: 1;
    max-width: 520px;
    margin-left: auto;
}
.search .bi-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search .form-control {
    padding-left: 36px;
    border-radius: 999px;
    border: 0;
    background: #fff;
    color: #1f2933;
}
.btn-year {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 999px;
}
.btn-year:hover, .btn-year:focus { color: #fff; background: rgba(255, 255, 255, .1); }

/* Når man er logget ind, ligger WordPress' admin-bar fast i toppen */
.admin-bar .topbar { top: 32px; }
@media (max-width: 782px) { .admin-bar .topbar { top: 46px; } }
@media (max-width: 600px) { .admin-bar .topbar { top: 0; } }

@media (max-width: 575.98px) {
    .topbar-inner { flex-wrap: wrap; gap: 10px; }
    .brand-sub { display: none; }
    .btn-year { margin-left: auto; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
}

/* ---------- Hero ---------- */
.hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    background: #0b1a29;
    /* Højden følger indholdet (min. 46 % af skærmen) — en fast højde skar overskriften af på lave skærme. */
    min-height: clamp(300px, 46vh, 440px);
    display: flex;
    align-items: flex-end;
}
.hero[hidden] { display: none; }
.hero-media, .hero-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.hero-video { opacity: 0; transition: opacity 1s; }
.hero-video.playing { opacity: 1; }
.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(11, 26, 41, .15) 0%, rgba(11, 26, 41, .75) 100%);
}
.hero-content {
    position: relative;
    padding-top: 48px;
    padding-bottom: 36px;
}
.hero .hero-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    max-width: 22ch;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .4);
}
.hero-lead {
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    max-width: 52ch;
    opacity: .92;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Layout ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding-top: 28px;
    padding-bottom: 56px;
}
@media (min-width: 992px) {
    .layout { grid-template-columns: 250px minmax(0, 1fr); }
}
.main { min-width: 0; outline: none; }

/* ---------- År-vælger ---------- */
.years-sticky {
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
    max-height: calc(100vh - var(--topbar-h) - 40px);
    overflow-y: auto;
    padding-right: 4px;
}
.aside-title {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: 12px;
}
.decade { margin-bottom: 14px; }
.decade-label {
    font-family: var(--serif);
    font-size: .95rem;
    color: var(--muted);
    margin-bottom: 4px;
}
.decade-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}
.year-btn {
    position: relative;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 6px;
    padding: 5px 0;
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    text-align: center;
}
.year-btn:hover { border-color: var(--navy); color: var(--ink); }
.year-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.year-btn.empty { opacity: .4; pointer-events: none; border-style: dashed; }
.year-btn.has-dagbog::after, .years-legend .dot {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dagbog);
}
.years-legend { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.years-legend .dot { position: relative; display: inline-block; top: -1px; right: 0; margin-right: 4px; }

/* ---------- Filter ---------- */
.toolbar { display: flex; justify-content: flex-end; margin-bottom: 18px; }
.filter .btn {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    font-size: .9rem;
}
.filter .btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
}
.swatch-logbog { background: var(--logbog); }
.swatch-dagbog { background: var(--dagbog); }

/* ---------- Forside-tekst ---------- */
.prose {
    font-family: var(--serif);
    font-size: 1.1rem;
    line-height: 1.7;
    max-width: 70ch;
}
.prose .lead { font-size: 1.35rem; line-height: 1.45; margin-bottom: 1.5rem; }
.prose h2 { font-size: 1.4rem; margin-top: 2rem; }
.howto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    margin: 0 0 2rem;
    font-family: var(--sans);
    font-size: .95rem;
    line-height: 1.45;
}
.howto-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    text-align: left;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
}
.howto-card:hover { border-color: var(--navy); color: var(--ink); }
.howto-card .bi { font-size: 1.5rem; color: var(--accent); }

/* ---------- Fortællinger ---------- */
.stories { margin-bottom: 2rem; }
.section-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: clamp(1.4rem, 2.6vw, 1.8rem);
    margin-bottom: 4px;
}
.section-lead { color: var(--muted); margin-bottom: 14px; }
.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.story-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
    transition: border-color .2s, transform .2s;
}
.story-card:hover, .story-card:focus-visible { border-color: var(--navy); color: var(--ink); transform: translateY(-2px); }
.story-card .bi { font-size: 1.6rem; color: var(--accent); }
.story-card-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.story-card-teaser { font-size: .92rem; color: var(--muted); line-height: 1.4; }
.story-card-count { font-size: .8rem; color: var(--muted); margin-top: auto; padding-top: 4px; }

.today-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 2.5rem;
    align-items: stretch;
}
@media (max-width: 767.98px) { .today-row { grid-template-columns: minmax(0, 1fr); } }
.today {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--dagbog);
    border-radius: 10px;
    background: var(--card);
}
.today.logbog { border-left-color: var(--logbog); }
.today-title { font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.today-title .bi { color: var(--accent); }
.today-quote { font-family: var(--serif); font-size: 1.08rem; line-height: 1.6; margin: 6px 0 8px; overflow-wrap: anywhere; }
.today-more { font-size: .9rem; }
.today-count { font-size: .85rem; color: var(--muted); }
.surprise {
    display: flex;
    gap: 12px;
    align-items: center;
    text-align: left;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    font-size: .95rem;
    line-height: 1.4;
    max-width: 320px;
}
.surprise:hover { border-color: var(--navy); }
.surprise .bi { font-size: 1.6rem; color: var(--accent); }
@media (max-width: 767.98px) { .surprise { max-width: none; } }

.back-link { display: inline-block; margin-bottom: 10px; text-decoration: none; font-size: .95rem; }
.story-intro {
    font-family: var(--serif);
    font-size: 1.15rem;
    line-height: 1.65;
    max-width: 70ch;
    margin-bottom: 24px;
}
.story-entries { max-width: 75ch; }
.story-entry { margin-bottom: 12px; }
.story-entry .entry-text { margin: 6px 0 8px; }
.story-date { font-weight: 600; margin-right: 8px; }
.story-link { font-size: .9rem; text-decoration: none; }
.story-link:hover { text-decoration: underline; }

/* ---------- Statistik ---------- */
.stats-note { color: var(--muted); max-width: 75ch; margin-bottom: 20px; }
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-tile {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
}
.stat-label { font-size: .85rem; color: var(--muted); }
.stat-value { font-size: 1.9rem; font-weight: 600; line-height: 1.2; }
.stat-note { font-size: .8rem; color: var(--muted); }
.chart-card {
    padding: 18px 18px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    margin-bottom: 20px;
    min-width: 0;
}
.chart-title { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin-bottom: 4px; }
.chart-sub { color: var(--muted); font-size: .92rem; margin-bottom: 10px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .9rem; margin-bottom: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; background: currentColor; }
.legend-line { width: 18px; height: 2px; border-radius: 1px; background: currentColor; }
.s-logbog { color: var(--chart-logbog); }
.s-dagbog { color: var(--chart-dagbog); }
.s-word { color: var(--chart-word); }
.chart { position: relative; min-height: 220px; transition: opacity .2s; }
.chart.loading { opacity: .5; }
.chart-svg { display: block; max-width: 100%; height: auto; outline: none; touch-action: pan-y; }
.chart-svg:focus-visible { box-shadow: 0 0 0 2px var(--navy); border-radius: 4px; }
.chart-svg.pickable { cursor: pointer; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .baseline { stroke: var(--muted); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .mark { fill: currentColor; }
.chart-svg .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: currentColor; stroke: var(--card); stroke-width: 2; }
.chart-svg .hover-band { fill: var(--ink); opacity: .06; }
.chart-svg .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart-tip {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    min-width: 130px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
    font-size: .85rem;
}
.tip-year { font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip-row strong { font-size: .95rem; }
.tip-row span:last-child { color: var(--muted); }
.tip-key { width: 12px; height: 2px; border-radius: 1px; background: currentColor; flex-shrink: 0; }
.chart-table { margin-top: 8px; font-size: .9rem; }
.chart-table summary { color: var(--logbog); cursor: pointer; }
.stats-table { max-width: 420px; margin-top: 8px; --bs-table-bg: transparent; --bs-table-color: var(--ink); font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { border-color: var(--line); }
.stats-table td:not(:first-child), .stats-table th:not(:first-child) { text-align: right; }
.word-form { display: flex; gap: 8px; max-width: 420px; margin-bottom: 8px; }
.word-form .form-control { background: var(--paper); color: var(--ink); border-color: var(--line); }
.word-form .btn { background: var(--navy); border-color: var(--navy); color: #fff; }
.word-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.word-presets .day-chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.word-summary { min-height: 1.5em; margin-bottom: 4px; }

/* ---------- Læsevisning ---------- */
.view-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    margin-bottom: 14px;
}
.months, .days {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}
.months { margin-bottom: 10px; }
.days { margin-bottom: 22px; }
.month-btn, .day-chip {
    flex-shrink: 0;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: .9rem;
    text-decoration: none;
}
.month-btn:hover, .day-chip:hover { border-color: var(--navy); color: var(--ink); }
.month-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.month-btn.empty { opacity: .4; pointer-events: none; }
.day-chip {
    padding: 3px 10px;
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    text-align: center;
}

.day-group { margin-bottom: 26px; max-width: 75ch; }
/* Server-renderet års-side (inden appen tegner måneds-visningen) */
.year-intro { color: var(--muted); max-width: 75ch; margin-bottom: 18px; }
.month-heading { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; margin: 28px 0 12px; }
.day-heading {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    padding-bottom: 4px;
    margin-bottom: 12px;
}
.entry {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--logbog);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 10px;
    transition: box-shadow .3s, border-color .3s;
}
.entry.dagbog { border-left-color: var(--dagbog); }
.entry.flash { box-shadow: 0 0 0 3px var(--mark); }
.entry-meta { margin-bottom: 6px; }
.badge-type {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--logbog);
    background: var(--logbog-bg);
}
.badge-type.dagbog { color: var(--dagbog); background: var(--dagbog-bg); }
.entry-place { font-size: .85rem; color: var(--muted); margin-left: 6px; }
.entry-text {
    font-family: var(--serif);
    font-size: 1.08rem;
    line-height: 1.7;
    white-space: pre-line;
    overflow-wrap: anywhere;
    margin: 0;
}
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }

.pager {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    max-width: 75ch;
    margin-top: 28px;
}
.pager a {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
    min-width: 0;
}
.pager a:hover { border-color: var(--navy); }
.pager .next { margin-left: auto; text-align: right; }
.pager small { color: var(--muted); }

.notice {
    color: var(--muted);
    font-style: italic;
    padding: 20px 0;
}

/* ---------- Søgning ---------- */
.search-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search-summary { color: var(--muted); margin-bottom: 20px; }
.result-year {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 24px 0 8px;
}
.result {
    display: block;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--logbog);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
    margin-bottom: 8px;
    max-width: 75ch;
}
.result.dagbog { border-left-color: var(--dagbog); }
.result:hover { border-color: var(--navy); color: var(--ink); }
.result-date { font-weight: 600; margin-right: 8px; }
.result-snippet { font-family: var(--serif); display: block; margin-top: 6px; line-height: 1.55; overflow-wrap: anywhere; }

/* ---------- Footer ---------- */
.site-footer {
    background: var(--navy);
    color: rgba(255, 255, 255, .85);
    padding: 40px 0 24px;
    font-size: .95rem;
}
.site-footer a { color: #fff; }
.footer-label { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; opacity: .7; }
/* Reklame for ejendomsbud.dk — i ejendomsbud's egne farver og skrift */
.edb-ad {
    --edb-navy: #1B2E4A;
    --edb-gold: #D4A54A;
    --edb-gold-dark: #B8893A;
    --edb-sand: #F5F1EB;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px 24px;
    border-radius: 12px;
    background: linear-gradient(165deg, #FAF8F4 0%, #fff 50%, var(--edb-sand) 100%);
    border-top: 4px solid var(--edb-gold);
    color: var(--edb-navy);
    text-decoration: none;
    font-family: "DM Sans", var(--sans);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    transition: transform .2s, box-shadow .2s;
}
.site-footer .edb-ad { color: var(--edb-navy); }
.edb-ad:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, .25); }
.edb-ad-logo { font-family: "DM Serif Display", var(--serif); font-size: 1.3rem; letter-spacing: -.02em; }
.edb-ad-logo span { color: var(--edb-gold); }
.edb-ad-title { font-family: "DM Serif Display", var(--serif); font-size: 1.55rem; line-height: 1.15; color: #111D32; }
.edb-ad-title em { font-style: normal; color: var(--edb-gold-dark); }
.edb-ad-text { font-size: .92rem; line-height: 1.5; color: #4a5568; }
.edb-ad-trust { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; font-weight: 600; }
.edb-ad-trust .bi { color: var(--edb-gold-dark); }
.edb-ad-cta {
    align-self: flex-start;
    margin-top: 4px;
    padding: 9px 18px;
    border-radius: 8px;
    background: var(--edb-navy);
    color: #fff;
    font-weight: 600;
    font-size: .9rem;
}
.edb-ad:hover .edb-ad-cta { background: var(--edb-gold-dark); }
.copyright { text-align: center; opacity: .6; margin: 24px 0 0; font-size: .85rem; }

/* ---------- Offcanvas (mobil år-vælger) ---------- */
.offcanvas { background: var(--paper); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; }
}
