/*
 * Tamland Psychology — frontend exam SPA (RTL, Persian).
 * Scoped under #psych-app to avoid clashing with the active theme.
 * Clean, distraction-free exam experience: cards, large click targets,
 * smooth transitions.
 *
 * TYPOGRAPHY — 'Yekan Bakh FaNum' EVERYWHERE (2026-10 final, verified):
 * the site's theme font is registered as 'Yekan Bakh FaNum' (note the
 * spaces and casing — this EXACT literal was verified working in the
 * field). Every rule below pins it verbatim with !important; the SPA
 * additionally stamps it INLINE on every rendered element
 * (enforceInlineFonts) and injects a backup <style> rule, so no theme /
 * optimizer / stale-CSS cascade can override it. The report iframe gets
 * the theme's @font-face rules copied in as well (a sandboxed srcdoc
 * document knows none of the parent's fonts).
 *
 * IF THE SITE FONT EVER CHANGES: update 'Yekan Bakh FaNum' here and the
 * SITE_FONT_FAMILY constants in assets/js/psych-exams-app.js +
 * assets/js/admin-app.js. Those are the only places.
 */

#psych-app {
    direction: rtl;
    text-align: right;
    font-family: 'Yekan Bakh FaNum';
    color: #1e293b;
    max-width: 880px;
    margin: 0 auto;
    padding: 12px;
    line-height: 1.8;
}

#psych-app *,
#psych-app *::before,
#psych-app *::after { box-sizing: border-box; }

/*
 * FORCE 'Yekan Bakh FaNum' on EVERY element inside the SPA — beats
 * browser defaults AND any theme rule that targets generic elements
 * inside our scope. <i> and <svg> are excluded so icon fonts
 * (Font Awesome) keep their glyph fonts.
 */
#psych-app,
#psych-app *:not(i):not(svg) {
    font-family: 'Yekan Bakh FaNum' !important;
}

/*
 * Strict rule for the interactive elements that kept falling back to the
 * browser default font (تاریخچه من / دانلود PDF / بازگشت به آزمون‌ها …):
 * the wrapper, all native form/interactive elements, and every plugin
 * control class — including the report iframe element itself.
 */
#psych-app,
#psych-app button,
#psych-app a,
#psych-app input,
#psych-app select,
#psych-app textarea,
.tamland-btn,
.tamland-button,
.tamland-link,
.tamland-report-frame {
    font-family: 'Yekan Bakh FaNum' !important;
}

#psych-app h1,
#psych-app h2,
#psych-app h3 { color: #0f172a; margin: 0; }
#psych-app h1 { font-size: 1.7rem; font-weight: 700; }
#psych-app h2 { font-size: 1.4rem; font-weight: 700; }
#psych-app h3 { font-size: 1.1rem; font-weight: 600; }

/*
 * Page title repeated above every exam screen («بالای هر آزمون هم تکرار
 * شود») — sits ABOVE each view's own bar; wraps (never truncates) on
 * narrow screens.
 */
#psych-app .tamland-page-title {
    margin: 4px 0 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

/*
 * Justify (admin «نمایش سایت» → متن هم‌تراز): exam texts, descriptions
 * and AI report bodies render with text-align: justify. Question options
 * and short labels are intentionally left alone.
 */
#psych-app.tamland-justify .tamland-question,
#psych-app.tamland-justify .tamland-intro-desc,
#psych-app.tamland-justify .tamland-muted,
#psych-app.tamland-justify p.tamland-meta,
#psych-app.tamland-justify .tamland-student-guide-body {
    text-align: justify;
}
#psych-app.tamland-justify .tamland-report {
    text-align: justify;
}

/* ---------- layout helpers ---------- */

#psych-app .tamland-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

#psych-app .tamland-muted { color: #64748b; margin: 4px 0; }
#psych-app .tamland-meta {
    color: #64748b;
    font-size: .85rem;
    margin: 4px 0;
    /* Chart-footer descriptions: theme font (inherited) + full wrapping. */
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
#psych-app .tamland-muted {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
#psych-app .tamland-strong { font-weight: 600; margin: 0 0 4px; }
#psych-app .tamland-flex { flex: 1; }

