/* style.css — بوابة توظيف وكالة الاستخبارات المركزية */

@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Black.woff2") format("woff2");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #0a0c0b;
    --surface: #111514;
    --surface-2: #171d1b;
    --line: #26302c;
    --line-strong: #35443e;
    --accent: #45d69a;
    --accent-ink: #06231a;
    --accent-dim: rgba(69, 214, 154, 0.14);
    --text: #e9edeb;
    --muted: #9aa8a2;
    --faint: #6b7772;
    --danger: #ef6a62;
    --danger-dim: rgba(239, 106, 98, 0.12);
    --mono: "Cascadia Mono", ui-monospace, "Courier New", monospace;
    --r: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Thmanyah Sans", "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.7;
}

button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* ── الهيكل العام ─────────────────────────────── */

.app {
    width: min(1200px, 100vw - 32px);
    margin: 0 auto;
    padding: 24px 0 40px;
}

.layout {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-top: 20px;
}

/* ── الشريط العلوي ────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.topbar-id {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.topbar-seal {
    width: 54px;
    height: 54px;
    object-fit: contain;
    flex: 0 0 auto;
}

.topbar-titles h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
    line-height: 1.3;
}

.topbar-titles p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex: 0 0 auto;
}

.meta-pill {
    padding: 3px 12px;
    border-radius: 4px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

.meta-code {
    direction: ltr;
    color: var(--faint);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 2px;
}

/* ── الشريط الجانبي ───────────────────────────── */

.rail {
    display: grid;
    gap: 14px;
    position: sticky;
    top: calc(var(--topbar-h, 88px) + 14px);
}

.stepper {
    display: grid;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
    cursor: pointer;
    color: var(--muted);
}

.step:last-child { border-bottom: 0; }

.step-no {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border-radius: 4px;
    border: 1px solid var(--line-strong);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
}

.step-copy { display: grid; min-width: 0; }
.step-copy strong { font-size: 14px; color: inherit; }
.step-copy small { color: var(--faint); font-size: 12px; }

.step.is-current {
    color: var(--text);
    background: var(--surface-2);
    box-shadow: inset 3px 0 0 var(--accent);
}

.step.is-current .step-no {
    border-color: var(--accent);
    color: var(--accent);
}

.step.is-done { color: var(--text); }

.step.is-done .step-no {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.rail-block {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
}

.rail-heading {
    margin: 0 0 8px;
    color: var(--faint);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.req-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 7px;
    font-size: 13px;
    color: var(--muted);
}

.req-list li {
    position: relative;
    padding-right: 18px;
    line-height: 1.55;
}

.req-list li::before {
    content: "✓";
    position: absolute;
    right: 0;
    color: var(--accent);
    font-weight: 900;
}

.rail-file strong {
    display: block;
    font-size: 18px;
    font-weight: 900;
}

.rail-file small {
    color: var(--faint);
    font-size: 12px;
}

/* ── اللوحات ─────────────────────────────────── */

.panel {
    display: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 20px;
}

.panel.is-open { display: block; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px dashed var(--line-strong);
}

.panel-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
}

