/* ========================================
   📤 دار سامي — نشر كتاب
   ⚠️ المشترك في base.css
   ======================================== */

.up-hero {
    padding: 2.8rem 0 2.2rem;
    background: linear-gradient(180deg, #fdfbfa 0%, var(--bg-alt) 100%);
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.up-hero h1 {
    font-size: clamp(1.6rem, 4vw, 2.3rem);
    font-weight: 900;
    color: var(--text);
    margin: .4rem 0 .7rem;
}

.up-hero p {
    color: var(--text-light);
    font-size: .98rem;
    max-width: 34rem;
    margin: 0 auto;
}

.up-hero strong { color: var(--primary); font-weight: 800; }

.up-wrap { max-width: 46rem; }


/* ========================================
   🧭 شريط الخطوات
   ======================================== */

.steps-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    list-style: none;
    margin-bottom: 2.5rem;
    position: relative;
}

/* الخطّ الواصل بين النقاط */
.steps-bar::before {
    content: '';
    position: absolute;
    top: 1.35rem;
    inset-inline: 12%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}

.step-dot {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    flex: 1;
    text-align: center;
}

.step-dot .dot {
    width: 2.7rem; height: 2.7rem;
    display: grid; place-items: center;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--border);
    color: var(--text-light);
    font-weight: 800;
    font-size: 1rem;
    transition: var(--transition);
}

.step-dot b {
    font-size: .84rem;
    font-weight: 600;
    color: var(--text-light);
    transition: color .3s;
}

.step-dot.active .dot {
    background: var(--primary-gradient);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 6px 18px var(--primary-glow);
    transform: scale(1.06);
}

.step-dot.active b { color: var(--primary); font-weight: 800; }

/* الخطوة المنجزة تُعلَّم بصح — تُطمئن المؤلف أنه تقدّم */
.step-dot.done .dot {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-size: 0;
}

.step-dot.done .dot::after {
    content: '✓';
    font-size: 1.1rem;
}

.step-dot.done { cursor: pointer; }
.step-dot.done b { color: var(--primary); }


/* ========================================
   📋 الخطوات
   ======================================== */

.step {
    display: none;
    border: none;
    padding: 0;
    animation: stepIn .4s cubic-bezier(.22,.61,.36,1);
}

.step.active { display: block; }

@keyframes stepIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.step-legend {
    display: block;
    width: 100%;
    padding: 0 0 1.4rem;
    margin-bottom: 1.6rem;
    border-bottom: 2px solid var(--border);
}

.step-legend h2 {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: .3rem;
}

.step-legend p { font-size: .87rem; color: var(--text-light); }


/* ---------- الحقول ---------- */