/* ---------- cards ---------- */

#psych-app .tamland-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .05);
    padding: 24px;
    margin-bottom: 18px;
}

#psych-app .tamland-question-card {
    padding: 28px;
    animation: tamland-fade-in .25s ease;
}

@keyframes tamland-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- buttons & links ---------- */

#psych-app .tamland-button {
    display: inline-block;
    background: var(--tamland-accent, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
    box-shadow: 0 1px 3px rgba(31, 41, 55, .3);
}
#psych-app .tamland-button:hover { background: var(--tamland-accent, #4f46e5); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(31, 41, 55, .3); }
#psych-app .tamland-button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Start/submit buttons while an async operation runs («در حال …»). */
#psych-app .tamland-button.is-loading {
    animation: tamland-pulse 1.2s ease-in-out infinite;
    pointer-events: none;
}
@keyframes tamland-pulse {
    0%, 100% { opacity: .55; }
    50% { opacity: 1; }
}

/*
 * Question-screen navigation: ONE tight row directly beneath the question
 * — «قبلی» at the start, hint dead-center, «بعدی»/«ثبت آزمون» at the end
 * (justify-content: space-between). The hint spans the middle (flex:1,
 * centered) and toggles via VISIBILITY, so its space is always reserved
 * and the buttons never move when it appears/disappears.
 */
#psych-app .tamland-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px; /* tight: was 34px combined (gate row + bar) before */
}
#psych-app .tamland-nav-row > .tamland-button {
    flex-shrink: 0; /* long hint text must never squash the buttons */
}
#psych-app .tamland-nav-row .tamland-gate-hint {
    flex: 1;
    text-align: center;
    visibility: hidden;
    font-size: .85rem;
    color: #b45309;
}
#psych-app .tamland-nav-row .tamland-gate-hint.is-visible { visibility: visible; }

#psych-app .tamland-button-secondary {
    background: #fff;
    color: #334155;
    border: 1px solid #cbd5e1;
    box-shadow: none;
}
#psych-app .tamland-button-secondary:hover { background: #f8fafc; box-shadow: none; }

#psych-app .tamland-button-success { background: #16a34a; box-shadow: 0 1px 3px rgba(31, 41, 55, .3); }
#psych-app .tamland-button-success:hover { background: #15803d; box-shadow: 0 4px 12px rgba(31, 41, 55, .3); }

#psych-app .tamland-link {
    background: none;
    border: none;
    color: var(--tamland-accent, #4f46e5);
    cursor: pointer;
    font-size: .95rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none;
    transition: background .15s ease;
}
#psych-app .tamland-link:hover { background: #eef2ff; color: var(--tamland-accent, #4f46e5); text-decoration: none; }

/* ---------- states ---------- */

#psych-app .tamland-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 16px;
}

#psych-app .tamland-loading-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
    color: #64748b;
}

#psych-app .tamland-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e0e7ff;
    border-top-color: var(--tamland-accent, #4f46e5);
    border-radius: 50%;
    animation: tamland-spin .8s linear infinite;
}

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

#psych-app .tamland-empty {
    text-align: center;
    color: #64748b;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    padding: 48px 24px;
}

/* ---------- exam list ---------- */

#psych-app .tamland-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
}

#psych-app .tamland-grid .tamland-card {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    transition: transform .15s ease, box-shadow .15s ease;
}
#psych-app .tamland-grid .tamland-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .1);
}
#psych-app .tamland-grid .tamland-button { margin-top: auto; }

#psych-app .tamland-exam-icon {
    display: block;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: cover;
    margin-bottom: 12px;
    background: #f1f5f9;
}

#psych-app .tamland-meta { color: #64748b; font-size: .85rem; margin: 6px 0 14px; }

/* ---------- exam wizard ---------- */

