/* Bersama Child — main.css */
/* products.css / news.css are enqueued per-template in functions.php with
   filemtime cache-busting. Do NOT @import them here — an @import URL has no
   version query, so browsers cache it forever and serve stale styles. */

/* === WEB FONT: Syne (self-hosted variable font, OFL licensed) === */
/* One variable file covers Regular→ExtraBold (wght 400–800). Path is relative
   to this CSS file: assets/css/ -> ../fonts/. format('truetype') is used (not
   'truetype-variations') for the widest browser support, incl. iOS Safari —
   the browser still reads the wght axis from the file itself. */
@font-face {
    font-family: 'Syne';
    src: url('../fonts/Syne-VariableFont_wght.ttf') format('truetype');
    font-weight: 400 800;
    font-style: normal;
    font-display: swap;
}

/* === GLOBAL RESET === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Clip horizontal overflow without creating an extra scroll container.
   `hidden` on both html and body promotes body to its own scroll box in
   some browsers (a second vertical scrollbar appears); `clip` never does.
   The `hidden` line is only a fallback for browsers without `clip`.
   `max-width: 100vw` was removed — 100vw includes the scrollbar width, so
   it forced content under the scrollbar and produced horizontal overflow. */
html,
body {
    overflow-x: hidden;
    overflow-x: clip;
}

/* === BASE TYPOGRAPHY === */
html {
    font-size: var(--font-size-base);
    background-color: var(--color-bg);
    color: var(--color-text);
}

body {
    font-family: var(--font-primary);
    font-weight: 400;
    line-height: var(--line-height-base);
    /* Claim the brand text colour on body too: the parent theme sets
       `body { color: #111 }`, which beats the color inherited from <html>, so
       without this any text that merely inherits (rather than using the token)
       stays near-black instead of Espresso. */
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === PAGE FADE TRANSITION === */
/* Body starts hidden and fades in once main.js adds .is-loaded; on outbound
   navigation the class is removed to fade out. A <noscript> override in
   header.php forces opacity:1 so the page is never permanently blank if JS
   fails to run. */
body {
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.is-loaded {
    opacity: 1;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition-hover);
}

a:hover {
    color: var(--color-muted);
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Performance — prevent layout shift */
img {
    height: auto;
    max-width: 100%;
}

.product-row__thumb img {
    aspect-ratio: 1 / 1;
}

.product-carousel__slide img {
    aspect-ratio: 16 / 9;
}

.news-card__image img {
    aspect-ratio: 4 / 3;
}

ul,
ol {
    list-style: none;
}

/* === HEADER === */

#bersama-header {
    position: fixed;
    top: 0; /* default for visitors — no admin bar */
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #ffffff;
    background: var(--color-bg);
    border-bottom: 1px solid #e8e8e8;
    z-index: 99998; /* just below WP admin bar (99999) */
    display: flex;
    align-items: center;
    transition: box-shadow 0.25s ease;
}

/* Elevation shadow once the page is scrolled — keeps the solid header
   visually separated from content passing underneath. */
#bersama-header.is-scrolled {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* Drop below the WP admin bar when it is shown. `.admin-bar` (not
   `.logged-in`) is the class WordPress ties to the bar actually rendering.
   The bar is 32px on desktop but 46px at ≤782px — without the media query
   the header sat 14px too high on small screens, leaving a stray white gap
   above it and overlapping the bar. */
.admin-bar #bersama-header {
    top: 32px;
}

@media (max-width: 782px) {
    .admin-bar #bersama-header {
        top: 46px;
    }
}

#bersama-nav {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
}

/* The logo is a dropdown TOGGLE button (was a home link) — reset native button
   chrome so only the PNG wordmark shows. flex-shrink lives on the wrapper. */
#bersama-logo {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    margin: 0;
    padding: 0;
    cursor: pointer;
    color: inherit;
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}

#bersama-logo img {
    height: var(--logo-height);
    width: auto;
    display: block;
}

/* === LOGO DROPDOWN MENU ===
   Clicking the logo opens this dropdown with the Products + News links (moved out
   of the nav bar). main.js adds .is-open on #bersama-logo-menu. */
#bersama-logo-menu {
    position: relative;
    flex-shrink: 0;
    /* Flex (not the default block) so the inline-flex logo button doesn't sit on
       a text baseline. As a block it did, leaving ~10px of descender space below
       the logo — that inflated this wrapper to 44px and pushed the logo above the
       header's true centre. Flexing it makes the wrapper hug the 34px button so
       the header/nav align-items:center can centre the logo. The absolutely
       positioned dropdown is out of flex flow, so it's unaffected. */
    display: flex;
    align-items: center;
}

#bersama-logo-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    min-width: 168px;
    padding: 6px 0;
    background: var(--color-bg);
    border: 1px solid #e8e8e8;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    /* Hidden until the logo is clicked. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1;
}

#bersama-logo-menu.is-open #bersama-logo-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Stack the menu vertically inside the dropdown (overrides the horizontal nav
   layout); each link gets a full-width tap row. */
#bersama-logo-dropdown .bersama-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

#bersama-logo-dropdown .bersama-menu a {
    display: block;
    padding: 11px 22px;
    font-weight: 500;
    /* Only the colour + glow change on hover — the weight/size stays put. */
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

/* Hover / keyboard focus — the word "shines" to a light yellow-brown and emits a
   matching warm glow halo. The colour change is an intentional exception to the
   one-Espresso rule (per request); the weight/size is deliberately unchanged. */
