/* ------------------------------------------------------------------
   Northern Tales - layout
   Site header, nav, main grid, footer.
   ------------------------------------------------------------------ */

/* --- Site header --- */

.site-header {
    border-bottom: 1px solid var(--rule);
    background: var(--bg-header);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header-inner {
    max-width: 78rem;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.5rem;
    align-items: center;
}
.site-brand {
    display: inline-flex;
    flex-direction: column;
    color: var(--fg);
    text-decoration: none;
    line-height: 1.1;
}
.site-brand:hover { color: var(--accent); }
.site-name {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.site-tagline {
    color: var(--fg-muted);
    font-size: 0.92rem;
    font-style: italic;
    margin-top: 0.15rem;
}

.site-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.98rem;
}
.site-nav-list a {
    color: var(--fg);
    text-decoration: none;
    padding: 0.25rem 0;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
}
.site-nav-list a:hover,
.site-nav-list a:focus-visible {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.site-nav-list .nav-modern {
    color: var(--fg-muted);
    font-style: italic;
}

.lang-switcher {
    justify-self: end;
    font-size: 0.95rem;
}
.lang-switcher-link {
    color: var(--fg-muted);
    text-decoration: none;
    border: 1px solid var(--rule-strong);
    padding: 0.3rem 0.7rem;
    border-radius: 2px;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.lang-switcher-link:hover { color: var(--accent); border-color: var(--accent); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: end;
}

/* --- Search toggle --- */

.search-toggle {
    background: none;
    border: 1px solid var(--rule-strong);
    border-radius: 2px;
    padding: 0.3rem;
    cursor: pointer;
    color: var(--fg-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, border-color 0.2s ease;
    line-height: 1;
}
.search-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* --- Search dialog --- */

.search-dialog {
    border: none;
    border-radius: 6px;
    padding: 0;
    max-width: 42rem;
    width: 90vw;
    margin: 10vh auto;
    background: var(--bg);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
}
.search-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.search-dialog-inner { padding: 1.5rem; position: relative; }
.search-dialog-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--fg-muted);
    line-height: 1;
    padding: 0.25rem;
}
.search-dialog-close:hover { color: var(--accent); }


@media (max-width: 780px) {
    .site-header-inner {
        grid-template-columns: 1fr auto;
        gap: 0.75rem;
    }
    .site-nav-list { grid-column: 1 / -1; }
}

/* --- Main page grid --- */

.page {
    max-width: 78rem;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

/* --- Overview pages --- */

.overview { max-width: calc(var(--measure) + 3.4rem); }
.overview--wide { max-width: 74rem; }
.overview-head { margin-bottom: 1.5rem; }
.overview-title { margin-bottom: 0.5rem; }
.overview-lead {
    color: var(--fg-muted);
    font-size: 1.1rem;
    font-style: italic;
    margin: 0;
}
.overview-body > * + * { margin-top: var(--step); }
.overview-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    display: grid;
    gap: 1.25rem;
}
@media (min-width: 48rem) {
    .overview-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 72rem) {
    .overview--wide .overview-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.overview-item {
    border-left: 2px solid var(--rule-strong);
    padding: 0.75rem 1rem;
    border-radius: 3px;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.overview-item:hover {
    border-left-color: var(--bronze);
    background: var(--bg-raised);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}
.overview-item-title {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
}
.overview-item-title a { color: var(--fg); text-decoration: none; }
.overview-item-title a:hover { color: var(--accent); }
.overview-item-meta {
    color: var(--fg-muted);
    font-size: 0.92rem;
    font-style: italic;
    margin: 0 0 0.4rem;
}
.overview-item-short { margin: 0; color: var(--fg); }

/* --- Category hub --- */

.cat-hub {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    display: grid;
    gap: 1rem;
}
@media (min-width: 40rem) {
    .cat-hub { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 64rem) {
    .cat-hub { grid-template-columns: 1fr 1fr 1fr; }
}
.cat-card {
    display: block;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    text-decoration: none;
    color: var(--fg);
    background: var(--bg-raised);
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.cat-card:hover {
    border-color: var(--bronze);
    box-shadow: var(--shadow-card);
    transform: translateY(-2px);
}
.cat-card-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 0.3rem;
    color: var(--accent);
}
.cat-card-count {
    font-size: 0.88rem;
    color: var(--fg-muted);
    margin: 0 0 0.5rem;
}
.cat-card-desc {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.5;
}

/* --- Letter navigation --- */

.letter-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule);
}
.letter-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    padding: 0.3rem 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--fg-muted);
    text-decoration: none;
    border: 1px solid var(--rule);
    border-radius: 2px;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.letter-nav a:hover,
.letter-nav a:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg-raised);
}

.letter-section { margin-bottom: 2rem; }
.letter-heading {
    font-size: 1.4rem;
    margin: 0 0 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--rule);
}

/* --- Footer --- */

.site-footer {
    border-top: 1px solid var(--rule);
    margin-top: 4rem;
    background: var(--bg-raised);
}
.site-footer-inner {
    max-width: 78rem;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}
