/**
 * Fasting Checker - "Does This Break My Fast?"
 * Sacred Geometric Night Sky Theme
 * A celestial design with deep midnight blues, sacred gold accents, and Islamic emerald
 */

/* ========================================
   CSS Custom Properties
   ======================================== */
:root {
    /* Primary - Midnight Sky */
    --fc-midnight: #0A1628;
    --fc-deep-space: #0F1D32;
    --fc-night-blue: #152238;
    --fc-twilight: #1E3050;

    /* Secondary - Islamic Emerald */
    --fc-emerald-deep: #0D3B2D;
    --fc-emerald: #10503D;
    --fc-emerald-light: #1A6B52;
    --fc-jade: #2D8B6E;

    /* Accent - Sacred Gold */
    --fc-gold: #D4A941;
    --fc-gold-light: #E8D5A3;
    --fc-gold-pale: #F5EED6;
    --fc-brass: #C4A35A;
    --fc-amber: #B8860B;

    /* Status Colors */
    --fc-breaks-red: #DC3545;
    --fc-breaks-red-dark: #A71D2A;
    --fc-breaks-red-bg: rgba(220, 53, 69, 0.15);
    --fc-safe-green: #28A745;
    --fc-safe-green-dark: #1E7B34;
    --fc-safe-green-bg: rgba(40, 167, 69, 0.15);
    --fc-caution-yellow: #FFC107;
    --fc-caution-yellow-dark: #D39E00;
    --fc-caution-yellow-bg: rgba(255, 193, 7, 0.15);

    /* Neutrals */
    --fc-cream: #F5F5F0;
    --fc-pearl: #E8E8E3;
    --fc-mist: #94A3B8;
    --fc-slate: #64748B;
    --fc-charcoal: #334155;

    /* Typography */
    --fc-font-display: 'Cormorant Garamond', Georgia, serif;
    --fc-font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --fc-font-arabic: 'Noto Naskh Arabic', 'Traditional Arabic', serif;

    /* Spacing */
    --fc-space-xs: 0.25rem;
    --fc-space-sm: 0.5rem;
    --fc-space-md: 1rem;
    --fc-space-lg: 1.5rem;
    --fc-space-xl: 2rem;
    --fc-space-2xl: 3rem;

    /* Effects */
    --fc-radius-sm: 8px;
    --fc-radius-md: 12px;
    --fc-radius-lg: 16px;
    --fc-radius-xl: 24px;
    --fc-radius-full: 9999px;
    --fc-shadow-gold: 0 4px 20px rgba(212, 169, 65, 0.3);
    --fc-shadow-emerald: 0 4px 20px rgba(16, 80, 61, 0.4);
    --fc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Base Styles
   ======================================== */
.fasting-checker-page {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--fc-space-md);
    font-family: var(--fc-font-body);
    color: var(--fc-cream);
    background: var(--fc-midnight);
    min-height: 100vh;
}

/* ========================================
   Hero Section - Emerald Night Sky
   ======================================== */
.checker-hero {
    text-align: center;
    padding: var(--fc-space-2xl) var(--fc-space-lg);
    background: linear-gradient(135deg, var(--fc-emerald-deep) 0%, var(--fc-emerald) 50%, var(--fc-twilight) 100%);
    border-radius: var(--fc-radius-lg);
    margin-bottom: var(--fc-space-xl);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(212, 169, 65, 0.2);
    box-shadow: var(--fc-shadow-emerald);
}

