/* ==========================================================================
   CSIP12 Papers + Solved Board Questions (Phase 3F)
   /resources (CBSE Question Papers — table), /solved-questions (list with
   filters) and the /paper/{slug} viewer chrome. Tokens come from csip-ui.css.
   ========================================================================== */

/* style.css forces Space Grotesk on h1–h6 with !important; the design's headings are Lora. */
.csip-res h1, .csip-res h2, .csip-res h3, .csip-viewer h1, .csip-viewer h2 { font-family: var(--f-serif) !important; letter-spacing: 0; }

/* Visually hidden, still read by screen readers (also defined in csip-quiz.css, which these pages don't load). */
.csip-sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.csip-res {
    flex: 1 1 auto; min-width: 0;
    overflow-y: auto; overflow-x: hidden;
    background: var(--c-paper); color: var(--c-ink); font-family: var(--f-sans);
}
.csip-res *, .csip-res *::before, .csip-res *::after { box-sizing: border-box; }
.csip-res__wrap { max-width: 900px; margin: 0 auto; padding: 40px 40px 72px; }

/* ---------- Page head ---------- */
.csip-res__head {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
    border-bottom: 2px solid var(--c-ink); padding-bottom: 16px; margin-bottom: 6px;
}
.csip-res__title { margin: 0; font-size: 26px; font-weight: 600; line-height: 1.2; color: var(--c-ink); }
.csip-res .csip-eyebrow { margin-bottom: 4px; }
.csip-res__cross { flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--c-amber-text); text-decoration: none; white-space: nowrap; }
.csip-res__cross:hover { text-decoration: underline; }
.csip-res__sub { font-size: 12.5px; color: var(--c-ink-3); margin: 12px 0 22px; }

/* ---------- Subject chips / segmented toggles ---------- */
.csip-res__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.csip-res-chip {
    display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: var(--r-sm);
    border: 1px solid var(--c-rule-2); background: transparent; color: var(--c-ink-3);
    font: 600 12px/1 var(--f-sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.csip-res-chip:hover { color: var(--c-ink); border-color: var(--c-ink-3); }
.csip-res-chip.is-active { border-color: var(--c-teal); background: var(--c-teal-tint); color: var(--c-teal-text); font-weight: 700; }
.csip-res-chip:focus-visible, .csip-seg2 button:focus-visible { outline: 2px solid var(--c-teal); outline-offset: 2px; }

.csip-seg2 { display: inline-flex; padding: 3px; gap: 2px; border-radius: 6px; border: 1px solid var(--c-rule); background: var(--c-surface); }
.csip-seg2 button {
    height: 28px; padding: 0 11px; border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer;
    font: 600 11.5px/1 var(--f-sans); color: var(--c-ink-3); white-space: nowrap;
}
.csip-seg2 button:hover { color: var(--c-ink); }
.csip-seg2 button.is-active { background: var(--c-teal-tint); color: var(--c-teal-text); font-weight: 700; }

/* ---------- Papers table ---------- */
.csip-ptable { width: 100%; }
.csip-ptable__head, .csip-prow {
    display: grid; align-items: center; column-gap: 20px;
    grid-template-columns: 56px minmax(0, 1fr) 104px 56px 88px 104px;
}
.csip-ptable__head {
    padding: 0 4px 8px; border-bottom: 1px solid var(--c-ink);
    font-size: 10px; font-weight: 700; color: var(--c-ink-3); text-transform: uppercase; letter-spacing: .05em;
}
.csip-prow { padding: 15px 4px; border-bottom: 1px solid var(--c-rule); }
.csip-prow[hidden] { display: none; }
.csip-prow__year { font-family: var(--f-serif); font-size: 20px; font-weight: 700; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.csip-prow__title { min-width: 0; font-size: 14.5px; font-weight: 600; color: var(--c-ink); overflow-wrap: anywhere; }
.csip-prow__meta { display: none; }
.csip-ptag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.csip-ptag--sample { color: var(--c-ink); }
.csip-ptag--board { color: var(--c-teal); }
.csip-ptag--compartment { color: var(--c-rust); }
html.dark .csip-ptag--board { color: var(--c-teal-text); }
.csip-prow__set { font-size: 12.5px; color: var(--c-ink-2); }
.csip-solved { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--c-teal); text-decoration: none; }
.csip-solved:hover { text-decoration: underline; }
html.dark .csip-solved { color: var(--c-teal-text); }
.csip-nosolved { font-size: 11px; color: var(--c-rule-2); }
.csip-prow__actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.csip-view { font-size: 12.5px; font-weight: 700; color: var(--c-amber-text); text-decoration: none; white-space: nowrap; }
.csip-view:hover { text-decoration: underline; }
.csip-bp {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 999px; border: 1px solid transparent; background: transparent;
    color: var(--c-ink-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}
.csip-bp:hover { color: var(--c-teal); border-color: var(--c-rule); background: var(--c-surface); }
.csip-ptable__empty { padding: 32px 4px; color: var(--c-ink-3); font-size: 14px; text-align: center; }
.csip-res__note { margin-top: 18px; font-size: 12px; color: var(--c-ink-3); display: flex; flex-wrap: wrap; gap: 6px 16px; }
.csip-res__note i { margin-right: 4px; }

/* Blueprint modal (existing charts) */
.csip-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--c-backdrop); }
.csip-modal.hidden { display: none; }
.csip-modal__panel { width: 100%; max-width: 1024px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; background: var(--c-surface); border: 1px solid var(--c-rule); border-radius: 14px; box-shadow: var(--shadow-pop); }
.csip-modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--c-rule); }
.csip-modal__head h3 { margin: 0; font-family: var(--f-serif) !important; font-size: 19px; font-weight: 600; color: var(--c-ink); }
.csip-modal__head p { margin: 4px 0 0; font-size: 12px; color: var(--c-ink-3); }
.csip-modal__body { flex: 1; overflow-y: auto; padding: 20px; }