#bersama-logo-dropdown .bersama-menu a:hover,
#bersama-logo-dropdown .bersama-menu a:focus-visible {
    color: var(--color-glow);
    text-shadow:
        0 0 5px color-mix( in srgb, var(--color-glow) 60%, transparent ),
        0 0 16px color-mix( in srgb, var(--color-glow) 35%, transparent );
}

/* Wrapper around wp_nav_menu output. margin-left:auto pins the link group
   to the right edge even if a plugin/theme style stretches this div. */
#bersama-nav-links {
    display: flex;
    align-items: center;
    gap: 28px;
    margin-left: auto;
}

/* Project search — quiet, big.dk-minimal: a thin underline that darkens and
   widens on focus. Sits to the left of the menu inside #bersama-nav-links. */
#bersama-search {
    display: flex;
    align-items: center;
}

#bersama-search-input {
    font-family: inherit;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--color-text);
    background: transparent;
    border: none;
    border-bottom: 1px solid #e8e8e8;
    padding: 4px 2px;
    width: 110px;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    transition: border-color 0.2s ease, width 0.2s ease;
}

#bersama-search-input::placeholder {
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
}

#bersama-search-input:focus {
    border-bottom-color: var(--color-text);
    width: 150px;
}

.bersama-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 32px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.bersama-menu a {
    font-size: 13px;
    color: #6b6b6b;
    color: var(--color-muted);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: color 0.2s ease;
    transition: var(--transition-hover);
}

.bersama-menu a:hover {
    color: #000000;
    color: var(--color-text);
}

/* Mobile: comfortable tap targets, tighter padding.
   IMPORTANT: this block must stay BELOW the base nav rules above — at equal
   specificity the later rule wins, so placing it earlier in the file let the
   desktop padding/font-size/gap override the mobile values. */
@media (max-width: 768px) {
    /* Phones keep the original 52px bar: the 28px logo already clears ~1.5x its
       "o" here, so the desktop clear-space bump isn't needed. */
    #bersama-header {
        height: 52px;
    }
    #bersama-products-root,
    #bersama-news-root {
        padding-top: 52px;
    }

    #bersama-nav {
        padding: 0 16px;
    }

    #bersama-logo img {
        height: 28px;
    }

    /* Tighten the nav-links gap and shrink the search so the logo + search +
       menu still fit a phone width without wrapping. */
    #bersama-nav-links {
        gap: 14px;
    }

    #bersama-search-input {
        width: 84px;
    }

    #bersama-search-input:focus {
        width: 104px;
    }

    .bersama-menu {
        gap: 20px;
    }

    .bersama-menu a {
        font-size: 12px;
        /* 44px-tall tap area without changing the visual layout */
        padding: 14px 4px;
        display: inline-block;
    }
}

/* Push page content below the fixed header (var(--header-height) — 64px on
   desktop, 52px on phones). The wrapper only needs to clear the header — NOT the
   admin bar: when the WP admin bar shows on the front end it already offsets the
   page via `html { margin-top: 32px/46px }`, and the header itself drops to
   `top: 32px` (.admin-bar #bersama-header). Re-adding the bar height here (the
   old .admin-bar 84px/98px overrides) double-counted it and left a ~32px gap
   above the filter bar for logged-in users, so the header height applies to all. */
#bersama-products-root,
#bersama-news-root {
    padding-top: var(--header-height);
}

/* === COMMENTS REMOVED === */
/* Comments are disabled for news posts in functions.php (and the core Comments
   block is stripped from single-post output). This is a safety net that hides
   any residual core Comments block markup a theme/version might still emit. */
.wp-block-comments,
.wp-block-comments-query-loop {
    display: none !important;
}

/* === WHATSAPP FAB === */

#bersama-whatsapp-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 52px;
    height: 52px;
    background: #25d366;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

#bersama-whatsapp-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#bersama-whatsapp-fab svg {
    width: 28px;
    height: 28px;
}

/* === FOOTER === */
/* big.dk-style: centered column of expandable sections. The +/− glyph on
   each toggle is swapped in JS (main.js), not in CSS. */

#bersama-footer {
    border-top: 1px solid #e8e8e8;
    background: var(--color-bg);
    padding: 80px 40px 48px;
    text-align: center;
}

.footer-sections {
    max-width: 600px;
    margin: 0 auto;
}

.footer-section {
    border-bottom: 1px solid #e8e8e8;
}

.footer-section__toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 20px 0;
    font-family: inherit;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text);
    text-align: center;
}

/* Hidden by default; height animates open when .is-open is set on the parent. */
.footer-section__content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.footer-section.is-open .footer-section__content {
    max-height: 200px;
}

.footer-section__content a,
.footer-section__content p {
    display: block;
    font-size: 13px;
    line-height: 1.7;
    color: var(--color-muted);
    text-decoration: none;
    padding: 4px 0;
    transition: color 0.2s ease;
    margin: 0;
}

/* Breathing room below the last item once a section is open. */
.footer-section__content > *:last-child {
    padding-bottom: 20px;
}

.footer-section__content a:hover {
    color: var(--color-text);
}

.footer-bottom {
    padding-top: 40px;
}

#footer-back-to-top {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

#footer-back-to-top:hover {
    color: var(--color-text);
}

/* Copyright notice — a quiet line under the back-to-top link. Muted Espresso,
   small, matching the rest of the footer chrome (one font, one colour token). */
.footer-copyright {
    margin: 20px 0 0;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}