.checker-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255, 255, 255, 0.4), transparent);
    background-size: 200px 150px;
    animation: twinkle 4s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes twinkle {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.checker-hero h1 {
    margin: 0 0 var(--fc-space-sm) 0;
    font-family: var(--fc-font-display);
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--fc-gold-light);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.hero-subtitle {
    margin: 0;
    font-size: 1.1rem;
    color: var(--fc-pearl);
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* ========================================
   Search Section
   ======================================== */
.search-section {
    margin-bottom: var(--fc-space-xl);
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--fc-space-lg);
    color: var(--fc-gold);
    pointer-events: none;
    font-size: 1.2rem;
    z-index: 1;
}

#search-input {
    width: 100%;
    padding: var(--fc-space-md) var(--fc-space-2xl);
    font-family: var(--fc-font-body);
    font-size: 1.1rem;
    background: var(--fc-deep-space);
    color: var(--fc-cream);
    border: 2px solid var(--fc-twilight);
    border-radius: var(--fc-radius-full);
    outline: none;
    transition: var(--fc-transition);
}

#search-input:focus {
    border-color: var(--fc-gold);
    box-shadow: 0 0 0 4px rgba(212, 169, 65, 0.2), var(--fc-shadow-gold);
}

#search-input::placeholder {
    color: var(--fc-slate);
}

.clear-btn {
    position: absolute;
    right: var(--fc-space-md);
    background: var(--fc-twilight);
    border: none;
    color: var(--fc-mist);
    cursor: pointer;
    padding: var(--fc-space-sm);
    border-radius: var(--fc-radius-full);
    transition: var(--fc-transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    background: var(--fc-gold);
    color: var(--fc-midnight);
}

.clear-btn.hidden {
    display: none;
}

.search-hint {
    text-align: center;
    color: var(--fc-mist);
    font-size: 0.9rem;
    margin-top: var(--fc-space-md);
}

/* ========================================
   Results Section
   ======================================== */
.results-section {
    margin-bottom: var(--fc-space-xl);
}

.results-section.hidden {
    display: none;
}

.result-card {
    background: var(--fc-deep-space);
    border-radius: var(--fc-radius-lg);
    overflow: hidden;
    border: 1px solid var(--fc-twilight);
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--fc-space-md);
    padding: var(--fc-space-lg);
    font-family: var(--fc-font-display);
    font-weight: 600;
    font-size: 1.3rem;
}

.result-header.breaks {
    background: linear-gradient(135deg, var(--fc-breaks-red) 0%, var(--fc-breaks-red-dark) 100%);
    color: white;
}

.result-header.safe {
    background: linear-gradient(135deg, var(--fc-safe-green) 0%, var(--fc-safe-green-dark) 100%);
    color: white;
}

.result-header.caution {
    background: linear-gradient(135deg, var(--fc-caution-yellow) 0%, var(--fc-caution-yellow-dark) 100%);
    color: var(--fc-midnight);
}

.result-icon {
    font-size: 1.6rem;
}

.result-action {
    padding: var(--fc-space-lg) var(--fc-space-lg) var(--fc-space-sm);
    margin: 0;
    font-family: var(--fc-font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--fc-gold-light);
}

.result-explanation {
    padding: 0 var(--fc-space-lg) var(--fc-space-lg);
    line-height: 1.8;
    color: var(--fc-pearl);
    font-size: 1rem;
}

.result-source {
    padding: var(--fc-space-md) var(--fc-space-lg);
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.9rem;
    color: var(--fc-mist);
    border-top: 1px solid var(--fc-twilight);
}

.result-actions {
    padding: var(--fc-space-md) var(--fc-space-lg);
    border-top: 1px solid var(--fc-twilight);
}

.share-btn {
    background: linear-gradient(135deg, var(--fc-gold) 0%, var(--fc-brass) 100%);
    color: var(--fc-midnight);
    border: none;
    padding: var(--fc-space-sm) var(--fc-space-lg);
    border-radius: var(--fc-radius-sm);
    font-family: var(--fc-font-body);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--fc-transition);
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--fc-shadow-gold);
}

.no-results {
    padding: var(--fc-space-2xl);
    text-align: center;
    color: var(--fc-mist);
    background: var(--fc-deep-space);
    border-radius: var(--fc-radius-lg);
    border: 1px solid var(--fc-twilight);
}

