/*
------------------ Content pages (Bagisto CMS) ------------------

Loaded only on CMS pages (cms/page.blade.php). Everything is scoped to
.cms-content, so it never affects the shop, product or checkout pages.

Write pages in the Bagisto editor with plain headings, paragraphs, lists and
images: the typography below takes care of hierarchy and spacing. For layout
there are a few building blocks, each a single class on a <div>:

  <p class="cms-lead">           larger intro paragraph under the H1
  <div class="cms-columns">      2 columns (stacked on mobile)
  <div class="cms-media">        text + image side by side (image right;
                                 add cms-media--left for image left)
  <div class="cms-swatches">     grid of small product/colour swatches:
                                 <figure><img><figcaption><strong>Wit</strong> RAL 9003</figcaption></figure>
  <div class="cms-cards">        grid of cards with a heading, text and optional image
  <ul class="cms-checklist">     list with green check marks (USPs)
  <div class="cms-note">         highlighted tip / info block
  <div class="cms-cta">          call-to-action block; links with class cms-button become buttons
  <p class="cms-buttons">        row of buttons
*/

.cms-content {
    --cms-text: #5b4a4a;
    --cms-heading: #4a3b3b;
    --cms-muted: #7d6e6e;
    --cms-green: #6f8d2c;
    --cms-green-light: #f4f5f0;
    --cms-border: #e8e2dc;
    --cms-surface: #faf7f3;
    --cms-radius: 12px;
    --cms-measure: 760px;

    color: var(--cms-text);
    font-size: 17px;
    line-height: 1.7;
    max-width: 1120px;
    margin: 0 auto;
    padding-bottom: 24px;
}

/* ---------- Rhythm: every block gets the same spacing ---------- */

.cms-content > * + *,
.cms-content :where(div, section, article) > * + * {
    margin-top: 1.1em;
}

/* Running text stays at a comfortable reading width; grids may be wider. */
.cms-content :where(p, ul, ol, blockquote, h1, h2, h3, h4, h5, h6, table, dl) {
    max-width: var(--cms-measure);
}

/* ---------- Headings: one clear, fixed hierarchy ---------- */

.cms-content :where(h1, h2, h3, h4, h5, h6) {
    font-family: "Nunito", sans-serif;
    color: var(--cms-heading);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.cms-content h1 {
    font-size: clamp(30px, 4vw, 42px);
    margin: 0 0 0.4em;
}

.cms-content h2 {
    font-size: clamp(24px, 2.6vw, 30px);
    margin-top: 2.2em;
    margin-bottom: 0.5em;
}

.cms-content h3 {
    font-size: clamp(19px, 1.8vw, 22px);
    font-weight: 700;
    margin-top: 1.8em;
    margin-bottom: 0.4em;
}

.cms-content h4,
.cms-content h5,
.cms-content h6 {
    font-size: 17px;
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.3em;
}

/* A heading directly after another heading or at the top of a block needs no extra gap. */
.cms-content :is(h1, h2, h3, h4) + :is(h2, h3, h4),
.cms-content :is(.cms-cards, .cms-columns, .cms-media) > * > :is(h2, h3, h4):first-child,
.cms-content :is(.cms-cta, .cms-note) > :is(h2, h3, h4):first-child,
.cms-content > :first-child,
.cms-content > div:first-child > :first-child {
    margin-top: 0;
}

/* Text directly under a heading sits close to it. */
.cms-content :is(h1, h2, h3, h4, h5, h6) + * {
    margin-top: 0;
}

/* ---------- Text ---------- */

.cms-content p {
    margin-bottom: 0;
}

.cms-content .cms-lead,
.cms-content h1 + p {
    font-size: clamp(18px, 1.6vw, 20px);
    line-height: 1.6;
    color: var(--cms-text);
}

.cms-content strong,
.cms-content b {
    color: var(--cms-heading);
    font-weight: 600;
}

.cms-content a:not(.cms-button) {
    color: var(--cms-green);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.cms-content a:not(.cms-button):hover {
    text-decoration-thickness: 2px;
}

.cms-content :where(ul, ol) {
    padding-left: 1.3em;
}

.cms-content ul {
    list-style: disc;
}

.cms-content ol {
    list-style: decimal;
}

.cms-content li + li {
    margin-top: 0.35em;
}

.cms-content li::marker {
    color: var(--cms-green);
}

.cms-content blockquote {
    border-left: 3px solid var(--cms-green);
    padding: 0.2em 0 0.2em 1.1em;
    color: var(--cms-muted);
    font-style: italic;
}

.cms-content hr {
    border: 0;
    border-top: 1px solid var(--cms-border);
    margin: 2.5em 0;
    max-width: none;
}

/* ---------- Images ---------- */

.cms-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.cms-content figure {
    margin: 0;
}

.cms-content figcaption {
    font-size: 14px;
    line-height: 1.4;
    color: var(--cms-muted);
    margin-top: 0.6em;
}

/* ---------- Tables ---------- */

.cms-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.cms-content :where(th, td) {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--cms-border);
    vertical-align: top;
}

.cms-content th {
    color: var(--cms-heading);
    font-weight: 600;
    background: var(--cms-surface);
}

/* ---------- Building blocks ---------- */

.cms-content .cms-columns,
.cms-content .cms-media,
.cms-content .cms-swatches,
.cms-content .cms-cards {
    display: grid;
    gap: 24px 40px;
    max-width: none;
    margin-top: 1.6em;
}

.cms-content :where(.cms-columns, .cms-media, .cms-swatches, .cms-cards) > * {
    margin-top: 0;
}

@media (min-width: 768px) {
    .cms-content .cms-columns,
    .cms-content .cms-media {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .cms-content .cms-media {
        grid-template-columns: 3fr 2fr;
        align-items: center;
    }

    .cms-content .cms-media--left {
        grid-template-columns: 2fr 3fr;
    }

    .cms-content .cms-media--left > :first-child {
        order: 2;
    }
}

.cms-content .cms-media img {
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    border-radius: var(--cms-radius);
}

/* Swatches: small square tiles, as many per row as fit. */
.cms-content .cms-swatches {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
}

.cms-content .cms-swatches > * {
    text-align: center;
    font-size: 14px;
    line-height: 1.35;
}

.cms-content .cms-swatches img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 10px;
    background: var(--cms-surface);
    border: 1px solid var(--cms-border);
}

.cms-content .cms-swatches :where(figcaption, p) {
    margin-top: 0.6em;
    color: var(--cms-muted);
}

.cms-content .cms-swatches strong {
    display: block;
    color: var(--cms-heading);
}

/* Cards */
.cms-content .cms-cards {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.cms-content .cms-cards > * {
    background: var(--cms-surface);
    border-radius: var(--cms-radius);
    padding: 24px;
}

.cms-content .cms-cards img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    margin-bottom: 14px;
}

/* Checklist (USPs) */
.cms-content ul.cms-checklist {
    list-style: none;
    padding-left: 0;
}

.cms-content ul.cms-checklist li {
    position: relative;
    padding-left: 30px;
}

.cms-content ul.cms-checklist li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.3em;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--cms-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 13px no-repeat;
}

