/*
Theme Name: Boxed Theme
Description: Main stylesheet
*/

/* ==========================================================================
   Breakpoints
   --------------------------------------------------------------------------
   Four widths, used everywhere:

     480px   phones
     768px   tablets and small phones in landscape
     992px   small desktops
    1100px   the point the boxed layout stops growing

   Two deliberate exceptions, neither of them an oversight:

     400px   one step finer than 480, where the compact list shrinks its
             thumbnail again on the narrowest phones
     782px   WordPress's own admin breakpoint, matched on purpose in
             inc/core/assets/css/theme-core.css so the admin bar behaves

   CSS cannot read a custom property inside a media query, so these are
   written out. Keeping to the four above is a convention, not a mechanism.
   ========================================================================== */

/* ==========================================================================
   CSS Variables (will be overridden by customizer)
   ========================================================================== */
:root {
    --primary-color: #e74c3c;
    --secondary-color: #f39c12;
    --content-bg: #ffffff;
    --outer-bg: #f5f5f5;
    --content-width: 700px;
    --sidebar-width: 300px;
    --total-width: 1060px;
    --text-color: #333333;
    --text-color-light: #666666;
    --border-color: #e0e0e0;
    --header-height: 70px;

    /* Surface tints — a wash from the opposite end of the scale over whatever sits behind.
       Two values rather than two rules: each of these used to be written twice, the second
       time under body.dark-mode with black swapped for white. */
    --tint-quote: rgba(0, 0, 0, 0.035);
    --tint-panel: rgba(0, 0, 0, 0.03);
    --tint-stripe: rgba(0, 0, 0, 0.02);
    --tint-row-hover: rgba(0, 0, 0, 0.04);
    /* Layered shadows — soft and modern; darkened variants below for dark mode */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.04), 0 6px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.06), 0 12px 28px rgba(0, 0, 0, 0.12);
    /* Match native form controls and scrollbars to the light palette */
    color-scheme: light;
    /* Tint checkboxes, radios, range sliders and progress bars */
    accent-color: var(--primary-color);
}

/* Dark Mode Variables */
body.dark-mode {
    --content-bg: #1a1a1a;
    --outer-bg: #0d0d0d;
    --text-color: #e0e0e0;
    --text-color-light: #a0a0a0;
    --border-color: #333333;

    --tint-quote: rgba(255, 255, 255, 0.045);
    --tint-panel: rgba(255, 255, 255, 0.03);
    --tint-stripe: rgba(255, 255, 255, 0.02);
    --tint-row-hover: rgba(255, 255, 255, 0.04);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 6px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
}

/* ==========================================================================
   Full-width site layout
   The outer background is unified with the content background for a flat,
   frameless look. Everything that referenced --outer-bg follows along
   automatically. The content wrapper keeps its max-width, so the content
   width settings and wrap-around side ads (AdSense etc.) still work.
   The doubled .dark-mode selector outranks the dynamic inline CSS that
   re-declares --outer-bg on body.dark-mode.
   ========================================================================== */
body.site-layout-full-width,
body.site-layout-full-width.dark-mode {
    --outer-bg: var(--content-bg);
}

.site-layout-full-width .content-wrapper {
    box-shadow: none;
}

/* Elements that relied on the outer-bg contrast alone (no border) get a
   subtle tint so they stay distinguishable on the flat background */
.site-layout-full-width .entry-content blockquote,
.site-layout-full-width .entry-content code,
.site-layout-full-width .entry-content pre,
.site-layout-full-width .entry-content table thead,
.site-layout-full-width .wp-block-table thead {
    background-color: var(--tint-quote);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--outer-bg);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Note: .site-content styling is in Content Area section */

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--secondary-color);
}

/* Content links — real underlines instead of border-bottom, so descenders
   are respected and line height doesn't shift */
.entry-content :is(p, ol, ul, tr) a:not(.mwpc-toc a, .page-numbers a) {
    color: var(--text-color);
    text-decoration: underline;
    text-decoration-color: var(--primary-color);
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
    transition: text-decoration-color 0.2s ease, opacity 0.2s ease;
}

.entry-content :is(p, ol, ul, tr) a:not(.smart-toc-wrapper a):hover {
    text-decoration-color: transparent;
    opacity: 0.85;
}

/* Text selection matches the accent color */
::selection {
    background-color: var(--primary-color);
    color: var(--button-text-color, #ffffff);
}

/* Visible keyboard focus without affecting mouse users */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Anchor targets should not disappear under the sticky header */
.sticky-header [id] {
    scroll-margin-top: calc(var(--header-height) + 20px);
}

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

.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}

/* Reveal the skip link when focused via keyboard */
.skip-link.screen-reader-text:focus {
    clip: auto;
    width: auto;
    height: auto;
    top: 8px;
    inset-inline-start: 8px;
    z-index: 100000;
    padding: 12px 20px;
    background-color: var(--content-bg);
    color: var(--primary-color);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    font-weight: 600;
    text-decoration: none;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
    background-color: var(--content-bg);
    border-bottom: var(--header-border-width, 1px) solid var(--border-color);
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease;
}

/* Sticky header - only when enabled */
.sticky-header .site-header {
    position: sticky;
    top: 0;
}

/* Optional: slide the sticky header away when scrolling down, bring it
   back when scrolling up (.scroll-down / .scroll-up set by theme.js) */