#psych-app .tamland-progress {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 22px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .06);
}
#psych-app .tamland-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tamland-accent, #4f46e5), var(--tamland-accent, #4f46e5));
    border-radius: 999px;
    transition: width .3s ease;
}

#psych-app .tamland-question { font-size: 1.15rem; font-weight: 600; margin: 0 0 20px; }

/* Age-dependent exams (RavenKids/RavenAdolescence): Jalali DOB step. */
#psych-app .tamland-dob-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 10px 0 4px;
}
#psych-app .tamland-dob-row label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: .85rem;
    color: #475569;
}
#psych-app .tamland-dob-row input[type="number"] {
    width: 96px;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    text-align: center;
}
#psych-app .tamland-dob-row input:focus {
    outline: none;
    border-color: var(--tamland-accent, #4f46e5);
}

/* Visual exams (RavenKids): the stem is a matrix image, options are images. */
#psych-app .tamland-question-image {
    display: block;
    max-width: min(420px, 100%);
    height: auto;
    margin: 0 auto 20px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    padding: 10px;
}
#psych-app .tamland-options { display: flex; flex-direction: column; gap: 12px; }
#psych-app .tamland-options--images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
#psych-app .tamland-options--images .tamland-option {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 8px;
    padding: 10px;
}
#psych-app .tamland-option-body { display: block; flex: 1; }
#psych-app .tamland-option-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    pointer-events: none; /* clicks select the label's radio, not the img */
}
#psych-app .tamland-option-caption { font-size: .85rem; color: #475569; }
#psych-app .tamland-row-image {
    max-width: 72px;
    max-height: 72px;
    height: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    vertical-align: middle;
}

#psych-app .tamland-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1rem;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
#psych-app .tamland-option:hover { border-color: #c7d2fe; background: #f8faff; }
#psych-app .tamland-option.is-selected {
    border-color: var(--tamland-accent, #4f46e5);
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(31, 41, 55, .12);
}
#psych-app .tamland-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--tamland-accent, #4f46e5);
    flex-shrink: 0;
}

#psych-app .tamland-scale-labels {
    display: flex;
    justify-content: space-between;
    color: #64748b;
    font-size: .85rem;
    margin-bottom: 10px;
}
#psych-app .tamland-scale { display: flex; flex-wrap: wrap; gap: 10px; }
#psych-app .tamland-scale-btn {
    min-width: 52px;
    height: 52px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
}
#psych-app .tamland-scale-btn:hover { border-color: #a5b4fc; background: #f8faff; }
#psych-app .tamland-scale-btn.is-selected {
    border-color: var(--tamland-accent, #4f46e5);
    background: var(--tamland-accent, #4f46e5);
    color: #fff;
    box-shadow: 0 4px 12px rgba(31, 41, 55, .3);
}

#psych-app .tamland-ranked { display: flex; flex-direction: column; gap: 10px; }
#psych-app .tamland-ranked-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    /* Ranking rows are a manipulation surface, not a reading surface. */
    user-select: none;
    -webkit-user-select: none;
}
#psych-app .tamland-ranked-tools { display: flex; align-items: center; gap: 6px; }

/* Guide line shown BELOW the ranked list (Kolb drag & drop). */
#psych-app .tamland-rank-guide {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: .87rem;
    margin: 12px 0 0;
}

/*
 * Drag handle (⋮⋮): the ONLY drag surface — touch-action:none stops the
 * page from scrolling instead of dragging on mobile; the rest of the row
 * and page keep their normal touch behavior.
 */
#psych-app .tamland-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    background: transparent;
    color: #94a3b8;
    cursor: grab;
    touch-action: none;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
