@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ============================================================
   Hafez Divination — front-end (modern, RTL)
   ============================================================ */
.hafez-divination-wrapper {
    --hd-wine: #8B0000;
    --hd-wine-2: #a52a2a;
    --hd-gold: #c9a24b;
    --hd-ink: #2b2118;
    --hd-paper: #fbf7ef;
    font-family: Vazirmatn, sans-serif;
    text-align: center;
}

#hafez-divination-button {
    background: linear-gradient(145deg, var(--hd-wine-2), var(--hd-wine));
    border: none;
    color: #fff;
    padding: 14px 38px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 999px;
    font-family: Vazirmatn, sans-serif;
    transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
    box-shadow: 0 8px 22px -6px rgba(139, 0, 0, .5);
    position: relative;
}

#hafez-divination-button::before {
    content: "📜";
    font-size: 19px;
    line-height: 1;
}

#hafez-divination-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px -8px rgba(139, 0, 0, .6);
    filter: brightness(1.05);
}

#hafez-divination-button:active { transform: translateY(-1px); }

/* ---------- Modal overlay ---------- */
#hafez-divination-result {
    display: none;
    position: fixed;
    z-index: 99999;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: rgba(20, 12, 8, .72);
    backdrop-filter: blur(4px);
    direction: rtl;
    font-family: Vazirmatn, sans-serif;
}

#hafez-divination-result .modal-content {
    background:
        radial-gradient(circle at 100% 0, rgba(201, 162, 75, .12), transparent 38%),
        var(--hd-paper);
    margin: 3% auto;
    padding: 30px 28px;
    border: 1px solid rgba(201, 162, 75, .35);
    width: 94%;
    max-width: 920px;
    border-radius: 18px;
    position: relative;
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .6);
    animation: hd-fade .45s cubic-bezier(.2, .8, .2, 1);
}

@keyframes hd-fade {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

#hafez-divination-result .close {
    color: var(--hd-wine);
    background: rgba(139, 0, 0, .08);
    position: absolute;
    left: 16px;
    top: 14px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 26px;
    font-weight: bold;
    line-height: 1;
    transition: background .2s ease, transform .2s ease;
}

#hafez-divination-result .close:hover,
#hafez-divination-result .close:focus {
    color: #fff;
    background: var(--hd-wine);
    transform: rotate(90deg);
    cursor: pointer;
}

.modal-body {
    padding: 12px 14px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#hafez-ghazal-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--hd-wine);
    text-align: center;
    margin-bottom: 22px;
    width: 100%;
    position: relative;
    padding-bottom: 14px;
}

#hafez-ghazal-title::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 50%;
    transform: translateX(50%);
    width: 90px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, transparent, var(--hd-gold), transparent);
}

.hafez-section {
    background: #fff;
    border: 1px solid rgba(201, 162, 75, .25);
    border-radius: 14px;
    padding: 26px;
    margin-bottom: 18px;
    box-shadow: 0 6px 18px -12px rgba(43, 33, 24, .4);
    width: 100%;
}

#hafez-poem {
    font-size: 17px;
    line-height: 2.4;
    white-space: pre-wrap;
    text-align: center;
    color: var(--hd-ink);
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#hafez-audio { text-align: center; }
#hafez-audio audio { width: 100%; max-width: 420px; }

#hafez-interpretation-container h3 {
    font-size: 21px;
    color: var(--hd-wine);
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(201, 162, 75, .25);
    display: flex;
    align-items: center;
    gap: 8px;
}

#hafez-interpretation-container h3::before { content: "✦"; color: var(--hd-gold); }

#hafez-interpretation {
    font-size: 16px;
    line-height: 2;
    color: #3a3128;
    text-align: justify;
}

/* ---------- Loading ---------- */
.hafez-loading { text-align: center; color: #6b5d4a; }
.hafez-loading .spinner {
    border: 4px solid rgba(201, 162, 75, .25);
    border-radius: 50%;
    border-top: 4px solid var(--hd-wine);
    width: 44px;
    height: 44px;
    animation: hd-spin 1s linear infinite;
    margin: 22px auto 0;
}

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

.hafez-error {
    text-align: center;
    padding: 18px 20px;
    color: #842029;
    background: #fbeaea;
    border: 1px solid #f1aeb5;
    border-radius: 12px;
}

.hd-custom-content-area {
    margin-top: 16px;
    padding: 10px;
    text-align: center;
    width: 100%;
}

#hd-custom-content-loading { border-top: 1px solid rgba(201, 162, 75, .2); }
#hd-custom-content-bottom { padding-bottom: 8px; }

.hafez-counter {
    font-family: Vazirmatn, sans-serif;
    display: inline-block;
    background: rgba(139, 0, 0, .07);
    color: var(--hd-wine, #8B0000);
    border: 1px solid rgba(139, 0, 0, .15);
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
}

@media (max-width: 600px) {
    #hafez-divination-result .modal-content { padding: 24px 16px; margin: 6% auto; }
    #hafez-ghazal-title { font-size: 22px; }
    #hafez-poem { font-size: 15.5px; line-height: 2.2; }
    .hafez-section { padding: 18px; }
}
