/*
Theme Name: Urdu Madrasa Master
Author: Expert Fix
Version: 4.0
Description: A fully responsive Urdu educational theme. Integrated with Mobile Stability, Cache Management, Search Highlighting, and a 3-Tier Header System.
Text Domain: urdu-madrasa
Tags: right-to-left, custom-background, custom-colors, custom-menu, featured-images, footer-widgets, full-width-template, theme-options, translation-ready, two-columns
*/

/* ==========================================================================
   1. RESET & GLOBAL VARIABLES
   ========================================================================== */
:root {
    /* Default Colors (Can be overridden by Customizer) */
    --primary-color: #0073aa;
    --secondary-color: #005177;
    --text-color: #333333;
    --bg-color: #f9f9f9;
    --header-bg: #ffffff;
    --footer-bg: #222222;
    --footer-text: #ffffff;
    --border-color: #eeeeee;
    
    /* Layout */
    --container-width: 1200px;
    --header-height: auto;
}

* {
    box-sizing: border-box;
}

/* -----------------------------------------------------------
   MOBILE STABILITY FIX
   Prevents the site from shaking or scrolling horizontally.
----------------------------------------------------------- */
html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative !important;
}

body {
    direction: rtl; /* Right-to-Left for Urdu */
    text-align: right;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 18px; /* Base Font Size */
    line-height: 1.8;
    font-family: sans-serif; /* Fallback until Fonts Loaded */
}

/* ==========================================================================
   2. TYPOGRAPHY & URDU FONTS
   ========================================================================== */