.field { margin-bottom: 1.2rem; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.field label {
    display: block;
    font-weight: 700;
    font-size: .88rem;
    color: var(--text);
    margin-bottom: .45rem;
}

.field label span { color: var(--primary-light); }

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: .8rem 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: .93rem;
    background: #fff;
    color: var(--text);
    transition: var(--transition-sm);
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.field .invalid { border-color: #dc3545; }

.field small {
    display: block;
    margin-top: .35rem;
    font-size: .78rem;
    color: var(--text-light);
}


/* ---------- اختيار الصورة ---------- */

.file-pick {
    position: relative;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .8rem 1rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    color: var(--text-light);
    font-size: .9rem;
    cursor: pointer;
    transition: var(--transition-sm);
}

.file-pick:hover { border-color: var(--primary); color: var(--primary); }
.file-pick i { font-size: 1.3rem; color: var(--primary); }

.file-pick input {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer;
}


/* ---------- منطقة رفع الملف ---------- */

.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: var(--bg-alt);
    transition: var(--transition-sm);
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.over {
    border-color: var(--primary);
    background: rgba(122,12,22,.05);
}

.drop-zone input {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer;
}

.drop-zone i {
    font-size: 2.6rem;
    color: var(--primary);
    display: block;
    margin-bottom: .6rem;
}

.drop-zone b {
    display: block;
    color: var(--text);
    font-size: .98rem;
    margin-bottom: .3rem;
}

.drop-zone small { color: var(--text-light); font-size: .82rem; }

.file-chosen {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1rem 1.2rem;
    background: rgba(122,12,22,.06);
    border: 1px solid rgba(122,12,22,.2);
    border-radius: var(--radius);
}

.file-chosen[hidden] { display: none; }

.file-chosen > i { font-size: 1.8rem; color: var(--primary); }
.file-chosen div { flex: 1; min-width: 0; }
.file-chosen b {
    display: block; font-size: .92rem; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-chosen span { font-size: .8rem; color: var(--text-light); }

.file-drop {
    width: 2rem; height: 2rem;
    display: grid; place-items: center;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-light);
    transition: var(--transition-sm);
}

.file-drop:hover { background: #dc3545; border-color: #dc3545; color: #fff; }


/* ---------- إقرار الحقوق ---------- */

.rights-box {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    padding: 1.2rem;
    background: var(--bg-alt);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition-sm);
    margin-bottom: 1.2rem;
}

.rights-box:hover { border-color: var(--primary); }

.rights-box input {
    width: 1.15rem; height: 1.15rem;
    margin-top: .25rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.rights-box input.invalid { outline: 2px solid #dc3545; outline-offset: 2px; }

.rights-box span {
    font-size: .87rem;
    color: var(--text-light);
    line-height: 1.8;
}

.rights-box b {
    display: block;
    color: var(--text);
    font-weight: 800;
    margin-bottom: .2rem;
}


/* ---------- التنبيه ---------- */

.alert {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .9rem 1.1rem;
    border-radius: 12px;
    font-size: .89rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
}

.alert[hidden] { display: none; }

.alert.err {
    background: rgba(220,53,69,.1);
    border-inline-start: 4px solid #dc3545;
    color: #b02a37;
}

.alert i { font-size: 1.2rem; flex-shrink: 0; }


/* ---------- أزرار التنقّل ---------- */

.step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.btn-next, .btn-submit {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .85rem 1.9rem;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-family: inherit;
    font-size: .93rem;
    font-weight: 800;
    transition: var(--transition);
    box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-next:hover, .btn-submit:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px var(--primary-glow);
    color: #fff;
}

.btn-submit:disabled { opacity: .7; cursor: not-allowed; transform: none; }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .8rem 1.5rem;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 30px;
    color: var(--text-light);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    transition: var(--transition-sm);
}

.btn-back:hover { border-color: var(--primary); color: var(--primary); }


/* ========================================
   ✅ التأكيد
   ======================================== */

.done {
    text-align: center;
    padding: 3rem 1.5rem;
}

.done[hidden] { display: none; }

.done > i {
    font-size: 4rem;
    color: #28a745;
    display: block;
    margin-bottom: 1rem;
}

.done h2 {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: .8rem;
}

.done p {
    color: var(--text-light);
    line-height: 2;
    max-width: 32rem;
    margin: 0 auto 2rem;
    font-size: .95rem;
}

.done b { color: var(--primary); font-weight: 700; }
.done strong { color: var(--text); font-weight: 800; }


/* ========================================
   📱 التجاوب
   ======================================== */

@media (max-width: 640px) {
    .grid-2 { grid-template-columns: 1fr; gap: 0; }
    .steps-bar::before { inset-inline: 18%; }
    .step-dot .dot { width: 2.3rem; height: 2.3rem; font-size: .9rem; }
    .step-dot b { font-size: .76rem; }
    .step-nav { flex-direction: column-reverse; }
    .step-nav button { width: 100%; justify-content: center; }
    .drop-zone { padding: 2rem 1rem; }
}


/* ========================================
   🖼️ غلاف الكتاب
   ======================================== */

.cover-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    background: var(--bg-alt);
    transition: var(--transition-sm);
    cursor: pointer;
}

.cover-zone[hidden] { display: none; }

.cover-zone:hover {
    border-color: var(--primary);
    background: rgba(122,12,22,.05);
}

.cover-zone input {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer;
}

.cover-zone i {
    font-size: 2.3rem;
    color: var(--primary);
    display: block;
    margin-bottom: .5rem;
}

.cover-zone b {
    display: block;
    color: var(--text);
    font-size: .96rem;
    margin-bottom: .25rem;
}

.cover-zone small { color: var(--text-light); font-size: .8rem; }

.cover-zone.invalid { border-color: #dc3545; }


/* ---------- المعاينة ---------- */

.cover-chosen {
    display: flex;
    gap: 1.1rem;
    align-items: center;
    padding: 1.1rem;
    background: rgba(122,12,22,.05);
    border: 1px solid rgba(122,12,22,.2);
    border-radius: var(--radius);
}

.cover-chosen[hidden] { display: none; }

/* نسبة الغلاف الحقيقية — المؤلف يرى ما سيراه القارئ */
.cover-chosen img {
    width: 5.5rem;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    background: var(--bg-alt);
    flex-shrink: 0;
}

.cover-info { flex: 1; min-width: 0; }

.cover-info b {
    display: block;
    font-size: .92rem;
    color: var(--text);
    margin-bottom: .2rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cover-info span {
    display: block;
    font-size: .8rem;
    color: var(--text-light);
    margin-bottom: .7rem;
}

.cover-change {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 25px;
    color: var(--primary);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 700;
    transition: var(--transition-sm);
}

.cover-change:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
/* ========================================
   🔧 منع الخروج عن الشاشة
   ----------------------------------------
   fieldset يفرض min-width = أعرض محتوى فيه،
   فحقلٌ واحد عريض يدفع الصفحة كلّها جانباً.
   و legend عنصر استثنائي في التدفّق، فنحوّله
   إلى كتلة عادية.
   ======================================== */

.up-section,
.up-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.up-wrap { max-width: 46rem; margin-inline: auto; }

/* ⭐ السطر الحاسم — fieldset لا يحترم العرض بدونه */
.step {
    min-width: 0 !important;
    width: 100%;
    max-width: 100%;
    padding-inline: 0;
    border: 0;
    margin: 0;
}

.step-legend {
    display: block;
    float: none;
    width: 100%;
    max-width: 100%;
    padding-inline: 0;
    margin: 0 0 1.6rem;
}

.grid-2 {
    min-width: 0;
    max-width: 100%;
}

.grid-2 > .field,
.field {
    min-width: 0;
    max-width: 100%;
}

.field input,
.field select,
.field textarea {
    max-width: 100%;
    box-sizing: border-box;
}

.steps-bar {
    width: 100%;
    max-width: 100%;
    padding-inline: 0;
}



/* ========================================
   📜 بوّابة شروط النشر
   ======================================== */

.terms-gate {
    background: var(--bg-alt);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}

.btn-terms {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem 1.3rem;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 30px;
    color: var(--primary);
    font-family: inherit;
    font-size: .87rem;
    font-weight: 800;
    transition: var(--transition);
    margin-bottom: 1rem;
}

.btn-terms:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

.agree-box {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
    cursor: pointer;
    margin: 0;
}

.agree-box input {
    width: 1.1rem; height: 1.1rem;
    margin-top: .2rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.agree-box input:disabled { cursor: not-allowed; opacity: .5; }

.agree-box input.invalid { outline: 2px solid #dc3545; outline-offset: 2px; }

.agree-box span {
    font-size: .89rem;
    color: var(--text);
    line-height: 1.7;
}

.agree-box b { color: var(--primary); font-weight: 800; }

.agree-box small {
    display: block;
    font-size: .78rem;
    color: var(--text-light);
    margin-top: .2rem;
}


/* ---------- النافذة ---------- */

.terms-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(6px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
}

.terms-overlay[hidden] { display: none; }

.terms-box {
    position: relative;
    background: #fff;
    border-radius: var(--radius-lg);
    max-width: 38rem;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
    animation: termsIn .35s cubic-bezier(.22,.61,.36,1);
}

@keyframes termsIn {
    from { opacity: 0; transform: translateY(18px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.terms-close {
    position: absolute;
    top: 1rem; left: 1rem;
    width: 2.2rem; height: 2.2rem;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--bg-alt);
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    transition: var(--transition-sm);
    z-index: 2;
}

.terms-close:hover {
    background: var(--primary);
    color: #fff;
    transform: rotate(90deg);
}

.terms-box > h2 {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--text);
    padding: 1.6rem 1.8rem 1.1rem;
    border-bottom: 2px solid var(--border);
}

.terms-box > h2 i { color: var(--primary); }

.terms-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.4rem 1.8rem;
}

.terms-scroll h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary);
    margin: 1.3rem 0 .6rem;
}

.terms-scroll h3:first-child { margin-top: 0; }

.terms-scroll ul {
    display: grid;
    gap: .55rem;
    margin-bottom: .8rem;
    list-style: none;
}

.terms-scroll li {
    position: relative;
    padding-inline-start: 1.1rem;
    font-size: .88rem;
    color: var(--text-light);
    line-height: 1.85;
}

.terms-scroll li::before {
    content: '';
    position: absolute;
    inset-inline-start: 0; top: .72rem;
    width: .38rem; height: .38rem;
    border-radius: 50%;
    background: var(--primary);
}

.terms-more {
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: .85rem;
    color: var(--text-light);
    line-height: 1.8;
}

.terms-more a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.terms-foot {
    padding: 1.1rem 1.8rem 1.5rem;
    border-top: 2px solid var(--border);
    background: var(--bg-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

#scrollHint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-size: .82rem;
    color: var(--text-light);
    margin-bottom: .8rem;
}

#scrollHint[hidden] { display: none; }

#scrollHint i { animation: hintBob 1.8s ease-in-out infinite; }

@keyframes hintBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(4px); }
}

.btn-agree {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .85rem;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-family: inherit;
    font-size: .93rem;
    font-weight: 800;
    transition: var(--transition);
    box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-agree:hover:not(:disabled) { transform: translateY(-3px); }

.btn-agree:disabled {
    background: var(--border);
    color: var(--text-light);
    box-shadow: none;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .terms-box > h2 { padding: 1.3rem 1.2rem 1rem; font-size: 1.1rem; }
    .terms-scroll { padding: 1.1rem 1.2rem; }
    .terms-foot { padding: 1rem 1.2rem 1.3rem; }
}

/* ========================================
   🎯 إصلاح إزاحة الخطوة الثانية
   ----------------------------------------
   grid-template-columns: 1fr 1fr تعني ضمنياً
   minmax(auto, 1fr) — و auto تساوي عرض أطول
   محتوى في العمود. و <select> عرضه الأدنى =
   أطول خيار فيه، وأسماء الأقسام طويلة، فيرفض
   العمود أن يصغر وتتجاوز الشبكة عرض الشاشة.

   minmax(0, 1fr) يرفع هذا القيد.
   ======================================== */

.up-wrap .grid-2,
.pr-card .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* <select> يرث عرضاً أدنى من أطول خياراته */
.field select,
.field input,
.field textarea,
.pr-card select,
.pr-card input,
.pr-card textarea {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* النصّ الطويل داخل القائمة يُقصّ بدل أن يمدّها */
.field select { text-overflow: ellipsis; }

@media (max-width: 640px) {
    .up-wrap .grid-2,
    .pr-card .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* الحقول الاختيارية تُعلَّم صراحةً —
   الصمت يجعل المستخدم يظنّها مطلوبة */
.field label em {
    font-style: normal;
    font-size: .76rem;
    font-weight: 500;
    color: var(--text-light);
}



/* ========================================
   🔢 الخطوة الثالثة — الغلاف والإتاحة
   ----------------------------------------
   مبدأ التصميم هنا: الاختياري يجب أن يبدو
   اختيارياً. كتلٌ هادئة بحدٍّ خفيف وخلفية
   شبه بيضاء، تُضيء عند العمل فيها فقط.
   ======================================== */

/* ---------- الرقم ---------- */

.ord {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: rgba(122,12,22,.08);
    color: var(--primary);
    font-size: .8rem;
    font-weight: 800;
    line-height: 1;
    flex: 0 0 auto;
    margin-inline-end: .65rem;
    vertical-align: -.35rem;
    transition: background .3s ease, color .3s ease;
}

.field label .ord { vertical-align: -.4rem; }


/* ---------- الكتلة الاختيارية ---------- */

.opt-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.4rem;
    margin-bottom: 1.5rem;
    background: #fdfcfc;
    transition: border-color .35s ease, background .35s ease, box-shadow .35s ease;
}

/* تُضيء عند العمل فيها — لا قبل ذلك */
.opt-block:focus-within {
    background: #fff;
    border-color: rgba(122,12,22,.35);
    box-shadow: 0 8px 30px rgba(122,12,22,.07);
}

.opt-block:focus-within .ord {
    background: var(--primary);
    color: #fff;
}

.opt-head {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 1.5rem;
}

.opt-head > div { flex: 1 1 auto; min-width: 0; }

.opt-head b {
    display: block;
    font-size: .97rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: .3rem;
}

.opt-head small {
    display: block;
    font-size: .82rem;
    color: var(--text-light);
    line-height: 1.85;
}

/* شارة رمادية هادئة — لا تنافس العنوان على الانتباه */
.opt-tag {
    flex: 0 0 auto;
    font-style: normal;
    font-size: .71rem;
    font-weight: 700;
    letter-spacing: .01em;
    color: var(--text-light);
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .22rem .75rem;
    margin-inline-start: .8rem;
    margin-top: .1rem;
    white-space: nowrap;
}

.opt-block .field:last-child { margin-bottom: 0; }


/* ---------- حقل بعملة ---------- */

.money { position: relative; }

.money input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: .8rem 1rem;
    padding-inline-end: 3rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: .93rem;
    font-weight: 600;
    background: #fff;
    color: var(--text);
    transition: border-color .25s ease, box-shadow .25s ease;
}

.money input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.money input.invalid { border-color: #dc3545; }

.money .cur {
    position: absolute;
    inset-inline-end: .95rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-light);
    pointer-events: none;
}

/* أسهم الزيادة والنقصان تزاحم العملة ولا تُستعمل */
.money input::-webkit-outer-spin-button,
.money input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.money input[type=number] { -moz-appearance: textfield; appearance: textfield; }


/* ========================================
   🏷️ أسعار النسخ المتعدّدة
   ======================================== */

.tiers {
    margin-top: 1.6rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.tiers[hidden] { display: none; }

/* دخولٌ من الأعلى بانزلاقٍ يتباطأ في نهايته —
   الحقل يستقرّ بدل أن يتوقّف فجأةً */
.tiers:not([hidden]) {
    animation: tiersIn .45s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes tiersIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: none; }
}

.tiers-head {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 1.3rem;
}

.tiers-head > div { flex: 1 1 auto; min-width: 0; }

.tiers-head b {
    display: block;
    font-size: .93rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: .3rem;
}

.tiers-head small {
    display: block;
    font-size: .81rem;
    color: var(--text-light);
    line-height: 1.85;
}

/* auto-fit بدل ثلاثة أعمدة ثابتة — الشبكة تنزل
   إلى عمودين ثم عمود من نفسها، بلا نقطة قطعٍ
   واحدة تكسر كل شيء دونها */
.tier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 1.1rem .9rem;
}

/* ظهورٌ متدرّج: الحقول تتتابع لا تقفز معاً */
.tier {
    min-width: 0;
    animation: tierIn .45s cubic-bezier(.16, 1, .3, 1) both;
}

.tier:nth-child(1) { animation-delay: .06s; }
.tier:nth-child(2) { animation-delay: .12s; }
.tier:nth-child(3) { animation-delay: .18s; }

@keyframes tierIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.tier label {
    display: block;
    font-weight: 700;
    font-size: .85rem;
    color: var(--text);
    margin-bottom: .45rem;
}

/* السطر تحت الحقل يحجز مكانه سلفاً —
   ظهور النصّ لا يجب أن يزحزح ما تحته */
.tier-hint {
    display: block;
    margin-top: .45rem;
    font-size: .77rem;
    line-height: 1.6;
    min-height: 1.25rem;
    color: var(--text-light);
    transition: color .3s ease;
}

.tier-hint.good,
.tier-hint.bad {
    font-weight: 700;
    animation: hintIn .3s ease both;
}

.tier-hint.good { color: #1a7f37; }
.tier-hint.bad  { color: #c02434; }

@keyframes hintIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: none; }
}


/* ========================================
   ℹ️ الملاحظات والملخّص
   ======================================== */

/* ملاحظة تشرح قاعدةً — ليست خطأً،
   فلا تأخذ ألوان الخطأ ولا حدّته */
.field-note {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-top: 1.2rem;
    padding: .85rem 1rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: .81rem;
    line-height: 1.9;
    color: var(--text-light);
}

.field-note[hidden] { display: none; }

.field-note i {
    color: var(--primary);
    opacity: .75;
    font-size: 1.05rem;
    flex-shrink: 0;
    margin-top: .28rem;
}

/* ملخّص حيّ لما سيحدث للكتاب.
   الأخضر تأكيد، والعنبري تنبيهٌ لا خطأ —
   الحالة مسموحة، لكن المؤلف يجب أن يعرفها */
.avail-note {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: 1rem 1.15rem;
    border: 1px solid transparent;
    border-radius: 14px;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.9;
    margin: 1.8rem 0 1.4rem;
    transition: background .35s ease, color .35s ease, border-color .35s ease;
}

.avail-note i {
    font-size: 1.15rem;
    flex-shrink: 0;
    margin-top: .3rem;
    opacity: .85;
}

.avail-note.ok {
    background: rgba(26,127,55,.07);
    border-color: rgba(26,127,55,.22);
    color: #166534;
}

.avail-note.warn {
    background: rgba(180,120,10,.09);
    border-color: rgba(180,120,10,.25);
    color: #8a5a09;
}

/* وميضة واحدة عند تغيّر الحالة — تلفت النظر
   إلى أنّ شيئاً تبدّل دون أن تُزعج */
.avail-note.flash { animation: availFlash .6s ease; }

@keyframes availFlash {
    0%   { transform: none; }
    30%  { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.07); }
    100% { transform: none; box-shadow: none; }
}


/* ========================================
   📱 التجاوب
   ======================================== */

@media (max-width: 640px) {
    .opt-block  { padding: 1.2rem 1rem; }
    .opt-head   { flex-wrap: wrap; }
    .opt-tag    { margin-inline-start: 0; margin-top: .6rem; order: 3; }
    .tier-grid  { gap: .9rem; }
    .avail-note { font-size: .85rem; }
}


/* من يطلب تقليل الحركة يجب أن يجدها ساكنة —
   الاستمارة تعمل تماماً بلا أي حركة */
@media (prefers-reduced-motion: reduce) {
    .tiers:not([hidden]),
    .tier,
    .tier-hint.good,
    .tier-hint.bad,
    .avail-note.flash {
        animation: none;
    }
}


/* ---------- نجمة الحقل المشروط ---------- */

/* بريد المشترين يصير مطلوباً لحظة كتابة سعر —
   النجمة تظهر معه لا عند محاولة الانتقال */
.field label .req {
    color: var(--primary-light);
    font-weight: 800;
}

.field label .req[hidden] { display: none; }

/* ========================================
   🚪 بوّابة الحساب
   ----------------------------------------
   تُسأل مرّة واحدة قبل الخطوات: من نشر معنا له
   حساب، ومن لم ينشر يُنشأ حسابه من الاستمارة.
   ======================================== */

.gate {
    max-width: 34rem;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.4rem 1.9rem 2.1rem;
    box-shadow: 0 14px 40px rgba(122,12,22,.07);
    animation: gateIn .45s cubic-bezier(.16, 1, .3, 1) both;
}

.gate[hidden] { display: none; }

@keyframes gateIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

.gate-ask { text-align: center; }
.gate-ask[hidden] { display: none; }

.gate-ask > i {
    display: inline-grid;
    place-items: center;
    width: 3.4rem; height: 3.4rem;
    border-radius: 50%;
    background: rgba(122,12,22,.08);
    color: var(--primary);
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.gate-ask h2 {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: .5rem;
}

.gate-ask > p {
    font-size: .89rem;
    color: var(--text-light);
    line-height: 1.9;
    max-width: 26rem;
    margin: 0 auto 1.8rem;
}


/* ---------- الخياران ---------- */

.gate-opts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: .9rem;
}

.gate-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: 1.4rem 1rem;
    border: 2px solid var(--primary);
    border-radius: 16px;
    background: var(--primary-gradient);
    color: #fff;
    font-family: inherit;
    text-align: center;
    transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s ease,
                background .25s ease, border-color .25s ease, color .25s ease;
    box-shadow: 0 8px 22px var(--primary-glow);
}

.gate-opt i { font-size: 1.7rem; margin-bottom: .35rem; }
.gate-opt b { font-size: .95rem; font-weight: 800; }

.gate-opt small {
    font-size: .77rem;
    line-height: 1.7;
    opacity: .85;
}

.gate-opt:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px var(--primary-glow);
}

