/*
 * CMS-owned layout system. Semantic classes are stable across themes;
 * each theme can override spacing, widths and grid behavior in adapter CSS.
 */

:root {
    --cms-section-width-narrow: 48rem;
    --cms-section-width-normal: 72rem;
    --cms-section-width-wide: 80rem;
    --cms-section-spacing-small: 1.5rem;
    --cms-section-spacing-medium: 3rem;
    --cms-section-spacing-large: 4.5rem;
    --cms-content-gap: 1.5rem;
    --cms-row-gap: 1.5rem;
    --cms-row-gap-small: 0.75rem;
    --cms-row-gap-large: 3rem;
    --cms-section-background-muted: #f5f5f5;
}

.cms-section__inner {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--cms-section-width-normal);
    margin-inline: auto;
    padding-inline: 1rem;
}

.cms-section--width-narrow .cms-section__inner {
    max-width: var(--cms-section-width-narrow);
}

.cms-section--width-normal .cms-section__inner {
    max-width: var(--cms-section-width-normal);
}

.cms-section--width-wide .cms-section__inner {
    max-width: var(--cms-section-width-wide);
}

.cms-section--width-full .cms-section__inner {
    max-width: none;
}

.cms-section--spacing-none {
    padding-block: 0;
}

.cms-section--spacing-small {
    padding-block: var(--cms-section-spacing-small);
}

.cms-section--spacing-medium {
    padding-block: var(--cms-section-spacing-medium);
}

.cms-section--spacing-large {
    padding-block: var(--cms-section-spacing-large);
}

.cms-section--background-muted {
    background-color: var(--cms-section-background-muted);
}

/* Row layout: flex (not CSS grid). Column widths use flex-basis via cms-column--* classes.
   Each epi-row is a direct child of the section (also carries cms-section__inner for width). */
.cms-section__content {
    display: flex;
    flex-wrap: wrap;
    gap: var(--cms-content-gap);
    align-items: stretch;
    width: 100%;
    /* Medium row spacing is the default (also applied via cms-row--spacing-medium). */
    margin-block-end: var(--cms-row-gap);
}

.cms-section > .cms-section__content:last-child {
    margin-block-end: 0;
}

.cms-section__content.cms-row--spacing-medium {
    margin-block-end: var(--cms-row-gap);
}

.cms-section__content.cms-row--spacing-small {
    margin-block-end: var(--cms-row-gap-small);
}

.cms-section__content.cms-row--spacing-large {
    margin-block-end: var(--cms-row-gap-large);
}

/* Listed last so an explicit "none" wins over the default medium class on the same element. */
.cms-section__content.cms-row--spacing-none {
    margin-block-end: 0;
}

.cms-section > .cms-section__content.cms-row--spacing-none:last-child,
.cms-section > .cms-section__content.cms-row--spacing-small:last-child,
.cms-section > .cms-section__content.cms-row--spacing-medium:last-child,
.cms-section > .cms-section__content.cms-row--spacing-large:last-child {
    margin-block-end: 0;
}

/* Columns with no explicit width share the row evenly. */
.cms-section__content > *,
.cms-section__content > .cms-column--equal {
    flex: 1 1 0;
    min-width: 0;
}

/* Explicit width choices override even distribution. The gap subtraction
   keeps complementary rows (half+half, third×3, two-thirds+third) flush.
   Scoped under the row so they outrank the even-distribution default.
   Full width only when a column is alone; siblings share the row evenly. */
.cms-section__content > .cms-column--full:only-child {
    flex: 0 0 100%;
}

.cms-section__content > .cms-column--half {
    flex: 0 0 calc(50% - var(--cms-content-gap) / 2);
}

.cms-section__content > .cms-column--one-third {
    flex: 0 0 calc(33.333% - var(--cms-content-gap) * 2 / 3);
}

.cms-section__content > .cms-column--two-thirds {
    flex: 0 0 calc(66.667% - var(--cms-content-gap) / 3);
}

.cms-section__content > .cms-column--one-quarter {
    flex: 0 0 calc(25% - var(--cms-content-gap) * 3 / 4);
}

/* Row display setting: equal-height columns (opt-in via Visual Builder). */
.cms-section__content.cms-row--height-equal {
    align-items: stretch;
}

.cms-section__content.cms-row--height-equal > .cms-column {
    display: flex;
    flex-direction: column;
}

.cms-section__content.cms-row--height-equal > .cms-column > * {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 100%;
}

