/*
 * v0.22.1 — GeneratePress chrome overrides
 *
 * Loaded conditionally by APT_Theme_Config::maybe_enqueue_overrides()
 * ONLY when GeneratePress (or a GP child theme) is the active theme.
 *
 * Why each rule exists is annotated inline — the plugin already
 * renders its own complete chrome (nav, logo, footer), so GP's
 * defaults are redundant or conflicting. We hide them rather than
 * leave Ahmed to click through Customizer toggles.
 *
 * !important is used freely because GP's CSS is loaded earlier and
 * higher-specificity selectors would still lose in some edge cases
 * (theme updates, custom CSS, etc.). The plugin's own chrome doesn't
 * fight with these — it uses .apt-* classes which GP doesn't style.
 */

/* ─── HEADER ──────────────────────────────────────────────────────── */

/* Hide GeneratePress's default site-title + tagline block.
 * The plugin renders the PriceWatch logo inside its own chrome
 * (class-chrome.php and the homepage shortcodes), so GP's site
 * branding would just be a duplicate text mention. */
.site-branding,
.site-logo,
.header-widget {
    display: none !important;
}

/* Hide GeneratePress's default primary navigation menu.
 * The plugin renders its own Arabic nav (الرئيسية / كل المنتجات /
 * الأقسام / الأكثر شعبية / المفضلة / اطلب منتجاً / حساب) via
 * class-chrome.php. A second nav from the theme would create a
 * confusing double-stack. */
.main-navigation,
#site-navigation,
.gen-sidebar-nav,
.menu-toggle {
    display: none !important;
}

/* v0.25.2 — Nuke the GP header band entirely.
 *
 * v0.22.1 zeroed padding/margin/border/min-height on .site-header but
 * left the wrapper in the DOM. Ahmed flagged 2026-05-30 that a thin
 * white strip remained between the WP admin bar and the plugin nav —
 * caused by GP's `.inside-header` child (the inner content wrapper)
 * carrying its own default padding (~20-40px depending on Customizer
 * defaults) that we hadn't covered. Now we display:none the whole
 * `.site-header` element + any sub-wrapper GP could possibly render,
 * AND zero any inherited padding/margin on the body/page wrappers.
 *
 * The plugin's nav renders via `wp_body_open` action which fires
 * BEFORE `.site-header` enters the DOM, so hiding `.site-header`
 * does not hide the plugin nav. */
.site-header,
header.site-header,
.site-header.grid-container {
    display: none !important;
}
.inside-header,
.header-image,
.header-image-aligned,
.main-title,
.site-description,
.navigation-branding,
.header-wrap,
.header-area {
    display: none !important;
}
/* Defensive: zero any inherited padding/margin on the page-level
 * wrappers GP uses, so the plugin nav sits flush against the WP
 * admin bar with no white gap. */
body {
    margin: 0 !important;
}
.site,
.site-container,
.site-content-wrap,
#page,
.hfeed.site {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* ─── FOOTER ──────────────────────────────────────────────────────── */

/* Hide GeneratePress's footer-widget area. The plugin's footer
 * already contains the brand mission, contact email, affiliate
 * disclosure, and copyright — nothing useful would go in GP's
 * widgets, and an empty widget area still adds visible padding. */
.footer-widgets,
.site-footer .footer-widgets,
.footer-widgets-container {
    display: none !important;
}

/* Hide the "© 2026 sitename — Built with GeneratePress" attribution
 * line. The generate_copyright filter also clears the text, but the
 * containing element still renders an empty pixel-row without this. */
.site-info,
footer.site-info,
.copyright-bar,
.site-footer .copyright {
    display: none !important;
}

/* If the parent .site-footer wraps both .footer-widgets and
 * .site-info (both now hidden), collapse the wrapper too so the
 * plugin's own forest-green footer sits flush against the content. */
.site-footer {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
}

/* ─── SIDEBAR (v0.22.2) ──────────────────────────────────────────── */

/* Belt-and-suspenders hide of GP's sidebar widget area. The
 * generate_sidebar_layout filter (in class-theme-config.php) tells
 * GP at the layout level to render with no sidebar, but on some
 * page templates / child themes the filter is bypassed and the
 * sidebar markup still renders. These selectors catch that case.
 *
 * Why this exists: GP's default layout includes a right (LTR) /
 * left (RTL) sidebar pre-populated with WP's stock Archives +
 * Categories widgets, which would otherwise squeeze the product
 * grid to ~50% width — exactly the symptom Ahmed flagged after
 * v0.22.1 first ran on staging. */
#right-sidebar,
#left-sidebar,
.sidebar,
.widget-area:not(.footer-widgets):not(.inside-footer-widgets),
[id^="primary-sidebar"],
[id^="secondary-sidebar"] {
    display: none !important;
}

/* When the sidebar is removed, GP's grid math still reserves the
 * sidebar's width for it (because GP uses floats, not flexbox).
 * Force the content column to fill the available width.
 *
 * v0.23.1 — also defeat GP's grid-percentage classes (.grid-70,
 * .grid-100, .tablet-grid-100, .mobile-grid-100, .grid-parent)
 * that GP adds to .content-area via the GeneratePress_Layout
 * filter. On staging the .grid-70 declaration plus an RTL margin
 * was leaving .content-area floated 30% of viewport width to the
 * right of center, pushing the entire .apt-page-inner block
 * right-of-center on the single-product and all-products pages.
 * Ahmed reported this 2026-05-29. The wildcard-attribute selector
 * `[class*="grid-"]` catches every grid-X helper without us
 * having to enumerate them. */
.site-content,
.content-area,
.content-area[class*="grid-"],
#primary,
#primary[class*="grid-"],
.site-main {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ─── CONTENT WIDTH ───────────────────────────────────────────────── */

/* Comfortable max-width for the content area. GP's default container
 * is 1100px which crowds the 4-up product grid on wide screens. 1200
 * gives the cards more breathing room without being so wide it loses
 * the centered "magazine" feel. */
.grid-container,
.site-container,
.site-content > .content-area {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* GP wraps page content in a .inside-article box with its own padding.
 * On the homepage (where we render section-style product carousels)
 * that padding fights the section's own padding. Zero it out. */
.page .inside-article,
.page .entry-content {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* ─── BRAND COLOR ALIGNMENT ──────────────────────────────────────── */

/* Map GP's default link color to the forest-green brand for any text
 * link inside post/page content (e.g. links inside the About page,
 * Privacy Policy, etc.). Plugin-rendered CTAs/buttons are scoped to
 * .apt-* and unaffected — they keep their own colors. */
.entry-content a:not(.apt-card-cta):not(.apt-card-amazon):not(.apt-buy-btn):not(.button):not(.wp-block-button__link) {
    color: #0a4d3a;
}
.entry-content a:not(.apt-card-cta):not(.apt-card-amazon):not(.apt-buy-btn):not(.button):not(.wp-block-button__link):hover {
    color: #0d6147;
}

/* ─── SAFETY NETS ────────────────────────────────────────────────── */

/* Some themes inject a "skip to content" link that floats over the
 * top-left and looks orphaned without a header. Hide it visually
 * but keep it accessible to screen readers via clip-path. */
.skip-link {
    clip: rect(1px, 1px, 1px, 1px) !important;
    height: 1px !important;
    overflow: hidden !important;
    position: absolute !important;
    width: 1px !important;
}
/* But restore it when keyboard-focused, per WCAG. */
.skip-link:focus {
    clip: auto !important;
    height: auto !important;
    overflow: visible !important;
    position: static !important;
    width: auto !important;
}