.no-results-tip {
    font-size: 0.9rem;
    color: var(--fc-slate);
    margin-top: var(--fc-space-md);
}

/* ========================================
   Popular Questions
   ======================================== */
.popular-section {
    margin-bottom: var(--fc-space-xl);
}

.popular-section h2 {
    font-family: var(--fc-font-display);
    font-size: 1.4rem;
    color: var(--fc-gold-light);
    margin-bottom: var(--fc-space-md);
}

.popular-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--fc-space-sm);
}

.popular-item {
    display: flex;
    align-items: center;
    gap: var(--fc-space-sm);
    padding: var(--fc-space-sm) var(--fc-space-md);
    background: var(--fc-deep-space);
    border: 2px solid var(--fc-twilight);
    border-radius: var(--fc-radius-full);
    cursor: pointer;
    transition: var(--fc-transition);
    font-size: 0.9rem;
}

.popular-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.popular-item.breaks {
    border-color: var(--fc-breaks-red);
}

.popular-item.breaks:hover {
    background: var(--fc-breaks-red-bg);
}

.popular-item.safe {
    border-color: var(--fc-safe-green);
}

.popular-item.safe:hover {
    background: var(--fc-safe-green-bg);
}

.popular-item.caution {
    border-color: var(--fc-caution-yellow);
}

.popular-item.caution:hover {
    background: var(--fc-caution-yellow-bg);
}

.popular-icon {
    font-size: 1rem;
}

.popular-text {
    color: var(--fc-pearl);
}

/* ========================================
   Categories Section
   ======================================== */
.categories-section {
    margin-bottom: var(--fc-space-xl);
}

.categories-section h2 {
    font-family: var(--fc-font-display);
    font-size: 1.4rem;
    color: var(--fc-gold-light);
    margin-bottom: var(--fc-space-md);
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--fc-space-sm);
    margin-bottom: var(--fc-space-lg);
}

.category-tab {
    padding: var(--fc-space-sm) var(--fc-space-md);
    background: var(--fc-deep-space);
    border: 2px solid var(--fc-twilight);
    border-radius: var(--fc-radius-sm);
    cursor: pointer;
    font-family: var(--fc-font-body);
    font-size: 0.9rem;
    color: var(--fc-pearl);
    transition: var(--fc-transition);
}

.category-tab:hover {
    border-color: var(--fc-gold);
    color: var(--fc-gold-light);
}

.category-tab.active {
    background: linear-gradient(135deg, var(--fc-gold) 0%, var(--fc-brass) 100%);
    color: var(--fc-midnight);
    border-color: var(--fc-gold);
    font-weight: 600;
}

.rulings-list {
    display: flex;
    flex-direction: column;
    gap: var(--fc-space-sm);
}

.ruling-item {
    display: flex;
    align-items: center;
    gap: var(--fc-space-md);
    padding: var(--fc-space-md);
    background: var(--fc-deep-space);
    border: 1px solid var(--fc-twilight);
    border-radius: var(--fc-radius-md);
    cursor: pointer;
    transition: var(--fc-transition);
}

.ruling-item:hover {
    background: var(--fc-night-blue);
    border-color: var(--fc-gold);
    transform: translateX(4px);
}

.ruling-icon {
    font-size: 1.3rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--fc-radius-full);
    flex-shrink: 0;
}

.ruling-icon.breaks {
    background: var(--fc-breaks-red-bg);
}

.ruling-icon.safe {
    background: var(--fc-safe-green-bg);
}

.ruling-icon.caution {
    background: var(--fc-caution-yellow-bg);
}

.ruling-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--fc-space-md);
}

.ruling-action {
    color: var(--fc-pearl);
    font-weight: 500;
}

