@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-Medium.woff2") format("woff2");
    font-weight: 500;
    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;
}

:root {
    --bg-main: linear-gradient(45deg, rgba(255, 241, 235, 1) 0%, rgba(172, 224, 249, 1) 100%);
    --glass: rgba(255, 255, 255, 0.24);
    --glass-strong: rgba(255, 255, 255, 0.38);
    --border: rgba(255, 255, 255, 0.45);
    --text-main: #17324a;
    --text-soft: #4b6882;
    --accent: #5a7cff;
    --accent-2: #7b61ff;
    --success: #1f9d74;
    --shadow-lg: 0 25px 80px rgba(34, 73, 112, 0.18);
    --shadow-md: 0 14px 40px rgba(34, 73, 112, 0.12);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --transition: 0.35s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    direction: rtl;
    font-family: "Vazirmatn", sans-serif;
    min-height: 100vh;
    color: var(--text-main);
    background: var(--bg-main);
    overflow-x: hidden;
    position: relative;
}

body.no-scroll {
    overflow: hidden;
}

button,
input,
textarea,
select {
    font-family: inherit;
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.65), transparent 35%),
        linear-gradient(45deg, rgba(255, 241, 235, 1) 0%, rgba(172, 224, 249, 1) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.app-loader.hide {
    opacity: 0;
    visibility: hidden;
}

.loader-core {
    position: relative;
    width: 110px;
    height: 110px;
}

.loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--accent);
    border-bottom-color: var(--accent-2);
    animation: spin 1.5s linear infinite;
    box-shadow: 0 0 30px rgba(90, 124, 255, 0.18);
}

.loader-ring-2 {
    inset: 14px;
    animation-direction: reverse;
    animation-duration: 1.1s;
    border-top-color: rgba(123, 97, 255, 0.9);
    border-bottom-color: rgba(90, 124, 255, 0.8);
}

.loader-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #5c63ff;
    animation: pulse 1.8s ease-in-out infinite;
}

.loader-title {
    font-size: 2rem;
    font-weight: 700;
}

.loader-text {
    color: var(--text-soft);
    font-size: 0.95rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(0.95);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.08);
        opacity: 1;
    }
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(70px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.55;
    animation: floatOrb 10s ease-in-out infinite;
}

.orb-1 {
    width: 280px;
    height: 280px;
    top: -60px;
    right: -60px;
    background: rgba(255, 255, 255, 0.75);
}

.orb-2 {
    width: 340px;
    height: 340px;
    bottom: -100px;
    left: -80px;
    background: rgba(125, 177, 255, 0.45);
    animation-delay: 1.5s;
}

.orb-3 {
    width: 220px;
    height: 220px;
    top: 35%;
    left: 12%;
    background: rgba(255, 255, 255, 0.32);
    animation-delay: 3s;
}

@keyframes floatOrb {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-20px) scale(1.06);
    }
}

.particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.particles span {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.95);
    animation: sparkle 6s linear infinite;
}

.particles span:nth-child(1) {
    top: 12%;
    right: 15%;
    animation-delay: 0.3s;
}

.particles span:nth-child(2) {
    top: 24%;
    right: 72%;
    animation-delay: 1.1s;
}

.particles span:nth-child(3) {
    top: 64%;
    right: 18%;
    animation-delay: 2.1s;
}

.particles span:nth-child(4) {
    top: 44%;
    right: 46%;
    animation-delay: 3.1s;
}

.particles span:nth-child(5) {
    top: 78%;
    right: 75%;
    animation-delay: 4s;
}

.particles span:nth-child(6) {
    top: 58%;
    right: 62%;
    animation-delay: 5s;
}

@keyframes sparkle {

    0%,
    100% {
        transform: scale(0.75);
        opacity: 0.25;
    }

    50% {
        transform: scale(1.45);
        opacity: 1;
    }
}

.app-shell {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 100vh;
    padding: 36px 16px 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.hero-card,
.result-card {
    width: 100%;
    max-width: 940px;
    background: var(--glass);
    border: 1px solid var(--border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
}

.hero-card::before,
.result-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(130deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.04)),
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.38), transparent 42%);
    pointer-events: none;
}

.hero-card {
    padding: 34px 26px;
    text-align: center;
    animation: fadeUp 0.7s ease;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 18px;
    box-shadow: 0 8px 22px rgba(50, 90, 140, 0.08);
}

.hero-title {
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    font-weight: 700;
    margin-bottom: 14px;
    letter-spacing: -0.8px;
}

.hero-text {
    max-width: 700px;
    margin: 0 auto 24px;
    line-height: 2.2;
    color: var(--text-soft);
    font-size: 1rem;
}

.hero-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.btn {
    position: relative;
    overflow: hidden;
    border: none;
    outline: none;
    cursor: pointer;
    min-width: 170px;
    padding: 15px 24px;
    border-radius: 18px;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), opacity var(--transition);
    font-size: 15px;
    font-weight: 700;
}

.btn span {
    position: relative;
    z-index: 2;
}