.cms-section__content.cms-row--height-equal > .cms-column > * > * {
    flex: 1 1 auto;
}

.cms-section__content.cms-row--height-equal > .cms-column .cms-card,
.cms-section__content.cms-row--height-equal > .cms-column .cms-link-card,
.cms-section__content.cms-row--height-equal > .cms-column .th-card {
    height: 100%;
    box-sizing: border-box;
}

.cms-rich-text > :first-child {
    margin-top: 0;
}

.cms-rich-text > :last-child {
    margin-bottom: 0;
}

/* Hero block — only the row containing the hero goes full-bleed. */
.cms-section__inner:has(.cms-hero),
.cms-section__inner:has(.th-cta-image-block),
.cms-section__inner:has(.banner.hero-banner-height-leftside) {
    max-width: none;
    padding-inline: 0;
}

/* Applied from ContentSectionLayout when the first row contains a Hero. */
.cms-section.cms-section--hero-flush-top {
    padding-block-start: 0;
}

.cms-section.cms-section--hero-only {
    padding-block: 0;
}

.cms-hero {
    display: flex;
    flex-direction: column;
    background-color: var(--cms-section-background-muted);
}

.cms-hero--full {
    align-items: center;
    justify-content: center;
    min-height: 22rem;
    padding-block: var(--cms-section-spacing-large);
    background-size: cover;
    background-position: center;
}

.cms-hero--splitted {
    position: relative;
    z-index: 1;
    padding-block: 0;
    background-color: var(--cms-section-background-muted);
}

.cms-hero--splitted::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--cms-section-background-muted);
    z-index: -1;
}

.cms-hero__inner {
    width: 100%;
    max-width: var(--cms-section-width-normal);
    margin-inline: auto;
    padding-inline: 1rem;
}

.cms-hero--full .cms-hero__inner {
    text-align: center;
}

.cms-hero--splitted .cms-hero__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-block: 2.5rem;
    text-align: left;
}

.cms-hero--splitted .cms-hero__content {
    width: 100%;
    max-width: 29.375rem;
    margin-inline: auto;
}

.cms-hero--splitted .cms-hero__heading {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    line-height: 1.15;
}

.cms-hero--splitted .cms-hero__body {
    margin-top: 1.25rem;
    margin-inline: 0;
    max-width: none;
    font-size: 0.938rem;
    line-height: 1.5;
}

.cms-hero--splitted .cms-hero__actions {
    margin-top: 1.25rem;
    justify-content: flex-start;
}

.cms-hero--splitted .cms-hero__media {
    position: relative;
}

.cms-hero--splitted .cms-hero__image {
    display: block;
    width: 100%;
    height: auto;
}

@media (min-width: 48em) and (max-width: 63.99em) {
    .cms-hero--splitted .cms-hero__media {
        overflow: hidden;
        height: 27.5rem;
    }

    .cms-hero--splitted .cms-hero__image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
    }

    .cms-hero--splitted .cms-hero__content {
        padding-inline: 3rem;
        max-width: none;
    }
}

@media (min-width: 64em) {
    .cms-hero--splitted {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: center;
    }

    .cms-hero--splitted::after {
        bottom: 2.5rem;
    }

    .cms-hero--splitted .cms-hero__media {
        grid-column: 2;
        grid-row: 1;
        max-width: none;
        margin: 0;
    }

    .cms-hero--splitted .cms-hero__inner {
        grid-column: 1;
        grid-row: 1;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 2.5rem 2.5rem 2.5rem 1rem;
        box-sizing: border-box;
    }

    .cms-hero--splitted .cms-hero__content {
        max-width: min(29.375rem, 100%);
    }

    .cms-hero--splitted .cms-hero__body {
        max-width: 29.375rem;
    }
}

@media (min-width: 71.875em) {
    .cms-hero--splitted::after {
        bottom: 5rem;
    }
}

.cms-hero__heading {
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.1;
}

.cms-hero__heading > :first-child {
    margin-top: 0;
}

.cms-hero__heading > :last-child {
    margin-bottom: 0;
}

.cms-hero__body {
    margin-top: 1rem;
    margin-inline: auto;
    font-size: clamp(1.05rem, 2.5vw, 1.375rem);
    max-width: 42rem;
}

.cms-hero__actions {
    margin-top: 1.75rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.cms-hero__button {
    display: inline-block;
    padding: 0.75rem 1.75rem;
    border-radius: 0.25rem;
    font-weight: 600;
    text-decoration: none;
}

.cms-hero__button--big {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
}

.cms-hero--full.cms-hero--has-image {
    position: relative;
    isolation: isolate;
}

/* The heading and body are forced white over a photo. Without a scrim they wash
   out on light images — and vanish entirely if the image fails to load. */
.cms-hero--full.cms-hero--has-image::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.45));
}