.panel-tag {
    padding: 3px 10px;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.panel-note {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 14px;
}

.panel-foot {
    display: flex;
    justify-content: flex-start;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed var(--line-strong);
}

.panel-foot.split { justify-content: space-between; }
.panel-foot.center { justify-content: center; }

/* ── الحقول ──────────────────────────────────── */

.fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field { display: grid; gap: 5px; min-width: 0; }
.field-full { grid-column: 1 / -1; }

.field label {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

.field input,
.field select,
.output {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    outline: none;
    transition: border-color 120ms ease;
}

.field input:focus,
.field select:focus,
.output:focus {
    border-color: var(--accent);
}

.field input[readonly] {
    color: var(--accent);
    background: var(--surface-2);
}

.field small {
    color: var(--faint);
    font-size: 12px;
}

/* ── الاختبار ────────────────────────────────── */

.quiz-meter {
    position: sticky;
    top: calc(var(--topbar-h, 88px) + 10px);
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 8px 0 10px;
    margin-bottom: 16px;
    background: var(--surface);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

.meter-cell {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.meter-cell strong {
    font-size: 20px;
    font-weight: 900;
    color: var(--accent);
    direction: ltr;
}

.meter-cell span { font-size: 12px; color: var(--faint); }

.quiz { display: grid; gap: 12px; }

.q {
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.q-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 11px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

.q-num {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    flex: 0 0 auto;
}

.q-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.q-opts { display: grid; }

.q-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    color: var(--muted);
    font-size: 14px;
    transition: background 100ms ease, color 100ms ease;
}

.q-opt:last-child { border-bottom: 0; }
.q-opt:hover { background: var(--surface-2); }

.q-opt input {
    appearance: none;
    width: 15px;
    height: 15px;
    margin: 0;
    flex: 0 0 auto;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    cursor: pointer;
}

.q-opt input:checked {
    border-color: var(--accent);
    background: radial-gradient(var(--accent) 45%, transparent 52%);
}

.q-opt:has(input:checked) {
    color: var(--text);
    background: var(--accent-dim);
}

/* ── رفع الصور ───────────────────────────────── */

.dropzone {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 260px;
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    background: var(--bg);
    cursor: pointer;
    overflow: hidden;
    transition: border-color 120ms ease;
}

.dropzone:hover { border-color: var(--accent); }

.dropzone.locked {
    cursor: not-allowed;
    opacity: 0.55;
}

.dropzone.locked:hover { border-color: var(--line-strong); }

.dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: inherit;
}

.dropzone-hint {
    color: var(--faint);
    font-size: 14px;
    padding: 12px;
    text-align: center;
}

.dropzone-preview {
    width: 100%;
    height: 100%;
    max-height: 380px;
    object-fit: contain;
}

/* ── خطوة الرولات والمخرجات ──────────────────── */

.duo,
.outputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.duo-cell,
.output-block {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.cell-full { grid-column: 1 / -1; }

.cell-title { margin: 0; font-size: 16px; font-weight: 900; }
.cell-note { margin: 0; color: var(--faint); font-size: 13px; }

.output {
    min-height: 150px;
    resize: vertical;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
}

.output-tall { min-height: 260px; }

.card-frame {
    display: grid;
    place-items: center;
    min-height: 220px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    overflow: hidden;
}

.card-loading { color: var(--faint); font-size: 14px; }

.card-image { width: 100%; height: auto; display: block; }

/* ── الأزرار ─────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: filter 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btn-solid {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn-solid:hover { filter: brightness(1.1); }

.btn-ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; margin-top: 8px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { flex: 1 1 160px; }

/* ── الأخطاء والتنبيهات ──────────────────────── */

.errors {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--danger-dim);
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: var(--danger);
    font-size: 13px;
    line-height: 1.9;
}

.fallback {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
}

/* ── التذييل ─────────────────────────────────── */

.footer {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--faint);
    font-size: 13px;
}

.footer-note {
    margin: 0 0 6px;
}

.footer .credit {
    color: var(--muted);
    font-weight: 700;
}

.footer .credit b {
    color: var(--accent);
    font-weight: 700;
}

/* ── النافذة المنبثقة ────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(4, 6, 5, 0.8);
}

.modal-box {
    display: grid;
    justify-items: center;
    gap: 10px;
    width: min(420px, 100%);
    padding: 28px 24px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    text-align: center;
}

.modal-glyph { font-size: 34px; }
.modal-box h2 { margin: 0; font-size: 20px; font-weight: 900; }
.modal-box p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }

body.modal-open { overflow: hidden; }

/* ── التوست ──────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 22px;
    right: 50%;
    transform: translate(50%, 16px);
    z-index: 70;
    padding: 10px 18px;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
    opacity: 1;
    transform: translate(50%, 0);
}

/* ── التجاوب ─────────────────────────────────── */

@media (max-width: 920px) {
    .layout { grid-template-columns: 1fr; }
    .rail { position: static; }
    .stepper {
        grid-template-columns: repeat(4, 1fr);
    }
    .step {
        flex-direction: column;
        gap: 6px;
        padding: 10px 4px;
        border-bottom: 0;
        border-left: 1px solid var(--line);
        text-align: center;
    }
    .step:last-child { border-left: 0; }
    .step-copy small { display: none; }
    .step.is-current { box-shadow: inset 0 -3px 0 var(--accent); }
    .duo, .outputs, .fields { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    /* الشريط العلوي يصبح أطول هنا، فنوقف تثبيته حفاظًا على مساحة الشاشة */
    .topbar {
        position: static;
        flex-direction: column;
        align-items: flex-start;
        box-shadow: none;
    }
    .topbar-meta { flex-direction: row; align-items: center; }
    .quiz-meter {
        top: 8px;
        gap: 6px;
    }
    .meter-cell { padding: 6px 4px; }
    .meter-cell strong { font-size: 15px; }
    .meter-cell span { font-size: 10px; }
    .step-copy strong { font-size: 12px; }
}

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