#psych-app .tamland-drag-handle:hover,
#psych-app .tamland-drag-handle:active {
    color: var(--tamland-accent, #4f46e5);
    border-color: var(--tamland-accent, #4f46e5);
    background: #eef2ff;
    cursor: grabbing;
}
#psych-app .tamland-drag-handle svg { width: 16px; height: 16px; pointer-events: none; }

/* Row currently being dragged: lifted look, accent outline. */
#psych-app .tamland-ranked-row.is-dragging {
    border-color: var(--tamland-accent, #4f46e5);
    background: #eef2ff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .16);
    opacity: .96;
    z-index: 5;
    position: relative;
}
/* While a ranked drag is active, kill accidental text selection globally. */
body.tamland-ranked-dragging { user-select: none; -webkit-user-select: none; }
#psych-app .tamland-mini-btn {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: .95rem;
    transition: background .15s ease;
}
#psych-app .tamland-mini-btn:hover { background: #eef2ff; }
#psych-app .tamland-mini-btn:disabled { opacity: .4; cursor: not-allowed; }

#psych-app .tamland-paired-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}
#psych-app .tamland-paired-controls { display: flex; align-items: center; gap: 10px; }
#psych-app .tamland-paired-score { width: 40px; text-align: center; font-weight: 700; font-size: 1.05rem; }

#psych-app .tamland-mostleast { display: flex; flex-direction: column; gap: 16px; }
#psych-app .tamland-select-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
#psych-app .tamland-select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    font-size: .95rem;
    cursor: pointer;
    transition: border-color .15s ease;
}
#psych-app .tamland-select:focus { border-color: var(--tamland-accent, #4f46e5); outline: none; box-shadow: 0 0 0 3px rgba(31, 41, 55, .12); }

#psych-app .tamland-ok { color: #16a34a; font-weight: 700; }
#psych-app .tamland-err { color: #dc2626; font-weight: 700; }

/* ---------- results ---------- */

/*
 * Chart container: fixed minimum height (maintainAspectRatio is OFF) so
 * rotated x-axis labels (mobile anti-truncation, maxRotation 45°) always
 * have room to render — never shrunk below the label block.
 */
#psych-app .tamland-chart-center {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
    min-height: 350px;
}

/*
 * DUAL per-exam charts (2026-10): chart 1 (scores) + chart 2 (percents)
 * side-by-side on wide desktop screens, stacked vertically below 860px
 * (each keeps the 350px-min chart-center so rotated mobile labels always
 * have room). Captions («نمودار امتیازها» / «نمودار درصدها») identify
 * which metric group each canvas plots.
 */
#psych-app .tamland-chart-dual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: start;
}
#psych-app .tamland-chart-cell { min-width: 0; /* grid child may shrink */ }
#psych-app .tamland-chart-caption {
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
    color: #475569;
    margin: 0 0 10px;
}

/* Muted in-place notice when an explicitly-selected CUSTOM chart's data
 * is missing (e.g. raven_iq without an IQ metric) — never a silent drop. */
#psych-app .tamland-chart-notice {
    text-align: center;
    font-size: .85rem;
    color: #94a3b8;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 14px 16px;
    margin: 0 0 18px;
    line-height: 1.9;
}
@media (max-width: 860px) {
    #psych-app .tamland-chart-dual { grid-template-columns: 1fr; }
}

/*
 * «جدول طبقه‌بندی هوش» — the static classification table under the
 * Raven bell curve (official-PDF visual). The user's row is highlighted
 * with the accent tint + the «جای شما» badge.
 */
