/* ==========================================================
   WorkerEra Job Portal - Responsive Stylesheet
   Breakpoints:
     Large tablet  : ≤ 1100px
     Tablet        : ≤ 1024px
     Mobile large  : ≤ 768px
     Mobile        : ≤ 580px
     Mobile small  : ≤ 420px
   ========================================================== */

/* ============================================================
   1. LARGE TABLET (≤ 1100px)
   Slight tightening before the full tablet breakpoint
   ============================================================ */
@media (max-width: 1100px) {
    .container {
        padding: 0 24px;
    }

    .header-inner {
        gap: 16px;
    }

    .nav-menu > li > a {
        padding: 8px 11px;
        font-size: 0.88rem;
    }

    /* Start hiding the Register/Create-Account CTA to save space */
    .header-actions .btn-blue {
        display: none;
    }

    .cta-card {
        padding: 52px 40px;
        gap: 28px;
    }

    .footer-grid {
        grid-template-columns: 1.2fr 1fr 1fr 1fr;
        gap: 32px;
    }
}

/* ============================================================
   2. TABLET (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {

    /* --- Layout --- */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .country-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
    }

    .steps-grid {
        grid-template-columns: 1fr;
        gap: 24px;
        max-width: 520px;
        margin-left: auto;
        margin-right: auto;
    }

    .step-connector {
        display: none;
    }

    /* Rotate connector to vertical when stacked */
    .step-card {
        margin-top: 20px; /* space for the floating step-number badge */
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 36px;
    }

    .content-sidebar-wrap {
        grid-template-columns: 1fr;
    }

    .widget-area {
        position: static;
    }

    /* --- CTA --- */
    .cta-card {
        flex-direction: column;
        text-align: center;
        padding: 48px 32px;
        gap: 28px;
    }

    .cta-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    /* --- Hero stats: allow a bit more breathing room --- */
    .hero-stats {
        padding: 18px 24px;
    }

    .hero-stat {
        padding: 0 20px;
    }

    /* --- Jobs grid on tablet: ensure minimum column width is sane --- */
    .jobs-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .awsm-jobs-list {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    /* --- Posts grid --- */
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

/* ============================================================
   3. MOBILE LARGE (≤ 768px)
   Main mobile overhaul — hamburger menu, single-column layouts
   ============================================================ */
@media (max-width: 768px) {

    /* --- Root / Body --- */
    :root {
        --we-header-h: 64px;
    }

    body {
        padding-top: var(--we-header-h);
    }

    /* --- Container --- */
    .container {
        padding: 0 20px;
    }

    /* --- Section spacing --- */
    .section-pad {
        padding: 52px 0;
    }

    .section-pad-sm {
        padding: 32px 0;
    }

    .section-header {
        margin-bottom: 32px;
    }

    .section-cta {
        margin-top: 36px;
    }

    /* ---- HEADER ---- */
    .header-inner {
        gap: 12px;
    }

    /* Hamburger: show on mobile */
    .mobile-menu-toggle {
        display: flex;
        order: 3;          /* sits after logo & actions */
        flex-shrink: 0;
        padding: 8px 6px;
    }

    /* Mobile navigation drawer */
    .primary-navigation {
        display: none;
        position: fixed;
        top: var(--we-header-h);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--we-white);
        z-index: 999;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px 24px 32px;
        flex-direction: column;
        box-shadow: var(--we-shadow-lg);
        border-top: 1px solid var(--we-border);
    }

    .primary-navigation.is-open {
        display: flex;
        animation: slideInLeft 0.22s ease;
    }

    @keyframes slideInLeft {
        from {
            opacity: 0;
            transform: translateX(-12px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    /* Nav menu inside drawer */
    .nav-menu {
        flex-direction: column;
        gap: 2px;
        width: 100%;
    }

    .nav-menu > li > a {
        font-size: 1rem;
        padding: 13px 16px;
        border-radius: var(--we-radius-sm);
        font-weight: 500;
        color: var(--we-text);
    }

    .nav-menu > li > a:hover,
    .nav-menu > li.current-menu-item > a,
    .nav-menu > li.current_page_item > a {
        color: var(--we-dark-blue);
        background: rgba(12, 61, 145, 0.06);
    }

    /* Submenu — static inside drawer */
    .nav-menu .sub-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(12, 61, 145, 0.04);
        border-radius: var(--we-radius-sm);
        padding: 6px 0 6px 12px;
        display: block;
        margin-top: 4px;
        animation: none;
    }

    .nav-menu .sub-menu li a {
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    /* Mobile menu overlay */
    .mobile-overlay.is-visible {
        display: block;
    }

    /* Header actions — only keep the most important single CTA */
    .header-actions {
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* On mobile, hide Login (outline) and Register; keep only "Post a Job" */
    .header-actions .btn-outline-blue,
    .header-actions .btn-blue {
        display: none;
    }

    /* Compact the "Post a Job" / orange button */
    .header-actions .btn-orange {
        padding: 8px 16px;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    /* ---- HERO ---- */
    .hero-section {
        padding: 60px 0 80px;
    }

    .hero-title {
        font-size: clamp(1.75rem, 7vw, 2.5rem);
        margin-bottom: 14px;
    }

    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 28px;
    }

    .hero-badge {
        font-size: 0.8rem;
        padding: 5px 14px;
        margin-bottom: 16px;
    }

    .hero-actions {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        margin-bottom: 36px;
    }

    .hero-actions .btn {
        width: 100%;
        max-width: 340px;
    }

    /* Hero stats — switch to a 2×2 grid on mobile */
    .hero-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        padding: 16px;
        border-radius: var(--we-radius-md);
    }

    .hero-stat {
        padding: 14px 12px;
        border-right: 1px solid rgba(255, 255, 255, 0.15);
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    /* Remove borders from last row / last column */
    .hero-stat:nth-child(2n) {
        border-right: none;
    }

    .hero-stat:nth-last-child(-n+2) {
        border-bottom: none;
    }

    .hero-stat strong {
        font-size: 1.35rem;
        display: block;
        margin-bottom: 2px;
    }

    .hero-stat span {
        font-size: 0.78rem;
    }

    /* Hide the old vertical dividers — replaced by grid borders above */
    .hero-stat-divider {
        display: none;
    }

    /* ---- INNER PAGE HERO ---- */
    .inner-page-hero {
        padding: 36px 0 28px;
    }

    .inner-page-hero .page-title {
        font-size: clamp(1.4rem, 5vw, 1.9rem);
    }

    .inner-page-hero .page-subtitle {
        font-size: 0.95rem;
    }

    /* ---- COUNTRY GRID ---- */
    .country-grid {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        margin-top: 28px;
    }

    .country-card {
        padding: 16px 14px;
        gap: 10px;
    }

    .country-flag {
        font-size: 1.8rem;
    }

    .country-info h3 {
        font-size: 0.88rem;
        margin-bottom: 0;
    }

    .country-info p {
        display: none; /* keep card compact */
    }

    .country-arrow {
        display: none;
    }

    /* ---- FEATURES ---- */
    .features-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .feature-card {
        padding: 22px 20px;
        text-align: left;
        display: flex;
        gap: 16px;
        align-items: flex-start;
    }

    .feature-icon {
        width: 54px;
        height: 54px;
        flex-shrink: 0;
        margin: 0;
    }

    .feature-card h3 {
        font-size: 1rem;
        margin-bottom: 6px;
    }

    .feature-card p {
        font-size: 0.88rem;
    }

    /* ---- STATS ---- */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0;
    }

    .stat-item {
        padding: 28px 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }

    .stat-number {
        font-size: 2rem;
    }

    .stat-label {
        font-size: 0.85rem;
    }

    /* ---- STEPS "HOW IT WORKS" ---- */
    .steps-grid {
        grid-template-columns: 1fr;
        gap: 28px;
        max-width: 100%;
    }

    .step-card {
        padding: 32px 22px 22px;
    }

    /* ---- JOBS ---- */
    .jobs-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .job-card {
        padding: 18px 16px;
        gap: 12px;
    }

    .job-card-action {
        align-items: center;
    }

    /* AWSM plugin */
    .jobs-section {
        padding-top: 52px;
    }

    .awsm-jobs-list {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .awsm-jobs-filter-form {
        position: relative;
        top: 0;
        margin-top: -120px;
        flex-direction: column;
        padding: 24px;
        gap: 12px;
        z-index: 10;
        box-shadow: 0 10px 25px rgba(15, 61, 145, 0.1);
    }

    .awsm-job-post {
        padding: 18px 20px;
    }

    /* ---- CTA SECTION ---- */
    .cta-card {
        flex-direction: column;
        text-align: center;
        padding: 40px 24px;
        gap: 24px;
    }

    .cta-actions {
        justify-content: center;
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .cta-actions .btn {
        width: 100%;
        max-width: 300px;
    }

    /* ---- FOOTER ---- */
    .footer-top {
        padding: 48px 0 36px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .footer-about-text {
        max-width: 100%;
    }

    .footer-menu {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 16px;
    }

    .footer-bottom-inner {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .footer-bottom-links {
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    /* ---- POSTS GRID ---- */
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* ---- POST NAVIGATION ---- */
    .post-navigation {
        flex-direction: column;
        gap: 16px;
        padding: 20px;
    }

    /* ---- SEARCH FORM ---- */
    .search-form {
        flex-direction: column;
        gap: 10px;
    }

    .search-field,
    .search-submit {
        width: 100%;
    }

    /* ---- UMF (Ultimate Member) Forms ---- */
    .um-login,
    .um-register {
        padding: 28px 20px;
    }

    /* ---- PAGINATION ---- */
    .posts-pagination,
    .page-links,
    .nav-links {
        gap: 6px;
        margin-top: 36px;
    }

    .page-numbers,
    .nav-links a,
    .nav-links span {
        padding: 8px 13px;
        font-size: 0.83rem;
    }

    /* ---- ERROR 404 ---- */
    .error-404 {
        padding: 52px 0;
    }

    .error-404-actions {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .error-404-actions .btn {
        width: 100%;
        max-width: 280px;
    }

    /* ---- SINGLE JOB ---- */
    .single-post-article {
        max-width: 100%;
    }

    /* ---- BACK TO TOP ---- */
    .back-to-top {
        bottom: 20px;
        right: 16px;
        width: 40px;
        height: 40px;
    }

    /* Social share */
    .social-share {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ============================================================
   4. MOBILE (≤ 580px)
   Tighter refinements for phones in the 420–580px range
   ============================================================ */
@media (max-width: 580px) {

    .container {
        padding: 0 16px;
    }

    /* --- Typography scale-down --- */
    .hero-title {
        font-size: clamp(1.6rem, 8vw, 2.2rem);
        line-height: 1.2;
    }

    .section-title {
        font-size: clamp(1.3rem, 5.5vw, 1.8rem);
    }

    /* --- Buttons --- */
    .btn-lg {
        padding: 14px 26px;
        font-size: 0.95rem;
    }

    .btn {
        white-space: normal;  /* allow wrapping on very small screens */
        text-align: center;
    }

    /* --- Hero --- */
    .hero-section {
        padding: 44px 0 36px;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .hero-actions .btn {
        max-width: 100%;
    }

    /* --- Header actions: shrink Post a Job button slightly --- */
    .header-actions .btn-orange {
        padding: 7px 13px;
        font-size: 0.78rem;
    }

    /* --- Country: single column on narrow phones --- */
    .country-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .country-card {
        padding: 16px;
        gap: 14px;
    }

    .country-info p {
        display: block; /* restore hint text when there's full width */
        font-size: 0.75rem;
    }

    /* --- Footer menu: back to single col --- */
    .footer-menu {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .footer-menu li {
        margin-bottom: 6px;
    }

    /* --- CTA card --- */
    .cta-card {
        padding: 32px 18px;
        border-radius: var(--we-radius-md);
    }

    /* --- Stats grid --- */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* --- Jobs filter --- */
    .awsm-jobs-filter-form {
        padding: 16px;
    }

    /* --- Feature cards --- */
    .feature-icon {
        width: 48px;
        height: 48px;
    }

    /* --- Section padding lower bound --- */
    .section-pad {
        padding: 44px 0;
    }

    .section-pad-sm {
        padding: 28px 0;
    }

    /* --- Step cards --- */
    .step-card {
        padding: 28px 18px 18px;
    }

    /* --- Post featured image: shorter on mobile --- */
    .post-featured-image img {
        max-height: 220px;
    }

    /* --- Social share horizontal scroll --- */
    .social-share {
        gap: 6px;
    }

    .share-btn {
        padding: 6px 13px;
        font-size: 0.78rem;
    }
}

/* ============================================================
   5. MOBILE SMALL (≤ 420px)
   Edge-case refinements for very small devices (iPhone SE, etc.)
   ============================================================ */
@media (max-width: 420px) {

    :root {
        --we-header-h: 60px;
    }

    .container {
        padding: 0 14px;
    }

    /* Header: hide everything in actions except hamburger interaction */
    .header-actions .btn-orange {
        padding: 6px 11px;
        font-size: 0.75rem;
    }

    /* Hero */
    .hero-section {
        padding: 36px 0 30px;
    }

    .hero-title {
        font-size: clamp(1.45rem, 9vw, 2rem);
    }

    .hero-badge {
        font-size: 0.75rem;
        padding: 4px 12px;
    }

    .hero-stats {
        grid-template-columns: 1fr 1fr;
        padding: 12px 10px;
    }

    .hero-stat {
        padding: 12px 8px;
    }

    .hero-stat strong {
        font-size: 1.2rem;
    }

    .hero-stat span {
        font-size: 0.72rem;
    }

    /* Logo text: slightly smaller */
    .text-logo a {
        font-size: 1.25rem;
    }

    /* CTA Card */
    .cta-card {
        padding: 28px 14px;
    }

    /* Country */
    .country-flag {
        font-size: 1.6rem;
    }

    /* Section headers */
    .section-header {
        margin-bottom: 26px;
    }

    .section-subtitle {
        font-size: 0.93rem;
    }

    /* Steps */
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
        top: -14px;
    }

    /* Buttons */
    .btn-lg {
        padding: 12px 22px;
        font-size: 0.9rem;
    }

    /* Error 404 */
    .error-404-title {
        font-size: 1.5rem;
    }

    /* Footer */
    .footer-top {
        padding: 40px 0 28px;
    }

    /* Pagination */
    .page-numbers,
    .nav-links a,
    .nav-links span {
        padding: 7px 11px;
        font-size: 0.8rem;
    }
}

/* ============================================================
   6. OVERFLOW GUARD — prevents any horizontal scroll
   ============================================================ */
html,
body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Prevent wide images / embeds from breaking layout */
img,
video,
iframe,
embed,
object {
    max-width: 100%;
}

/* Tables can overflow — add scroll wrapper for content tables */
.entry-content table {
    width: 100%;
    overflow-x: auto;
    display: block;
}

@media (max-width: 768px) {
    /* Ensure flexbox rows don't overflow */
    .hero-actions,
    .cta-actions,
    .header-actions,
    .footer-bottom-links,
    .breadcrumbs ol,
    .post-meta,
    .job-card-meta,
    .awsm-job-specification {
        flex-wrap: wrap;
    }

    /* Fix: Step numbering that's absolute-positioned can clip content */
    .step-card {
        overflow: visible;
    }

    /* Gutenberg columns — stack on mobile */
    .wp-block-columns {
        flex-direction: column;
    }

    .wp-block-column {
        flex-basis: 100% !important;
        width: 100% !important;
    }
}

/* ============================================================
   7. PRINT
   ============================================================ */
@media print {
    .site-header,
    .site-footer,
    .sidebar,
    .back-to-top,
    .hero-section,
    .mobile-overlay {
        display: none !important;
    }

    body {
        padding-top: 0 !important;
        color: #000 !important;
        font-size: 12pt;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}