/**
 * Kreng CMS — Frontend Styles
 * Implements a 3-tier width system for CMS components on CMS pages:
 *
 *   Normal     — component within the standard content column
 *   Full Width  (.kreng-width-full)      — background edge-to-edge, content constrained
 *   Full Bleed  (.kreng-width-full-bleed) — everything edge-to-edge
 *
 * Uses CSS Grid (Hyvä Method 3) instead of the legacy negative-margin hack.
 */

/* ── CSS Grid layout — CMS pages only ────────────────────────────────────
 * On CMS pages Magento adds `cms-page-view` to <body>; the homepage gets
 * `cms-home` instead.  We target both.
 * We expand .page-main and .columns to full viewport width, then turn
 * .column.main into a 3-column grid:  [1fr] [content ≤ 80rem] [1fr]
 * The two 1fr side columns act as padding for "Normal" components and
 * collapse to 0 on narrow viewports so content fills the screen.
 *
 * .page-main must also be expanded — it carries max-width + padding in Hyvä
 * which would otherwise prevent full-bleed components from reaching the edges.
 */
:is(.cms-page-view, .cms-home) .page-main {
    max-width: 100%;
    padding-inline: 0;
    margin-top: 0;
}

:is(.cms-page-view, .cms-home) .columns {
    max-width: 100%;
    padding-inline: 0;
    margin-inline: 0;
}

:is(.cms-page-view, .cms-home) .column.main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(80rem, calc(100% - 3rem)) minmax(0, 1fr);
}

/* Default (Normal): place every direct child in the center column */
:is(.cms-page-view, .cms-home) .column.main > * {
    grid-column: 2;
}

/* Full Width + Full Bleed: span all 3 columns (viewport edge-to-edge) */
:is(.cms-page-view, .cms-home) .column.main > .kreng-width-full,
:is(.cms-page-view, .cms-home) .column.main > .kreng-width-full-bleed {
    grid-column: 1 / -1;
}

/* ── Content constraint wrapper ───────────────────────────────────────────
 * Use inside full-width / full-bleed sections to constrain content to the
 * same visual column as the CSS grid's center column.
 *
 * Formula matches grid column 2:  min(80rem, calc(100% - 3rem))
 *   - viewport > ~83rem → gutters = (100% - 80rem) / 2
 *   - viewport ≤ ~83rem → gutters = 1.5rem (half of the 3rem gap)
 */
.kreng-content-wrap {
    padding-inline: max(1.5rem, calc((100% - 80rem) / 2));
}

/* ── Hero ─────────────────────────────────────────────────────────────────
 * Only set display:flex here. Alignment (items-start/center/end) and
 * justification are controlled by Tailwind classes in each template so
 * individual projects can customise without overriding this file.
 */
.kreng-hero {
    display: flex;
}

.kreng-hero__content {
    width: 100%;
    max-width: 80rem;
    margin-inline: auto;
    padding-inline: 1.5rem;
    padding-top: 3rem;
    padding-bottom: 4rem;
}

@media (min-width: 640px) {
    .kreng-hero__content {
        padding-inline: 2.5rem;
        padding-bottom: 5rem;
    }
}

@media (min-width: 1024px) {
    .kreng-hero__content { padding-inline: 4rem; }
}

/* ── Features grid ────────────────────────────────────────────────────────
 * Subtle separator from preceding sections.
 */
.kreng-features-grid {
    border-top: 1px solid #f3f4f6;
}

/* ── Two-column section ───────────────────────────────────────────────────
 * Ensure columns can shrink below their content size on narrow viewports.
 */
.kreng-two-column__left,
.kreng-two-column__right {
    min-width: 0;
}

/* ── Stats bar number styling ─────────────────────────────────────────────
 * Ensure stat numbers look sharp across fonts.
 */
