/*
Theme Name: MDH (Muzakarah Darulhana) Default Theme
Theme URI: https://mdh-02.test:8443/
Author: Maswan
Author URI: https://mdh-02.test:8443/
Description: MDH (Muzakarah Darulhana) Default Theme is a serene, tactile digital magazine and community dashboard theme built with soft-clay design tokens, full-width viewport utilization, and native WordPress template hierarchy.
Version: 1.6.0
Requires at least: 6.0
Tested up to: 6.7
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: mdh
Tags: magazine, blog, two-columns, three-columns, grid-layout, custom-background, custom-colors, custom-header, custom-menu, featured-images, full-width-template, theme-options, threaded-comments, translation-ready
*/

/* Core Custom Properties & Typography Defaults (Default to Moss Green as in Mockup) */
:root {
    --bg-primary: #DCE7E0;
    --surface-card: rgba(242, 248, 244, 0.90);
    --surface-well: rgba(202, 220, 209, 0.55);
    --accent-primary: #5B8C7A;
    --mesh-1: rgba(184, 216, 200, 0.75);
    --mesh-2: rgba(134, 157, 138, 0.45);
    --mesh-3: rgba(220, 236, 227, 0.80);
    --mesh-4: rgba(210, 230, 220, 0.65);
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 6.5rem;
}

body {
    background-color: var(--bg-primary);
    color: #2A322E;
    overflow-x: hidden;
    transition: background-color 0.45s ease;
}

/* Ambient organic background gradients driven by CSS variables */
.ambient-mesh {
    background:
        radial-gradient(circle at 12% 18%, var(--mesh-1) 0%, transparent 42%),
        radial-gradient(circle at 86% 12%, var(--mesh-2) 0%, transparent 45%),
        radial-gradient(circle at 78% 82%, var(--mesh-3) 0%, transparent 48%),
        radial-gradient(circle at 22% 75%, var(--mesh-4) 0%, transparent 40%),
        var(--bg-primary);
    background-attachment: fixed;
    transition: background 0.5s ease;
}

/* Tactile Soft-Clay Card Surface */
.clay-card {
    background: var(--surface-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 14px 32px -8px rgba(42, 50, 46, 0.06), 0 4px 12px -2px rgba(42, 50, 46, 0.03), inset 0 2px 0 0 rgba(255, 255, 255, 0.9);
    border-radius: 28px;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.clay-card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 22px 42px -10px rgba(42, 50, 46, 0.09), 0 8px 18px -4px rgba(42, 50, 46, 0.04), inset 0 2px 0 0 rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 0.95);
}

/* Recessed Well (Inner container) */
.clay-well {
    background: var(--surface-well);
    box-shadow: inset 0 2px 5px rgba(42, 50, 46, 0.05), 0 1px 0 rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    border: 1px solid rgba(42, 50, 46, 0.03);
    transition: background 0.35s ease;
}