/* ---------- Solved Board Questions ---------- */
.csip-sq__filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.csip-select {
    height: 34px; max-width: 100%; padding: 0 30px 0 12px; border-radius: 6px; border: 1px solid var(--c-rule); background-color: var(--c-surface);
    color: var(--c-ink); font: 600 11.5px/1 var(--f-sans); cursor: pointer; appearance: none; -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--c-ink-3) 50%), linear-gradient(135deg, var(--c-ink-3) 50%, transparent 50%);
    background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat;
}
#chapter-filter { width: 220px; text-overflow: ellipsis; } /* long chapter names must not push the other filters to a new row */
.csip-select:focus-visible { outline: 2px solid var(--c-teal); outline-offset: 1px; }
.csip-select.is-set { border-color: var(--c-teal); color: var(--c-teal-text); background-color: var(--c-teal-tint); }
.csip-sq__search { position: relative; margin-bottom: 8px; }
.csip-sq__search i { position: absolute; left: 0; top: 50%; transform: translateY(-50%); color: var(--c-ink-3); font-size: 13px; }
.csip-sq__search input {
    width: 100%; height: 38px; padding: 0 4px 0 24px; border: 0; border-bottom: 1px solid var(--c-rule-2); border-radius: 0;
    background: transparent; color: var(--c-ink); font: 400 14px/1 var(--f-sans); outline: none;
}
.csip-sq__search input::placeholder { color: var(--c-ink-3); }
.csip-sq__search input:focus { border-bottom-color: var(--c-teal); }
.csip-sq__bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin: 12px 0 8px; font-size: 12px; color: var(--c-ink-3); }
.csip-sq__bar strong { color: var(--c-ink); }
.csip-sq__bar .csip-link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-weight: 700; }
.csip-sq__bar .csip-link[hidden] { display: none; }
.csip-sq__group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c-ink-3); margin-right: 4px; }

