/**
 * Mercantile layout: page shell, the framework's 12-column row grid, the chrome
 * bands (announce strip, header, footer) and the mobile navigation drawer.
 */

* ,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

/* Paper canvas with a subtle grain dot-matrix, both schemes. */
body {
    margin: 0;
    background-color: var(--ec-bg);
    background-image: radial-gradient(rgba(120, 90, 50, 0.05) 1px, transparent 1px);
    background-size: 5px 5px;
    color: var(--ec-fg);
    font-family: var(--ec-font-body);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

/* Page shell: boxed via --ec-cw (100% when full width) */
.ts-container {
    max-width: var(--ec-cw);
    margin-inline: auto;
    padding-inline: var(--ec-gut);
}

/* Framework rows: a real 12-column grid */
.ts-row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--ec-grid-gap);
    align-items: start;
}

.ts-row + .ts-row {
    margin-top: var(--ec-sect-y);
}

.ts-span-1 { grid-column: span 1; }
.ts-span-2 { grid-column: span 2; }
.ts-span-3 { grid-column: span 3; }
.ts-span-4 { grid-column: span 4; }
.ts-span-5 { grid-column: span 5; }
.ts-span-6 { grid-column: span 6; }
.ts-span-7 { grid-column: span 7; }
.ts-span-8 { grid-column: span 8; }
.ts-span-9 { grid-column: span 9; }
.ts-span-10 { grid-column: span 10; }
.ts-span-11 { grid-column: span 11; }
.ts-span-12 { grid-column: span 12; }

/*
 * Responsive collapse rule (SPEC, Layout): below the md breakpoint every
 * column stacks full width. Per-breakpoint spans are a Studio app
 * feature and will refine this.
 */
@media (max-width: 767.98px) {
    .ts-col {
        grid-column: 1 / -1;
    }

    .ts-row + .ts-row {
        margin-top: calc(var(--ec-sect-y) / 2);
    }
}

/* Page shell between the chrome bands */
.ts-shell {
    padding-block: calc(var(--ec-sect-y) / 2) var(--ec-sect-y);
    min-height: 45vh;
}

/* Announce strip: inverted ink band with mono ticker type */
.ts-topbar {
    background: var(--ec-fg);
    color: var(--ec-bg);
    font-family: var(--ec-font-mono);
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* In dark mode a foreground-colored band would glow cream; drop to true black. */
[data-color-scheme="dark"] .ts-topbar {
    background: #000;
    color: var(--ec-fg-2);
}

.ts-topbar__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    min-height: 2.25rem;
    padding-block: 0.35rem;
}

.ts-topbar__text {
    margin: 0;
    text-align: center;
}

.ts-topbar__side {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ts-topbar__side--end {
    justify-content: flex-end;
}

.ts-topbar a {
    color: inherit;
    text-decoration: none;
}

.ts-social-links {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.ts-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
    border-radius: 999px;
    color: inherit;
    opacity: 0.85;
    transition: opacity var(--ec-dur-1) var(--ec-ease), border-color var(--ec-dur-1) var(--ec-ease);
}

.ts-social:hover {
    opacity: 1;
    border-color: currentColor;
}

.ts-social svg {
    width: 13px;
    height: 13px;
}

.ts-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.ts-lang {
    padding: 0.15rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 999px;
    color: inherit;
    opacity: 0.7;
    text-decoration: none;
    transition: opacity var(--ec-dur-1) var(--ec-ease), border-color var(--ec-dur-1) var(--ec-ease);
}

.ts-lang:hover {
    opacity: 1;
}

.ts-lang.is-active {
    opacity: 1;
    border-color: color-mix(in srgb, currentColor 45%, transparent);
}

@media (max-width: 639.98px) {
    .ts-topbar__inner {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 0.35rem;
        padding-block: 0.4rem;
    }

    .ts-topbar__side {
        justify-content: center;
    }
}

/* Header band */
.ts-header {
    background: var(--ec-bg);
    border-bottom: 1px solid var(--ec-border);
}

.ts-header.is-sticky {
    position: sticky;
    top: 0;
    z-index: 950;
    background: color-mix(in srgb, var(--ec-bg) 88%, transparent);
}

/* The blur lives on a pseudo-element: backdrop-filter on the header itself
   would make it the containing block for the fixed off-canvas nav panel,
   trapping the drawer inside the 76px header box. */
.ts-header.is-sticky::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.ts-header__inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-height: 76px;
    position: relative;
}

