/* Study parts (diagrams, glossary, tabs, quiz, flashcards). Colours come from theme.css tokens. */

/* diagrams */
figure.diagram { margin: 1.6rem 0; padding: 1rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); max-width: 900px; }
figure.diagram > .diagram-title { font-family: var(--font-sans); font-size: .9rem; font-weight: 600; color: var(--text); margin: 0 0 .6rem; }
figure.diagram svg { width: 100%; height: auto; display: block; }
figure.diagram figcaption { font-family: var(--font-sans); font-size: .82rem; color: var(--text-faint); margin-top: .6rem; min-height: 1.3em; }
figure.diagram svg text { font-family: var(--font-sans); fill: var(--text); font-size: 14px; }
figure.diagram svg .sub { fill: var(--text-muted); font-size: 12px; }
figure.diagram svg .mono { font-family: var(--font-mono); font-size: 13px; }
figure.diagram svg .box { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
figure.diagram svg .box-acc { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
figure.diagram svg .box-danger { fill: var(--c-danger-bg); stroke: var(--c-danger); stroke-width: 1.5; }
figure.diagram svg .line { stroke: var(--accent); stroke-width: 1.8; fill: none; }
figure.diagram svg .line-dash { stroke: var(--text-faint); stroke-width: 1.5; fill: none; stroke-dasharray: 5 4; }
figure.diagram svg .arrow-head { fill: var(--accent); }
figure.diagram svg .accent-text { fill: var(--accent-text); }
figure.diagram svg .row { cursor: pointer; outline: none; }
figure.diagram svg .row rect.hit, figure.diagram svg rect.hit { fill: transparent; }
figure.diagram svg .row:hover rect.hit, figure.diagram svg .row.on rect.hit, figure.diagram svg .row:focus rect.hit { fill: var(--accent-soft); }
figure.diagram svg .tag rect { fill: var(--surface-2); stroke: var(--accent); stroke-width: 1; }

/* glossary */
.term { border-bottom: 1px dotted var(--accent); color: var(--accent-text); cursor: help; }
.term:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#popover {
  position: absolute; z-index: 50; max-width: 300px; display: none;
  background: var(--surface-2); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: .6rem .8rem; font-family: var(--font-sans); font-size: .85rem; line-height: 1.45; color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
#popover strong { display: block; color: var(--accent-text); margin-bottom: .2rem; }

/* tabs */
.tabs { margin: 1.4rem 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; max-width: 900px; }
.tabs > .tabs-title { margin: 0; padding: .5rem 1rem; font-family: var(--font-sans); font-size: .85rem; font-weight: 600; background: var(--surface); border-bottom: 1px solid var(--border); }
.tab-list { display: flex; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-list button {
  font: inherit; font-family: var(--font-sans); font-size: .85rem; color: var(--text-muted);
  background: none; border: 0; padding: .55rem 1rem; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab-list button:hover { color: var(--text); }
.tab-list button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab-list button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab-panel[hidden] { display: none; }
.tab-panel pre { margin: 0; border: 0; border-radius: 0; }
.tab-panel .tab-note { margin: 0; padding: .6rem 1rem; font-family: var(--font-sans); font-size: .85rem; color: var(--text-muted); background: var(--bg-sidebar); border-top: 1px solid var(--border); }

/* check yourself */
.check { max-width: var(--measure); margin-top: 3.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.check h3 { font-family: var(--font-sans); }
.q { margin: 1rem 0; padding: 1rem 1.2rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-sans); }
.q p.text { margin: 0 0 .7rem; font-weight: 600; }
.q .opt {
  display: block; width: 100%; text-align: left; font: inherit; font-size: .93rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .8rem; margin: .35rem 0; cursor: pointer;
}
.q .opt:hover:not(:disabled) { border-color: var(--accent); }
.q .opt.right { border-color: var(--c-success); background: var(--c-success-bg); }
.q .opt.wrong { border-color: var(--c-danger); background: var(--c-danger-bg); }
.q .opt:disabled { cursor: default; color: var(--text-muted); }
.q .opt.right:disabled, .q .opt.wrong:disabled { color: var(--text); }
.q .why { display: none; margin: .7rem 0 0; font-size: .88rem; color: var(--text-muted); }
.q.done .why { display: block; }
.score { display: inline-block; font-family: var(--font-sans); background: var(--surface-2); border: 1px solid var(--accent); border-radius: 999px; padding: .25rem .9rem; font-size: .88rem; }
.btn { font: inherit; font-family: var(--font-sans); font-size: .88rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .4rem .9rem; cursor: pointer; }
.btn:hover { border-color: var(--accent); }

#flash { outline: none; text-align: center; }
#flash:focus-visible .face { border-color: var(--accent); }
.flip { perspective: 1000px; height: 230px; max-width: 560px; margin: 1rem auto; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem; text-align: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; font-family: var(--font-sans);
}
.face.front { font-size: 1.5rem; font-weight: 650; color: var(--accent-text); }
.face.back { transform: rotateY(180deg); font-size: 1.05rem; line-height: 1.55; color: var(--text); }
.flash-bar { display: flex; justify-content: center; align-items: center; gap: 1rem; font-family: var(--font-sans); font-size: .88rem; color: var(--text-muted); }
.hint { font-family: var(--font-sans); font-size: .8rem; color: var(--text-faint); margin-top: .6rem; }