.btn::after {
    content: "";
    position: absolute;
    top: 0;
    right: -130%;
    width: 45%;
    height: 100%;
    transform: skewX(-22deg);
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transition: right 0.7s ease;
}

.btn:hover::after {
    right: 140%;
}

.btn:hover:not(:disabled) {
    transform: translateY(-3px);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 16px 34px rgba(89, 113, 255, 0.28);
}

.btn-secondary {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none !important;
    box-shadow: none;
}

.result-card {
    padding: 24px;
    perspective: 1600px;
    opacity: 0;
    transform: translateY(30px) scale(0.96);
    transition: opacity 0.55s ease, transform 0.55s ease;
    overflow: visible;
}

.result-card.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: cardOpen 0.7s ease;
}

.hidden {
    display: none;
}

.card-3d {
    position: relative;
    width: 100%;
    min-height: 320px;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-3d.flipped {
    transform: rotateY(180deg);
}

.card-3d.result-mode {
    transform: none !important;
}

.card-face {
    width: 100%;
    border-radius: 24px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.32);
    box-shadow: var(--shadow-md);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-front,
.card-back {
    position: absolute;
    inset: 0;
}

.card-front {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.front-inner {
    padding: 40px 20px;
}

.seal-icon {
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(90, 124, 255, 0.18), rgba(123, 97, 255, 0.2));
    box-shadow: 0 20px 45px rgba(80, 90, 180, 0.16);
    font-size: 34px;
    color: #5667ff;
    animation: glowFloat 2.8s ease-in-out infinite;
}

.front-inner h2 {
    font-size: 1.45rem;
    margin-bottom: 10px;
}

.front-inner p {
    color: var(--text-soft);
    line-height: 2;
}

@keyframes glowFloat {

    0%,
    100% {
        transform: translateY(0);
        box-shadow: 0 20px 45px rgba(80, 90, 180, 0.16);
    }

    50% {
        transform: translateY(-8px);
        box-shadow: 0 28px 55px rgba(80, 90, 180, 0.22);
    }
}

.card-back {
    transform: rotateY(180deg);
    padding: 16px;
}

.card-3d.result-mode .card-front {
    display: none;
}

.card-3d.result-mode .card-back {
    position: relative;
    inset: auto;
    transform: none;
}

.result-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.result-heading {
    display: flex;
    align-items: center;
    gap: 14px;
}

.result-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(90, 124, 255, 0.15), rgba(123, 97, 255, 0.18));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #4e67ff;
    box-shadow: var(--shadow-md);
}

.result-heading h2 {
    font-size: 1.15rem;
    margin-bottom: 4px;
    font-weight: 700;
}

.result-heading p {
    color: var(--text-soft);
    font-size: 14px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mini-btn {
    border: none;
    outline: none;
    cursor: pointer;
    padding: 11px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.48);
    box-shadow: 0 10px 24px rgba(50, 90, 140, 0.08);
    transition: 0.25s ease;
    font-size: 14px;
    font-weight: 700;
}

.mini-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.82);
}

.mini-btn.copied {
    background: rgba(31, 157, 116, 0.18);
    color: #177a5b;
}

.content-box {
    position: relative;
    background: var(--glass-strong);
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: var(--radius-lg);
    padding: 22px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
}

.content-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3), transparent 68%);
    pointer-events: none;
}

.box-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    padding: 8px 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    color: #5f53d8;
    font-size: 13px;
    font-weight: 700;
}

.poem-text {
    white-space: pre-line;
    line-height: 2.5;
    color: #18324d;
    font-size: 1.04rem;
    min-height: 110px;
    word-break: break-word;
}

.interpretation-text {
    white-space: pre-line;
    line-height: 2.2;
    color: #274c67;
    font-size: 1rem;
    min-height: 80px;
    word-break: break-word;
}

.audio-wrap {
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 18px;
    padding: 14px;
}

.audio-wrap audio {
    width: 100%;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardOpen {
    0% {
        opacity: 0;
        transform: translateY(35px) scale(0.88);
    }

    60% {
        opacity: 1;
        transform: translateY(-6px) scale(1.02);
    }

    100% {
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {

    .hero-card,
    .result-card {
        border-radius: 24px;
    }

    .hero-card {
        padding: 26px 16px;
    }

    .result-card {
        padding: 16px;
    }

    .hero-text,
    .poem-text,
    .interpretation-text {
        font-size: 0.96rem;
    }

    .poem-text {
        line-height: 2.35;
    }

    .hero-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .result-top {
        flex-direction: column;
    }

    .top-actions {
        width: 100%;
    }

    .mini-btn {
        width: 100%;
    }

    .result-heading {
        align-items: flex-start;
    }

    .card-back {
        padding: 12px;
    }
}


.music-icon {
    font-size: 15px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#musicBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#musicBtn.playing {
    background: linear-gradient(135deg, rgba(90, 124, 255, 0.16), rgba(123, 97, 255, 0.2));
    color: #3558ff;
    border-color: rgba(90, 124, 255, 0.28);
}

#musicBtn.playing .music-icon {
    animation: musicPulse 1.2s ease-in-out infinite;
}

@keyframes musicPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.18);
        opacity: 0.75;
    }
}