#psych-app .tamland-raven-table-wrap { margin: 4px 0 18px; }
#psych-app .tamland-raven-table-title {
    font-size: .95rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 10px;
    text-align: center;
}
#psych-app .tamland-raven-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
#psych-app .tamland-raven-table th,
#psych-app .tamland-raven-table td {
    border: 1px solid #e2e8f0;
    padding: 9px 12px;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
}
#psych-app .tamland-raven-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #334155;
}
#psych-app .tamland-raven-table tbody tr.is-active {
    background: #eef2ff;
    font-weight: 700;
    color: var(--tamland-accent, #4f46e5);
}
#psych-app .tamland-raven-you {
    display: inline-block;
    background: var(--tamland-accent, #4f46e5);
    color: #fff;
    border-radius: 999px;
    padding: 2px 12px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

/*
 * Per-exam «راهنمای آزمون» accordion (admin Exams tab): a subtle,
 * clickable card header with the admin's custom title (fallback
 * «راهنمای آزمون») + a rotating chevron. COLLAPSED by default — the body
 * expands via the grid-template-rows 0fr→1fr transition (no JS height
 * measurement, works on any content length). Placement per the admin's
 * choice: above «شروع آزمون» on the intro screen or at the top of the
 * exam page. .tamland-guide-justify (per-guide checkbox) applies
 * text-align: justify to the body text only.
 */
#psych-app .tamland-student-guide {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    margin: 18px 0 16px;
    overflow: hidden; /* clip the animating body inside the rounded card */
}

/* Header = a full-width, unstyled <button> (card-header look). */
#psych-app .tamland-student-guide-header {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    background: transparent;
    border: 0;
    border-radius: 0;
    cursor: pointer;
    text-align: right;
    font: inherit;
    color: inherit;
    transition: background .15s ease;
}
#psych-app .tamland-student-guide-header:hover { background: #e0e7ff; }
#psych-app .tamland-student-guide-header:focus-visible {
    outline: 2px solid var(--tamland-accent, #4f46e5);
    outline-offset: -2px;
}

#psych-app .tamland-student-guide-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 700;
    font-size: .9rem;
    color: var(--tamland-accent, #4f46e5);
    /* Custom admin titles may be long: wrap, never truncate/overflow. */
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.7;
}
#psych-app .tamland-student-guide-title svg { width: 17px; height: 17px; flex-shrink: 0; }

/* Chevron: points DOWN when closed, rotates 180° (points up) when open. */
#psych-app .tamland-guide-chevron {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--tamland-accent, #4f46e5);
    transition: transform .3s ease;
}
#psych-app .tamland-student-guide.is-open .tamland-guide-chevron { transform: rotate(180deg); }

/*
 * Smooth collapse: the 1-row grid animates its track 0fr→1fr; the body
 * (the grid child) needs min-height:0 + overflow:hidden to be squeezable
 * below its content size. NO vertical padding while closed — the open
 * state's bottom padding animates together with the track.
 */
#psych-app .tamland-guide-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s ease;
}
#psych-app .tamland-student-guide.is-open .tamland-guide-collapse { grid-template-rows: 1fr; }
#psych-app .tamland-guide-collapse > .tamland-student-guide-body {
    min-height: 0;
    overflow: hidden;
    padding: 0 16px;
    transition: padding .3s ease;
}
#psych-app .tamland-student-guide.is-open .tamland-guide-collapse > .tamland-student-guide-body {
    padding: 2px 16px 14px;
}

#psych-app .tamland-student-guide-body {
    color: #334155;
    line-height: 2.1; /* site font inherits; generous for Persian */
    white-space: pre-line; /* admin line breaks are meaningful */
    overflow-wrap: anywhere; /* mobile-safe wrapping */
}
#psych-app .tamland-student-guide.tamland-guide-justify .tamland-student-guide-body {
    text-align: justify;
}

#psych-app .tamland-chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

/*
 * PER-EXAM chart type (2026-10): 'radar' (default) or 'bar' exams draw
 * the #metricsChart canvas in .tamland-chart-center above; 'none' exams
 * (RavenKids-style — official PDF has no chart, just an IQ gauge and a
 * classification table) render NO canvas and their metric chips become
 * the display. The --hero variant (AFTER the base rule on purpose —
 * equal specificity, later wins) makes those chips prominent.
 */
#psych-app .tamland-chips--hero {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
#psych-app .tamland-chips--hero .tamland-chip { padding: 24px 14px; }
#psych-app .tamland-chips--hero .tamland-chip-value { font-size: 2.1rem; }
#psych-app .tamland-chips--hero .tamland-chip-key { font-size: .95rem; margin-top: 6px; }

