/*
 * 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);
}

.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) {
    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__inner {
    width: 100%;
    max-width: var(--cms-section-width-normal);
    margin-inline: auto;
    padding-inline: 1rem;
}

.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;
    font-size: clamp(1.05rem, 2.5vw, 1.375rem);
    max-width: 42rem;
}

.cms-hero__actions {
    margin-top: 1.75rem;
    display: flex;
    flex-wrap: wrap;
    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--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;
}

/* Product tile */
.cms-product-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 9.75rem;
    padding: 1.25rem 1rem;
    border: 1px solid var(--cms-border-color);
    border-radius: 0.25rem;
    background: var(--cms-surface-background);
    color: inherit;
    text-align: center;
    text-decoration: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cms-product-tile:hover,
.cms-product-tile:focus {
    border-color: var(--cms-link-color);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

.cms-product-tile__badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background: var(--cms-link-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.cms-product-tile__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

.cms-product-tile__icon img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cms-product-tile__title {
    font-family: var(--cms-font-heading);
    font-weight: 700;
    color: var(--cms-heading-color);
    line-height: 1.2;
}

.cms-product-tile__subtitle {
    display: none;
    font-size: 0.875rem;
    color: var(--cms-text-muted);
    line-height: 1.3;
}

@media (min-width: 768px) {
    .cms-product-tile__subtitle {
        display: block;
    }
}