.sticky-header.header-hide-on-scroll .site-header {
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.sticky-header.header-hide-on-scroll .site-header.scroll-down {
    transform: translateY(-100%);
}

.header-wrapper {
    max-width: var(--total-width);
    margin: 0 auto;
    padding: 0 20px;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    gap: 20px;
}

/* Compact Header Specifics */
.header-compact .header-container {
    min-height: auto;
}

.header-compact-top {
    min-height: var(--header-height);
    padding-block: var(--compact-header-padding, 5px);
}

.header-compact-bottom-outer {
    background-color: var(--tint-panel);
}

.header-compact-bottom {
    min-height: 50px;
}

.header-compact .main-navigation a {
    /* +2.5px on each side: the 5px gap the items used to have, moved inside them. */
    padding: var(--compact-header-menu-padding-block, 10px) calc(var(--compact-header-menu-padding-inline, 16px) + 2.5px);
}

.header-compact-right-elements {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-grow: 1;
    justify-content: flex-end;
}

.header-compact-right-elements .compact-search {
    flex-grow: 1;
    max-width: 100%;
    margin-inline-start: 30px;
}

.header-compact-right-elements .compact-search .search-form {
    width: 100%;
}

.header-compact-right-elements .compact-search label {
    flex-grow: 1;
}

.header-compact-right-elements .compact-search .search-field {
    width: 100%;
}

.header-compact-right-elements .compact-search .search-field:focus {
    width: 100%;
}

@media screen and (max-width: 992px) {
    .header-compact-right-elements .compact-search {
        max-width: 100%;
        margin-inline-start: 10px;
    }
    
    .header-compact-right-elements {
        gap: 10px;
    }
}

@media screen and (max-width: 480px) {
    .header-compact-right-elements .compact-search {
        max-width: 100%;
        margin-inline-start: 5px;
    }
    
    .header-compact-right-elements .compact-search .search-field {
        padding-block: 8px; padding-inline: 12px 40px;
    }
    
    .header-compact-right-elements {
        gap: 5px;
    }
}

/* Logo / Site Branding */
.site-branding {
    flex-shrink: 1;
}

.custom-logo {
    max-height: 50px;
    width: auto;
    display: block;
}

/* SVG logo (inc/core/logo.php). It has no pixel size of its own, so the settings give it a
   height, and the width follows the file's proportions. A wordmark wider than the maximum
   shrinks inside its box instead of stretching: an SVG keeps its aspect ratio within an img. */
.custom-logo.custom-logo-svg {
    height: var(--logo-svg-height, 40px);
    max-height: none;
    width: auto;
    max-width: min(100%, var(--logo-svg-max-width, 240px));
}

@media (max-width: 768px) {
    .custom-logo.custom-logo-svg {
        height: min(var(--logo-svg-height, 40px), 50px);
    }
}

.mobile-menu-logo .custom-logo-svg {
    height: min(var(--logo-svg-height, 40px), 40px);
}

.site-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.site-title a {
    color: var(--text-color);
    text-decoration: none;
}

.site-title a:hover {
    color: var(--primary-color);
}

/* Logo Light/Dark Mode Switching */
.logo-default,
.logo-dark {
    display: block;
}

/* Hide dark logo by default (light mode) */
body:not(.dark-mode) .logo-dark {
    display: none;
}

/* Hide light logo in dark mode, show dark logo */
body.dark-mode .logo-default {
    display: none;
}

body.dark-mode .logo-dark {
    display: block;
}

/* Mobile menu logo switching */
.mobile-menu-logo .logo-default,
.mobile-menu-logo .logo-dark {
    display: block;
}

body:not(.dark-mode) .mobile-menu-logo .logo-dark {
    display: none;
}

body.dark-mode .mobile-menu-logo .logo-default {
    display: none;
}

body.dark-mode .mobile-menu-logo .logo-dark {
    display: block;
}

/* Header Theme Overrides */
/* When header is forced to always light */
.header-theme-light .site-header {
    --content-bg: #ffffff;
    --text-color: #333333;
    --outer-bg: #f5f5f5;
    --text-color-light: #666666;
    --border-color: #e0e0e0;
}

.header-theme-light .site-header .logo-dark {
    display: none !important;
}

.header-theme-light .site-header .logo-default {
    display: block !important;
}

.header-theme-light .mobile-menu-container {
    --content-bg: #ffffff;
    --text-color: #333333;
    --text-color-light: #666666;
    --border-color: #e0e0e0;
    --outer-bg: #f5f5f5;
}

.header-theme-light .mobile-menu-logo .logo-dark {
    display: none !important;
}

.header-theme-light .mobile-menu-logo .logo-default {
    display: block !important;
}

/* When header is forced to always dark */
.header-theme-dark .site-header {
    --content-bg: #1a1a1a;
    --text-color: #e0e0e0;
    --outer-bg: #0d0d0d;
    --text-color-light: #a0a0a0;
    --border-color: #333333;
}

.header-theme-dark .site-header .logo-default {
    display: none !important;
}

.header-theme-dark .site-header .logo-dark {
    display: block !important;
}

.header-theme-dark .mobile-menu-container {
    --content-bg: #1a1a1a;
    --text-color: #e0e0e0;
    --text-color-light: #a0a0a0;
    --border-color: #333333;
    --outer-bg: #0d0d0d;
}

.header-theme-dark .mobile-menu-logo .logo-default {
    display: none !important;
}

.header-theme-dark .mobile-menu-logo .logo-dark {
    display: block !important;
}

/* Primary Navigation */
.main-navigation {
    flex-grow: 1;
    display: flex;
    align-self: stretch; /* stretch to full header-container height */
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    /* No gap: the items sit edge to edge, and the space that was between them is in their
       own padding, so a hovered or current item's background has no strip beside it. */
    gap: 0;
    width: 100%;
    height: 100%; /* fill the full nav height */
    justify-content: flex-start;
    align-items: stretch; /* top-level items grow to full height */
}

.menu-align-center .main-navigation ul {
    justify-content: center;
}

.menu-align-right .main-navigation ul {
    justify-content: flex-end;
}

.main-navigation li {
    position: relative;
    display: flex;           /* allow the <a> child to stretch */
    align-items: stretch;
}

/* Reset for submenu items — they should be normal block height */
.main-navigation ul ul li {
    display: block;
}

.main-navigation a {
    display: flex;
    align-items: center;
    padding: 10px 18.5px; /* 16px + half of the 5px gap the items used to have */
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.2s ease;
}

.main-navigation a:hover,
.main-navigation a:focus {
    background-color: var(--primary-color);
    color: var(--button-text-color, #ffffff);
}

/* Active / current menu item — same look as hover.
   WordPress sets these classes automatically:
     current-menu-item     → exact match (the page/archive itself)
     current-menu-ancestor → a descendant is current (e.g. category when reading a post in it)
     current-menu-parent   → direct parent of the current item */
.main-navigation .current-menu-item > a,
.main-navigation .current-menu-ancestor > a,
.main-navigation .current-menu-parent > a {
    background-color: var(--primary-color);
    color: var(--button-text-color, #ffffff);
}

/* Dropdown indicator for menu items with children - page_item_has_children is the
   same thing in the fallback menu, which is a page list rather than a menu */
.main-navigation li.menu-item-has-children > a::after,
.main-navigation li.page_item_has_children > a::after {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-inline-start: 6px;
    background-color: currentColor; /* this sets the icon color */
    mask: var(--icon-arrow-down) center/contain no-repeat;
    -webkit-mask: var(--icon-arrow-down) center/contain no-repeat;
}


/* Submenu Styles */
.main-navigation ul ul {
    position: absolute;
    top: 100%;
    inset-inline-start: 0;
    background-color: var(--content-bg);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    padding: 0;

    /*
     * Undo what .main-navigation ul above sets for the top-level bar, which reaches every
     * list inside the nav, dropdowns included.
     *
     * height: 100% is the one that showed. On an absolutely positioned list it resolves
     * against the parent <li>, so the dropdown's box - its background and its shadow - was
     * exactly one header-row tall, and every item below the first hung out of it over the
     * page with nothing behind it. width: 100% pinned it to the parent item's width, which
     * min-width then raised to 200px, so a longer label wrapped onto two lines. And gap: 5px
     * opened a strip between the items that the hover colour could not reach.
     */
    height: auto;
    width: max-content;
    max-width: min(320px, 90vw);
    gap: 0;
    display: none; /* Completely hide from DOM for ad compliance */
    opacity: 0;
    visibility: hidden;

    /*
     * Grown downwards from its top edge rather than slid down from above it.
     *
     * This used to be translateY(-10px) -> 0, which moved the whole box - background,
     * shadow and all - ten pixels up into the menu bar on the way in and again on the way
     * out, while it was still mostly opaque. Only for a fifth of a second, but it read as
     * a shadow flickering over the menu every time the pointer moved to another item.
     *
     * Scaled from the top instead, the top edge never leaves the header's bottom edge and
     * the downward movement is still there, at the bottom. Not clip-path, which would do
     * the same reveal but also clip everything inside the box - including a third-level
     * dropdown, which opens beside this one and would be cut off at its edge.
     */
    transform: scaleY(0.95);
    transform-origin: top;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 9999;
    flex-direction: column;
}

/* Step 1: Show submenu in DOM (display: flex) - JS adds this class first */
.main-navigation li.submenu-open > ul {
    display: flex;
}

/* Step 2: Animate visibility/opacity - JS adds this class after a frame delay */
.main-navigation li.submenu-visible > ul {
    opacity: 1;
    visibility: visible;
    transform: scaleY(1);
}

.main-navigation ul ul li {
    width: 100%;
}

.main-navigation ul ul a {
    padding: 10px 20px;
    border-radius: 0;
}

/* Nested submenus */
.main-navigation ul ul ul {
    top: 0;
    inset-inline-start: 100%;
}

/* A dropdown that would run off the end edge (right, or left on a right-to-left page)
   opens the other way instead - set by
   placeSubmenu() in theme.js, which measures it on the way open. */
.main-navigation li.submenu-flip > ul {
    inset-inline-start: auto;
    inset-inline-end: 0;
}

.main-navigation ul ul li.submenu-flip > ul {
    inset-inline-end: 100%;
}

/* ==========================================================================
   Menu item icons - an emoji or an image per item, set in Appearance > Menus
   (inc/features/menu-icons.php). Sized by Theme Settings > Header > Menu Icon Size.
   ========================================================================== */
.menu-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: var(--menu-icon-size, 24px);
    height: var(--menu-icon-size, 24px);
    margin-inline-end: 10px;
    font-size: calc(var(--menu-icon-size, 24px) * 0.85);
    line-height: 1;
}

.menu-item-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.menu-item-label {
    min-width: 0;
}

/* Mobile menu links are blocks; with an icon they line it up beside the label, and the
   submenu arrow, which floats there otherwise, is pushed to the end instead. */
.mobile-navigation li.has-menu-icon > a {
    display: flex;
    align-items: center;
}

.mobile-navigation li.has-menu-icon.menu-item-has-children > a::after {
    float: none;
    margin-inline-start: auto;
    flex: 0 0 auto;
}

/* ==========================================================================
   Mega menu - Theme Settings > Header > Dropdown Style
   A top-level dropdown becomes a panel as wide as the header, its items in columns
   (--mega-menu-columns). A second-level item with children of its own is a column
   heading, its children listed under it rather than flying out beside it. Desktop
   only: below 993px the header menu is hidden and the mobile menu takes over.
   ========================================================================== */
@media screen and (min-width: 993px) {

    /* The panel hangs from the header row, not from the item. */
    .dropdown-style-mega .header-container {
        position: relative;
    }

    .dropdown-style-mega .main-navigation > ul > li {
        position: static;
    }

    .dropdown-style-mega .main-navigation > ul > li > ul,
    .dropdown-style-mega .main-navigation > ul > li.submenu-flip > ul {
        inset-inline-start: 0;
        inset-inline-end: 0;
        top: 100%;
        width: auto;
        max-width: none;
        /* The set number of columns, but never narrower than 200px each: on a small
           desktop a six-column panel drops to as many columns as fit. */
        grid-template-columns: repeat(auto-fill, minmax(max(200px, (100% - (var(--mega-menu-columns, 3) - 1) * 24px) / var(--mega-menu-columns, 3)), 1fr));
        align-items: start;
        gap: 2px 24px;
        padding: 18px 20px;
        border-top: 1px solid var(--border-color);
    }

    .dropdown-style-mega .main-navigation > ul > li.submenu-open > ul {
        display: grid;
    }

    .dropdown-style-mega .main-navigation > ul > li > ul > li {
        width: auto;
        min-width: 0;
    }

    .dropdown-style-mega .main-navigation > ul > li > ul a {
        padding: 9px 12px;
        border-radius: var(--card-radius, 0);
        line-height: 1.3;
    }

    /* Column headings and their lists */
    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-item-has-children > a {
        font-weight: 700;
    }

    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-item-has-children > a::after {
        display: none;
    }

    .dropdown-style-mega .main-navigation ul ul ul,
    .dropdown-style-mega .main-navigation ul ul li.submenu-flip > ul {
        position: static;
        display: flex;
        flex-direction: column;
        opacity: 1;
        visibility: visible;
        transform: none;
        min-width: 0;
        width: auto;
        max-width: none;
        box-shadow: none;
        background: transparent;
        padding-block: 0 6px; padding-inline: 14px 0;
    }

    .dropdown-style-mega .main-navigation ul ul ul a {
        font-weight: 400;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    /* A section runs across the whole panel, and the items after it start on a new row
       under it - the grid places anything after a full-width row on the next one. */
    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-section {
        grid-column: 1 / -1;
        margin-top: 12px;
        padding-top: 10px;
        border-top: 1px solid var(--border-color);
    }

    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-section:first-child {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-section > .menu-section-title {
        padding: 2px 12px 6px;
    }

    /* A section that holds its items as sub-items: they are laid out under the heading in
       the panel's own columns, rather than as the narrow list a column heading gets. */
    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-section > ul {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(max(200px, (100% - (var(--mega-menu-columns, 3) - 1) * 24px) / var(--mega-menu-columns, 3)), 1fr));
        align-items: start;
        gap: 2px 24px;
        padding: 0;
    }

    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-section > ul > li {
        width: auto;
        min-width: 0;
    }

    /* Drawn exactly as the items of a flat section: the weight and spacing of a panel's
       own links, not the lighter ones of a column heading's list. The weight follows
       Theme Settings > Typography, see custom-css.php. */
    .dropdown-style-mega .main-navigation > ul > li > ul > li.menu-section > ul a {
        padding-top: 9px;
        padding-bottom: 9px;
        font-weight: 500;
    }
}

/* ==========================================================================
   Menu sections - a Custom Link with the URL #section (inc/features/menu-sections.php)
   A heading with no link. In the mega menu it spans the panel (above); in a simple
   dropdown and in the mobile menu it is a small label between the items.
   ========================================================================== */
.menu-section > .menu-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.3;
    text-transform: uppercase;
    color: var(--text-color-light, #666);
    cursor: default;
    user-select: none;
}

/* The icon in front of a section's name follows the name's size, not a link's. */
.menu-section > .menu-section-title .menu-item-icon-emoji {
    font-size: 1.2em;
}

.mobile-navigation .menu-section > .menu-section-title {
    padding: 16px 0 6px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

/* A section's own items, in a simple dropdown: listed under the heading, not flown out
   beside it - a section is a heading, not a dropdown of its own. */
.main-navigation ul ul li.menu-section > ul {
    position: static;
    display: flex;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    transform: none;
    min-width: 0;
    width: auto;
    max-width: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
}

/* And in the mobile menu, at the level of the heading rather than indented under it. */
.mobile-navigation li.menu-section > ul {
    padding-inline-start: 0;
}

/* ==========================================================================
   Language Switcher in Header
   ========================================================================== */
.header-language-switcher {
    display: flex;
    align-items: center;
}

.header-language-switcher .lang-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.header-language-switcher .lang-menu > li {
    position: relative;
    display: flex;
    align-items: center;
}

.header-language-switcher,
.header-language-switcher-placeholder {
    --lang-padding-y: 8px;
}

/* Invisible placeholder to retain header height when there are no translations */
.header-language-switcher-placeholder {
    visibility: hidden;
    width: 0;
    /* Uses max of flag height or font size, plus 2 * vertical padding */
    min-height: calc(max(var(--header-flag-height, 20px), var(--header-lang-font-size, 16px) * 1.2) + (var(--lang-padding-y) * 2));
}

.header-language-switcher a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--lang-padding-y) 12px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: var(--header-lang-font-weight, 500);
    transition: color 0.2s ease;
    text-transform: var(--header-lang-text-transform, none);
    font-size: clamp(1rem, 2.5vw, var(--header-lang-font-size, 16px));
}

.header-language-switcher a:hover,
.header-language-switcher a:focus {
    background-color: var(--primary-color);
    color: var(--button-text-color, #ffffff);
}

.header-language-switcher img.lang-switcher-flag,
.header-language-switcher .lang-switcher-flag-wrapper > img {
    height: clamp(14px, 4vw, var(--header-flag-height, 20px));
    width: auto;
    aspect-ratio: var(--header-flag-ratio, 1);
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Wrapper for split flags: fixed square so hreflang-flag-split (position:relative)
   has a real containing block for its absolutely-positioned image slices. */
.header-language-switcher .lang-switcher-flag-wrapper {
    display: inline-block;
    flex-shrink: 0;
    width: clamp(14px, 4vw, var(--header-flag-height, 20px));
    aspect-ratio: 1;
    vertical-align: middle;
    line-height: 0;
}

/* Arrow indicator */
.header-language-switcher .menu-item-has-children > a::after {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-inline-start: 4px;
    background-color: currentColor;
    mask: var(--icon-arrow-down) center/contain no-repeat;
    -webkit-mask: var(--icon-arrow-down) center/contain no-repeat;
}

/* Submenu container */
.header-language-switcher .lang-submenu {
    position: absolute;
    top: 100%;
    inset-inline-end: 0; /* Align right to prevent overflow due to being on right side */
    background-color: var(--content-bg);
    min-width: 150px;
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    display: none;
    opacity: 0;
    visibility: hidden;
    /* Grown from its top edge, like the navigation dropdowns - see the note there. */
    transform: scaleY(0.95);
    transform-origin: top;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 9999;
    list-style: none; /* remove dots */
}

/* Submenu state classes identical to main-navigation */
.header-language-switcher .submenu-open > ul.lang-submenu-list {
    display: flex;
}

.header-language-switcher .submenu-open > ul.lang-submenu-grid {
    display: grid;
}

.header-language-switcher .submenu-visible > ul {
    opacity: 1;
    visibility: visible;
    transform: scaleY(1);
}

/* Single column list */
.header-language-switcher .lang-submenu-list {
    flex-direction: column;
}

.header-language-switcher .lang-submenu-list li {
    width: 100%;
}

.header-language-switcher .lang-submenu-list a {
    padding: 10px 16px;
    border-radius: 0;
    justify-content: flex-start;
}

/* Flag or Name only view in single column list */
.header-language-switcher .lang-submenu-list.lang-submenu-flag-only,
.header-language-switcher .lang-submenu-list.lang-submenu-name-only {
    min-width: 0; /* Override the 150px min-width */
    width: max-content;
}

.header-language-switcher .lang-submenu-list.lang-submenu-flag-only a,
.header-language-switcher .lang-submenu-list.lang-submenu-name-only a {
    justify-content: center;
    padding: 10px 15px;
    text-align: center;
}

/* Grid layout */
.header-language-switcher .lang-submenu-grid {
    grid-template-columns: repeat(3, 1fr);
    padding: 12px;
    gap: 8px;
    width: max-content;
}

.header-language-switcher .lang-submenu-grid-2 { 
    grid-template-columns: repeat(2, 1fr);
}

.header-language-switcher .lang-submenu-grid li {
    display: block;
    width: 100%;
}

.header-language-switcher .lang-submenu-grid a {
    padding: 8px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 4px;
    width: 100%;
}

.header-language-switcher .lang-submenu-grid a .lang-switcher-name {
    font-size: var(--header-lang-grid-font-size, 11px);
    line-height: 1.2;
}

/* Header Right Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--border-color);
}

.theme-icon {
    display: none;
    width: 30px;
    height: 30px;
}

.theme-icon-svg {
    width: 100%;
    height: 100%;
    display: block;
}

body:not(.dark-mode) .theme-icon.light-icon {
    display: flex;
}

body.dark-mode .theme-icon.dark-icon {
    display: flex;
}

/* Header Search — compact variant of the embedded-button search form */
.header-search {
    position: relative;
}

.header-search .search-field {
    padding-block: 8px; padding-inline: 14px 40px;
    font-size: 14px;
    width: 200px;
    transition: width 0.2s ease, border-color 0.2s ease;
}

.header-search .search-field:focus {
    width: 250px;
}

.header-search .search-submit {
    width: 28px;
    height: 28px;
    inset-inline-end: 4px;
}


/* ==========================================================================
   Content Area
   ========================================================================== */
/* --layout-gap: Element Gap in the Layout settings. Unset, every use below falls back to
   the spacing it always had; set, it is one gap for all of them (0 = flush). The side
   margin stays: it is the distance from the edge of the window, not between parts. */
.site-content {
    margin: var(--layout-gap, 20px) 20px;
    word-wrap: break-word;
}

.content-wrapper {
    max-width: var(--total-width);
    margin: 0 auto;
    background-color: var(--content-bg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    transition: background-color 0.3s ease;
}

.content-area-wrapper {
    display: flex;
    gap: var(--layout-gap, 40px);
    align-items: flex-start;
}

/* Sidebar Positions */
.content-area-wrapper.sidebar-right {
    flex-direction: row;
}

.content-area-wrapper.sidebar-left {
    flex-direction: row-reverse;
}

.content-area-wrapper.sidebar-none .site-main,
.no-sidebar .site-main {
    flex: 1;
    max-width: 100%;
}

/* Full Width page template — content spans the whole wrapper */
.content-area-wrapper.layout-full-width .site-main {
    max-width: 100%;
}

/* Main Content */
.site-main {
    flex: 1;
    max-width: var(--content-width);
    min-width: 0; /* Prevents flex items from overflowing */
}

/* Sidebar */
.widget-area {
    flex: 0 0 var(--sidebar-width);
    max-width: var(--sidebar-width);
}

.widget {
    margin-bottom: var(--layout-gap, 15px);
    padding: 12px;
    /* The content background, not the page one.
       Painted with --outer-bg these sat at exactly the colour behind them and read as loose
       text rather than as panels - while the reports sidebar next to them, which uses
       --content-bg, does read as one. */
    background-color: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius, 0);
}

.widget-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget a {
    color: var(--text-color);
}

.widget a:hover {
    color: var(--primary-color);
}

/* ==========================================================================
   Posts & Pages
   ========================================================================== */
article {
    margin-bottom: 40px;
}

article.type-post {
    border: 1px solid var(--border-color);
}

/* Strip border and margin from list items — spacing and separation are handled
   by the post list's own padding and row separator */
.boxedtheme-post-list article.type-post {
    border: none;
    margin-bottom: 0;
}

.entry-header {
    padding: 30px 30px 20px;
}

.entry-title {
    margin: 0 0 10px 0;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-color);
    text-wrap: balance;
}

.page-title {
    text-wrap: balance;
}

.entry-title a {
    color: var(--text-color);
}

.entry-title a:hover {
    color: var(--primary-color);
}

.post-thumbnail {
    margin-bottom: 25px;
}

.post-thumbnail img {
    display: block;
}

.entry-content {
    margin-bottom: 25px;
    line-height: 1.8;
    padding-inline: 20px;
}

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--text-color);
    font-weight: 600;
}

.entry-content p {
    margin-bottom: 20px;
    text-wrap: pretty;
}

.entry-content blockquote {
    margin: 25px 0;
    padding: 20px 25px;
    border-inline-start: 4px solid var(--primary-color);
    background-color: var(--outer-bg);
    font-style: italic;
}

.entry-content ul,
.entry-content ol {
    margin: 20px 0;
    padding-inline-start: 30px;
}

.entry-content li {
    margin-bottom: 8px;
}

.entry-content code {
    background-color: var(--outer-bg);
    padding: 2px 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
}

.entry-content pre {
    background-color: var(--outer-bg);
    padding: 20px;
    overflow-x: auto;
}

/* Tables */
.entry-content table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    margin: 25px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    font-size: inherit;
}