/* One-time true-limit note above the chips (Newman PDF format: the
 * shared {metric}Max is stated ONCE — not a card per metric). */
#psych-app .tamland-chips-note {
    text-align: center;
    margin: 2px 0 4px;
    font-size: .85rem;
    color: #64748b;
}

/*
 * «گزارش توصیفی» metric table (Kolb official-PDF layout): the four
 * styles (احساسی، مشاهده گر، فکری، عمل گرا) with امتیاز + درصد
 * columns; value columns centered and bold.
 */
#psych-app .tamland-metric-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
    margin: 0 0 16px;
}
#psych-app .tamland-metric-table th,
#psych-app .tamland-metric-table td {
    border: 1px solid #e2e8f0;
    padding: 11px 14px;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
}
#psych-app .tamland-metric-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #334155;
}
#psych-app .tamland-metric-table th:nth-child(2),
#psych-app .tamland-metric-table th:nth-child(3),
#psych-app .tamland-metric-table td:nth-child(2),
#psych-app .tamland-metric-table td:nth-child(3) {
    text-align: center;
    width: 28%;
}
#psych-app .tamland-metric-table td:nth-child(2),
#psych-app .tamland-metric-table td:nth-child(3) {
    font-weight: 700;
    color: var(--tamland-accent, #4f46e5);
}
#psych-app .tamland-chip {
    text-align: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 12px;
    min-width: 0; /* grid children must be allowed to shrink */
    overflow: visible; /* never clip footer text */
}
#psych-app .tamland-chip-value { font-size: 1.6rem; font-weight: 700; color: var(--tamland-accent, #4f46e5); }
/*
 * Chart footer text (metric chips under the chart): the THEME's active
 * font via inheritance (no hardcoded family — theme-agnostic) and FULLY
 * responsive wrapping: labels stay 100% visible on any viewport (no
 * nowrap, no ellipsis, no overflow hidden; long compound Persian labels
 * may break mid-word when needed).
 */
#psych-app .tamland-chip-value,
#psych-app .tamland-chip-key {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.7;
}
#psych-app .tamland-chip-key { font-size: .85rem; color: #64748b; font-weight: 500; }

#psych-app .tamland-report {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    max-height: 460px;
    overflow-y: auto;
    line-height: 2;
}
/* Report tabs (mode = both): «تفسیر آزمون» / «گزارش جامع (ویژه مشاور)» */
#psych-app .tamland-report-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
#psych-app .tamland-report-tab {
    font-size: .92rem;
    padding: 9px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    transition: background .15s, color .15s;
}
#psych-app .tamland-report-tab:hover { background: #eef2f7; }
#psych-app .tamland-report-tab.is-active {
    background: var(--tamland-accent, #4f46e5);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
#psych-app .tamland-report.is-hidden { display: none; }
/*
 * Sandboxed report frame: report CSS lives INSIDE the iframe and can no
 * longer leak document-wide rules into the host page (the previous cause
 * of the metrics chart collapsing seconds after report injection).
 */
#psych-app .tamland-report-frame {
    display: block;
    width: 100%;
    min-height: 160px;
    border: 0;
    background: transparent;
}
#psych-app .tamland-report h1,
#psych-app .tamland-report h2,
#psych-app .tamland-report h3 { margin: 18px 0 8px; }
#psych-app .tamland-report p { margin: 8px 0; }
#psych-app .tamland-report ul,
#psych-app .tamland-report ol { margin: 8px 24px 8px 0; }
#psych-app .tamland-report table { border-collapse: collapse; width: 100%; margin: 12px 0; }
#psych-app .tamland-report th,
#psych-app .tamland-report td { border: 1px solid #e2e8f0; padding: 8px 12px; text-align: right; }
#psych-app .tamland-report code { background: #f1f5f9; padding: 2px 6px; border-radius: 6px; font-size: .9em; }
#psych-app .tamland-report blockquote {
    border-inline-start: 3px solid #c7d2fe;
    margin: 10px 0;
    padding: 4px 14px;
    color: #475569;
    background: #f8fafc;
    border-radius: 8px;
}

