/* ============================================================
   Modern CSS Grid System - 2026 Rewrite

   WHAT'S CHANGED - OVERVIEW:
   - Gaps now use clamp() — no more repeated @media for spacing.
   - Padding utilities use clamp() for fluid scaling too.
   - Column classes renamed from .col-lg-6 → .col-6@lg (sort of
     concept, but since @ isn't valid in plain CSS class names,
     we've instead moved to a cleaner BEM-ish naming convention:
     .col--sm-6, .col--md-6, .col--lg-6 to signal they're
     modifiers, not standalone classes).
   - All @media blocks now use CSS Nesting — rules live where
     they belong, not scattered at the bottom.
   - Replaced fixed padding scale with fluid clamp() values.
   - Added @layer to give you cascade control without !important hacks.
   - Dropped .pad-none !important in favour of .u-pad-0
     (utility prefix pattern is cleaner).
   ============================================================ */


/* ============================================================
   LAYERS — controls cascade priority cleanly.
   No more !important wars.
   ============================================================ */
@layer reset, base, layout, utilities;


/* ============================================================
   TOKENS

   WHAT'S NEW:
   - --gap and --gap-lg replaced with clamp() — gap now scales
     fluidly between mobile (1rem) and desktop (2rem) without
     a single @media query.
   - --container-max kept as-is, still useful.
   - --columns stays at 12.
   ===========================================================§= */
@layer base {
    :root {
        --gap: clamp(1rem, 2vw, 2rem);
        --container-max: 1200px;
        --columns: 12;

        /* Fluid spacing scale — replaces the old pad-sm/md/lg @media stacks */
        --space-xs:  clamp(0.5rem,  1vw,   1rem);
        --space-sm:  clamp(1rem,    2vw,   2rem);
        --space-md:  clamp(1.5rem,  3vw,   3rem);
        --space-lg:  clamp(2rem,    5vw,   5rem);
        --space-xl:  clamp(4rem,    8vw,   10rem);
    }
}


/* ============================================================
   CONTAINERS
   ============================================================ */
@layer layout {

    /* .container → unchanged name, still the main centred wrapper */
    .container {
        width: 100%;
        max-width: var(--container-max);
        margin-inline: auto;             /* Modern shorthand for margin left/right */
        /*padding-inline: var(--space-sm); !* Replaces padding-left + padding-right *!*/
        box-sizing: border-box;
        border-right: 1px solid var(--color-border);
        border-bottom: 1px solid var(--color-border);
        border-left: 1px solid var(--color-border);
    }

    /* .full-width-row → unchanged.
       Inner wrapper now uses subgrid where supported for perfect column alignment.
       WHAT'S NEW: @supports check means old browsers get the safe fallback. */
    .full-width-row {
        width: 100%;
        position: relative;
    }

    .full-width-row__inner {
        /* RENAMED: .full-width-row-inner → .full-width-row__inner (BEM convention) */
        display: grid;
        grid-template-columns: repeat(var(--columns), 1fr);
        gap: var(--gap); /* clamp() does the responsive work — no @media needed */
    }


    /* ============================================================
       ROWS
       ============================================================ */

    /* .row — unchanged name */
    .row {
        display: grid;
        grid-template-columns: repeat(var(--columns), 1fr);
        gap: var(--gap); /* fluid, no @media required */
        width: 100%;
    }


    /* ============================================================
       COLUMNS

       NAMING CHANGE:
       Old: .col-sm-6, .col-md-6, .col-lg-6
       New: .col--sm-6, .col--md-6, .col--lg-6

       WHY: Double-dash signals these are modifiers of .col (BEM).
       Makes it obvious in markup that .col is the base and
       --sm/md/lg are variants, not independent classes.

       Base .col still defaults to full-width (span 12).
       Breakpoints use CSS Nesting — all rules live here together,
       not split across the file.
       ============================================================ */

    .col {
        grid-column: span 12;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: flex-start;

        /* Small screens: 600px+ (37.5em) */
        @media (width >= 37.5em) {
            &.col--sm-1  { grid-column: span 1; }
            &.col--sm-2  { grid-column: span 2; }
            &.col--sm-3  { grid-column: span 3; }
            &.col--sm-4  { grid-column: span 4; }
            &.col--sm-5  { grid-column: span 5; }
            &.col--sm-6  { grid-column: span 6; }
            &.col--sm-7  { grid-column: span 7; }
            &.col--sm-8  { grid-column: span 8; }
            &.col--sm-9  { grid-column: span 9; }
            &.col--sm-10 { grid-column: span 10; }
            &.col--sm-11 { grid-column: span 11; }
            &.col--sm-12 { grid-column: span 12; }
        }

        /* Medium screens: 768px+ (48em) */
        @media (width >= 48em) {
            &.col--md-1  { grid-column: span 1; }
            &.col--md-2  { grid-column: span 2; }
            &.col--md-3  { grid-column: span 3; }
            &.col--md-4  { grid-column: span 4; }
            &.col--md-5  { grid-column: span 5; }
            &.col--md-6  { grid-column: span 6; }
            &.col--md-7  { grid-column: span 7; }
            &.col--md-8  { grid-column: span 8; }
            &.col--md-9  { grid-column: span 9; }
            &.col--md-10 { grid-column: span 10; }
            &.col--md-11 { grid-column: span 11; }
            &.col--md-12 { grid-column: span 12; }
        }

        /* Large screens: 1024px+ (64em) */
        @media (width >= 64em) {
            &.col--lg-1  { grid-column: span 1; }
            &.col--lg-2  { grid-column: span 2; }
            &.col--lg-3  { grid-column: span 3; }
            &.col--lg-4  { grid-column: span 4; }
            &.col--lg-5  { grid-column: span 5; }
            &.col--lg-6  { grid-column: span 6; }
            &.col--lg-7  { grid-column: span 7; }
            &.col--lg-8  { grid-column: span 8; }
            &.col--lg-9  { grid-column: span 9; }
            &.col--lg-10 { grid-column: span 10; }
            &.col--lg-11 { grid-column: span 11; }
            &.col--lg-12 { grid-column: span 12; }
        }
    }

} /* end @layer layout */