/* الخيار الثاني أهدأ — لكنه ليس أقلّ شأناً، فأغلب
   الزوّار أول مرّة. الفرق في اللون لا في الحجم. */
.gate-opt.ghost {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
}

.gate-opt.ghost i     { color: var(--primary); }
.gate-opt.ghost small { color: var(--text-light); opacity: 1; }

.gate-opt.ghost:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 26px rgba(122,12,22,.1);
}


/* ---------- لوحة الدخول ---------- */

.gate-login[hidden] { display: none; }

.gate-login h2 {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 1.3rem;
}

.gate-login h2 i { color: var(--primary); font-size: 1.35rem; }

.gate-back {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-bottom: 1rem;
    padding: .4rem .9rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: #fff;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-light);
    transition: var(--transition-sm);
}

.gate-back:hover { border-color: var(--primary); color: var(--primary); }


/* ========================================
   ✅ لافتة المؤلف المعروف
   ======================================== */

.known-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .85rem 1.1rem;
    margin-bottom: 1.4rem;
    background: rgba(26,127,55,.07);
    border: 1px solid rgba(26,127,55,.22);
    border-radius: 12px;
    font-size: .86rem;
    line-height: 1.8;
    color: #166534;
}

.known-bar[hidden] { display: none; }

.known-bar > i { font-size: 1.15rem; flex-shrink: 0; }
.known-bar span { flex: 1; min-width: 12rem; }
.known-bar b { font-weight: 800; }

