/* Language switcher and suggestion bar (Paper: "Language switcher" page, draft F).
   Markup: includes/language-switcher.php, template-parts/header/lang-suggest.php.

   Switcher:
   - From 1200px: globe + code button that opens a menu (languages in their own names).
   - Below 1200px: globe + inline code buttons, in the tablet Meny panel and the
     phone Meny drawer. The root keeps .header__lang, so the existing rules still
     place and show/hide it there.

   Suggestion bar: one row from 768px (switch + stay buttons); on phones the
   switch button goes full width under the text and there's no stay button. */

/* ---------- Switcher ---------- */

.lang-switch {
    position: relative;
    text-transform: none; /* .header__lang uppercases its contents */
}

.lang-switch svg {
    fill: none;
    stroke: currentColor;
    flex-shrink: 0;
}

.lang-switch__globe-icon {
    width: 16px;
    height: 16px;
    stroke-width: 1.4;
}

.lang-switch__trigger {
    display: none;
}

.lang-switch__item {
    color: #25292D;
    transition: color .2s, background-color .2s, border-color .2s;
}

@media (min-width: 1200px) {

    /* 10px each side widens the click area. The 12px gap before Logg inn
       (.header__lang) shrinks by the same 10px, so the label stays put. */
    .lang-switch {
        margin-right: 2px;
    }

    .lang-switch__trigger {
        display: flex;
        align-items: center;
        gap: 4px;
        height: 42px;
        margin: 0;
        padding: 0 10px;
        border: 0;
        border-radius: var(--r-control, 5px);
        background: none;
        font: inherit;
        font-size: 14px;
        line-height: 17px;
        color: #25292D;
        cursor: pointer;
        transition: color .2s;
    }

    .lang-switch__code {
        padding-left: 2px;
    }

    .lang-switch__chevron {
        width: 10px;
        height: 10px;
        stroke-width: 1.5;
        stroke-linecap: round;
        stroke-linejoin: round;
        transition: transform .2s;
    }

    .lang-switch__trigger:hover,
    .lang-switch.is-open .lang-switch__trigger {
        color: #06f;
    }

    /* Ring inside the padding, so it can't touch Logg inn 2px away. */
    .lang-switch__trigger:focus-visible {
        outline-offset: -2px;
    }

    .lang-switch.is-open .lang-switch__code {
        font-weight: 600;
    }

    .lang-switch.is-open .lang-switch__chevron {
        transform: rotate(180deg);
    }

    .lang-switch__menu {
        display: none;
        position: absolute;
        top: calc(100% + 4px);
        right: 0;
        z-index: 30;
        flex-direction: column;
        gap: 2px;
        min-width: 210px;
        padding: 6px;
        background: #fff;
        border-radius: var(--r-surface, 10px);
        box-shadow: 0 16px 40px rgba(37, 41, 45, .12), 0 2px 6px rgba(37, 41, 45, .06);
    }

    .lang-switch.is-open .lang-switch__menu {
        display: flex;
    }

    .lang-switch__globe {
        display: none;
    }

    .lang-switch__item {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 40px;
        padding: 0 10px;
        border-radius: var(--r-control, 5px);
        font-size: 14px;
        line-height: 17px;
    }

    .lang-switch__item:hover,
    .lang-switch__item.is-current {
        background-color: #F4F8FC;
    }

    .lang-switch__item:hover {
        color: #06f;
    }

    .lang-switch__check {
        width: 16px;
        height: 16px;
        stroke: #06f;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
        visibility: hidden;
    }

    .lang-switch__item.is-current .lang-switch__check {
        visibility: visible;
    }

    .lang-switch__name {
        flex-grow: 1;
    }

    .lang-switch__item.is-current .lang-switch__name {
        font-weight: 600;
    }

    .lang-switch__item-code {
        font-size: 12px;
        letter-spacing: .04em;
        color: #636D77;
    }
}

@media (max-width: 1199px) {

    .lang-switch__menu {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .lang-switch__globe {
        display: flex;
        margin-right: 2px;
        color: #25292D;
    }

    .lang-switch__globe .lang-switch__globe-icon {
        width: 20px;
        height: 20px;
        stroke-width: 1.3;
    }

    .lang-switch__check,
    .lang-switch__name {
        display: none;
    }

    .lang-switch__item {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 52px;
        height: 44px;
        padding: 0 10px;
        border: 1px solid #BFBFBF;
        border-radius: var(--r-control, 5px);
        font-size: 16px;
        line-height: 20px;
    }

    .lang-switch__item.is-current {
        background-color: #06f;
        border-color: #06f;
        color: #fff;
        font-weight: 600;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {

    .lang-switch__item:not(.is-current):hover {
        color: #06f;
        border-color: #06f;
    }

    /* Tablet Meny panel (mod.css, board 02): the languages sit at the top of
       the card, 30px down. Make room for the 44px buttons plus a 26px gap
       before the first link (the panel reserved 84px for one line of text). */
    .header:not(.header_mini) .header__menu.active .header__nav {
        padding-top: 100px;
    }
}

/* Phone Meny drawer: languages on the left, the account button on the right. */
@media (max-width: 767px) {

    .header__right {
        height: auto;
    }

    .header__right .lang-switch {
        width: auto;
        margin-right: 12px;
    }

    .header__right .header__login {
        width: 44px;
        height: 44px;
        padding: 0;
        margin-left: auto;
        justify-content: center;
    }
}

/* ---------- Suggestion bar ---------- */

/* Stacked like the top bar below it, so the hero's background art (.main__bg)
   can't paint over it. */
.lang-suggest {
    position: relative;
    z-index: 10;
    background: #25292D;
    color: #fff;
}

.lang-suggest[hidden] {
    display: none;
}

.lang-suggest__wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 6px 0;
}

.lang-suggest__globe {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
}

.lang-suggest__text {
    margin: 0;
    font-size: 15px;
    line-height: 20px;
}

.lang-suggest__switch,
.lang-suggest__stay {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--r-control, 5px);
    font: inherit;
    font-size: 14px;
    line-height: 17px;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .2s, border-color .2s;
}

.lang-suggest__switch {
    margin-left: 8px;
    background: #FFED02;
    color: #25292D;
    font-weight: 600;
}

.lang-suggest__switch:hover {
    background: #FFF35C;
}

.lang-suggest__stay {
    border: 1px solid rgba(255, 255, 255, .45);
    background: none;
    color: #fff;
    font-weight: 500;
}

.lang-suggest__stay:hover {
    border-color: #fff;
}

/* 44px tap area around a 14px ✕. The negative margin lets the area overhang
   the page margin, so the visible ✕ lines up with the column edge (and with
   Prøv Gratis below it). */
.lang-suggest__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin: 0 -15px 0 auto;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    cursor: pointer;
}

.lang-suggest__close svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.lang-suggest__close:focus-visible,
.lang-suggest__switch:focus-visible,
.lang-suggest__stay:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

@media (max-width: 767px) {

    .lang-suggest__wrap {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        column-gap: 10px;
        row-gap: 12px;
        padding: 14px 0 16px;
    }

    .lang-suggest__switch {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: center;
        height: 44px;
        margin: 0;
        font-size: 16px;
    }

    .lang-suggest__stay {
        display: none;
    }

    .lang-suggest__close {
        grid-column: 3;
        grid-row: 1;
        margin: -12px -15px -12px 0;
    }
}
