/* Sınav sorularında resim ve formül (S6): öğrenci kâğıdı (Live), değerlendirme (Grade) ve soru editörü (Settings).
   Renkler sitenin tema değişkenlerinden gelir (açık/koyu tema); sabit palet yok. */

/* Izgara öğeleri içeriğin en küçük genişliğine kadar daralabilsin (uzun formül / geniş resim kartı dışarı itmesin). */
.exam-live > section,
.exam-paper-questions,
.exam-grade-main,
.exam-grade-answers {
    min-width: 0;
}

/* ---- resim: telefonda taşmaz, oran korunur ---- */
.exam-q-body img,
.exam-grade-question img {
    display: inline-block;
    max-width: 100%;
    height: auto;
    vertical-align: middle;
    border-radius: 0.5rem;
    margin: 0.2rem 0;
    box-sizing: border-box;
}

/* Yüklenemeyen resim (ağ koptu): alt metin çerçeveli görünür; ağ dönünce kendiliğinden yeniden denenir.
   width/height öznitelikleri bu durumda devre dışıdır: kırık resim kutusu öznitelikteki genişliği (örn. 1200) korursa dar ekranda sayfayı taşırırdı. */
.exam-q-body img.exam-img--failed,
.exam-grade-question img.exam-img--failed {
    width: auto;
    height: auto;
    min-height: 3rem;
    padding: 0.6rem 0.85rem;
    border: 1px dashed color-mix(in srgb, var(--text-secondary) 60%, transparent);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ---- formül: uzun formül sayfayı yatay taşırmaz, kendi içinde kayar ---- */
.exam-q-body .ql-formula,
.exam-grade-question .ql-formula {
    display: inline-block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    vertical-align: middle;
    padding: 0.1em 0.15em;
    box-sizing: border-box;
    scrollbar-width: thin;
}

/* KaTeX yüklenemediyse formül ham LaTeX metni olarak okunur kalır. */
.exam-math--raw {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 0.05em 0.35em;
    border-radius: 0.35rem;
    background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

/* ---- editör (Quill) ---- */
.exam-question .ql-editor {
    min-height: 4.5rem;
}

.exam-question .ql-editor img {
    max-width: 100%;
    height: auto;
}

.exam-question .ql-editor .ql-formula {
    cursor: pointer;
    border-radius: 0.3rem;
}

.exam-question .ql-editor .ql-formula:hover {
    outline: 2px solid color-mix(in srgb, var(--accent-primary) 45%, transparent);
}

.exam-question .ql-container[data-busy="1"]::after {
    content: "Resim yükleniyor…";
    position: absolute;
    right: 0.6rem;
    top: 0.45rem;
    z-index: 2;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--accent-primary) 20%, var(--bg-primary));
    pointer-events: none;
}

/* ---- formül penceresi ---- */
html.exam-fx-open body {
    overflow: hidden;
}

.exam-fx {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.45);
}

.exam-fx[hidden] {
    display: none;
}

.exam-fx__panel {
    width: min(36rem, 100%);
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    display: grid;
    gap: 0.8rem;
    padding: 1rem 1.1rem;
    box-sizing: border-box;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.exam-fx__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.exam-fx__head h3 {
    margin: 0;
    font-size: 1.1rem;
}

.exam-fx__input {
    width: 100%;
    min-height: 4.5rem;
    resize: vertical;
    box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
}

.exam-fx__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.exam-fx__chip {
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.2rem 0.55rem;
    border-radius: 0.6rem;
    border: 1px solid color-mix(in srgb, var(--text-primary) 18%, transparent);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.exam-fx__chip:hover,
.exam-fx__chip:focus-visible {
    border-color: var(--accent-primary);
    outline: none;
}

.exam-fx__preview {
    min-height: 3.2rem;
    padding: 0.7rem 0.9rem;
    border-radius: 0.8rem;
    background: var(--bg-secondary);
    overflow-x: auto;
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    box-sizing: border-box;
}

.exam-fx__preview.is-error {
    color: #c0392b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
}

.exam-fx__status {
    margin: 0.35rem 0 0;
    min-height: 1.2em;
    font-size: 0.85rem;
    color: #c0392b;
}

.exam-fx__help {
    margin: 0;
}

.exam-fx__help code {
    padding: 0 0.25em;
    border-radius: 0.25rem;
    background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.exam-fx__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.exam-fx__spacer {
    flex: 1 1 auto;
}

@media (max-width: 480px) {
    .exam-fx {
        align-items: flex-end;
        padding: 0.5rem;
    }

    .exam-fx__panel {
        max-height: calc(100dvh - 1rem);
    }
}