.known-out {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .85rem;
    border: 1px solid rgba(26,127,55,.3);
    border-radius: 20px;
    background: #fff;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    color: #166534;
    transition: var(--transition-sm);
}

.known-out:hover { background: #166534; border-color: #166534; color: #fff; }

/* البريد هوية الحساب — يُقفل ولا يُخفى، فالمؤلف
   يجب أن يراه ويعرف أنّ الطلب مرتبط به */
.field input.locked {
    background: var(--bg-alt);
    color: var(--text-light);
    cursor: not-allowed;
}


/* ========================================
   🔑 كتلة كلمة السرّ
   ======================================== */

.pw-block {
    padding: 1.3rem 1.2rem;
    margin-bottom: 1.4rem;
    background: #fdfcfc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.pw-block[hidden] { display: none; }

.pw-head {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    margin-bottom: 1.1rem;
    padding-bottom: .9rem;
    border-bottom: 1px solid var(--border);
}

.pw-head > i {
    font-size: 1.3rem;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: .1rem;
}

.pw-head b {
    display: block;
    font-size: .93rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: .2rem;
}

.pw-head small {
    display: block;
    font-size: .8rem;
    color: var(--text-light);
    line-height: 1.8;
}

.pw-block .field:last-child { margin-bottom: 0; }

#pw2Note { display: block; margin-top: .35rem; font-size: .78rem; }
#pw2Note.pw-ok  { color: #1a7f37; font-weight: 700; }
#pw2Note.pw-bad { color: #b02a37; font-weight: 700; }


@media (max-width: 640px) {
    .gate { padding: 1.7rem 1.1rem 1.5rem; }
    .gate-opts { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .gate { animation: none; }
    .gate-opt:hover { transform: none; }
}


/* ========================================
   💰 سعرا البيع — ورقية وإلكترونية
   ----------------------------------------
   بطاقتان متجاورتان لا حقلان في صفّ: السعران
   يخصّان شيئين مختلفين تماماً، وعرضهما كحقلين
   عاديين يجعل المؤلف يظنّهما بديلين أحدهما عن
   الآخر — وهما ليسا كذلك.
   ======================================== */

.price-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: .9rem;
    margin-bottom: 1.3rem;
}

.price-card {
    padding: 1.1rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    min-width: 0;
    transition: border-color .28s ease, box-shadow .28s ease;
}

.price-card:focus-within {
    border-color: rgba(122,12,22,.35);
    box-shadow: 0 8px 24px rgba(122,12,22,.07);
}

.pc-head {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-bottom: 1rem;
    padding-bottom: .8rem;
    border-bottom: 1px solid var(--border);
}

.pc-head > i {
    display: grid;
    place-items: center;
    width: 2.1rem; height: 2.1rem;
    flex-shrink: 0;
    border-radius: 9px;
    background: rgba(122,12,22,.07);
    color: var(--primary);
    font-size: 1.15rem;
}

.pc-head > div { flex: 1; min-width: 0; }

.pc-head b {
    display: block;
    font-size: .92rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: .12rem;
}

.pc-head small {
    display: block;
    font-size: .77rem;
    color: var(--text-light);
    line-height: 1.65;
}

.price-card .field { margin-bottom: 0; }

/* الملاحظة تتغيّر حين يصير الملف مدفوعاً —
   تبديلٌ في المعنى يستحقّ تبديلاً في اللون */
#digitalNote.hot {
    color: var(--primary);
    font-weight: 700;
}

#mailField { margin-bottom: 0; }


@media (max-width: 640px) {
    .price-pair { grid-template-columns: minmax(0, 1fr); }
}


/* ========================================
   ▾ كتلة البيع القابلة للطيّ
   ----------------------------------------
   مغلقة افتراضياً. أغلب من ينشر يريد كتاباً
   مجانياً، فعرض أربعة حقول أسعار عليه يجعله
   يظنّ البيع مطلوباً — والحقول المطويّة تقول
   «هذا موجود إن أردته» دون أن تفرضه.
   ======================================== */

.sell-head {
    display: flex;
    align-items: flex-start;
    gap: 0;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    text-align: start;
    cursor: pointer;
}

.sell-head > div { flex: 1 1 auto; min-width: 0; }

.sell-head b {
    display: block;
    font-size: .97rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: .3rem;
}

.sell-head small {
    display: block;
    font-size: .82rem;
    color: var(--text-light);
    line-height: 1.85;
}

/* السهم هو الإشارة الوحيدة إلى وجود محتوى مطويّ،
   فيجب أن يُرى: دائرة باهتة تزيده وضوحاً */
.sell-arrow {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2.1rem; height: 2.1rem;
    margin-inline-start: .7rem;
    border-radius: 50%;
    background: rgba(122,12,22,.08);
    color: var(--primary);
    font-size: 1.35rem;
    transition: transform .35s cubic-bezier(.34, 1.4, .5, 1),
                background .25s ease, color .25s ease;
}

.sell-head:hover .sell-arrow {
    background: var(--primary);
    color: #fff;
}

.sell-block.open .sell-arrow { transform: rotate(180deg); }

.sell-body {
    margin-top: 1.5rem;
    animation: sellIn .38s cubic-bezier(.16, 1, .3, 1) both;
}

.sell-body[hidden] { display: none; }

@keyframes sellIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: none; }
}

