﻿:root {
    --paper-width: 900px;
    --bg-page: #1a1a1a; /* تم تاریک: تیره‌تر */
    --spot-dim: 0.8; /* شدت نورافکن: پیش‌فرض زیاد (مقدار فعلی شما) */
}

@font-face {
    font-family: iranyekan;
    src: url('/SiteTemplate/pagecssjs/Home/TypewritingMachine/fonts/iranyekanwebregular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: typefont;
    src: url('/SiteTemplate/pagecssjs/Home/TypewritingMachine/fonts/Far_MashinTahrir/Far_MashinTahrir.woff2') format('woff2'), url('/SiteTemplate/pagecssjs/Home/TypewritingMachine/fonts/Far_MashinTahrir/Far_MashinTahrir.eot') format('eot'), url('/SiteTemplate/pagecssjs/Home/TypewritingMachine/fonts/Far_MashinTahrir/Far_MashinTahrir.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--bg-page);
    overflow: hidden;
    font-family: 'typefont', monospace;
}

body {
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.4s ease;
    font-family: 'typefont';
    /* background: url('/SiteTemplate/pagecssjs/Home/TypewritingMachine/backgrounds/bg1.jpg'); */
    background-repeat: no-repeat;
    background-size: 100%;
}

#loader {
    font-family: 'typefont' !important;
    font-size: 35px;
}

h3, .option-btn, .input-field, .menu-panel *, .about-text, #loaderText {
    font-family: 'iranyekan' !important;
}

.hr {
    border: 0.5px solid #272727;
}

a {
    color: burlywood;
    text-decoration: none;
}

.about-footer {
    text-align: center;
}
/* ==========================================
                   🌟 منوی شناور (Flowing Menu)
                   ========================================== */
.menu-fab {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 200;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 1.35rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    transition: transform 0.35s ease, background 0.2s ease;
    touch-action: manipulation;
}

    .menu-fab:hover {
        background: rgba(255, 255, 255, 0.28);
    }

    .menu-fab.open {
        transform: rotate(90deg);
    }

.menu-panel {
    position: fixed;
    top: 78px;
    left: 18px;
    z-index: 190;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: rgba(20, 20, 20, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-14px) scale(0.96);
    transform-origin: top left;
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
    user-select: none;
    -webkit-user-select: none;
}

    .menu-panel.open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
    }

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-family: Tahoma, sans-serif;
    font-size: 0.8rem;
    text-align: right;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-12px);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s ease;
    touch-action: manipulation;
}

    .menu-item:hover {
        background: rgba(255, 255, 255, 0.15);
    }

.menu-icon {
    display: inline-block;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* جریان باز شدن آیتم‌ها (Stagger) */
.menu-panel.open .menu-item {
    opacity: 1;
    transform: translateX(0);
}

    .menu-panel.open .menu-item:nth-child(1) {
        transition-delay: 0.03s;
    }

    .menu-panel.open .menu-item:nth-child(2) {
        transition-delay: 0.07s;
    }

    .menu-panel.open .menu-item:nth-child(3) {
        transition-delay: 0.11s;
    }

    .menu-panel.open .menu-item:nth-child(4) {
        transition-delay: 0.15s;
    }

    .menu-panel.open .menu-item:nth-child(5) {
        transition-delay: 0.19s;
    }

    .menu-panel.open .menu-item:nth-child(6) {
        transition-delay: 0.23s;
    }

    .menu-panel.open .menu-item:nth-child(7) {
        transition-delay: 0.27s;
    }

    .menu-panel.open .menu-item:nth-child(8) {
        transition-delay: 0.31s;
    }

    .menu-panel.open .menu-item:nth-child(9) {
        transition-delay: 0.35s;
    }

    .menu-panel.open .menu-item:nth-child(10) {
        transition-delay: 0.39s;
    }

    .menu-panel.open .menu-item:nth-child(11) {
        transition-delay: 0.43s;
    }

    .menu-panel.open .menu-item:nth-child(12) {
        transition-delay: 0.47s;
    }

    .menu-panel.open .menu-item:nth-child(13) {
        transition-delay: 0.51s;
    }

/* ==========================================
                   🌟 مودال‌ها (Dialogs)
                   ========================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

    .modal.active {
        display: flex;
        opacity: 1;
    }

.modal-content {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 25px 30px;
    border-radius: 15px;
    color: white;
    position: relative;
    min-width: 320px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    max-height: 85vh;
    overflow-y: auto;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    font-size: 1.5rem;
    color: #aaa;
    transition: color 0.2s;
    touch-action: manipulation;
}

    .close-btn:hover {
        color: white;
    }

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-family: Tahoma, sans-serif;
    font-size: 1.2rem;
    color: #ddd;
}

/* گزینه‌های رنگ */
.color-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    touch-action: manipulation;
}

    .color-swatch:hover {
        transform: scale(1.15);
        border-color: white;
    }