.ts-brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--ec-fg);
}

.ts-brand__text {
    font-family: var(--ec-font-display);
    font-weight: 600;
    font-size: clamp(1.375rem, 1.1rem + 1.1vw, 1.875rem);
    letter-spacing: 0.13em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
}

/* The coral full stop, Mercantile's signature */
.ts-brand__text::after {
    content: ".";
    color: var(--ec-accent);
}

.ts-brand__logo {
    max-height: 2.5rem;
    width: auto;
}

.ts-header__nav {
    flex: 1;
    min-width: 0;
}

.ts-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

/* Header actions (cart, search, account, scheme toggle): hairline pills */
.ts-action {
    appearance: none;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 40px;
    height: 40px;
    padding-inline: 0.55rem;
    border: 1px solid var(--ec-border-2);
    border-radius: 999px;
    background: none;
    color: var(--ec-fg-2);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    transition: color var(--ec-dur-1) var(--ec-ease), border-color var(--ec-dur-1) var(--ec-ease);
}

.ts-action:hover {
    border-color: var(--ec-fg-2);
    color: var(--ec-fg);
}

/* Count circle sits inline inside the pill, like the design's cart button */
.ts-action__badge {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: -3px;
    border-radius: 50%;
    background: var(--ec-accent);
    color: var(--ec-accent-fg);
    font-family: var(--ec-font-mono);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
}

/* The explicit display above would otherwise defeat the hidden attribute
   the ec-bridge toggles on the badge. */
.ts-action__badge[hidden] {
    display: none;
}

/* Header variants. Centered = single-row 3-column grid, brand in the middle.
   ChromeRenderer emits brand, nav, actions in that DOM order. */
.ts-header--centered .ts-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "nav brand actions";
    align-items: center;
}

.ts-header--centered .ts-brand {
    grid-area: brand;
    justify-self: center;
}

.ts-header--centered .ts-header__nav {
    grid-area: nav;
    justify-self: start;
    flex: none;
}

.ts-header--centered .ts-header__actions {
    grid-area: actions;
    justify-self: end;
    margin-left: 0;
}

.ts-header--minimal .ts-header__inner {
    justify-content: space-between;
}

/* Navigation: styles Joomla's menu module output */
.ts-header__nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.ts-header__nav li {
    position: relative;
}

.ts-header__nav a,
.ts-header__nav .nav-header,
.ts-header__nav .separator {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 0.7rem;
    color: var(--ec-fg-2);
    font-size: 12.5px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color var(--ec-dur-1) var(--ec-ease), border-color var(--ec-dur-1) var(--ec-ease);
}

.ts-header__nav a:hover {
    color: var(--ec-fg);
}

.ts-header__nav li.active > a,
.ts-header__nav li.current > a {
    color: var(--ec-accent);
    border-bottom-color: var(--ec-accent);
}

/* Desktop dropdowns for nested menu levels: square paper panels */
.ts-header__nav li ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 960;
    min-width: 13rem;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0;
    background: var(--ec-surface);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius);
    box-shadow: var(--ec-shadow);
}

.ts-header__nav li:hover > ul,
.ts-header__nav li:focus-within > ul {
    display: flex;
}

.ts-header__nav li ul a {
    width: 100%;
    padding: 0.55rem 1.1rem;
    border-bottom: none;
}

.ts-header__nav li ul a:hover {
    color: var(--ec-accent);
}

.ts-nav-toggle {
    display: none;
}