/* ---------- recommendations ---------- */

#psych-app .tamland-recommendations {
    background: linear-gradient(135deg, #eef2ff, #faf5ff);
    border-color: #c7d2fe;
}
#psych-app .tamland-stack { display: flex; flex-direction: column; gap: 14px; }
#psych-app .tamland-rec-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .07);
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------- history ---------- */

#psych-app .tamland-pills { display: flex; gap: 8px; flex-wrap: wrap; }
#psych-app .tamland-pill {
    padding: 5px 14px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
    /* Footer-label responsiveness: theme font (inherited) + wrap, never
     * truncate (mobile safe). */
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.7;
    max-width: 100%;
}
#psych-app .tamland-pill.is-green { background: #dcfce7; color: #166534; }
#psych-app .tamland-pill.is-yellow { background: #fef9c3; color: #854d0e; }
#psych-app .tamland-pill.is-blue { background: #dbeafe; color: #1e40af; }
#psych-app .tamland-pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
/* ---------- admin-driven layout modes («نمایش سایت») ---------- */

/* list: full-width rows, icon + text + button on one line */
#psych-app .tamland-grid.tamland-view-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#psych-app .tamland-view-list .tamland-card {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

#psych-app .tamland-view-list .tamland-exam-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 0;
    flex-shrink: 0;
}

#psych-app .tamland-view-list .tamland-card > h3,
#psych-app .tamland-view-list .tamland-card > .tamland-muted,
#psych-app .tamland-view-list .tamland-card > .tamland-meta {
    margin: 0;
    width: 100%;
}

#psych-app .tamland-view-list .tamland-card > h3 { margin-bottom: 4px; }

#psych-app .tamland-view-list .tamland-button { margin-inline-start: auto; }

@media (max-width: 640px) {
    #psych-app .tamland-view-list .tamland-card { flex-direction: column; align-items: stretch; }
    #psych-app .tamland-view-list .tamland-button { margin-inline-start: 0; }
}

/* compact: smaller tiles, icon-focused */
#psych-app .tamland-view-compact { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }

#psych-app .tamland-view-compact .tamland-card { padding: 14px; text-align: center; }

#psych-app .tamland-view-compact .tamland-exam-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 8px;
    border-radius: 10px;
}

#psych-app .tamland-view-compact .tamland-muted { font-size: .8rem; }
#psych-app .tamland-view-compact .tamland-button { padding: 9px 16px; font-size: .85rem; }

/* exam intro screen (detail view after selecting an exam) */
#psych-app .tamland-intro-card { padding: 34px 30px; }

#psych-app .tamland-intro-icon {
    width: 84px;
    height: 84px;
    border-radius: 18px;
    margin: 0 0 18px;
}

#psych-app .tamland-intro-desc {
    color: #334155;
    line-height: 2.1;
    margin: 14px 0;
    white-space: pre-line;
}

/* ---------- logged-out login gate ---------- */

#psych-app .tamland-login-gate {
    display: flex;
    justify-content: center;
    padding: 48px 12px;
}

#psych-app .tamland-login-card {
    max-width: 460px;
    width: 100%;
    text-align: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
    padding: 40px 32px;
}

#psych-app .tamland-login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--tamland-accent, #4f46e5);
    margin-bottom: 18px;
}

#psych-app .tamland-login-icon svg {
    width: 34px;
    height: 34px;
}

#psych-app .tamland-login-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 10px;
}

#psych-app .tamland-login-card .tamland-muted {
    color: #64748b;
    line-height: 2;
    margin: 0 0 20px;
}

#psych-app .tamland-login-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    padding: 13px 30px;
    font-size: 1rem;
}

#psych-app .tamland-login-button svg {
    width: 19px;
    height: 19px;
}

#psych-app .tamland-login-button:hover {
    color: #fff;
}