.entry-content table thead {
    background-color: var(--outer-bg);
}

.entry-content table th {
    padding: 14px 16px;
    text-align: start;
    font-weight: 600;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.entry-content table td {
    padding: 12px 16px;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    vertical-align: top;
}

/* Alternating row colors - subtle */
.entry-content table tbody tr:nth-child(even) {
    background-color: var(--tint-stripe);
}

/* Row hover effect */
.entry-content table tbody tr:hover {
    background-color: var(--tint-row-hover);
}

/* Allow plain tables to scroll horizontally on small screens instead of overflowing the page */
@media (max-width: 768px) {
    .entry-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
}

/* Responsive tables - horizontal scroll on mobile */
.entry-content .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 25px 0;
}

.entry-content .table-responsive table {
    margin: 0;
    min-width: 600px;
}

/* Caption styling */
.entry-content table caption {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-color-light);
    text-align: start;
    caption-side: bottom;
    font-style: italic;
}

/* WordPress block table support */
.wp-block-table {
    margin: 25px 0;
    overflow-x: auto;
}

.wp-block-table table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    font-size: inherit;
}

.wp-block-table th,
.wp-block-table td {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
}

.wp-block-table thead {
    background-color: var(--outer-bg);
}

.wp-block-table th {
    font-weight: 600;
    text-align: start;
}

.wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
    background-color: var(--tint-stripe);
}

.entry-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-color-light);
}

.entry-footer > span {
    margin-inline-end: 20px;
}

/* Post Tags Styling */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.post-tag {
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--outer-bg);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--border-color);
}

.post-tag:hover {
    background-color: var(--primary-color);
    color: var(--button-text-color, #ffffff);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Entry Meta Styling */
.entry-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    font-size: 14px;
    line-height: 14px;
    color: var(--text-color-light);
    margin-bottom: 15px;
}

.entry-meta > span {
    display: flex;
    align-items: center;
}

.entry-meta a {
    color: var(--text-color-light);
}

.entry-meta a:hover {
    color: var(--primary-color);
}

.entry-meta .cat-links a {
    color: var(--primary-color);
    font-weight: 500;
}

.entry-meta .cat-links a:hover {
    color: var(--secondary-color);
}

/* Separator for meta items */
.entry-meta > span:not(:last-child)::after {
    content: "\2022";
    margin-inline-start: 15px;
    font-size: 20px;
}

/* Posts Navigation (Archive pages) */
.posts-navigation {
    margin: 40px 0;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.posts-navigation .nav-links {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.posts-navigation .nav-previous,
.posts-navigation .nav-next {
    flex: 1;
}

.posts-navigation .nav-next {
    text-align: end;
}

.nav-subtitle {
    display: block;
    font-size: 14px;
    color: var(--text-color-light);
    margin-bottom: 5px;
}

.nav-title {
    color: var(--text-color);
    font-weight: 600;
}



/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    background-color: var(--content-bg);
    border-top: 1px solid var(--border-color);
    padding: 30px 20px;
    margin-top: 60px;
    transition: background-color 0.3s ease;
}

.footer-wrapper {
    max-width: var(--total-width);
    margin: 0 auto;
}

/* Footer widget columns — only output when a footer sidebar has widgets */
.footer-widgets {
    display: grid;
    gap: 30px;
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.footer-widgets-2 {
    grid-template-columns: repeat(2, 1fr);
}

.footer-widgets-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Footer widgets sit on the footer background, not the sidebar's boxed look */
.footer-widgets .widget {
    background-color: transparent;
    border: none;
    padding: 0;
    margin-bottom: 20px;
}

.footer-widgets .widget-title {
    font-size: 16px;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 12px;
}

.footer-widgets .widget a {
    color: var(--text-color-light);
}

.footer-widgets .widget a:hover {
    color: var(--primary-color);
}

@media screen and (max-width: 768px) {
    .footer-widgets-2,
    .footer-widgets-3 {
        grid-template-columns: 1fr;
    }
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.footer-left {
    color: var(--text-color-light);
    font-size: 14px;
}

.footer-navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-navigation a {
    color: var(--text-color-light);
    font-size: 14px;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.footer-navigation a:hover {
    opacity: 0.65;
}

/* ==========================================================================
   Search Form (general)
   Pill input with the submit button embedded inside its right edge.
   The input's right padding reserves space so text never runs under
   the button.
   ========================================================================== */
.search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.search-form label {
    display: flex;
    flex: 1;
    min-width: 0;
}

.search-field {
    width: 100%;
    padding-block: 10px; padding-inline: 16px 48px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background-color: var(--outer-bg);
    color: var(--text-color);
    font-size: 15px;
    transition: border-color 0.2s ease;
}

/* Keyboard focus keeps the ring.
   This used to drop the outline entirely and colour the border instead, and did it on :focus,
   so it fired for mouse clicks too. A recoloured border is a weak signal on a field that is
   already bordered. */
.search-field:focus {
    border-color: var(--primary-color);
}

.search-field:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Round icon button inside the input */
.search-submit {
    position: absolute;
    inset-inline-end: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: var(--button-text-color, #ffffff);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.search-submit:hover {
    background-color: var(--secondary-color);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    z-index: 1001;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 24px;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    transition: transform 0.3s ease;
}

/* Hide mobile elements on desktop */
.mobile-only {
    display: none;
}

/* Mobile Header Right Container */
.mobile-header-right {
    display: none;
    align-items: center;
    gap: 8px;
}

.mobile-header-theme-toggle {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--control-radius, 4px);
}

.mobile-header-theme-toggle:hover {
    background-color: var(--border-color);
}

.mobile-header-theme-toggle .theme-icon-svg {
    width: 22px;
    height: 22px;
}

.mobile-header-theme-toggle .theme-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Show only the appropriate icon based on current mode */
body:not(.dark-mode) .mobile-header-theme-toggle .dark-icon {
    display: none;
}

body.dark-mode .mobile-header-theme-toggle .light-icon {
    display: none;
}

/* Mobile Menu Modal */
.mobile-menu-modal {
    display: none;
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    bottom: 0;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-modal.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-overlay {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.mobile-menu-container {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
    bottom: 0;
    width: 85%;
    max-width: 400px;
    background-color: var(--content-bg);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-menu-modal.active .mobile-menu-container {
    transform: translateX(0);
}

/* Right to left: the panel sits at the left edge, so it slides in from the left. */
[dir="rtl"] .mobile-menu-container {
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
}

[dir="rtl"] .mobile-menu-modal.active .mobile-menu-container {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu-logo img {
    max-height: 40px;
}

.mobile-menu-logo span {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
}

.mobile-menu-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--control-radius, 4px);
}

.mobile-menu-close:hover {
    background-color: var(--border-color);
}

.mobile-menu-content {
    flex: 1;
    padding: 20px;
}

/* Mobile Navigation Styles */
.mobile-navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-navigation li {
    border-bottom: 1px solid var(--border-color);
}

.mobile-navigation li:last-child {
    border-bottom: none;
}

.mobile-navigation a {
    display: block;
    padding: 15px 0;
    color: var(--text-color);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.mobile-navigation a:hover {
    color: var(--primary-color);
}

/* Mobile Submenus */
.mobile-navigation ul ul {
    padding-inline-start: 20px;
    margin-top: 0;
}

.mobile-navigation ul ul li {
    border-bottom: none;
}

.mobile-navigation ul ul a {
    padding: 10px 0;
    font-size: 15px;
    font-weight: 400;
}

.mobile-navigation .menu-item-has-children > a::after {
    content: "";
    float: inline-end;
    width: 16px;
    height: 16px;
    background-color: currentColor; /* this sets the icon color */
    mask: url(../images/arrow-right.svg) center/contain no-repeat;
    -webkit-mask: url(../images/arrow-right.svg) center/contain no-repeat;
}

/* The arrow points the way the submenu opens: towards the end of the line. */
[dir="rtl"] .mobile-navigation .menu-item-has-children > a::after {
    transform: scaleX(-1);
}

/* Mobile menu controls - search and the light/dark switch, in one row above the menu so
   they are in reach however long the menu is. The switch shows its icon only; the button
   keeps its aria-label and the label stays in the markup for screen readers. */
.mobile-menu-controls {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding-bottom: 16px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-search {
    flex: 1 1 auto;
    min-width: 0;
}

.mobile-search .search-field {
    padding-block: 12px; padding-inline: 16px 50px;
    font-size: 15px;
}

.mobile-search .search-submit {
    width: 34px;
    height: 34px;
    inset-inline-end: 5px;
}

/* Mobile Theme Toggle */
.mobile-theme-toggle {
    flex: 0 0 auto;
    display: flex;
}

.mobile-theme-toggle .theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    padding: 0 12px;
    background-color: var(--outer-bg);
    border: 1px solid var(--border-color);
    border-radius: calc(var(--control-radius, 4px) * 8 / 4);
    cursor: pointer;
}

.mobile-theme-toggle .theme-toggle:hover {
    background-color: var(--border-color);
}

.mobile-theme-toggle .theme-icon {
    width: 20px;
    height: 20px;
}

.mobile-theme-toggle .toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

body:not(.dark-mode) .mobile-theme-toggle .dark-label {
    display: none;
}

body.dark-mode .mobile-theme-toggle .light-label {
    display: none;
}

/* Prevent scrolling when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
}

/* Support for inert attribute */
[inert] {
    pointer-events: none;
    cursor: default;
}

[inert] * {
    pointer-events: none;
    cursor: default;
}

@media screen and (max-width: 1100px) {
    :root {
        --content-width: 600px;
        --sidebar-width: 280px;
    }
}

@media screen and (max-width: 992px) {

    .site-main {
        max-width: none;  /* Remove percentage constraint */
        width: 100%;      /* Force full width */
    }

    /* Show mobile menu button, hide desktop navigation */
    .mobile-only {
        display: block;
    }
    
    .mobile-header-right {
        display: flex;
    }
    
    .mobile-header-right .mobile-menu-toggle {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .mobile-menu-modal {
        display: block;
    }

    .main-navigation {
        display: none;
    }

    .header-container {
        justify-content: space-between;
    }

    /* Fix lang-switcher dropdown: anchor to viewport so it can never overflow
       left on narrow screens. Applies to both header-base and header-compact. */
    .header-language-switcher .lang-submenu {
        position: fixed;
        top: var(--lang-submenu-top, var(--header-height, 60px));
        inset-inline-end: 10px;
        inset-inline-start: auto;
        max-width: calc(100vw - 20px);
        /* A long list scrolls inside itself rather than running off the bottom. */
        max-height: calc(100dvh - var(--lang-submenu-top, var(--header-height, 60px)) - 10px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    
    :root {
        --content-width: 100%;
        --sidebar-width: 100%;
    }
    
    .content-area-wrapper {
        flex-direction: column !important;
    }
    
    .widget-area {
        max-width: 100%;
        width: 100%;
    }
}

@media screen and (max-width: 768px) {
    /* The language grid on a phone: the width of the screen, as many columns as fit, and
       each language as a row of flag and name rather than a flag stacked over a tiny label.
       Three fixed columns of max-content used to run off the side. !important because a
       switcher with fewer than three languages sets its columns inline. */
    .header-language-switcher .lang-submenu-grid {
        inset-inline-start: 10px;
        width: auto;
        grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)) !important;
        gap: 4px;
        padding: 8px;
    }

    .header-language-switcher .lang-submenu-grid a {
        flex-direction: row;
        justify-content: flex-start;
        text-align: start;
        gap: 8px;
        padding: 8px 10px;
    }

    .header-language-switcher .lang-submenu-grid a .lang-switcher-name {
        font-size: max(13px, var(--header-lang-grid-font-size, 11px));
        min-width: 0;
        overflow-wrap: anywhere;
    }

    /* Hide search and theme toggle in header on mobile */
    .header-right .header-search,
    .header-right .theme-toggle,
    .header-compact-right-elements .header-search,
    .header-compact-right-elements .theme-toggle {
        display: none !important;
    }

    .content-wrapper {
        padding: 20px;
    }
    
    .site-footer {
        padding: 20px 15px;
    }

    .footer-container {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .footer-left {
        font-size: 13px;
    }

    .footer-navigation ul {
        justify-content: center;
        gap: 10px 16px;
    }

    .footer-navigation a {
        font-size: 13px;
    }

    .site-content {
        margin: var(--layout-gap, 20px) 0;
    }
}

@media screen and (max-width: 480px) {
    /* Never more than 10px on a phone, whatever the gap on a desktop. */
    .site-content {
        margin: min(var(--layout-gap, 10px), 10px) 0;
    }
    
    .header-container {
        gap: 10px;
    }
    
    .mobile-menu-container {
        width: 100%;
        max-width: none;
    }
    
    .content-wrapper {
        padding: 0;
        box-shadow: none;
    }
    
    .site-main {
        padding: 10px;
    }

    .widget-area {
        padding: 10px;
    }
    
    .site-footer {
        padding: 15px 12px;
        margin-top: 30px;
    }

    .site-footer .footer-wrapper {
        padding: 0;
    }

    .footer-container {
        padding: 0;
        gap: 10px;
    }

    .footer-left {
        font-size: 12px;
    }

    .footer-navigation ul {
        gap: 8px 12px;
    }

    .footer-navigation a {
        font-size: 12px;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.alignleft {
    float: inline-start;
    margin-block: 0 20px; margin-inline: 0 20px;
}

.alignright {
    float: inline-end;
    margin-block: 0 20px; margin-inline: 20px 0;
}

.aligncenter {
    display: block;
    margin-inline-start: auto;
    margin-inline-end: auto;
}

.wp-caption {
    max-width: 100%;
}

.wp-caption-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-color-light);
    margin-top: 8px;
}

.sticky {
    /* WordPress required class for sticky posts - add custom styles as needed */
    position: relative;
}

.bypostauthor {
    /* WordPress required class for post author comments - add custom styles as needed */
    border-inline-start: 3px solid var(--primary-color);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.gallery-item {
    position: relative;
}

.gallery-item img {
    border-radius: calc(var(--image-radius, 10px) * 4 / 10);
}

.footer-disclaimer {
    font-size: 0.7em;
}

/* ── Featured Image Caption Overlay ──────────────────────────────────────── */

.post-thumbnail--has-caption {
    position: relative;
}

.post-thumbnail__caption {
    position: absolute;
    bottom: 0;
    inset-inline-start: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 13px;
    max-width: 100%;
    line-height: 1.8;
}

.post-thumbnail__caption a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.post-thumbnail__caption a:hover {
    opacity: 0.8;
}

.post-thumbnail__caption-icon {
    display: inline-block;
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    background-color: #fff;
    -webkit-mask-image: url('../icons/custom/camera.svg');
    mask-image: url('../icons/custom/camera.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

/* ── Post Sources ─────────────────────────────────────────────────────────── */

.post-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 0 0.25rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.source-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    background: var(--outer-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: border-color 0.2s ease;
}

.source-tag:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.post-sources__label {
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color-light);
    white-space: nowrap;
}

/* ── Related Posts ────────────────────────────────────────────────────────── */

.related-posts {
    margin: 40px 0;
}

/* ── Author Box ───────────────────────────────────────────────────────────── */

.author-box {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin: 30px 20px;
    padding: 24px;
    background-color: var(--outer-bg);
    border: 1px solid var(--border-color);
}

.author-box__avatar {
    flex-shrink: 0;
}

.author-box__avatar img {
    display: block;
    border-radius: 50%;
}

.author-box__name {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.author-box__bio {
    margin: 0 0 10px;
    color: var(--text-color-light);
    line-height: 1.6;
}

.author-box__link {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
}

.author-box__link:hover {
    color: var(--secondary-color);
}

@media (max-width: 480px) {
    .author-box {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-inline: 10px;
        padding: 20px;
    }
}

/* ==========================================================================
   Accessibility — Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}