.csip-sq-group + .csip-sq-group { margin-top: 26px; }
.csip-sq-group__head {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 12px 4px 8px; background: var(--c-paper); border-bottom: 1px solid var(--c-ink);
}
.csip-sq-group__head h2 { margin: 0; font-size: 17px; font-weight: 600; color: var(--c-ink); }
.csip-sq-group__count { flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--c-ink-3); }

.csip-sq { padding: 18px 4px; border-bottom: 1px solid var(--c-rule); }
.csip-sq__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 8px; font-size: 11px; font-weight: 700; }
.csip-sq__chapter { color: var(--c-amber-text); }
.csip-sq__marks, .csip-sq__qno { color: var(--c-ink-2); }
.csip-sq__origin { color: var(--c-ink-3); font-weight: 600; }
.csip-sq__py { color: var(--c-ink-3); font-weight: 600; }
.csip-sq__q {
    margin: 0 0 10px; font-size: 14.5px; font-weight: 500; line-height: 1.6; color: var(--c-ink);
    white-space: pre-wrap; overflow-wrap: anywhere;
}
.csip-sq__q--code { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.csip-sq__opts { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
.csip-sq__opts li { display: flex; gap: 8px; font-size: 13.5px; color: var(--c-ink-2); overflow-wrap: anywhere; }
.csip-sq__opts b { font-family: var(--f-serif); color: var(--c-ink); flex-shrink: 0; }
.csip-sq__toggle {
    display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; cursor: pointer;
    font: 700 12.5px/1.4 var(--f-sans); color: var(--c-teal);
}
html.dark .csip-sq__toggle { color: var(--c-teal-text); }
.csip-sq__toggle:hover { text-decoration: underline; }
.csip-sq__answer { margin-top: 12px; border-left: 3px solid var(--c-teal); background: var(--c-teal-tint); padding: 14px 16px; min-width: 0; }
.csip-sq__answer[hidden] { display: none; }
.csip-sq__answer-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--c-teal-text); margin-bottom: 6px; }
.csip-sq__answer-text { font-size: 13.5px; line-height: 1.6; color: var(--c-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.csip-sq__expl { margin-top: 10px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--c-teal) 25%, transparent); font-size: 12.5px; line-height: 1.55; color: var(--c-ink-2); overflow-wrap: anywhere; }
.csip-sq__expl i { color: var(--c-amber); margin-right: 4px; }
.csip-sq__code { position: relative; margin-top: 12px; }
.csip-sq__code pre { margin: 0; max-width: 100%; overflow-x: auto; border-radius: 6px; }
.csip-sq__code pre code { font-size: 12.5px; }
.csip-sq__run {
    position: absolute; top: 8px; right: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
    border: 0; border-radius: var(--r-sm); background: var(--c-teal); color: var(--c-on-teal); font: 700 11.5px/1 var(--f-sans); cursor: pointer;
}
.csip-sq__run:hover { background: var(--c-teal-hover); }
.csip-sq__empty { padding: 44px 16px; text-align: center; }
.csip-sq__empty h3 { margin: 0 0 6px; font-size: 18px; font-weight: 600; color: var(--c-ink); }
.csip-sq__empty p { margin: 0 0 16px; color: var(--c-ink-2); font-size: 13.5px; }