/* Tactile Pill Button */
.clay-btn {
    background: linear-gradient(180deg, #FFFFFF 0%, #F5EFE6 100%);
    box-shadow: 0 4px 12px rgba(42, 50, 46, 0.06), inset 0 1.5px 0 #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.9);
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.clay-btn:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 8px 18px rgba(42, 50, 46, 0.09), inset 0 1.5px 0 #FFFFFF;
}

.clay-btn:active {
    transform: translateY(0.5px);
    box-shadow: inset 0 2px 4px rgba(42, 50, 46, 0.08);
}

.clay-btn-primary {
    background: linear-gradient(135deg, #689B88 0%, #4E7D6B 100%);
    color: #FFFFFF;
    box-shadow: 0 8px 20px -4px rgba(91, 140, 122, 0.4), inset 0 1.5px 0 rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.clay-btn-primary:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 12px 24px -4px rgba(91, 140, 122, 0.5), inset 0 1.5px 0 rgba(255, 255, 255, 0.45);
    filter: brightness(1.03);
}

/* Sticky Header Transition State */
#masthead.header-scrolled .header-inner {
    background: rgba(250, 247, 242, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 14px 34px -8px rgba(42, 50, 46, 0.08), inset 0 1.5px 0 0 rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.85);
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

/* Global Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #F5EFE6;
}

::-webkit-scrollbar-thumb {
    background: #D5C7B2;
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5B8C7A;
}

/* ==========================================================================
   Sticky Header & Sidebar Spacing Architecture
   Prevents sidebars from touching or colliding with the sticky navigation bar
   ========================================================================== */
:root {
    --header-sticky-top: 0.75rem;
    --header-total-height: 5rem;
    --sidebar-gap: 1.5rem;
    --sidebar-sticky-top: calc(var(--header-sticky-top) + var(--header-total-height) + var(--sidebar-gap));
}

body.admin-bar {
    --header-sticky-top: 2.25rem;
    /* 36px offset for WP admin bar */
    --sidebar-sticky-top: calc(32px + var(--header-total-height) + var(--sidebar-gap) + 0.75rem);
    /* ~148px */
}

@media screen and (max-width: 782px) {
    body.admin-bar {
        --header-sticky-top: 3.25rem;
    }
}

#masthead {
    top: var(--header-sticky-top) !important;
}

#secondary-left,
#secondary-right {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    align-self: start !important;
}

/* Center Content Column Independent Scrollport (Desktop) */
@media screen and (min-width: 1024px) {
    #primary {
        position: sticky !important;
        top: var(--sidebar-sticky-top, 144px) !important;
        height: calc(100vh - var(--sidebar-sticky-top, 144px) - 1.5rem) !important;
        max-height: calc(100vh - var(--sidebar-sticky-top, 144px) - 1.5rem) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        padding-top: 6px !important;
        padding-bottom: 32px !important;
        padding-left: 4px !important;
        padding-right: 8px !important;
        box-sizing: border-box !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    #primary::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }
}

/* Circular SVG Gauge Animation */
.gauge-ring {
    transition: stroke-dashoffset 1s cubic-bezier(0.22, 1, 0.36, 1);
}

/* WordPress Gutenberg Block Content Styling */
.entry-content p {
    margin-bottom: 1.35rem;
    line-height: 1.8;
    font-size: 1.08rem;
    color: #3B4440;
}

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    color: #2A322E;
    margin-top: 2rem;
    margin-bottom: 0.9rem;
    letter-spacing: -0.02em;
}

.entry-content h2 {
    font-size: 1.55rem;
}

.entry-content h3 {
    font-size: 1.35rem;
}

.entry-content blockquote.wp-block-quote,
.prose blockquote {
    background: rgba(220, 236, 227, 0.45);
    border-inline-start: 4px solid #5B8C7A;
    border-inline-end: 0;
    padding-block: 1.25rem;
    padding-inline-start: 1.5rem;
    padding-inline-end: 1rem;
    border-start-end-radius: 20px;
    border-end-end-radius: 20px;
    border-start-start-radius: 0;
    border-end-start-radius: 0;
    font-family: 'Newsreader', serif;
    font-style: italic;
    font-size: 1.25rem;
    color: #2A322E;
    margin: 1.75rem 0;
}

.entry-content ul {
    list-style-type: disc;
    margin-left: 1.5rem;
    margin-bottom: 1.35rem;
    color: #3B4440;
}

.entry-content ol {
    list-style-type: decimal;
    margin-left: 1.5rem;
    margin-bottom: 1.35rem;
    color: #3B4440;
}

.entry-content li {
    margin-bottom: 0.5rem;
}

.entry-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88em;
    background: rgba(235, 227, 213, 0.55);
    padding: 0.15rem 0.4rem;
    border-radius: 0.4rem;
    color: #35584B;
}