/* Mobile: hamburger + slide-in navigation drawer */
@media (max-width: 899.98px) {
    .ts-nav-toggle {
        display: inline-flex;
    }

    .ts-header__nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 990;
        width: min(20rem, 85vw);
        padding: 4.5rem 1.5rem 1.5rem;
        background: var(--ec-bg);
        border-left: 1px solid var(--ec-border);
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform var(--ec-dur-3) var(--ec-ease);
    }

    body.ts-nav-open .ts-header__nav {
        transform: none;
    }

    /* Below the sticky header's 950: the nav panel lives inside the header's
       stacking context, so a higher backdrop would paint over the open panel. */
    body.ts-nav-open::after {
        content: '';
        position: fixed;
        inset: 0;
        z-index: 940;
        background: rgba(0, 0, 0, 0.35);
    }

    body.ts-nav-open {
        overflow: hidden;
    }

    .ts-header__nav ul {
        flex-direction: column;
        gap: 0;
    }

    .ts-header__nav a {
        width: 100%;
        padding: 0.75rem 0.25rem;
        border-bottom: none;
        font-size: 0.85rem;
    }

    .ts-header__nav li + li {
        border-top: 1px solid var(--ec-border);
    }

    .ts-header__nav li ul {
        display: block;
        position: static;
        min-width: 0;
        padding: 0 0 0 1rem;
        border: none;
        box-shadow: none;
        background: none;
    }

    .ts-header__nav li ul li + li {
        border-top: none;
    }

    /* The nav is off-canvas here, so the grid collapses to brand + actions */
    .ts-header--centered .ts-header__inner {
        grid-template-columns: auto 1fr;
        grid-template-areas: "brand actions";
    }

    .ts-header--centered .ts-brand {
        justify-self: start;
    }
}

/* Tight phones: the action row must never push the nav toggle off screen */
@media (max-width: 639.98px) {
    .ts-header__inner {
        gap: 0.75rem;
        min-height: 64px;
    }

    .ts-header__actions {
        gap: 0.375rem;
    }

    .ts-action {
        min-width: 36px;
        height: 36px;
    }

    .ts-brand__text {
        font-size: 1.25rem;
    }
}

/* Footer band: raised cream surface with a hairline top rule in both
   schemes (surface-2 derives from the tokens, so no dark override). */
.ts-footer {
    background: var(--ec-surface-2);
    color: var(--ec-fg);
    border-top: 1px solid var(--ec-border);
    padding-block: calc(var(--ec-sect-y) / 1.25) 1.75rem;
}

.ts-footer a {
    color: var(--ec-fg-2);
    text-decoration: none;
    transition: color var(--ec-dur-1) var(--ec-ease);
}

.ts-footer a:hover {
    color: var(--ec-accent);
}

.ts-footer__cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: calc(var(--ec-grid-gap) * 2);
    margin-bottom: 2.5rem;
}

/* Column headings as mono micro-labels */
.ts-footer h5,
.ts-footer .ts-module__title {
    margin: 0 0 0.85rem;
    font-family: var(--ec-font-mono);
    font-weight: 400;
    font-size: 9.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ec-fg-3);
}

.ts-footer ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.55rem;
}

.ts-footer,
.ts-footer p,
.ts-footer li {
    font-size: 0.8125rem;
}

.ts-footer p {
    color: var(--ec-fg-2);
}

.ts-footer__copy {
    margin: 2.25rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--ec-border);
    font-family: var(--ec-font-mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ec-fg-3);
}

/* Accessibility: skip link */
.ts-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    background: var(--ec-accent);
    color: var(--ec-accent-fg);
}

.ts-skip-link:focus {
    left: 0;
}


/* --- TS rich footer (brand block + columns + bottom bar) --- */
.ts-footer .ts-footer__cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 2rem 2.5rem;
    margin-bottom: 2.75rem;
}
.ts-footer .ts-footer__col ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.55rem;
}
.ts-footer .ts-footer__col h5 {
    margin: 0 0 0.95rem;
    font-family: var(--ec-font-mono, inherit);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ec-accent);
}
.ts-footer .ts-footer__col a,
.ts-footer .ts-footer__brand a {
    text-decoration: none;
}
.ts-footer__brand {
    display: grid;
    align-content: start;
    gap: 0.9rem;
    max-width: 24rem;
}
.ts-footer__brand .ts-brand,
.ts-footer__brand .ts-brand__text {
    font-size: 1.15rem;
}
.ts-footer__blurb {
    margin: 0;
    max-width: 34ch;
    line-height: 1.65;
    opacity: 0.85;
}
.ts-footer__brand .ts-social-links {
    margin-top: 0.15rem;
}
.ts-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.85rem 1.75rem;
    margin-top: 2.5rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--ec-border);
}
.ts-footer__bottom .ts-footer__copy {
    margin: 0;
    padding: 0;
    border: 0;
}
.ts-footer .ts-footer__legal {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--ec-font-mono, inherit);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.75;
}
.ts-footer .ts-footer__legal a {
    text-decoration: none;
}