/* ============================================================
   UTILITIES

   WHAT'S CHANGED — PADDING & MARGIN:

   Old naming was inconsistent: pad-t-sm, pad-tb, pad-tb-lg,
   pad-b-xsm — no real pattern you could predict.

   New system uses a consistent scale suffix:
   -0  = zero
   -xs = extra small  → var(--space-xs)
   -sm = small        → var(--space-sm)
   -md = medium       → var(--space-md)
   -lg = large        → var(--space-lg)
   -xl = extra large  → var(--space-xl)

   Direction shorthand is kept lean:
   .p-  = padding (all sides)
   .pt- = padding-top
   .pb- = padding-bottom
   .py- = padding block (top + bottom) — replaces pad-tb-*
   .px- = padding inline (left + right)
   .mt- = margin-top
   .mb- = margin-bottom

   ALL of these are fluid via clamp() — zero @media needed.

   MIGRATION MAP (old → new):
   .pad-none     → .p-0
   .pad-sm       → .p-sm
   .pad-md       → .p-md
   .pad-lg       → .p-lg
   .pad-t-sm     → .pt-sm
   .pad-t-md     → .pt-md
   .pad-tb-sm    → .py-sm
   .pad-tb       → .py-md
   .pad-tb-lg    → .py-xl
   .pad-b        → .pb-md
   .pad-b-sm     → .pb-sm
   .pad-b-xsm    → .pb-xs
   .pad-tr       → no direct equivalent — use .pt-md + .px-md
   .mar-b        → .mb-md
   .gap-sm       → .gap-xs
   .gap-md       → .gap-sm
   .gap-lg       → .gap-md
   .m-pad-b      → removed. Use .pb-sm scoped to your own @media if needed.
   .mt-pad-b     → removed. Same reason.
   ============================================================ */

@layer utilities {

    /* Padding — all sides */
    .p-0  { padding: 0; }
    .p-xs { padding: var(--space-xs); }
    .p-sm { padding: var(--space-sm); }
    .p-md { padding: var(--space-md); }
    .p-lg { padding: var(--space-lg); }
    .p-xl { padding: var(--space-xl); }

    /* Padding — top */
    .pt-xs { padding-top: var(--space-xs); }
    .pt-sm { padding-top: var(--space-sm); }
    .pt-md { padding-top: var(--space-md); }
    .pt-lg { padding-top: var(--space-lg); }
    .pt-xl { padding-top: var(--space-xl); }

    /* Padding — bottom */
    .pb-xs { padding-bottom: var(--space-xs); }
    .pb-sm { padding-bottom: var(--space-sm); }
    .pb-md { padding-bottom: var(--space-md); }
    .pb-lg { padding-bottom: var(--space-lg); }
    .pb-xl { padding-bottom: var(--space-xl); }

    /* Padding — block (top + bottom) — replaces .pad-tb-* */
    .py-xs { padding-block: var(--space-xs); }
    .py-sm { padding-block: var(--space-sm); }
    .py-md { padding-block: var(--space-md); }
    .py-lg { padding-block: var(--space-lg); }
    .py-xl { padding-block: var(--space-xl); }

    /* Padding — inline (left + right) */
    .px-xs { padding-inline: var(--space-xs); }
    .px-sm { padding-inline: var(--space-sm); }
    .px-md { padding-inline: var(--space-md); }
    .px-lg { padding-inline: var(--space-lg); }
    .px-xl { padding-inline: var(--space-xl); }

    /* Padding — left */
    .pl-xs { padding-inline: var(--space-xs); }
    .pl-sm { padding-inline: var(--space-sm); }
    .pl-md { padding-inline: var(--space-md); }
    .pl-lg { padding-inline: var(--space-lg); }
    .pl-xl { padding-inline: var(--space-xl); }

    /* Margin — bottom */
    .mb-xs { margin-bottom: var(--space-xs); }
    .mb-sm { margin-bottom: var(--space-sm); }
    .mb-md { margin-bottom: var(--space-md); }
    .mb-lg { margin-bottom: var(--space-lg); }
    .mb-xl { margin-bottom: var(--space-xl); }

    /* Margin — top */
    .mt-xs { margin-top: var(--space-xs); }
    .mt-sm { margin-top: var(--space-sm); }
    .mt-md { margin-top: var(--space-md); }
    .mt-lg { margin-top: var(--space-lg); }
    .mt-xl { margin-top: var(--space-xl); }

    /* Gap utilities — used inside .row or flex containers */
    .gap-xs { gap: var(--space-xs); }
    .gap-sm { gap: var(--space-sm); }
    .gap-md { gap: var(--space-md); }
    .gap-lg { gap: var(--space-lg); }

}