/* گزینه‌های فونت، سایز، صدا، پس‌زمینه */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
    font-family: Tahoma, sans-serif;
    font-size: 0.95rem;
    touch-action: manipulation;
}

    .option-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

/* متن درباره ما */
.about-text {
    text-align: right;
    direction: rtl;
    font-family: Tahoma, sans-serif;
    font-size: 0.92rem;
    line-height: 2;
    color: #ddd;
}

    .about-text ul {
        margin: 10px 0;
        padding-right: 20px;
    }

/* انتخاب قالب کاغذ */
.paper-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.paper-thumb {
    display: inline-block;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background-color: #fdfaf4;
    background-size: cover;
    background-repeat: repeat;
    flex-shrink: 0;
}

/* 🎬 دستورهای فیلمنامه‌نویسی */
.modal-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: right;
}

.input-field {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-family: Tahoma, sans-serif;
    font-size: 0.95rem;
    box-sizing: border-box;
    text-align: right;
    direction: rtl;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

    .input-field::placeholder {
        color: rgba(255,255,255,0.45);
    }

    .input-field:focus {
        border-color: rgba(255, 255, 255, 0.6);
        background: rgba(255, 255, 255, 0.14);
    }

textarea.input-field {
    resize: vertical;
    min-height: 90px;
    line-height: 1.8;
}
/* خطوط درج‌شده در کاغذ */
.dlg-name {
    margin-right: 300px;
}

.dlg-feel {
    margin-right: 320px;
}

.dlg-line {
    margin-right: 320px;
}

/* ==========================================
                   🌟 صفحه لودینگ
                   ========================================== */
#loader {
    position: fixed;
    inset: 0;
    background: var(--bg-page);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-family: 'Special Elite', Tahoma, sans-serif;
    transition: opacity 1s ease, visibility 1s ease;
}

    #loader.hidden {
        opacity: 0;
        visibility: hidden;
    }

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================
                   1. لایه تاریکی و هاله نور (اسپات‌لایت)
                   گرادیان از روشن (خط تایپ) به تاریک (به سمت بالا)
                   ========================================== */
.spotlight-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
    background: rgba(0, 0, 0, var(--spot-dim)); /*رنگ کاغذ*/
    -webkit-mask-image: radial-gradient( ellipse 240px 280px at var(--x, 50%) calc(var(--y, 50%) + 70px), transparent 0%, rgba(0,0,0,0.2) 30%, rgba(0,0,0,0.6) 60%, rgba(0,0,0,0.95) 100% );
    mask-image: radial-gradient( ellipse 240px 280px at var(--x, 50%) calc(var(--y, 50%) + 70px), transparent 0%, rgba(0,0,0,0.2) 30%, rgba(0,0,0,0.6) 60%, rgba(0,0,0,0.95) 100% );
}

/* 2. ظرف کاغذ */
.paper-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: var(--paper-width);
    height: 100vh;
    height: 100dvh;
    z-index: 10;
    overflow-y: scroll;
    scrollbar-width: none;
    /* -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
                    mask-image: linear-gradient(to bottom, black 80%, transparent 100%); */
    border-radius: 80px 80px 0 0;
    -webkit-box-shadow: 4px 12px 34px 21px rgba(0,0,0,0.58);
    box-shadow: 4px 12px 34px 21px rgba(0,0,0,0.58);
}

    .paper-container::-webkit-scrollbar {
        display: none;
    }