/* ملخّص الأسعار حين تُطوى الكتلة — بدونه يظنّ
   المؤلف أنّ ما كتبه ضاع بالطيّ */
.sell-sum {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    margin-top: .8rem;
    padding: .5rem .85rem;
    background: rgba(22,140,73,.08);
    border: 1px solid rgba(22,140,73,.22);
    border-radius: 20px;
    font-size: .79rem;
    font-weight: 700;
    color: #166534;
}

.sell-sum[hidden] { display: none; }
.sell-sum i { font-size: .95rem; }


/* ========================================
   📜 أيقونة شروط النشر
   ----------------------------------------
   حركة مركّبة لا تكبيراً وحده: الأيقونة تنبض
   وتميل قليلاً، والزرّ حوله حلقة تتّسع وتتلاشى.

   السبب: تكبيرٌ من ١ إلى ١٫٣٥ على أيقونة صغيرة
   لا يكاد يُرى في الزاوية. الحركة تحتاج أن تتغيّر
   في اتّجاهين لتلفت النظر فعلاً.
   ======================================== */

.btn-terms {
    position: relative;
    overflow: visible;
}

/* الحلقة — تنبع من الزرّ وتتلاشى */
.btn-terms::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 30px;
    border: 2px solid var(--primary);
    opacity: 0;
    pointer-events: none;
    animation: termsRing 2.4s ease-out infinite;
}

