/* Extras — small overrides on top of theme.json defaults */

/* ─────────── Logo (two variants: full text + mini turtle) ─────────── */
.fretta-logo {
    display: inline-block;
    line-height: 0;
    margin: 5px;
}
.fretta-logo img { width: auto; }
.fretta-logo img.fretta-logo--full { display: block; height: 72px; }
.fretta-logo img.fretta-logo--mini { display: none; }      /* hidden by default */

/* On mobile: container width 125px (matches live site), full text logo 105px tall */
@media (max-width: 720px) {
    .fretta-logo { width: 125px; }
    .fretta-logo img.fretta-logo--full { height: 105px; }
}

/* ─────────── Nav bar — break out to viewport regardless of WP layout ─────────── */
.fretta-nav.alignfull,
.fretta-nav {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    box-sizing: border-box;
}
/* but the inner ul should still center within 1170px */
.fretta-nav > .wp-block-navigation {
    max-width: 1170px;
    margin-left: auto;
    margin-right: auto;
}

/* ─────────── Nav items — labels include slashes/brackets, no pseudo wrap ─────────── */
.fretta-nav .wp-block-navigation-item__content {
    text-transform: lowercase;
    font-family: var(--wp--preset--font-family--label);
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
    color: var(--wp--preset--color--ink);
    padding: 0;
    line-height: 1;
}
.fretta-nav a:hover { text-decoration: underline; color: var(--wp--preset--color--ink); }

/* ─────────── Pinned nav: JS toggles `.is-fixed` on scroll ─────────── */
body { overflow-x: clip; }

/* The wrapper inserted by sticky-nav.js holds the nav's space when nav is
   fixed, so the page doesn't jitter when scrolling past the threshold. */
.fretta-nav-wrapper { width: 100%; }