#psych-app .tamland-login-alt {
    margin: 18px 0 0;
    color: #475569;
    font-size: .92rem;
}

#psych-app .tamland-login-alt a {
    color: var(--tamland-accent, #4f46e5);
    font-weight: 600;
    text-decoration: none;
}

#psych-app .tamland-login-alt a:hover {
    text-decoration: underline;
}

#psych-app .tamland-login-note {
    margin: 16px 0 0;
    font-size: .8rem;
    color: #94a3b8;
}

/* ── Holland grouped question pages (v1.31.17) ──────────────────────
 * ۷ صفحه: ۱–۶ هر صفحه یک type با ۳ ستون checkbox (Activity/Experience/
 * Career)، صفحه ۷ مقیاس ۱–۷ (Ability/Skill). Desktop = 3-column grid,
 * mobile = stacked collapsible <details> sections. */

#psych-app .holland-page {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
    align-items: start;
}

#psych-app .holland-page--scale {
    grid-template-columns: 1fr 1fr;
}

#psych-app .holland-cat {
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 12px;
    background: rgba(255, 255, 255, .55);
    overflow: hidden;
}

#psych-app .holland-cat summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 700;
    background: rgba(15, 23, 42, .04);
    list-style: none;
    user-select: none;
}

#psych-app .holland-cat summary::-webkit-details-marker {
    display: none;
}

#psych-app .holland-cat summary::after {
    content: ' ▾';
    opacity: .55;
}

#psych-app .holland-cat-items {
    padding: 8px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#psych-app .checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 44px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
}

#psych-app .checkbox-item:hover {
    background: rgba(15, 23, 42, .045);
}

#psych-app .checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    flex: none;
    accent-color: var(--tamland-accent, #6d28d9);
    cursor: pointer;
}

#psych-app .holland-item-text {
    line-height: 1.8;
}

#psych-app .holland-scale-item {
    padding: 10px 0;
    border-bottom: 1px dashed rgba(15, 23, 42, .08);
}

#psych-app .holland-scale-item:last-child {
    border-bottom: 0;
}

@media (max-width: 767px) {
    #psych-app .holland-page,
    #psych-app .holland-page--scale {
        grid-template-columns: 1fr;
    }
}

/* ── Holland official-PDF result view (v1.31.19) ──────────────────── */

#psych-app .holland-section-heading {
    font-size: 18px;
    font-weight: 700;
    margin: 4px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--tamland-accent, #6d28d9);
    color: var(--tamland-accent, #6d28d9);
}

#psych-app .holland-descriptive-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 4px;
    font-size: 14px;
}

#psych-app .holland-descriptive-table th,
#psych-app .holland-descriptive-table td {
    border: 1px solid #e0e0e0;
    padding: 10px 8px;
    text-align: center;
}

#psych-app .holland-descriptive-table th {
    background: var(--tamland-accent, #6d28d9);
    color: #ffffff;
    font-weight: 600;
}

#psych-app .holland-descriptive-table td:first-child {
    background: #f5f5f5;
    font-weight: 600;
    text-align: right;
}

#psych-app .holland-descriptive-table tr:last-child td {
    background: #f0f0f0;
    font-weight: 700;
}

#psych-app .holland-charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 12px 0 4px;
}

#psych-app .holland-charts-container .tamland-chart-cell {
    min-height: 300px;
}

/* v1.31.26: .holland-legend / -item / -color removed — every bar shares
 * the accent color, so the color legend mapped nothing; the Persian
 * label under each bar identifies it. */

@media (max-width: 767px) {
    #psych-app .holland-charts-container {
        grid-template-columns: 1fr;
    }
}

/* ── Viral CTA loading (v1.31.23): dim + block double-taps while the
 * viral-card module builds the card. The modal spinner is the primary
 * feedback (this button may be re-rendered by the SPA's AI poll). */
#psych-app .tamland-viral-cta-button.is-loading {
    opacity: .7;
    pointer-events: none;
    cursor: wait;
}