/* 3. کاغذ */
.paper {
    background-color: #fdfaf4;
    background-image: url('https://www.transparenttextures.com/patterns/cream-paper.png');
    width: 100%;
    min-height: 200vh;
    position: relative;
    padding: 100vh 40px 100px 40px;
    box-sizing: border-box;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.1);
}

/* ناحیه تایپ */
.typing-area {
    outline: none;
    font-size: 1.5rem;
    color: #222;
    line-height: 1.5;
    text-shadow: 0.5px 0.5px 0px rgba(0,0,0,0.2);
    caret-color: transparent;
    word-wrap: break-word;
    text-align: start;
    min-height: 20px;
    font-family: 'Special Elite', Tahoma, sans-serif;
    transition: color 0.3s, font-family 0.3s, font-size 0.3s;
}

/* 4. تصویر ماشین تحریر */
.typewriter-image {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 45vh;
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    z-index: 15;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 25%), radial-gradient(ellipse 120px 60px at 50% 100%, transparent 40%, black 80%);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to bottom, transparent 0%, black 25%), radial-gradient(ellipse 120px 60px at 50% 100%, transparent 40%, black 80%);
    mask-composite: intersect;
}

/* ==========================================
                   5.  — تصاویر واقعی (carridge.png + قطعات کناری + عقربه)
                   ========================================== */
.typewriter-carriage {
    --needle-width: clamp(48px, 10vw, 80px); /* عرض عقربه — کاملاً ریسپانسیو */
    --needle-bottom: 140px; /* فاصله عقربه از پایین (تنظیم خودت حفظ شد) */
    --side-height: 300px; /* ارتفاع قطعات کناری (پیش‌فرض؛ JS آن را دقیق تنظیم می‌کند) */
    --side-bottom: 0px; /* فاصله قطعات کناری از پایین */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 25;
    pointer-events: none;
}

/* پس‌زمینه  (عکس) */
.carriage-bg {
    display: block;
    width: var(--paper-width); /* همیشه داخل کاغذ */
    margin: 0 auto;
    height: auto; /* ارتفاع از نسبت طبیعی عکس به عرض کاغذ — در همه سایزها */
    object-fit: contain;
    object-position: center bottom;
}

/* قطعات کناری — چسبیده به لبه‌های کاغذ */
.carriage-side {
    position: absolute;
    bottom: var(--side-bottom);
    pointer-events: none;
    height: 400px;
}

    .carriage-side img {
        display: block;
        /* height: var(--side-height); */
        height: 100%;
        width: auto;
    }

    .carriage-side.left {
        left: calc(50% - (var(--paper-width) / 2));
        transform: translateX(-100%); /* بیرون کاغذ، چسبیده به لبه چپ */
    }

    .carriage-side.right {
        left: calc(50% + (var(--paper-width) / 2));
        transform: none; /* بیرون کاغذ، چسبیده به لبه راست */
    }

@media (max-width:900px) {
    .carriage-side.left {
        display: none;
    }

    .carriage-side.right {
        display: none;
    }
}

@media (max-width:500px) {
    .paper-container {
        border-radius: 30px 30px 0 0;
    }
}

/* عقربه (Index Pointer) — عکس واقعی */
.index-pointer {
    position: absolute;
    bottom: var(--needle-bottom);
    width: var(--needle-width);
    transform: translateX(-50%);
    transform-origin: bottom center;
    transition: transform 0.05s ease-out;
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.35));
}


    .index-pointer img {
        display: block;
        width: 100%;
        height: auto;
    }

    .index-pointer.hitting {
        transform: translateX(-50%) translateY(-6px) scaleY(0.9);
    }

    /* اسلاید برگشت (Enter) */
    .index-pointer.sliding {
        transition: left 0.45s cubic-bezier(0.25, 0.8, 0.3, 1), transform 0.05s ease-out;
    }

/* 🎹 کلیدهای — همیشه دیده می‌شوند؛ هنگام فشردن پایین می‌روند */
.key-cap {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
    transition: transform 0.07s ease, filter 0.07s ease;
    will-change: transform;
}

    .key-cap.pressed {
        transform: translateY(6px) scale(0.95);
        filter: brightness(0.6);
    }