.entry-content pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    background: #2A322E;
    color: #F5EFE6;
    padding: 1.25rem;
    border-radius: 18px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.entry-content img {
    border-radius: 20px;
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   Desktop Dropdown Sub-menu & Mobile Drawer Navigation
   ========================================================================== */
.site-navigation .menu-item-has-children {
    position: relative;
}

.site-navigation .sub-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: rgba(245, 239, 230, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(42, 48, 45, 0.08);
    box-shadow: 0 16px 32px -8px rgba(42, 48, 45, 0.12);
    border-radius: 1.25rem;
    padding: 0.75rem;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 100%;
    inset-inline-start: 0;
    margin-top: 0.5rem;
    transform: translateY(6px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.site-navigation .menu-item-has-children:hover>.sub-menu,
.site-navigation .menu-item-has-children:focus-within>.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.site-navigation .sub-menu a {
    padding: 0.5rem 0.875rem;
    border-radius: 0.875rem;
    font-size: 0.875rem;
    color: #4A524E;
    transition: background 0.15s ease, color 0.15s ease;
    display: block;
    width: 100%;
}

.site-navigation .sub-menu a:hover {
    background: rgba(91, 140, 122, 0.1);
    color: #5B8C7A;
}

/* Nested Sub-sub-menus (Level 3+) */
.site-navigation .sub-menu .menu-item-has-children>.sub-menu {
    top: 0;
    inset-inline-start: 100%;
    margin-top: 0;
    margin-inline-start: 0.5rem;
}

/* Mobile Drawer Accordion Styles */
#mobile-drawer .sub-menu {
    display: none;
    padding-inline-start: 1rem;
    margin-top: 0.5rem;
    border-inline-start: 2px solid rgba(91, 140, 122, 0.2);
    flex-direction: column;
    gap: 0.25rem;
}

#mobile-drawer .menu-item-has-children.active-accordion>.sub-menu {
    display: flex;
}

#mobile-drawer .menu-item-has-children.active-accordion>div .accordion-arrow,
#mobile-drawer .menu-item-has-children.active-accordion>a .accordion-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   RTL & Bidirectional (BiDi) Compatibility
   ========================================================================== */

/* 1. Mirror directional arrows, chevrons, and pagination icons */
[dir="rtl"] .ph-arrow-right,
[dir="rtl"] .ph-arrow-left,
[dir="rtl"] .ph-caret-right,
[dir="rtl"] .ph-caret-left,
[dir="rtl"] .ph-arrow-bend-down-left,
[dir="rtl"] .rtl-flip,
.rtl .ph-arrow-right,
.rtl .ph-arrow-left,
.rtl .ph-caret-right,
.rtl .ph-caret-left,
.rtl .ph-arrow-bend-down-left,
.rtl .rtl-flip {
    transform: scaleX(-1);
    display: inline-block;
}

/* 2. Nav Pill Indicator reset */
#nav-pill-indicator {
    right: auto;
}

/* 3. Threaded Comments & FluentComments Indentation */
.comment-list .children,
.comments-area .children,
.mdh-comments-shell .children,
.mdh-comments-shell .fcom-children,
.mdh-comments-shell .fcom-replies {
    margin-block-start: 0.75rem !important;
    margin-inline-start: 1.75rem !important;
    margin-inline-end: 0 !important;
    padding-inline-start: 1rem !important;
    padding-inline-end: 0 !important;
    border-inline-start: 2px solid rgba(91, 140, 122, 0.2) !important;
    border-inline-end: 0 !important;
}

.comments-area textarea,
.comments-area input[type="text"],
.comments-area input[type="email"],
.mdh-comments-shell textarea,
.mdh-comments-shell input {
    direction: inherit;
    text-align: start;
}

/* 4. Arabic & RTL Typography */
[dir="rtl"] body,
.rtl body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans Arabic', sans-serif;
}

[dir="rtl"] .font-serif,
.rtl .font-serif,
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 {
    font-family: 'Newsreader', 'Amiri', Georgia, serif;
}

/* 5. BiDi Plaintext Support for Mixed Quranic/Arabic Content */
.entry-content p,
.comment-content p {
    unicode-bidi: plaintext;
}