.kreng-stats-bar .kreng-stat-number {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* ── Component visibility ─────────────────────────────────────────────────
 * Visibility wrappers are regular block-level divs. The CSS Grid > * rule
 * assigns grid-column:2 (center column) automatically. Full-width and
 * full-bleed components get style="grid-column:1/-1" applied inline by
 * ContentRenderer::buildGridColumnStyle() so the wrapper spans correctly
 * without needing display:contents (which breaks CSS > child selectors).
 */

/* Device visibility — hide via media queries */
@media (max-width: 767px) {
    [data-kreng-visible-devices]:not([data-kreng-visible-devices~="mobile"]) {
        display: none !important;
    }
}
@media (min-width: 768px) and (max-width: 1023px) {
    [data-kreng-visible-devices]:not([data-kreng-visible-devices~="tablet"]) {
        display: none !important;
    }
}
@media (min-width: 1024px) {
    [data-kreng-visible-devices]:not([data-kreng-visible-devices~="desktop"]) {
        display: none !important;
    }
}

/* Customer group visibility — applied by kreng-cms-visibility.js */
.kreng-vis-group-hidden {
    display: none !important;
}

/* ── Tabs component ───────────────────────────────────────────────────────
 * Desktop: standard underline tab nav.
 * Mobile (<768px): tab nav hidden; accordion buttons shown instead.
 */
@media (max-width: 767px) {
    .kreng-tabs__nav { display: none; }
}
@media (min-width: 768px) {
    .kreng-tabs__acc-btn { display: none; }
}

/*
 * Accordion: native <details>. Loaded on Luma and Hyvä, so the open/closed state needs no
 * script and no class from a theme's Tailwind build.
 */
.kreng-accordion__summary { cursor: pointer; list-style: none; }
.kreng-accordion__summary::-webkit-details-marker { display: none; }
.kreng-accordion__chevron { transition: transform 0.2s ease; }
.kreng-accordion__item[open] .kreng-accordion__chevron { transform: rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
    .kreng-accordion__chevron { transition: none; }
}

/*
 * Marquee. The duration comes from a style attribute on the track; everything else is here,
 * so it runs without script on Luma and Hyvä.
 */
.kreng-marquee { overflow: hidden; white-space: nowrap; padding: 12px 0; }
.kreng-marquee-track { display: inline-flex; animation: kreng-marquee-rtl 25s linear infinite; }
.kreng-marquee--ltr .kreng-marquee-track { animation-name: kreng-marquee-ltr; }
.kreng-marquee:hover .kreng-marquee-track,
.kreng-marquee:focus-within .kreng-marquee-track { animation-play-state: paused; }
.kreng-marquee-copy { display: inline-flex; }
.kreng-marquee-item { margin: 0 16px; font-size: 1rem; font-weight: 500; }
.kreng-marquee-sep { opacity: 0.5; }

@keyframes kreng-marquee-rtl { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes kreng-marquee-ltr { from { transform: translateX(-50%); } to { transform: translateX(0); } }

/* No movement when the visitor asks for none: the text stands still and can be scrolled. */
@media (prefers-reduced-motion: reduce) {
    .kreng-marquee { overflow-x: auto; }
    .kreng-marquee-track { animation: none; }
    .kreng-marquee-copy[aria-hidden="true"] { display: none; }
}

/* A hidden announcement bar or close button stays hidden whatever its style attribute says. */
.kreng-announcement-bar[hidden],
.kreng-announcement-bar [hidden] { display: none !important; }

/*
 * Carousel. One markup and one stylesheet for Luma and Hyvä; kreng-cms-components.js moves
 * the track. Before the script runs (or without it) the slides scroll sideways.
 *
 * Every selector starts at the root (two classes): on Luma the components stylesheet resets
 * `.kreng-component *` and is loaded after this file, so a single class would lose to it.
 * Sizes are in px: Luma sets the root font size to 62.5%, which shrinks rem.
 */
.kreng-component.kreng-carousel { position: relative; overflow-x: auto; background: #000; scroll-snap-type: x mandatory; }
.kreng-component.kreng-carousel--ready { overflow: hidden; scroll-snap-type: none; }
.kreng-carousel .kreng-carousel-track { display: flex; transition: transform 0.4s ease; will-change: transform; }
.kreng-carousel .kreng-carousel-slide {
    position: relative; display: flex; align-items: flex-end;
    min-width: 100%; min-height: 420px; scroll-snap-align: start;
}
.kreng-carousel .kreng-carousel-image { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.kreng-carousel .kreng-carousel-caption {
    position: relative; width: 100%; padding: 32px; color: #fff;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.5) 60%, transparent);
}
.kreng-carousel .kreng-carousel-title { margin: 0 0 6px; font-size: 24px; font-weight: 700; line-height: 1.25; color: #fff; }
.kreng-carousel .kreng-carousel-text { margin: 0 0 10px; font-size: 14px; opacity: 0.9; }
.kreng-carousel .kreng-carousel-cta {
    display: inline-block; padding: 8px 20px; background: #fff; color: #000;
    text-decoration: none; border-radius: 4px; font-size: 14px; font-weight: 600;
}
.kreng-carousel .kreng-carousel-cta:hover { background: #f3f4f6; color: #000; text-decoration: none; }
/* Three classes: the rules below set display on these, which would undo the hidden attribute. */
.kreng-component.kreng-carousel .kreng-carousel-controls[hidden],
.kreng-component.kreng-carousel .kreng-carousel-pause[hidden] { display: none; }
.kreng-carousel .kreng-carousel-prev,
.kreng-carousel .kreng-carousel-next {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4); border: 0; color: #fff; font-size: 40px;
    padding: 8px 14px; cursor: pointer; z-index: 2; line-height: 1;
}
.kreng-carousel .kreng-carousel-prev { left: 0; }
.kreng-carousel .kreng-carousel-next { right: 0; }
.kreng-carousel .kreng-carousel-prev:hover,
.kreng-carousel .kreng-carousel-next:hover,
.kreng-carousel .kreng-carousel-pause:hover { background: rgba(0, 0, 0, 0.65); }
.kreng-carousel .kreng-carousel-pause {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
    background: rgba(0, 0, 0, 0.4); cursor: pointer;
}
/* Two bars while playing, a triangle while paused. */
.kreng-carousel .kreng-carousel-pause::before,
.kreng-carousel .kreng-carousel-pause::after { content: ""; width: 3px; height: 12px; background: #fff; }
.kreng-carousel .kreng-carousel-pause[aria-pressed="true"]::before {
    width: 0; height: 0; margin-left: 3px; background: none;
    border-style: solid; border-width: 7px 0 7px 11px; border-color: transparent transparent transparent #fff;
}
.kreng-carousel .kreng-carousel-pause[aria-pressed="true"]::after { display: none; }
.kreng-carousel .kreng-carousel-dots {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    display: flex; z-index: 2;
}
/* A 24x24 target around the 10px dot: WCAG 2.5.8 (and Lighthouse's target-size). */
.kreng-carousel .kreng-carousel-dot {
    display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border: 0; background: transparent; cursor: pointer; padding: 0;
}
.kreng-carousel .kreng-carousel-dot::before {
    content: ""; width: 10px; height: 10px; box-sizing: border-box; border-radius: 50%;
    border: 2px solid #fff; background: transparent;
}
.kreng-carousel .kreng-carousel-dot--active::before { background: #fff; }
.kreng-component.kreng-carousel button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .kreng-carousel .kreng-carousel-track { transition: none; }
}

/* ── Shared component frame ────────────────────────────────────────────────
 * One inner box for every component, the same in Luma and Hyvä: one side
 * padding and three widths (Model\ComponentFrame). Pixels, because Luma's rem
 * is 10px; two-class selectors, so a theme's own reset does not win.
 *
 * A site sets its own values once, on :root or .kreng-component:
 *   --kreng-cms-width-text / -medium / -wide   inner widths
 *   --kreng-cms-accent, --kreng-cms-accent-strong, --kreng-cms-accent-soft
 *   --kreng-cms-heading-weight
 */
.kreng-component .kreng-inner {
    box-sizing: border-box;
    width: 100%;
    margin-inline: auto;
    padding-inline: 16px;
    max-width: var(--kreng-cms-width-wide, 1280px);
}

.kreng-component .kreng-inner--text {
    max-width: var(--kreng-cms-width-text, 896px);
}

.kreng-component .kreng-inner--medium {
    max-width: var(--kreng-cms-width-medium, 1024px);
}

.kreng-component .kreng-inner--bleed {
    max-width: none;
}

@media (min-width: 640px) {
    .kreng-component .kreng-inner {
        padding-inline: 24px;
    }
}

@media (min-width: 1024px) {
    .kreng-component .kreng-inner {
        padding-inline: 32px;
    }
}

/* Main headings follow the site's heading weight when it sets one. */
.kreng-component .kreng-heading.font-bold {
    font-weight: var(--kreng-cms-heading-weight, 700);
}

.kreng-component .kreng-heading.font-black {
    font-weight: var(--kreng-cms-heading-weight, 900);
}

/* A call to action as a text link (CTA Button, style "link"). */
.kreng-component .kreng-link {
    display: inline-block;
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

.kreng-component .kreng-link:hover {
    text-decoration-thickness: 3px;
}

/* Keyboard focus is visible on every background: a dark ring with a white one inside it,
 * whatever colour the element or the section has. */
.kreng-component :is(a, button, summary, [tabindex]):focus-visible {
    outline: 2px solid #111827;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #fff;
}

/* A testimonial is a figure with a blockquote: undo what a theme gives those. */
.kreng-component .kreng-quote-card {
    margin: 0;
}

.kreng-component .kreng-quote {
    margin-inline: 0;
    margin-top: 0;
    padding: 0;
    border: 0;
    font-size: inherit;
    quotes: none;
}

.kreng-component .kreng-quote::before,
.kreng-component .kreng-quote::after {
    content: none;
}

/* Accent colour where a theme has no "primary" of its own (Luma). */
.kreng-component.kreng-bg-accent {
    background-color: var(--kreng-cms-accent, #4f46e5);
}

.kreng-component .kreng-accent-solid {
    background-color: var(--kreng-cms-accent, #6366f1);
    color: #fff;
}

.kreng-component .kreng-accent-soft {
    background-color: var(--kreng-cms-accent-soft, #e0e7ff);
    color: var(--kreng-cms-accent-strong, #4338ca);
}

.kreng-component .kreng-tab--active {
    border-color: var(--kreng-cms-accent, #4f46e5);
    color: var(--kreng-cms-accent-strong, #4338ca);
}

.kreng-component .kreng-on-dark-muted {
    color: rgba(255, 255, 255, 0.85);
}

/* ── Components with one template for both themes ─────────────────────────
 * Image + Text, Category Tiles, Logo Row, Newsletter Signup. Everything they
 * need is here, so they look the same on Luma and Hyvä and no theme has to be
 * rebuilt. Buttons carry both themes' own classes ("btn btn-primary" and
 * "action primary") and take their look from the theme.
 */
.kreng-component.kreng-on-dark {
    color: #fff;
}

.kreng-component .kreng-section-pad {
    padding-block: 48px;
}

.kreng-component .kreng-section-heading {
    margin: 0 0 24px;
    font-size: 30px;
    line-height: 1.2;
    font-weight: var(--kreng-cms-heading-weight, 700);
    color: inherit;
}

.kreng-component .kreng-section-heading--center {
    text-align: center;
}

.kreng-component .kreng-btn {
    display: inline-block;
}

/* Image + Text */
.kreng-component .kreng-image-text__grid {
    display: grid;
    gap: 32px;
    padding-block: 48px;
    align-items: center;
}

.kreng-component .kreng-image-text__grid--top {
    align-items: start;
}

.kreng-component .kreng-image-text__media img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.kreng-component .kreng-image-text__text {
    max-width: none;
    font-size: 17px;
    line-height: 1.6;
}

/* A theme's own text styles are in rem, which is 10px on Luma. */
.kreng-component .kreng-image-text__text :is(p, li) {
    font-size: 17px;
    line-height: 1.6;
}

.kreng-component .kreng-image-text__action {
    margin: 24px 0 0;
}

@media (min-width: 768px) {
    .kreng-component .kreng-image-text__grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 56px;
    }

    .kreng-component .kreng-image-text__grid--right .kreng-image-text__media {
        order: 2;
    }
}

/* Category Tiles */
.kreng-component .kreng-category-tiles__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.kreng-component .kreng-category-tiles__item {
    margin: 0;
}

.kreng-component .kreng-category-tiles__link {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    background-color: #f3f4f6;
    color: #fff;
    text-decoration: none;
}

.kreng-component .kreng-category-tiles__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.kreng-component .kreng-category-tiles__link:hover .kreng-category-tiles__image {
    transform: scale(1.04);
}

.kreng-component .kreng-category-tiles__name {
    position: absolute;
    inset: auto 0 0 0;
    padding: 40px 16px 14px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

/* A tile without an image: the name on a plain surface. */
.kreng-component .kreng-category-tiles__link--plain {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    background-color: #fff;
    color: #111827;
}

.kreng-component .kreng-category-tiles__link--plain .kreng-category-tiles__name {
    position: static;
    padding: 12px 16px;
    background: none;
    text-align: center;
}

@media (min-width: 768px) {
    .kreng-component .kreng-category-tiles__list {
        gap: 24px;
    }

    .kreng-component .kreng-category-tiles__list--3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .kreng-component .kreng-category-tiles__list--4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Subpage List */
.kreng-component .kreng-subpage-list__cards {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.kreng-component .kreng-subpage-list__item {
    margin: 0;
}

.kreng-component .kreng-subpage-list__card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background-color: #fff;
    color: #111827;
    text-decoration: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.kreng-component .kreng-subpage-list__card:hover,
.kreng-component .kreng-subpage-list__card:focus-visible {
    border-color: #9ca3af;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    text-decoration: none;
}

.kreng-component .kreng-subpage-list__image {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.kreng-component .kreng-subpage-list__body {
    display: block;
    padding: 16px 18px 18px;
}

.kreng-component .kreng-subpage-list__title {
    display: block;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.kreng-component .kreng-subpage-list__text {
    display: block;
    margin-top: 6px;
    color: #4b5563;
    font-size: 15px;
    line-height: 1.5;
}

.kreng-component .kreng-subpage-list__links {
    margin: 0;
    padding: 0;
    list-style: none;
}

.kreng-component .kreng-subpage-list__links .kreng-subpage-list__item {
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.kreng-component .kreng-subpage-list__links .kreng-subpage-list__item:last-child {
    border-bottom: 0;
}

.kreng-component .kreng-subpage-list__link {
    font-size: 17px;
    font-weight: 600;
}

.kreng-component.kreng-on-dark .kreng-subpage-list__links .kreng-subpage-list__item {
    border-color: rgba(255, 255, 255, 0.25);
}

.kreng-component.kreng-on-dark .kreng-subpage-list__links .kreng-subpage-list__text {
    color: rgba(255, 255, 255, 0.8);
}

@media (min-width: 640px) {
    .kreng-component .kreng-subpage-list__cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
    }
}

@media (min-width: 1024px) {
    .kreng-component .kreng-subpage-list__cards--3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .kreng-component .kreng-subpage-list__cards--4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .kreng-component .kreng-subpage-list__card {
        transition: none;
    }
}

/* Logo Row */
.kreng-component .kreng-logo-row__heading {
    margin: 0 0 24px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    color: inherit;
    opacity: 0.7;
}

.kreng-component .kreng-logo-row__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 24px 48px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.kreng-component .kreng-logo-row__item {
    margin: 0;
}

.kreng-component .kreng-logo-row__item img {
    display: block;
    width: auto;
    max-width: 160px;
    height: 40px;
    object-fit: contain;
}

.kreng-component .kreng-logo-row__list--small img {
    height: 28px;
    max-width: 120px;
}

.kreng-component .kreng-logo-row__list--large img {
    height: 56px;
    max-width: 200px;
}

.kreng-component .kreng-logo-row__list--gray img {
    filter: grayscale(1);
    opacity: 0.7;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

.kreng-component .kreng-logo-row__list--gray li:hover img,
.kreng-component .kreng-logo-row__list--gray a:focus-visible img {
    filter: none;
    opacity: 1;
}

/* Newsletter Signup */
.kreng-component .kreng-newsletter__inner {
    text-align: center;
}

.kreng-component .kreng-newsletter__text {
    margin: 0 auto 24px;
    max-width: 560px;
    font-size: 17px;
    line-height: 1.6;
}

.kreng-component .kreng-newsletter__form {
    margin: 0 auto;
    max-width: 480px;
    text-align: left;
}

.kreng-component .kreng-newsletter__label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
}

.kreng-component .kreng-newsletter__row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.kreng-component .kreng-newsletter__input {
    flex: 1 1 220px;
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid #9ca3af;
    border-radius: 6px;
    background-color: #fff;
    color: #111827;
    font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
    .kreng-component .kreng-category-tiles__image,
    .kreng-component .kreng-logo-row__list--gray img {
        transition: none;
    }
}