.fretta-nav {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.fretta-nav.is-fixed {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
}

/* Mobile overlay menu — same look as the desktop strip, items centred */
.fretta-nav .wp-block-navigation__responsive-container.is-menu-open {
    background-color: var(--wp--preset--color--accent-bar) !important;
    color: var(--wp--preset--color--ink) !important;
}
.fretta-nav .wp-block-navigation__responsive-container.is-menu-open
    .wp-block-navigation__container {
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    gap: 0.25rem !important;
}
.fretta-nav .wp-block-navigation__responsive-container.is-menu-open
    .wp-block-navigation-item {
    width: 100%;
    text-align: center;
}
.fretta-nav .wp-block-navigation__responsive-container.is-menu-open
    .wp-block-navigation-item__content {
    display: inline-block;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    transition: background 120ms ease, color 120ms ease;
    border-radius: 2px;
}
/* Mouseover effect — matches fretta.no's hover behaviour */
.fretta-nav .wp-block-navigation-item__content:hover,
.fretta-nav .wp-block-navigation-item__content:focus {
    background: rgba(0, 0, 0, 0.08);
    color: var(--wp--preset--color--ink-dark) !important;
    text-decoration: none !important;
}
/* Mobile hamburger — replace SVG with legacy PNG icons */
.fretta-nav .wp-block-navigation__responsive-container-open svg,
.fretta-nav .wp-block-navigation__responsive-container-close svg {
    display: none;
}
.fretta-nav .wp-block-navigation__responsive-container-open,
.fretta-nav .wp-block-navigation__responsive-container-close {
    background: transparent;
    border: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
}
.fretta-nav .wp-block-navigation__responsive-container-open {
    background: url('images/icon-menu.png') center/40px 40px no-repeat;
    /* Invert white→dark so it reads on the light strip (desktop) */
    filter: invert(35%) sepia(15%) saturate(800%) hue-rotate(160deg);
}
.fretta-nav .wp-block-navigation__responsive-container-close {
    background: url('images/hamburger_lukk.png') center/40px 40px no-repeat;
}

/* ─────────── Mobile: streamlined header ─────────── */
@media (max-width: 720px) {
    .fretta-header { position: relative; }

    /* Reposition the topbar as a small fixed element next to the icons.
       Show only the user action link (Velkomen / Logg ut), hide date + the
       extra parts (Min side, display name etc). */
    .fretta-topbar {
        position: fixed;
        top: 55px;
        right: 115px;            /* left of search-trigger(65) + hamburger(15) */
        z-index: 250;
        background: transparent !important;
        padding: 0 !important;
        width: auto !important;
        height: auto !important;
        min-width: 0 !important;
    }
    .fretta-topbar > .wp-block-group { display: block !important; }
    /* Hide the date (first shortcode inside the topbar) */
    .fretta-topbar .wp-block-shortcode:first-child { display: none !important; }
    /* Hide everything in the user menu except the action link */
    .fretta-user-greet,
    .fretta-user-name,
    .fretta-user-sep,
    .fretta-user-page { display: none !important; }
    .fretta-user,
    .fretta-user a,
    .fretta-user strong {
        font-size: 0.875rem;
        color: #fff;
        font-family: var(--wp--preset--font-family--label);
    }
    /* When scrolled (compact header), shift the user link up to match */
    body.is-scrolled-mobile .fretta-topbar {
        top: 16px;
        right: 90px;             /* compact icons: 25px hamburger at 15, 25px search at 50 */
    }

    /* Move the hamburger to the top-right of the viewport. position:fixed
       avoids the WP navigation block's own position:relative interfering
       with the absolute containing-block chain. */
    .fretta-nav .wp-block-navigation__responsive-container-open {
        position: fixed;
        top: 45px;
        right: 15px;
        z-index: 250;            /* above the fixed header (200) */
        filter: none;            /* white icon on dark teal — visible as-is */
    }

    /* Collapse the empty nav strip + its placeholder wrapper completely on
       mobile so the page doesn't render a thin white/blue separator line
       between the dark header and the content below. */
    .fretta-nav {
        min-height: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    .fretta-nav-wrapper {
        min-height: 0 !important;
        height: 0 !important;
        overflow: visible !important;  /* keep so the absolute hamburger isn't clipped */
    }
}

/* ─────────── Mobile: always-fixed header (matches live fretta.no) ─────────── */
@media (max-width: 720px) {
    .fretta-header {
        position: fixed !important;
        top: 0; left: 0; right: 0;
        z-index: 200;
        box-shadow: none !important;     /* no shadow under mobile header */
    }
    .fretta-nav { box-shadow: none !important; }

    /* The JS-inserted nav wrapper is position:relative; that makes the
       absolute hamburger position from the wrapper instead of the header.
       Force static on mobile so the button anchors to .fretta-header. */
    .fretta-nav-wrapper { position: static !important; }
    /* Reserve space below the fixed header — value matches the *initial*
       (un-scrolled) header height so content lines up cleanly at top of page. */
    body { padding-top: 130px; }
    /* When scrolled past the threshold, the header is compact, so less padding */
    body.is-scrolled-mobile { padding-top: 55px; }

    /* Compact-state visuals (turtle + smaller hamburger) */
    body.is-scrolled-mobile .fretta-logo img.fretta-logo--full { display: none; }
    body.is-scrolled-mobile .fretta-logo img.fretta-logo--mini {
        display: block;
        height: 35px;
        width: auto;
    }
    body.is-scrolled-mobile .fretta-header-band { padding: 6px 1rem !important; }
    body.is-scrolled-mobile .fretta-nav .wp-block-navigation__responsive-container-open {
        width: 25px;
        height: 25px;
        background-size: 25px 25px;       /* icon fills the button */
        top: 12px;
        right: 15px;
    }
}

/* ─────────── "/ category /" list label ─────────── */
.fretta-cat-badge::before { content: "/ "; opacity: .55; }
.fretta-cat-badge::after  { content: " /"; opacity: .55; }
.fretta-cat-badge {
    font-family: var(--wp--preset--font-family--label);
    font-size: 0.875rem;
    text-transform: lowercase;
    color: var(--wp--preset--color--muted);
}

/* ─────────── Date / utility bar at very top ─────────── */
.fretta-topbar {
    font-family: var(--wp--preset--font-family--label);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--wp--preset--color--on-ink);
}
.fretta-topbar p,
.fretta-topbar .wp-block-shortcode { margin: 0; font-size: 0.75rem; color: #ffffff; }

/* User-menu shortcode rendered inside the top strip */
.fretta-topbar .fretta-user,
.fretta-topbar .fretta-user a,
.fretta-topbar .fretta-user strong {
    color: #ffffff;
    font-family: var(--wp--preset--font-family--label);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}
.fretta-topbar .fretta-user a { text-decoration: none; }
.fretta-topbar .fretta-user a:hover { text-decoration: underline; }

/* ─────────── Search: separate input + icon button (matches legacy) ─────────── */
.fretta-search {
    display: inline-flex;
    align-items: stretch;
    gap: 0.4rem;
    width: 320px;
    max-width: 100%;
    height: 32px;
    background: transparent;
    border: 0;
}
.fretta-search input[type="search"] {
    flex: 1 1 auto;
    border: 0;
    outline: none;
    padding: 0 0.6rem;
    font-family: var(--wp--preset--font-family--body);
    font-size: 0.8125rem;
    color: var(--wp--preset--color--ink);
    background: #ffffff;
    min-width: 0;
    height: 100%;
}
.fretta-search input[type="search"]::placeholder { color: #98a4ab; }
.fretta-search button {
    flex: 0 0 auto;
    background: transparent;       /* inherits dark header behind */
    border: 0;
    padding: 0;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.fretta-search button img {
    width: 18px;
    height: 18px;
    display: block;
    /* legacy icon is white-on-transparent — perfect on dark teal header */
}
/* Mobile: hide the desktop in-band search; the search form lives in the
   menu overlay (JS clones it from the <template> in the header). */
@media (max-width: 720px) {
    .fretta-header-band .fretta-search { display: none; }

    /* Form injected at the top of the open navigation overlay */
    .fretta-search-mobile-overlay {
        display: flex;
        align-items: stretch;
        gap: 0;
        width: calc(100% - 30px);
        max-width: 360px;
        height: 36px;
        margin: 0 auto 1rem auto;
        background: #fff;
        border: 0;
    }
    .fretta-search-mobile-overlay input[type="search"] {
        flex: 1 1 auto;
        border: 0;
        outline: none;
        padding: 0 0.6rem;
        font-family: var(--wp--preset--font-family--body);
        font-size: 0.875rem;
        color: var(--wp--preset--color--ink);
        background: #fff;
        min-width: 0;
        height: 100%;
    }
    .fretta-search-mobile-overlay input[type="search"]::placeholder {
        color: #98a4ab;
    }
    .fretta-search-mobile-overlay button {
        flex: 0 0 auto;
        background: var(--wp--preset--color--ink-dark);
        border: 0;
        padding: 0;
        width: 40px;
        height: 100%;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .fretta-search-mobile-overlay button img {
        width: 20px;
        height: 20px;
        display: block;
    }
}

/* ─────────── Top accent bar (the powder-blue 7px stripe) ─────────── */
.fretta-article-col::before,
.fretta-related-box::before {
    content: '';
    display: block;
    height: 7px;
    background: var(--wp--preset--color--accent-bar);
    margin-bottom: 1rem;
}

/* ─────────── Article meta (date + byline) ─────────── */
.fretta-meta {
    font-family: var(--wp--preset--font-family--label);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wp--preset--color--muted);
}

/* ─────────── Hairline divider ─────────── */
.fretta-hairline {
    border-top: 1px solid var(--wp--preset--color--rule);
    margin: 2rem 0;
}

/* ─────────── Featured-image baseline ─────────── */
.wp-block-post-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Card featured images: crop to a fixed landscape box.
   We size the *figure* (a normal container) and let the <img> fill it with
   object-fit:cover. Relying on aspect-ratio on the <img> alone is unreliable
   because the theme's `height:auto` lets portrait images keep their native
   (tall) height — making the figure the box sidesteps that entirely. */
.fretta-card-media,
.fretta-card-media-sm {
    display: block;
    overflow: hidden;
    width: 100%;
}
.fretta-card-media    { aspect-ratio: 16 / 9; }   /* front-page lead column */
.fretta-card-media-sm { aspect-ratio: 4 / 3; }    /* sidebar cards */
.fretta-card-media img,
.fretta-card-media-sm img,
.fretta-card-media a,
.fretta-card-media-sm a {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ─────────── Inline body images: width from eZ embed `class` ───────────
   Default (no lock class) → full content width, matching the legacy site.
   `image_lock_size` → locked to 199px, floated left with the text wrapping
   around it (the classic eZ small-portrait/logo treatment, usually
   captioned). */
.entry-content figure.wp-block-image img { height: auto; max-width: 100%; }
.entry-content figure.wp-block-image            { margin-left: auto; margin-right: auto; }

.entry-content figure.is-style-fretta-large {
    max-width: 100%;
}
.entry-content figure.is-style-fretta-large img {
    width: 100%;       /* fill the content column */
}

.entry-content figure.is-style-fretta-locked {
    max-width: 199px;
    width: fit-content;
    /* Beat the constrained-layout `margin:auto !important` that otherwise
       centres every direct child of the post content. */
    margin: 0.5rem auto 1rem 0;
    margin-left: 0 !important;
    margin-right: auto !important;
    text-align: left;
}
.entry-content figure.is-style-fretta-locked img {
    width: auto;
    max-width: 199px;   /* cap at 199px; don't upscale smaller originals */
    height: auto;
}

/* Legacy size classes kept for any hand-edited posts (no longer emitted) */
.entry-content figure.is-style-fretta-byline-portrait,
.entry-content figure.is-style-fretta-small {
    max-width: 180px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}
.entry-content figure.is-style-fretta-medium {
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.entry-content figure.alignleft  { float: left;  margin: 0.3rem 1.5rem 1rem 0; }
.entry-content figure.alignright { float: right; margin: 0.3rem 0 1rem 1.5rem; }
.entry-content figure.aligncenter { float: none; clear: both; margin-left: auto; margin-right: auto; }

/* On mobile, drop all floats and centre every figure */
@media (max-width: 720px) {
    .entry-content figure.alignleft,
    .entry-content figure.alignright,
    .entry-content figure.aligncenter,
    .entry-content figure.is-style-fretta-byline-portrait,
    .entry-content figure.is-style-fretta-small,
    .entry-content figure.is-style-fretta-medium,
    .entry-content figure.is-style-fretta-locked,
    .entry-content figure.is-style-fretta-large {
        float: none !important;
        clear: both;
        margin-left: auto !important;
        margin-right: auto !important;
        display: block;
        text-align: center;
    }
}

.entry-content figure figcaption,
.entry-content figure .wp-element-caption {
    font-family: var(--wp--preset--font-family--label);
    font-size: 0.8125rem;
    line-height: 1.4;
    text-align: center;
    color: var(--wp--preset--color--muted);
    margin-top: 0.5rem;
    font-style: italic;
}

.entry-content { overflow: hidden; }

/* ─────────── Body paragraph rhythm ─────────── */
.entry-content > .wp-block-paragraph {
    font-size: 1.0625rem;
    line-height: 1.7;
}

/* ─────────── Card titles ─────────── */
.fretta-card-title a {
    font-family: var(--wp--preset--font-family--headline);
    font-weight: 500;
    color: var(--wp--preset--color--ink);
    text-decoration: none;
}
.fretta-card-title a:hover { text-decoration: underline; }

/* ─────────── Mobile title overrides ─────────── */
@media (max-width: 720px) {
    /* Front-page card titles: klavika_boldbold, 26px, weight 100 */
    .fretta-card-title,
    .fretta-card-title a,
    .wp-block-post-title.fretta-card-title,
    .wp-block-post-title.fretta-card-title a {
        font-family: "Klavika-Bold", "Klavika-Regular", "Helvetica Neue", Arial, sans-serif !important;
        font-size: 26px !important;
        font-weight: 100 !important;
        line-height: 1.15 !important;
    }

    /* Single article H1: klavika_boldbold, 26px, weight 400 */
    .fretta-article-col .wp-block-post-title,
    .fretta-article-col .wp-block-post-title a {
        font-family: "Klavika-Bold", "Klavika-Regular", "Helvetica Neue", Arial, sans-serif !important;
        font-size: 26px !important;
        font-weight: 400 !important;
        line-height: 1.15 !important;
    }
}

/* ─────────── Sidebar "Aktuelle saker" ─────────── */
.fretta-news-ticker .wp-block-latest-posts__list { list-style: none; padding: 0; margin: 0; }
.fretta-news-ticker li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--wp--preset--color--rule);
    font-size: 0.875rem;
}
.fretta-news-ticker li a { color: var(--wp--preset--color--ink); text-decoration: none; }
.fretta-news-ticker li a:hover { text-decoration: underline; }

/* ─────────── Single page "Les flere saker" sidebar item ─────────── */
.fretta-related-item .fretta-related-date {
    color: var(--wp--preset--color--muted);
    font-family: var(--wp--preset--font-family--label);
    font-size: 0.75rem;
    margin-right: 0.4rem;
}
.fretta-related-item .fretta-cat-badge { font-size: 0.75rem; }
.fretta-related-title a {
    font-family: var(--wp--preset--font-family--headline);
    color: var(--wp--preset--color--ink);
    text-decoration: none;
    font-size: 0.95rem;
}
.fretta-related-title a:hover { text-decoration: underline; }

/* Sidebar is sticky on tall screens — nice for long articles */
@media (min-width: 1000px) {
    .fretta-related-col .fretta-related-box {
        position: sticky;
        top: 1rem;
    }
}
