/*
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.5
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.55rem;
    padding-bottom: 0.55rem;
}

/* ==========================================================================
   Fluid Responsive Architecture (clamp(), flexible sizing & zero cutoff)
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: clip;
}

/* Fluid outer shell padding across header & main workspace */
.mdh-fluid-shell {
    padding-inline: clamp(0.75rem, 1.8vw, 2rem);
}

#masthead .header-inner {
    padding-inline: clamp(0.875rem, 1.6vw, 2rem);
}

/* Fluid Site Title */
.mdh-fluid-site-title {
    font-size: clamp(0.95rem, 1.05vw, 1.125rem);
}

/* Balanced 2-Line Wrapping Tagline (prevents pushing center/right header off-screen) */
.mdh-fluid-tagline {
    font-size: clamp(0.65rem, 0.72vw, 0.72rem);
    line-height: 1.32;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-wrap: pretty;
    max-width: clamp(14.5rem, 18.5vw, 26rem);
}

@media screen and (min-width: 1280px) and (max-width: 1535px) {
    /* On 1280px–1535px laptops where the 5-item pill nav is visible, keep tagline cleanly on 2 lines */
    .mdh-fluid-tagline {
        max-width: clamp(14.5rem, 17.5vw, 19.5rem);
    }
}

/* Fluid Primary Navigation Pill Links */
.mdh-fluid-nav-link {
    padding-inline: clamp(0.6rem, 0.88vw, 1rem);
    padding-block: clamp(0.38rem, 0.45vw, 0.5rem);
    font-size: clamp(0.75rem, 0.82vw, 0.875rem);
}

/* Fluid Search Input Wrapper */
.mdh-fluid-search {
    width: clamp(8.5rem, 12vw, 16rem);
}

@media screen and (min-width: 640px) and (max-width: 1279px) {
    /* Tablet/small laptop (before center nav pill appears): search bar can breathe wider */
    .mdh-fluid-search {
        width: clamp(10.5rem, 22vw, 15rem);
    }
    .mdh-fluid-tagline {
        max-width: clamp(16rem, 38vw, 26rem);
    }
}

/* Fluid 3-Column & 2-Column Workspace Grid */
.mdh-fluid-grid {
    gap: clamp(1rem, 1.6vw, 2rem);
}

.mdh-fluid-grid > * {
    min-width: 0;
}

@media screen and (min-width: 1024px) and (max-width: 1535px) {
    /* Balanced card padding on 1024px–1535px screens so sidebars and center column never feel cramped */
    #secondary-left .clay-card,
    #secondary-right .clay-card,
    #secondary-qa-sidebar .clay-card {
        padding: clamp(1rem, 1.25vw, 1.35rem);
    }
}

/* 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;
}

@media screen and (min-width: 1024px) {
    #secondary-left,
    #secondary-right,
    #secondary-qa-sidebar {
        position: sticky !important;
        top: var(--sidebar-sticky-top, 108px) !important;
        height: calc(100vh - var(--sidebar-sticky-top, 108px) - 1.5rem) !important;
        max-height: calc(100vh - var(--sidebar-sticky-top, 108px) - 1.5rem) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        box-sizing: border-box !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
        padding-bottom: 2rem !important;
    }

    #secondary-left::-webkit-scrollbar,
    #secondary-right::-webkit-scrollbar,
    #secondary-qa-sidebar::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    /* Center Content aligns 100% flush with sidebars at the top of the grid */
    #primary {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
        padding-bottom: 48px !important;
        box-sizing: border-box !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: var(--surface-card, 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), background 0.3s ease;
    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;
}


/* ==========================================================================
   Two-Tier Arabic & BiDi Isolation (Frontend Single Post & Content)
   ========================================================================== */

/* 1. Inline Arabic Phrases (bilingual text inside LTR paragraphs) */
.entry-content .ar-inline,
.comment-content .ar-inline,
.tiptap-prose .ar-inline,
bdi.ar-inline {
    display: inline;
    font-family: 'Amiri', 'Traditional Arabic', serif;
    font-size: 1.22em;
    line-height: 1.5;
    direction: rtl;
    unicode-bidi: isolate;
    color: #1a4433;
    padding: 0 3px;
    background: rgba(91, 140, 122, 0.08);
    border-radius: 4px;
}

/* 2. Standalone Arabic Blocks (Verses, Hadith Matn, Du'a) */
.entry-content .ar-block,
.entry-content blockquote[dir="rtl"],
.entry-content [dir="rtl"]:not(.ar-inline),
.comment-content [dir="rtl"]:not(.ar-inline),
.tiptap-prose .ar-block {
    direction: rtl;
    text-align: right;
    font-family: 'Amiri', 'Traditional Arabic', serif;
    font-size: 1.4rem;
    line-height: 2.3;
    color: #1a4433;
    margin-block: 1.25rem;
}