/* ==========================================
                   🌟 قدیمی (Old Fashtion)
                   ========================================== */
body.theme-old {
    --bg-page: #442c05;
}
    /* تم روشن: کرم گرم — واضحاً تیره‌تر از سفید */
    body.theme-old #loader {
        background: #ffffff;
        color: #333;
    }

        body.theme-old #loader .spinner {
            border-color: rgba(0,0,0,0.15);
            border-top-color: #333;
        }

    body.theme-old .menu-fab {
        background: rgba(0, 0, 0, 0.5);
        border-color: rgba(255, 255, 255, 0.4);
    }

/* ==========================================
                   🌟 تم روشن (Light Theme)
                   ========================================== */
body.theme-light {
    --bg-page: #e9e2d3;
}
    /* تم روشن: کرم گرم — واضحاً تیره‌تر از سفید */
    body.theme-light #loader {
        background: var(--bg-page);
        color: #333;
    }

        body.theme-light #loader .spinner {
            border-color: rgba(0,0,0,0.15);
            border-top-color: #333;
        }

    body.theme-light .menu-fab {
        background: rgba(0, 0, 0, 0.5);
        border-color: rgba(255, 255, 255, 0.4);
    }

/* 🌟 تم سفید (White Theme) */
body.theme-white {
    --bg-page: #ffffff;
}

    body.theme-white #loader {
        background: var(--bg-page);
        color: #333;
    }

        body.theme-white #loader .spinner {
            border-color: rgba(0,0,0,0.15);
            border-top-color: #333;
        }

    body.theme-white .menu-fab {
        background: rgba(0, 0, 0, 0.5);
        border-color: rgba(255, 255, 255, 0.4);
    }

/* 🔦 شدت نورافکن (سه حالت) */
body.spot-low {
    --spot-dim: 0.35;
}

body.spot-mid {
    --spot-dim: 0.58;
}

body.spot-high {
    --spot-dim: 0.8;
}

/* ==========================================
                   🌟 ریسپانسیو (موبایل)
                   ========================================== */
@media (max-width: 768px) {
    :root {
        --paper-width: 100%;
    }

    .paper {
        padding: 100vh 40px 120px 40px;
    }

    .typing-area {
        font-size: 1.3rem;
        line-height: 1.1;
    }

    .menu-fab {
        top: 12px;
        left: 12px;
        width: 46px;
        height: 46px;
        font-size: 1.3rem;
    }

    .menu-panel {
        top: 66px;
        left: 12px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-content {
        min-width: 0;
        width: 88vw;
        padding: 22px 16px;
    }

    .color-options {
        gap: 10px;
    }

    .color-swatch {
        width: 34px;
        height: 34px;
    }

    .typewriter-image {
        height: 38vh;
    }

    .typewriter-carriage {
        --side-height: 130px;
    }

    .carriage-side.left {
        left: 0;
        transform: none;
    }

    .carriage-side.right {
        left: 100%;
        transform: translateX(-100%);
    }
    /* در موبایل تورفتگی دیالوگ‌ها کوچک‌تر شود تا متن جا شود */
    .dlg-name {
        margin-right: 30px;
    }

    .dlg-feel {
        margin-right: 40px;
    }

    .dlg-line {
        margin-right: 40px;
    }
}
/* --------------------------------------------------- */
/* --------------------------------------------------- */
/* --------------------------------------------------- */
/* --------------------------------------------------- */
/* ---------- Overlay ---------- */
.loader-dialog {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    /* hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

    /* visible state — pointer-events:auto also blocks every click behind it */
    .loader-dialog.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: opacity 0.35s ease, visibility 0s;
    }

/* ---------- Card ---------- */
.loader-card {
    width: min(360px, 100%);
    padding: 26px 24px;
    border-radius: 14px;
    background: #1b222e;
    border: 1px solid #2b3546;
    color: #e8edf5;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(10px) scale(0.98);
    transition: transform 0.35s ease;
}

.loader-dialog.show .loader-card {
    transform: translateY(0) scale(1);
}

.loader-card p {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* ---------- Spinner ---------- */
.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2s;
    }

    .loader-dialog,
    .loader-card {
        transition-duration: 0.01s;
    }
}