/* ============================================================
   ai45.xyz — IB subject pages (notes.html, course-documents.html)
   A compact header, subject cards, and a sticky syllabus tree on
   the left with progress rings.
   Colours come from the theme tokens (site.css / themes.css).
   ============================================================ */

.ib { max-width: 1320px; margin: 0 auto; padding: 96px 32px 24px; min-height: 80vh; }
.ib-loading { padding: 140px 0; text-align: center; font-size: 11px; color: var(--faint); }
.ib .ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- compact page header ---------- */
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; padding: 6px 0 18px; border-bottom: 1px solid var(--hairline); }
.ph__crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.ph__crumbs a { color: var(--muted); border-bottom: 1px solid transparent; }
.ph__crumbs a:hover { color: var(--paper); border-color: var(--faint); }
.ph__crumbs i { font-style: normal; color: var(--faint); }
.ph__crumbs b { color: var(--paper); font-weight: 600; }
.ph__t { margin-top: 8px; font-size: clamp(26px, 3.4vw, 38px); font-weight: 600; letter-spacing: -0.025em; line-height: 1.08; }
.ph__t small { font-weight: 500; color: var(--muted); font-size: .6em; margin-left: 8px; }
.ph__s { margin-top: 6px; font-size: 14px; color: var(--muted); }
.ph__acts { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600; white-space: nowrap; color: var(--paper); background: rgba(var(--fg-rgb), .05); border: 1px solid rgba(var(--fg-rgb), .12); transition: background-color .2s, border-color .2s, transform .2s var(--ease); }
.btn:hover { background: rgba(var(--fg-rgb), .09); border-color: rgba(var(--fg-rgb), .25); }
.btn--p { color: var(--on-accent); background: linear-gradient(135deg, var(--accent-hi), var(--orange)); border-color: transparent; }
.btn--p:hover { background: linear-gradient(135deg, var(--accent-hi), var(--orange)); filter: brightness(1.06); }
.btn.is-on { border-color: var(--orange); color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, transparent); }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- subjects grid ---------- */
.subjects { margin-top: 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.subj { display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid rgba(var(--fg-rgb), .08); transition: transform .25s var(--ease), border-color .2s; }
.subj:hover { transform: translateY(-3px); border-color: rgba(var(--fg-rgb), .22); }
.subj__g { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.subj__n { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }

/* ---------- subject layout: tree + list ---------- */
.lay { margin-top: 20px; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; }
.tree { position: sticky; top: 92px; max-height: calc(100vh - 112px); overflow-y: auto; overscroll-behavior: contain; padding: 10px; border-radius: 20px; background: var(--surface); border: 1px solid rgba(var(--fg-rgb), .08); scrollbar-width: thin; }
.tree__h { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 10px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.tree__all { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; font-size: 13.5px; font-weight: 600; }
.tree__all:hover { background: rgba(var(--fg-rgb), .05); }
.tree__all.is-on { background: color-mix(in srgb, var(--orange) 14%, transparent); }
.tp { border-top: 1px solid rgba(var(--fg-rgb), .06); margin-top: 4px; padding-top: 4px; }
.tp__h { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 12px; text-align: left; font-size: 13.5px; font-weight: 600; color: var(--paper); }
.tp__h:hover { background: rgba(var(--fg-rgb), .05); }
.tp__h .ic { width: 14px; height: 14px; color: var(--faint); margin-left: auto; transition: transform .25s var(--ease); }
.tp.is-open .tp__h .ic { transform: rotate(180deg); }
.tp__h .n { font-family: var(--font-mono); font-size: 10px; color: var(--faint); font-weight: 400; }
.tp__body { display: none; padding: 2px 0 6px 10px; }
.tp.is-open .tp__body { display: block; }
.ts { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 8px; border-radius: 10px; font-size: 13px; color: var(--muted); position: relative; }
.ts::before { content: ""; position: absolute; left: 15px; top: -8px; bottom: -8px; width: 1px; background: rgba(var(--fg-rgb), .08); z-index: 0; }
.ts:first-child::before { top: 50%; }
.ts:last-child::before { bottom: 50%; }
.ts:hover { color: var(--paper); background: rgba(var(--fg-rgb), .04); }
.ts.is-on { color: var(--paper); background: color-mix(in srgb, var(--orange) 14%, transparent); }
.ts.is-on::after { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--orange); }
.ts__t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts__n { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }
.ts__hl { font-family: var(--font-mono); font-size: 9px; padding: 1px 5px; border-radius: 5px; background: rgba(var(--fg-rgb), .08); color: var(--muted); }
/* progress ring (completion of that subtopic) */
.ring { position: relative; z-index: 1; width: 16px; height: 16px; flex: none; border-radius: 50%; background: conic-gradient(var(--c-gpt) calc(var(--p, 0) * 1%), rgba(var(--fg-rgb), .12) 0); display: grid; place-items: center; }
.ring::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); }
.ring.is-full { background: var(--c-gpt); }
.ring.is-full::after { content: ""; width: 6px; height: 4px; border-left: 2px solid var(--on-accent, #fff); border-bottom: 2px solid var(--on-accent, #fff); border-radius: 0; background: none; transform: rotate(-45deg) translate(1px, -1px); }
.tp__h .ring { width: 18px; height: 18px; }
.tp__h .ring::after { width: 11px; height: 11px; }

.chipx { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; background: rgba(var(--fg-rgb), .06); color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed rgba(var(--fg-rgb), .12); border-radius: 16px; }

.panel { padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid rgba(var(--fg-rgb), .08); }
.panel h3 { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }

@media (max-width: 1000px) {
  .lay { grid-template-columns: 1fr; }
  .tree { position: static; max-height: none; }
  .subjects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ib { padding: 84px 14px 10px; }
  .subjects { grid-template-columns: 1fr; }
}