#audioWrap {
    display: none !important;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    padding:
        max(20px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom)) 14px;
}

.hero-card,
.result-card {
    width: 100%;
    max-width: 940px;
}

.hero-title {
    line-height: 1.25;
    word-break: break-word;
}

.hero-text {
    line-height: 2.1;
}

.result-heading {
    min-width: 0;
}

.result-heading-text {
    min-width: 0;
    flex: 1;
}

.result-heading h2,
.result-heading p,
.poem-text,
.interpretation-text,
.loader-title,
.loader-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.top-actions {
    flex-wrap: wrap;
}

.top-actions .mini-btn {
    white-space: nowrap;
}

.btn,
.mini-btn {
    touch-action: manipulation;
}

.poem-text,
.interpretation-text {
    text-align: right;
}

@media (max-width: 768px) {
    .app-shell {
        gap: 18px;
        padding:
            max(18px, env(safe-area-inset-top)) 12px max(24px, env(safe-area-inset-bottom)) 12px;
    }

    .hero-card,
    .result-card {
        border-radius: 22px;
    }

    .hero-card {
        padding: 22px 14px;
    }

    .hero-badge {
        font-size: 12px;
        padding: 8px 12px;
        margin-bottom: 14px;
    }

    .hero-title {
        font-size: clamp(1.95rem, 8vw, 2.7rem);
        margin-bottom: 12px;
    }

    .hero-text {
        font-size: 0.95rem;
        line-height: 2.05;
        margin-bottom: 20px;
    }

    .hero-actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        width: 100%;
        min-width: 100%;
        padding: 14px 16px;
        font-size: 14px;
        border-radius: 16px;
    }

    .result-card {
        padding: 12px;
    }

    .card-back {
        padding: 10px;
    }

    .result-top {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 14px;
    }

    .result-heading {
        gap: 10px;
        align-items: center;
    }

    .result-icon {
        width: 44px;
        height: 44px;
        border-radius: 14px;
        font-size: 19px;
        flex-shrink: 0;
    }

    .result-heading h2 {
        font-size: 1rem;
        margin-bottom: 2px;
    }

    .result-heading p {
        font-size: 13px;
        line-height: 1.8;
    }

    .top-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
    }

    .mini-btn {
        width: 100%;
        min-height: 46px;
        padding: 11px 12px;
        font-size: 13px;
        border-radius: 13px;
    }

    .content-box {
        padding: 16px 14px;
        border-radius: 18px;
        margin-bottom: 12px;
    }

    .box-label {
        font-size: 12px;
        padding: 7px 11px;
        margin-bottom: 12px;
    }

    .poem-text {
        font-size: 0.95rem;
        line-height: 2.25;
        min-height: 80px;
    }

    .interpretation-text {
        font-size: 0.93rem;
        line-height: 2.1;
        min-height: 70px;
    }

    .loader-core {
        width: 92px;
        height: 92px;
    }

    .loader-title {
        font-size: 1.7rem;
    }

    .loader-text {
        font-size: 0.9rem;
        text-align: center;
        padding: 0 20px;
    }

    .orb-1 {
        width: 190px;
        height: 190px;
        top: -40px;
        right: -40px;
    }

    .orb-2 {
        width: 220px;
        height: 220px;
        bottom: -70px;
        left: -50px;
    }

    .orb-3 {
        width: 150px;
        height: 150px;
        top: 42%;
        left: 8%;
    }
}

@media (max-width: 480px) {
    .app-shell {
        padding:
            max(14px, env(safe-area-inset-top)) 10px max(22px, env(safe-area-inset-bottom)) 10px;
    }

    .hero-card {
        padding: 18px 12px;
        border-radius: 20px;
    }

    .result-card {
        padding: 10px;
        border-radius: 20px;
    }

    .hero-title {
        font-size: clamp(1.8rem, 9vw, 2.3rem);
    }

    .hero-text {
        font-size: 0.9rem;
        line-height: 2;
    }

    .btn {
        font-size: 13.5px;
        padding: 13px 14px;
        border-radius: 15px;
    }

    .top-actions {
        grid-template-columns: 1fr;
    }

    .mini-btn {
        min-height: 44px;
        font-size: 13px;
    }

    .result-icon {
        width: 40px;
        height: 40px;
        font-size: 17px;
    }

    .result-heading h2 {
        font-size: 0.96rem;
    }

    .result-heading p {
        font-size: 12.5px;
    }

    .content-box {
        padding: 14px 12px;
    }

    .poem-text {
        font-size: 0.92rem;
        line-height: 2.15;
    }

    .interpretation-text {
        font-size: 0.9rem;
        line-height: 2;
    }

    .seal-icon {
        width: 72px;
        height: 72px;
        font-size: 29px;
        border-radius: 20px;
    }

    .front-inner h2 {
        font-size: 1.1rem;
    }

    .front-inner p {
        font-size: 0.9rem;
        line-height: 1.9;
    }

    .particles span:nth-child(2),
    .particles span:nth-child(4),
    .particles span:nth-child(6) {
        display: none;
    }
}