.cms-hero--full.cms-hero--has-image .cms-hero__inner {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Header section */
.cms-header {
    position: relative;
    background: var(--cms-surface-background, #fff);
    border-bottom: 1px solid var(--cms-border-color, rgba(0, 0, 0, 0.12));
}

.cms-header__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: var(--cms-section-width-wide);
    margin-inline: auto;
    padding: 0.75rem 1rem;
}

.cms-header__menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.cms-header__menu-toggle-bar {
    display: block;
    width: 1.5rem;
    height: 2px;
    background: currentColor;
}

.cms-header__logo {
    flex: 0 0 auto;
}

.cms-header__logo img {
    display: block;
    max-height: 2.5rem;
    width: auto;
}

.cms-header__nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
}

.cms-header__menu {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cms-header__menu-link,
.cms-header__language-link {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

.cms-header__menu-link:hover,
.cms-header__menu-link:focus,
.cms-header__language-link:hover,
.cms-header__language-link:focus {
    color: var(--cms-link-color);
}

.cms-header__language-switcher {
    position: relative;
}

.cms-header__language-current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
}

.cms-header__language-current::-webkit-details-marker {
    display: none;
}

.cms-header__language-list {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 20;
    min-width: 10rem;
    margin: 0;
    padding: 0.5rem 0;
    list-style: none;
    background: var(--cms-surface-background, #fff);
    border: 1px solid var(--cms-border-color, rgba(0, 0, 0, 0.12));
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
}

.cms-header__language-item + .cms-header__language-item {
    margin-top: 0.25rem;
}

.cms-header__language-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.cms-header__language-flag {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    border-radius: 50%;
}

@media (max-width: 768px) {
    .cms-header__menu-toggle {
        display: inline-flex;
    }

    .cms-header__nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
        background: var(--cms-surface-background, #fff);
        border-bottom: 1px solid var(--cms-border-color, rgba(0, 0, 0, 0.12));
    }

    .cms-header--nav-open .cms-header__nav {
        display: flex;
    }

    .cms-header__menu {
        flex-direction: column;
        align-items: flex-start;
    }

    .cms-header__language-list {
        position: static;
        box-shadow: none;
        border: 0;
        padding: 0;
    }

    .cms-section__content > *,
    .cms-section__content > .cms-column--full,
    .cms-section__content > .cms-column--half,
    .cms-section__content > .cms-column--one-third,
    .cms-section__content > .cms-column--two-thirds,
    .cms-section__content > .cms-column--one-quarter {
        flex: 0 0 100%;
    }
}

/* Site footer */
.cms-footer {
    margin-top: auto;
    background: var(--cms-surface-background, #fff);
    border-top: 1px solid var(--cms-border-color, rgba(0, 0, 0, 0.12));
}

.cms-footer__inner {
    max-width: var(--cms-section-width-wide);
    margin-inline: auto;
    padding: 2rem 1rem;
}

.cms-footer__logo {
    margin-bottom: 1.5rem;
}

.cms-footer__logo img {
    display: block;
    max-height: 2.5rem;
    width: auto;
}

.cms-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
}

.cms-footer__text {
    flex: 1 1 16rem;
    color: var(--cms-text-muted);
    font-size: 0.875rem;
}

.cms-footer__menu {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cms-footer__menu-link {
    color: inherit;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
}

.cms-footer__menu-link:hover,
.cms-footer__menu-link:focus {
    color: var(--cms-link-color);
}

@media (max-width: 768px) {
    .cms-footer__bottom {
        flex-direction: column;
        align-items: flex-start;
    }

    .cms-footer__menu {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* Theme-specific layout tuning */
.theme-trygghansa-se {
    --cms-section-width-normal: 74rem;
}

.theme-tryg-no {
    --cms-section-width-normal: 71.25rem;
}

/* Standalone block preview (edit/preview mode) */
.cms-block-preview {
    padding: 1.5rem;
}

.cms-block-preview__header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.cms-block-preview__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.5);
}

.cms-block-preview__name {
    font-weight: 600;
}

.cms-block-preview__body:empty::after {
    content: "This block has no content yet.";
    display: block;
    padding: 2rem;
    text-align: center;
    color: rgba(0, 0, 0, 0.4);
    border: 1px dashed rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
}

/* Content blocks */
.cms-heading {
    margin: 0 0 1rem;
    color: var(--cms-heading-color);
    font-family: var(--cms-font-heading);
    line-height: 1.15;
}

.cms-heading--bold {
    font-weight: 700;
}

.cms-button {
    display: inline-block;
    padding: 0.75rem 1.75rem;
    border-radius: 0.25rem;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
}

.cms-button--big {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
}

.cms-link-card {
    display: block;
    padding: 1.25rem;
    border: 1px solid var(--cms-border-color);
    border-radius: 0.25rem;
    text-decoration: none;
    color: inherit;
    background: var(--cms-surface-background);
    transition: border-color 0.2s ease;
}

.cms-link-card:hover,
.cms-link-card:focus {
    border-color: var(--cms-link-color);
}

.cms-link-card__title {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--cms-heading-color);
}

.cms-link-card__body {
    display: block;
    color: var(--cms-text-muted);
}

.cms-card {
    padding: 1.25rem;
    border: 1px solid var(--cms-border-color);
    border-radius: 0.25rem;
    background: var(--cms-surface-background);
}

.cms-card__index {
    margin: 0 0 0.5rem;
    font-weight: 700;
    color: var(--cms-link-color);
}

.cms-card__heading {
    margin-bottom: 0.75rem;
}

.cms-accordion {
    display: grid;
    gap: 0.5rem;
}

.cms-accordion__item {
    border: 1px solid var(--cms-border-color);
    border-radius: 0.25rem;
    background: var(--cms-surface-background);
}

.cms-accordion__title {
    padding: 1rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--cms-heading-color);
}

.cms-accordion__body {
    padding: 0 1.25rem 1.25rem;
}

.cms-accordion__item--edit .cms-accordion__title {
    cursor: default;
}

/* Page teaser */
.cms-page-teaser__inner {
    display: grid;
    gap: 2rem;
    align-items: center;
}

.cms-page-teaser__image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 0.25rem;
}