.ruling-status {
    font-size: 0.75rem;
    font-weight: 700;
    padding: var(--fc-space-xs) var(--fc-space-md);
    border-radius: var(--fc-radius-full);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ruling-status.breaks {
    background: var(--fc-breaks-red);
    color: white;
}

.ruling-status.safe {
    background: var(--fc-safe-green);
    color: white;
}

.ruling-status.caution {
    background: var(--fc-caution-yellow);
    color: var(--fc-midnight);
}

/* ========================================
   Quick Reference Cards
   ======================================== */
.quick-reference {
    margin-bottom: var(--fc-space-xl);
}

.quick-reference h2 {
    font-family: var(--fc-font-display);
    font-size: 1.4rem;
    color: var(--fc-gold-light);
    margin-bottom: var(--fc-space-md);
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--fc-space-md);
}

.reference-card {
    border-radius: var(--fc-radius-md);
    padding: var(--fc-space-lg);
    backdrop-filter: blur(10px);
}

.reference-card h3 {
    margin: 0 0 var(--fc-space-md) 0;
    font-family: var(--fc-font-display);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--fc-space-sm);
}

.reference-card ul {
    margin: 0;
    padding-left: var(--fc-space-lg);
}

.reference-card li {
    margin-bottom: var(--fc-space-sm);
    font-size: 0.95rem;
    color: var(--fc-pearl);
    line-height: 1.5;
}

.reference-card.breaks {
    background: var(--fc-breaks-red-bg);
    border: 2px solid var(--fc-breaks-red);
}

.reference-card.breaks h3 {
    color: var(--fc-breaks-red);
}

.reference-card.breaks h3::before {
    content: "✗";
}

.reference-card.safe {
    background: var(--fc-safe-green-bg);
    border: 2px solid var(--fc-safe-green);
}

.reference-card.safe h3 {
    color: var(--fc-safe-green);
}

.reference-card.safe h3::before {
    content: "✓";
}

.reference-card.caution {
    background: var(--fc-caution-yellow-bg);
    border: 2px solid var(--fc-caution-yellow);
}

.reference-card.caution h3 {
    color: var(--fc-caution-yellow);
}

.reference-card.caution h3::before {
    content: "⚠";
}

/* ========================================
   Educational Content
   ======================================== */
.educational-content {
    margin-bottom: var(--fc-space-xl);
    padding: var(--fc-space-lg);
    background: var(--fc-deep-space);
    border-radius: var(--fc-radius-lg);
    border: 1px solid var(--fc-twilight);
}

.educational-content h2 {
    font-family: var(--fc-font-display);
    font-size: 1.4rem;
    color: var(--fc-gold-light);
    margin-top: var(--fc-space-xl);
    margin-bottom: var(--fc-space-md);
}

.educational-content h2:first-child {
    margin-top: 0;
}

.educational-content h3 {
    font-family: var(--fc-font-display);
    font-size: 1.2rem;
    color: var(--fc-gold);
    margin-top: var(--fc-space-lg);
    margin-bottom: var(--fc-space-sm);
}

.educational-content p {
    color: var(--fc-pearl);
    line-height: 1.7;
    margin-bottom: var(--fc-space-md);
}

.educational-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--fc-space-md) 0;
}

.educational-content th,
.educational-content td {
    padding: var(--fc-space-md);
    border: 1px solid var(--fc-twilight);
    text-align: left;
}

.educational-content th {
    background: var(--fc-night-blue);
    color: var(--fc-gold-light);
    font-family: var(--fc-font-display);
    font-weight: 600;
}

.educational-content td {
    color: var(--fc-pearl);
}

.educational-content tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.1);
}

/* ========================================
   FAQ Section
   ======================================== */
.faq-section {
    margin-bottom: var(--fc-space-xl);
}

.faq-section h2 {
    font-family: var(--fc-font-display);
    font-size: 1.4rem;
    color: var(--fc-gold-light);
    margin-bottom: var(--fc-space-lg);
}