/* ---------- Phone ---------- */
@media (max-width: 767.98px) {
    .csip-res { padding-top: var(--bar-h); } /* fixed mobile top bar */
    .csip-res__wrap { padding: 20px 16px 24px; }
    .csip-res__head { flex-direction: column; align-items: flex-start; gap: 8px; }
    .csip-res__title { font-size: 22px; }
    .csip-res__cross { font-size: 12px; }
    .csip-res__sub { margin: 10px 0 16px; }
    .csip-ptable__head { display: none; }
    .csip-prow { grid-template-columns: 42px minmax(0, 1fr) auto; column-gap: 12px; padding: 12px 0; }
    .csip-prow__year { font-size: 16px; }
    .csip-prow__title { font-size: 13px; }
    .csip-prow__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 3px; }
    .csip-prow__meta .csip-ptag { font-size: 10px; }
    .csip-prow__type, .csip-prow__set, .csip-prow__solved { display: none; }
    .csip-prow__actions { gap: 2px; }
    .csip-view { font-size: 12px; }
    .csip-modal { padding: 10px; }
    .csip-modal__body { padding: 14px; }

    .csip-sq__filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 4px; scrollbar-width: none; }
    .csip-sq__filters::-webkit-scrollbar { display: none; }
    .csip-sq__filters > * { flex-shrink: 0; }
    .csip-sq__group-label { display: none; }
    .csip-sq-group__head h2 { font-size: 15px; }
    .csip-sq { padding: 14px 0; }
    .csip-sq__meta { font-size: 10px; }
    .csip-sq__q { font-size: 13px; line-height: 1.55; }
    .csip-sq__q--code { font-size: 12px; }
    .csip-sq__opts { grid-template-columns: 1fr; }
    .csip-sq__opts li { font-size: 12.5px; }
    .csip-sq__answer { padding: 12px 12px; }
    .csip-sq__answer-text { font-size: 12.5px; }
}

/* ==========================================================================
   /paper/{slug} viewer chrome (PDF area and its object/iframe are unchanged)
   ========================================================================== */
.csip-viewer { background: var(--c-paper); color: var(--c-ink); font-family: var(--f-sans); }
.csip-viewer *, .csip-viewer *::before, .csip-viewer *::after { box-sizing: border-box; }
.csip-viewer__bar {
    flex: none; z-index: 20; display: flex; align-items: center; gap: 14px;
    height: 56px; padding: 0 20px; background: var(--c-surface); border-bottom: 1px solid var(--c-rule);
}
.csip-viewer__left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.csip-viewer__brand { text-decoration: none; }
.csip-viewer__back { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 700; color: var(--c-ink-2); text-decoration: none; }
.csip-viewer__back:hover { background: var(--c-band); color: var(--c-ink); }
.csip-viewer__title {
    flex: 1; min-width: 0; margin: 0; text-align: center;
    font-size: 15px; font-weight: 600; color: var(--c-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.csip-viewer__actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.csip-viewer__actions .csip-btn { gap: 7px; }
.csip-viewer__pdf { background: var(--c-band); }
.csip-viewer__mobile-dl { padding: 12px 16px; background: var(--c-surface); border-bottom: 1px solid var(--c-rule); }
.csip-viewer__mobile-dl p { margin: 0 0 10px; text-align: center; font-size: 12.5px; color: var(--c-ink-2); }
.csip-viewer__smart { background: var(--c-paper); }
.csip-viewer__smartbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; background: var(--c-surface); border-bottom: 1px solid var(--c-rule); }
.csip-viewer__count { font-size: 12px; font-weight: 600; color: var(--c-ink-3); font-variant-numeric: tabular-nums; }
.csip-viewer__scroll { padding: 0 20px 80px; }
.csip-viewer__list { max-width: 760px; margin: 0 auto; padding-top: 8px; }
.csip-viewer .csip-sq-group__head { top: 0; }

@media (max-width: 1023.98px) {
    .csip-viewer__label--wide { display: none; }
}
@media (max-width: 767.98px) {
    .csip-viewer__bar { height: 52px; padding: 0 10px; gap: 8px; }
    .csip-viewer__left { gap: 4px; }
    .csip-viewer__back { padding: 0 8px; }
    .csip-viewer__back-text { display: none; }
    .csip-viewer__title { font-size: 12.5px; text-align: left; }
    .csip-viewer__label { display: none; }
    .csip-viewer__actions .csip-btn--sm { padding: 0 10px; }
    .csip-viewer__dl { display: none; }
    .csip-viewer__smartbar { padding: 8px 12px; }
    .csip-viewer__scroll { padding: 0 16px 60px; }
}