.footer-head {
    font-size: 1.05rem;
    margin: 0 0 0.5rem;
    color: var(--accent);
}
.footer-note {
    color: var(--fg-muted);
    font-size: 0.95rem;
    margin: 0;
    max-width: 50rem;
}
.site-footer-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.95rem;
    display: grid;
    gap: 0.3rem;
}
.site-footer-nav a {
    color: var(--fg-muted);
    text-decoration: none;
}
.site-footer-nav a:hover { color: var(--accent); text-decoration: underline; }
.site-footer-meta {
    grid-column: 1 / -1;
    margin: 1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    color: var(--fg-muted);
    font-size: 0.9rem;
}
.site-footer-meta [lang="non"] { font-style: italic; }

@media (max-width: 720px) {
    .site-footer-inner { grid-template-columns: 1fr; }
}

/* --- Home hero --- */

.home-hero {
    text-align: center;
    padding: 3rem 1.5rem 2.5rem;
    margin: -2.5rem -1.5rem 2rem;
    border-bottom: 1px solid var(--rule);
    background:
        radial-gradient(ellipse at 50% 60%, rgba(138, 106, 46, 0.07) 0%, transparent 60%);
}
.home-hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 2rem + 3vw, 4rem);
    font-weight: 600;
    color: var(--accent);
    letter-spacing: -0.01em;
    margin: 0 0 0.5rem;
    line-height: 1.05;
}
.home-hero-subtitle {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-style: italic;
    color: var(--fg-muted);
    margin: 0 0 1.5rem;
    letter-spacing: 0.02em;
}
.home-hero .ornament { margin: 0 auto; }


/* --- Section headings with decorative line --- */

.section-heading {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2.5rem 0 1.25rem;
}
.section-heading::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--rule-strong), transparent);
}
.section-heading h2 {
    margin: 0;
    white-space: nowrap;
}

/* --- Poem section color accents --- */

.section-accent-myth { border-left: 3px solid var(--moss); padding-left: 0.75rem; }
.section-accent-hero { border-left: 3px solid var(--bronze); padding-left: 0.75rem; }
.section-accent-extra { border-left: 3px solid var(--mist); padding-left: 0.75rem; }
.section-accent-myth h2 { color: var(--moss); }
.section-accent-hero h2 { color: var(--bronze); }
.section-accent-extra h2 { color: var(--mist); }


/* --- Breadcrumbs --- */

.breadcrumb { margin-bottom: 1.5rem; }
.breadcrumb-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    font-size: 0.88rem;
    font-family: var(--font-sans);
    color: var(--fg-muted);
}
.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    margin-right: 0.3rem;
    color: var(--rule-strong);
}
.breadcrumb-item a {
    color: var(--fg-muted);
    text-decoration: none;
}
.breadcrumb-item a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb-item [aria-current] { color: var(--fg); font-weight: 600; }

/* --- Back to top --- */

/* --- Privacy banner --- */

.privacy-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: var(--shadow);
    color: var(--parchment);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.9rem 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.25);
}
.privacy-banner[hidden] { display: none; }
.privacy-banner p { margin: 0; max-width: 48rem; }
.privacy-banner-ok {
    flex-shrink: 0;
    background: var(--gold-leaf);
    color: var(--shadow);
    border: none;
    padding: 0.4rem 1.2rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.privacy-banner-ok:hover { background: var(--bronze); }

@media (max-width: 600px) {
    .privacy-banner { flex-direction: column; gap: 0.75rem; text-align: center; }
}

/* --- Back to top --- */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 40;
    background: var(--bg-raised);
    color: var(--fg-muted);
    border: 1px solid var(--rule-strong);
    border-radius: 50%;
    width: 2.8rem;
    height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: opacity 0.25s ease, transform 0.25s ease, color 0.2s ease, border-color 0.2s ease;
    opacity: 0;
    transform: translateY(0.5rem);
    pointer-events: none;
}
.back-to-top[hidden] { display: flex; }
.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.back-to-top:hover { color: var(--accent); border-color: var(--accent); }

/* --- Poem prev/next navigation --- */

.poem-nav {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
    max-width: calc(var(--measure) + 3.4rem);
}
.poem-nav-link {
    text-decoration: none;
    color: var(--fg);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.75rem;
    border-radius: 3px;
    transition: background 0.2s ease, color 0.2s ease;
}
.poem-nav-link:hover {
    background: var(--bg-raised);
    color: var(--accent);
}
.poem-nav-dir {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
}
.poem-nav-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-style: italic;
}
.poem-nav-next { text-align: right; margin-left: auto; }
.poem-nav-prev::before { content: "← "; color: var(--fg-muted); }
.poem-nav-next::after { content: " →"; color: var(--fg-muted); }

@media (max-width: 500px) {
    .poem-nav { flex-direction: column; gap: 0.75rem; }
    .poem-nav-next { text-align: left; margin-left: 0; }
}

/* --- Progress bar for poems --- */

.poem-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.3rem;
}
.poem-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--rule);
    border-radius: 2px;
    overflow: hidden;
    max-width: 5rem;
}
.poem-progress-fill {
    height: 100%;
    background: var(--bronze);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.poem-progress-label {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--fg-muted);
    white-space: nowrap;
}