/* Note */
.cms-content .cms-note {
    background: var(--cms-green-light);
    border-left: 4px solid var(--cms-green);
    border-radius: 0 var(--cms-radius) var(--cms-radius) 0;
    padding: 18px 22px;
    max-width: var(--cms-measure);
}

/* Call to action */
.cms-content .cms-cta {
    background: var(--cms-surface);
    border-radius: var(--cms-radius);
    padding: clamp(24px, 4vw, 40px);
    margin-top: 2.5em;
    max-width: none;
}

.cms-content .cms-cta :where(h2, h3) {
    margin-top: 0;
}

.cms-content .cms-button {
    display: inline-block;
    background: var(--cms-green);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 999px;
    padding: 12px 26px;
    line-height: 1.2;
    transition: background-color .15s;
}

.cms-content .cms-button:hover {
    background: #5b7524;
}

.cms-content .cms-button--outline {
    background: transparent;
    color: var(--cms-green);
    box-shadow: inset 0 0 0 2px var(--cms-green);
}

.cms-content .cms-button--outline:hover {
    background: var(--cms-green-light);
}

/* ---------- Compatibility with pages from the old page builder ----------
   Those pages use utility classes (grid-cols-6, space-y-10, text-2xl ...) that
   are not all present in the shop CSS, which made headings jump and swatches
   huge. Until a page is rewritten, these rules give it the same calm layout. */

.cms-content :where(.max-w-7xl) {
    max-width: none;
    padding: 0;
}

.cms-content :where(h2, h3, h4)[class] {
    margin-bottom: 0.4em;
}

/* Grids made of image tiles become swatch grids. */
.cms-content .grid:has(> .text-center > img) {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
    max-width: none;
}

.cms-content .grid > .text-center {
    text-align: center;
    font-size: 14px;
    line-height: 1.35;
    margin-top: 0;
}

.cms-content .grid > .text-center > br {
    display: none;
}

.cms-content .grid > .text-center img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--cms-border);
    background: var(--cms-surface);
}

.cms-content .grid > .text-center p {
    margin-top: 0.6em;
    color: var(--cms-muted);
}

.cms-content .grid > .text-center strong {
    display: block;
    color: var(--cms-heading);
}

/* Grids of text columns read as one column, so headings no longer jump. */
.cms-content .grid:not(:has(> .text-center > img)) {
    display: block;
}

.cms-content .grid:not(:has(> .text-center > img)) > * + * {
    margin-top: 1.1em;
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
    .cms-content {
        font-size: 16px;
    }

    .cms-content h2 {
        margin-top: 1.8em;
    }

    .cms-content .cms-swatches,
    .cms-content .grid:has(> .text-center > img) {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 14px;
    }
}

/* Row of buttons: <p class="cms-buttons"><a class="cms-button" ...> <a class="cms-button cms-button--outline" ...></p> */
.cms-content .cms-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