.cms-page-teaser__headline {
    margin: 0 0 1rem;
    color: var(--cms-heading-color);
    font-family: var(--cms-font-heading);
    line-height: 1.15;
}

.cms-page-teaser__body {
    margin-bottom: 1.5rem;
}

.cms-page-teaser__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.cms-page-teaser__bottom-text {
    color: var(--cms-text-muted);
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .cms-page-teaser__inner {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .cms-page-teaser--image-right .cms-page-teaser__media {
        order: 2;
    }

    .cms-page-teaser--image-right .cms-page-teaser__content {
        order: 1;
    }
}

.cms-cta {
    text-align: center;
}

.cms-cta__title {
    margin: 0 0 1rem;
    color: var(--cms-heading-color);
    font-family: var(--cms-font-heading);
}

.cms-cta__body {
    margin-bottom: 1.5rem;
}

.cms-cta__actions {
    display: flex;
    justify-content: center;
}

/* External application embed (iframe) */
.cms-iframe-embed {
    width: 100%;
    min-width: 0;
}

.cms-iframe-embed__frame {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
}

.cms-iframe-embed__fallback {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    color: var(--cms-text-muted, #535c5e);
}

.cms-iframe-embed__open {
    color: var(--cms-link-color, #ce0303);
}

.cms-iframe-embed__missing {
    padding: 1.5rem;
    border: 1px dashed var(--cms-border-color, #e1e1e1);
    border-radius: 0.25rem;
    background: var(--cms-bg-muted, #ededed);
}

.cms-iframe-embed__missing p {
    margin: 0 0 0.5rem;
}

.cms-iframe-embed__missing-key {
    margin: 0;
    font-size: 0.875rem;
    color: var(--cms-text-muted, #535c5e);
}

/*
 * Cross-origin Angular element hosts. While these apps were framed, the Apps
 * layout wrapped them in a Bootstrap `.container`; the CMS page owns that wrapper
 * now that the elements render inline in the section grid.
 */
.cms-angular-embed {
    width: 100%;
    min-width: 0;
}

.cms-angular-embed__container {
    box-sizing: border-box;
    width: 100%;
    max-width: 71.25rem;
    margin-inline: auto;
    padding-inline: 0.75rem;
}

.cms-angular-embed__container > [data-cms-angular-embed] {
    display: block;
}

.cms-requisition-embed__login {
    max-width: 32rem;
    margin-inline: auto;
}

.cms-requisition-embed__login .form__field {
    margin-block: 1rem;
}