@keyframes termsRing {
    0%   { transform: scale(1);    opacity: .55; }
    60%  { transform: scale(1.14); opacity: 0;   }
    100% { transform: scale(1.14); opacity: 0;   }
}

.btn-terms i {
    display: inline-block;
    transform-origin: center;
    animation: termsPulse 1.6s cubic-bezier(.34, 1.4, .5, 1) infinite;
}

@keyframes termsPulse {
    0%   { transform: scale(1)    rotate(0deg);  }
    20%  { transform: scale(1.55) rotate(-9deg); }
    40%  { transform: scale(.92)  rotate(6deg);  }
    60%  { transform: scale(1.28) rotate(-4deg); }
    80%  { transform: scale(1)    rotate(0deg);  }
    100% { transform: scale(1)    rotate(0deg);  }
}

/* تتوقّف بمجرّد القراءة — نبضٌ بلا سبب إزعاج */
.btn-terms:hover i,
.btn-terms.read i {
    animation: none;
    transform: none;
}

.btn-terms:hover::after,
.btn-terms.read::after { animation: none; opacity: 0; }

.btn-terms.read {
    border-color: #1a7f37;
    color: #166534;
}

.btn-terms.read:hover { background: #166534; border-color: #166534; color: #fff; }


@media (prefers-reduced-motion: reduce) {
    .btn-terms i,
    .btn-terms::after { animation: none; }
    .sell-body { animation: none; }
    .sell-arrow { transition: none; }
}