/* Define Jameel Noori Nastaleeq */
@font-face {
    font-family: 'UrduFont';
    src: url('fonts/jameel-noori.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Define Arabic Font (Optional) */
@font-face {
    font-family: 'ArabicFont';
    src: url('fonts/noto-naskh.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Apply Fonts Globaly */
body, h1, h2, h3, h4, h5, h6, p, a, li, span, div, input, button, textarea {
    font-family: 'UrduFont', 'Arial', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    color: #000;
    margin-top: 0;
    margin-bottom: 20px;
    line-height: 1.4;
    font-weight: bold;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--secondary-color);
}

/* ==========================================================================
   3. LAYOUT & GRID SYSTEM
   ========================================================================== */
.site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

/* Columns */
.col-md-8 { /* Main Content */
    flex: 0 0 66.666667%;
    max-width: 66.666667%;
    padding: 0 15px;
}

.col-md-4 { /* Sidebar */
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
    padding: 0 15px;
}

.col-md-12 { /* Full Width */
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 15px;
}

/* Sidebar Position Logic (Right vs Left) */
/* Default is Left Sidebar (because RTL). If user wants Right, we swap order */
.sidebar-right .col-md-8 { order: 2; }
.sidebar-right .col-md-4 { order: 1; }

/* -----------------------------------------------------------
   RESPONSIVE BREAKPOINTS (Mobile)
  
----------------------------------------------------------- */
@media screen and (max-width: 768px) {
    .col-md-8, .col-md-4, .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 0 15px;
    }

    /* Reset Margins */
    .row, .container {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: 100% !important;
    }

    /* Fix Media sizing */
    img, iframe, video, table {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ==========================================================================
   4. HEADER SYSTEM (3-TIER)
   ========================================================================== */
.site-header-1, 
.site-header-2, 
.site-header-3 {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    position: relative;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

/* Branding */
.site-branding {
    padding: 5px 0;
}
.site-title {
    font-size: 2.5rem;
    margin: 0;
    line-height: 1;
}
.site-description {
    font-size: 1rem;
    color: #666;
    margin: 0;
}

/* Header Widgets */
.header-widget {
    margin: 0 10px;
}

/* ==========================================================================
   5. NAVIGATION MENU (Desktop & Mobile)
  
   ========================================================================== */
.main-navigation-container {
    position: relative;
}

/* --- Desktop Styles --- */
@media screen and (min-width: 769px) {
    .menu-toggle { display: none; } /* Hide hamburger on desktop */
    
    .main-navigation ul {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
    }

    .main-navigation li {
        position: relative;
    }

    .main-navigation a {
        display: block;
        padding: 10px 20px;
        color: var(--text-color);
        font-weight: bold;
    }

    /* Sub-menu (Dropdown) */
    .main-navigation ul ul {
        display: none; /* Hidden by default */
        position: absolute;
        top: 100%;
        right: 0;
        background: #fff;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        z-index: 999;
        flex-direction: column;
        min-width: 220px;
    }

    /* Show on Hover */
    .main-navigation li:hover > ul {
        display: flex;
    }

    .main-navigation ul ul li {
        border-bottom: 1px solid #eee;
    }
    
    /* Hide the mobile arrow toggle on desktop */
    .dropdown-toggle { display: none; }
}

/* --- Mobile Styles (Hamburger & Accordion) --- */
@media screen and (max-width: 768px) {
    
    /* Hamburger Icon */
    .menu-toggle {
        display: block;
        background: transparent;
        border: 2px solid #ddd;
        font-size: 24px;
        cursor: pointer;
        padding: 5px 12px;
        border-radius: 4px;
        color: var(--text-color);
    }

    /* Hide Menu Default */
    .main-navigation {
        display: none; 
        width: 100%;
        background: #fff;
        border-top: 1px solid #eee;
        position: absolute;
        top: 100%;
        right: 0;
        z-index: 1000;
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    }

    .main-navigation.toggled-open {
        display: block; /* JS toggles this class */
    }

    .main-navigation ul {
        display: block;
        margin: 0;
        padding: 0;
    }

    .main-navigation li {
        display: block;
        border-bottom: 1px solid #f1f1f1;
        position: relative;
    }

    .main-navigation a {
        display: block;
        padding: 15px 20px;
        width: 100%;
    }

    /* Sub-menu Hidden (Accordion) */
    .main-navigation ul ul {
        display: none; /* Hidden until arrow clicked */
        background: #f9f9f9;
        padding-right: 20px; /* Indent */
    }
    
    .main-navigation ul ul.toggled-on {
        display: block; /* JS toggles this class */
    }

    /* The Arrow Button */
    .dropdown-toggle {
        position: absolute;
        top: 0;
        left: 0;
        width: 50px;
        height: 100%;
        background: transparent;
        border: none;
        border-right: 1px solid #f1f1f1;
        font-size: 1.2rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
   6. POST & CONTENT STYLING
   ========================================================================== */
.site-main {
    padding: 40px 0;
}

article {
    margin-bottom: 40px;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    border: 1px solid var(--border-color);
}

.entry-header {
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

.entry-title {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.entry-meta {
    color: #888;
    font-size: 0.9rem;
}

/* Edit Button */
.edit-link-top {
    display: inline-block;
    background: #f1f1f1;
    color: #333;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-top: 5px;
    border: 1px solid #ddd;
}
.edit-link-top:hover {
    background: #e1e1e1;
}

/* Search Highlight */
mark.urdu-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 0 5px;
    border-radius: 3px;
    font-weight: bold;
}

/* Pagination */
.pagination {
    margin-top: 40px;
    text-align: center;
}
.pagination .page-numbers {
    display: inline-block;
    padding: 8px 15px;
    background: #fff;
    border: 1px solid #ddd;
    margin: 0 2px;
    border-radius: 4px;
    color: var(--text-color);
}
.pagination .page-numbers.current,
.pagination .page-numbers:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* ==========================================================================
   7. SIDEBAR & WIDGETS
   ========================================================================== */
.widget-area {
    padding-top: 40px;
}

.widget {
    background: #fff;
    padding: 25px;
    margin-bottom: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.widget-title {
    font-size: 1.4rem;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    display: inline-block;
}

.widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget li {
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

/* ==========================================================================
   8. FOOTER
   ========================================================================== */
.site-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 50px 0 20px;
    margin-top: auto;
}

.site-footer a {
    color: #fff;
    text-decoration: underline;
}

.site-info {
    text-align: center;
    border-top: 1px solid #444;
    padding-top: 20px;
    margin-top: 30px;
    opacity: 0.8;
}

/* ==========================================================================
   9. ANIMATIONS & EFFECTS
   ========================================================================== */
/* Preloader */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Reveal on Scroll */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.reveal-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}
/* Fallback if JS disabled */
.no-js .reveal-on-scroll {
    opacity: 1;
    transform: none;
}