/*
Theme Name: Courtaginov
Theme URI: https://example.com/rgaa-theme
Author: Your Name
Author URI: https://example.com
Description: A fully RGAA-compliant WordPress theme with complete page builder compatibility. Designed for French public sector websites with zero accessibility errors, optimized performance, and full responsive support.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.4
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: rgaa-theme
Tags: accessibility-ready, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, full-width-template, rtl-language-support, theme-options, threaded-comments, translation-ready, block-styles, wide-blocks

RGAA Accessibility Theme
Fully compliant with RGAA 4.1 standards
*/

/* ==========================================================================
   CSS Reset & Base Styles
   ========================================================================== */

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

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    background-color: #fff;
    overflow-x: hidden;
}

/* ==========================================================================
   Skip Links (RGAA Requirement)
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100000;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* ==========================================================================
   Focus Styles (RGAA Requirement)
   ========================================================================== */

*:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: #222;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

h6 {
    font-size: 1.1rem;
}

p {
    margin-bottom: 1rem;
}

a {
    color: #0066cc;
    text-decoration: underline;
    transition: color 0.2s ease;
}

a:hover {
    color: #004499;
}

a:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* ==========================================================================
   Container & Layout
   ========================================================================== */

.site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-content {
    flex: 1;
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.content-wrapper {
    padding: 40px 0;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.site-header {
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.site-branding {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-title {
    margin: 0;
    font-size: 1.5rem;
}

.site-title a {
    color: #222;
    text-decoration: none;
}

.site-description {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

/* Navigation */
.main-navigation {
    position: relative;
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.5rem;
}

.main-navigation li {
    position: relative;
}

.main-navigation a {
    display: block;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.main-navigation a:hover,
.main-navigation a:focus {
    background-color: #f5f5f5;
    color: #0066cc;
}

.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a {
    font-weight: 600;
    color: #0066cc;
}

/* Submenu */
.main-navigation ul ul {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    display: none;
    flex-direction: column;
    gap: 0;
}

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

.main-navigation li:hover > ul,
.main-navigation li:focus-within > ul {
    display: flex;
}

.main-navigation ul ul a {
    padding: 0.75rem 1rem;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: transparent;
    border: 2px solid #333;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    color: #333;
    border-radius: 4px;
}

.menu-toggle:hover,
.menu-toggle:focus {
    background-color: #f5f5f5;
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

.menu-toggle[aria-expanded="true"] .menu-icon-close {
    display: inline;
}

.menu-toggle[aria-expanded="true"] .menu-icon-open {
    display: none;
}

.menu-toggle[aria-expanded="false"] .menu-icon-close {
    display: none;
}

.menu-toggle[aria-expanded="false"] .menu-icon-open {
    display: inline;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.entry-header {
    margin-bottom: 2rem;
}

.entry-title {
    margin-bottom: 0.5rem;
}

.entry-meta {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
}

.entry-content {
    margin-bottom: 2rem;
}

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

.entry-footer {
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
    margin-top: 2rem;
}

/* Archive & Blog */
.posts-wrapper {
    display: grid;
    gap: 2rem;
}

.post-item {
    border: 1px solid #e0e0e0;
    padding: 1.5rem;
    border-radius: 8px;
    background: #fff;
}

.post-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 3rem 0;
    list-style: none;
}

.pagination a,
.pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid #e0e0e0;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
}

.pagination a:hover,
.pagination a:focus {
    background-color: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

.pagination .current {
    background-color: #0066cc;
    color: #fff;
    border-color: #0066cc;
    font-weight: 600;
}

/* ==========================================================================
   Search Results
   ========================================================================== */

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.search-form label {
    flex: 1;
}

.search-form .search-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 1rem;
}

.search-form .search-field:focus {
    border-color: #4A90E2;
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

.search-form .search-submit {
    padding: 0.75rem 2rem;
    background-color: #0066cc;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.search-form .search-submit:hover,
.search-form .search-submit:focus {
    background-color: #004499;
}

.search-results .page-title {
    margin-bottom: 2rem;
}

.search-no-results .page-header {
    margin-bottom: 2rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    background-color: #222;
    color: #fff;
    padding: 3rem 0 1rem;
    margin-top: auto;
}

.footer-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-widget {
    padding: 1rem;
}

.footer-widget h2,
.footer-widget h3 {
    color: #fff;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.footer-widget ul {
    list-style: none;
}

.footer-widget li {
    margin-bottom: 0.5rem;
}

.footer-widget a {
    color: #ccc;
    text-decoration: none;
}

.footer-widget a:hover,
.footer-widget a:focus {
    color: #fff;
    text-decoration: underline;
}

.site-info {
    border-top: 1px solid #444;
    padding-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: #999;
}

.site-info a {
    color: #ccc;
}

/* ==========================================================================
   Comments
   ========================================================================== */

.comments-area {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 2px solid #e0e0e0;
}

.comment-list {
    list-style: none;
}

.comment {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: 8px;
}

.comment-body {
    margin-bottom: 1rem;
}

.comment-author {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.comment-metadata {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 1rem;
}

.comment-content {
    margin-bottom: 1rem;
}

.reply {
    margin-top: 1rem;
}

.reply a {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background: #0066cc;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    display: inline-block;
}

.reply a:hover,
.reply a:focus {
    background: #004499;
}

.children {
    list-style: none;
    margin-left: 2rem;
    margin-top: 1rem;
}

.comment-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-family: inherit;
    font-size: 1rem;
}

.comment-form input:focus,
.comment-form textarea:focus {
    border-color: #4A90E2;
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

.comment-form .submit {
    padding: 0.75rem 2rem;
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.comment-form .submit:hover,
.comment-form .submit:focus {
    background: #004499;
}

/* ==========================================================================
   Page Builder Compatibility
   ========================================================================== */

/* Elementor */
.elementor-section {
    width: 100%;
}

.elementor-widget-container {
    width: 100%;
}

/* Gutenberg */
.wp-block-group,
.wp-block-columns {
    width: 100%;
}

.alignwide {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.alignfull {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
}

/* Spectra Compatibility */
.uagb-block-grid,
.uagb-section {
    width: 100%;
}

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

@media (max-width: 768px) {
    /* Remove submenu icons on mobile */
    .main-navigation .menu-item-has-children > a::after { content: none; }
    .main-navigation .menu-item-has-children > a { padding-right: 0; }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    .header-inner {
        flex-wrap: wrap;
    }

    .menu-toggle {
        display: block;
    }

    .main-navigation {
        width: 100%;
        order: 3;
    }

    .main-navigation ul {
        display: none;
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
        border-top: 1px solid #e0e0e0;
        padding-top: 1rem;
    }

    .main-navigation.toggled ul {
        display: flex;
    }

    .main-navigation ul ul {
        position: static;
        box-shadow: none;
        border: none;
        border-left: 2px solid #0066cc;
        margin-left: 1rem;
        margin-top: 0.5rem;
    }

    .footer-widgets {
        grid-template-columns: 1fr;
    }

    .children {
        margin-left: 1rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form .search-submit {
        width: 100%;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.screen-reader-text:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 8px 16px;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background-color: #000;
    color: #fff;
    font-weight: 600;
    z-index: 100000;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .site-header,
    .site-footer,
    .menu-toggle,
    .skip-link,
    .comment-respond {
        display: none;
    }

    body {
        font-size: 12pt;
        color: #000;
    }

    a {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }
}


}


/* ===============================
   Dropdown (level 1) + Flyout (level 2+)
   - Level 1 submenu opens UNDER the parent item
   - Level 2+ submenus open to the RIGHT of their parent submenu
   - Unlimited levels supported
================================= */

/* Base submenu styling */
.main-navigation ul ul {
    position: absolute;
    display: none;
    z-index: 9999;
}

/* Level 1: dropdown under parent */
.main-navigation > ul > li {
    position: relative;
}
.main-navigation > ul > li > ul {
    top: 100%;
    left: 0;
}

/* Level 2+ : flyout to the right */
.main-navigation ul ul li {
    position: relative;
}
.main-navigation ul ul ul {
    top: 0;
    left: 100%;
}

/* Open behavior (hover/focus + JS class for touch) */
.main-navigation ul li:hover > ul,
.main-navigation ul li:focus-within > ul,
.main-navigation ul li.submenu-open > ul {
    display: block;
}

/* Arrow indicators */

/* Desktop/Web: show arrow ONLY for submenu items that have their own submenu (level 2+) */
.main-navigation ul ul li.menu-item-has-children > a {
    position: relative;
    padding-right: 1.4em; /* room for arrow */
}
.main-navigation ul ul li.menu-item-has-children > a::after {
    content: "▸";
    position: absolute;
    right: 0.4em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85em;
    line-height: 1;
}

/* Mobile: submenus should stack */
@media (max-width: 768px) {
    .main-navigation ul ul,
    .main-navigation ul ul ul {
        position: relative;
        top: auto;
        left: auto;
    }
    .main-navigation > ul > li > ul {
        top: auto;
        left: auto;
    }
}


/* ===============================
   Mobile Menu Cleanup (Courtaginov)
   - Reduce padding/margins
   - Remove left border from submenu items
   - Keep accordion submenus clean
================================= */
@media (max-width: 768px) {

    /* Remove default list spacing */
    .main-navigation ul,
    .main-navigation ul li {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    /* Make links clean and consistent */
    .main-navigation a {
        display: block;
        padding: 12px 16px;
        margin: 0;
        border: 0;
    }

    /* Remove any borders that may look like a left bar */
    .main-navigation ul ul,
    .main-navigation ul ul li,
    .main-navigation ul ul a {
        border-left: 0 !important;
    }

    /* Submenus stacked under parent with minimal indentation */
    .main-navigation ul ul a {
        padding-left: 24px;
    }
    .main-navigation ul ul ul a {
        padding-left: 32px;
    }
    .main-navigation ul ul ul ul a {
        padding-left: 40px;
    }

    /* Remove extra spacing often added by themes */
    .main-navigation .sub-menu {
        margin: 0;
        padding: 0;
    }

    /* Ensure submenu is hidden unless opened via JS class */
    .main-navigation ul ul {
        display: none;
    }
    .main-navigation li.submenu-open > ul {
        display: block;
    }
}


/* ===============================
   Mobile Menu Toggle Icon Styling
   - Inline SVG hamburger/close
   - No border
   - No hover effect
================================= */
.menu-toggle {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 0;
}

.menu-toggle:hover,
.menu-toggle:focus,
.menu-toggle:active {
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
    outline: none;
}

/* Icon swap based on aria-expanded */
.menu-toggle .menu-icon-close {
    display: none;
}
.menu-toggle[aria-expanded="true"] .menu-icon-open {
    display: none;
}
.menu-toggle[aria-expanded="true"] .menu-icon-close {
    display: inline-block;
}

.menu-toggle svg {
    display: block;
}