.faq-item {
    background: var(--fc-deep-space);
    border-radius: var(--fc-radius-md);
    padding: var(--fc-space-md) var(--fc-space-lg);
    margin-bottom: var(--fc-space-md);
    border: 1px solid var(--fc-twilight);
    transition: var(--fc-transition);
}

.faq-item:hover {
    border-color: var(--fc-gold);
}

.faq-question {
    margin: 0 0 var(--fc-space-sm) 0;
    font-family: var(--fc-font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--fc-gold);
}

.faq-answer {
    color: var(--fc-pearl);
    margin: 0;
    line-height: 1.7;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .checker-hero {
        padding: var(--fc-space-xl) var(--fc-space-md);
    }

    .checker-hero h1 {
        font-size: 1.6rem;
    }

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

    #search-input {
        font-size: 1rem;
        padding: var(--fc-space-md) var(--fc-space-xl);
    }

    .popular-grid {
        gap: var(--fc-space-xs);
    }

    .popular-item {
        padding: var(--fc-space-xs) var(--fc-space-sm);
        font-size: 0.8rem;
    }

    .category-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: var(--fc-space-sm);
        -webkit-overflow-scrolling: touch;
    }

    .category-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .ruling-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--fc-space-sm);
    }

    .reference-grid {
        grid-template-columns: 1fr;
    }

    .result-action {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .fasting-checker-page {
        padding: var(--fc-space-sm);
    }

    .checker-hero {
        padding: var(--fc-space-lg) var(--fc-space-md);
        border-radius: var(--fc-radius-md);
    }

    .checker-hero h1 {
        font-size: 1.4rem;
    }

    .result-header {
        font-size: 1.1rem;
        padding: var(--fc-space-md);
    }

    .result-explanation {
        padding: 0 var(--fc-space-md) var(--fc-space-md);
    }

    .educational-content {
        padding: var(--fc-space-md);
    }
}

/* ========================================
   RTL Support (Arabic/Urdu)
   ======================================== */
[dir="rtl"] .fasting-checker-page,
.fasting-checker-page:lang(ar),
.fasting-checker-page:lang(ur) {
    direction: rtl;
    font-family: var(--fc-font-arabic), var(--fc-font-body);
}

[dir="rtl"] .search-icon {
    left: auto;
    right: var(--fc-space-lg);
}

[dir="rtl"] .clear-btn {
    right: auto;
    left: var(--fc-space-md);
}

[dir="rtl"] #search-input {
    text-align: right;
    padding-right: var(--fc-space-2xl);
    padding-left: var(--fc-space-2xl);
}

[dir="rtl"] .ruling-item:hover {
    transform: translateX(-4px);
}

[dir="rtl"] .reference-card ul {
    padding-left: 0;
    padding-right: var(--fc-space-lg);
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .fasting-checker-page {
        background: white;
        color: black;
        max-width: 100%;
    }

    .checker-hero {
        background: #f0f0f0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .checker-hero h1 {
        color: var(--fc-emerald-deep);
    }

    .search-section,
    .share-btn,
    .clear-btn {
        display: none;
    }

    .result-card,
    .ruling-item,
    .reference-card,
    .faq-item,
    .educational-content {
        break-inside: avoid;
        border: 1px solid #ccc;
        background: white;
    }

    .result-header.breaks,
    .result-header.safe,
    .result-header.caution {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.popular-item:focus,
.category-tab:focus,
.ruling-item:focus,
.share-btn:focus,
.clear-btn:focus,
#search-input:focus {
    outline: 2px solid var(--fc-gold);
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    .result-card,
    .ruling-item,
    .reference-card,
    .faq-item {
        border-width: 2px;
    }

    .checker-hero {
        border-width: 2px;
    }
}

/* ========================================
   Loading State
   ======================================== */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--fc-space-sm);
    padding: var(--fc-space-xl);
    color: var(--fc-mist);
}

.search-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--fc-twilight);
    border-top-color: var(--fc-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
