/* Deliberately light-touch: inherits the theme's fonts and colours so the bank
   looks like part of the site rather than an embedded app. */
.tdb-app, .tdb-gallery { --tdb-line:#d8dddb; --tdb-ink:#1a1a1a; --tdb-muted:#63726d; --tdb-accent:#0f5f52; }

.tdb-controls { margin-bottom: 18px; }
#tdb-q { width:100%; padding:11px 14px; border:1px solid var(--tdb-line); border-radius:8px; font-size:16px; }
.tdb-filters { display:flex; gap:6px; flex-wrap:wrap; align-items:center; margin-top:12px; }
.tdb-filters > span { font-size:11px; letter-spacing:.1em; text-transform:uppercase; color:var(--tdb-muted); }
.tdb-chip { font-size:13px; padding:5px 11px; border-radius:999px; border:1px solid var(--tdb-line);
  background:#fff; color:var(--tdb-ink); cursor:pointer; }
.tdb-chip.on { background:var(--tdb-accent); border-color:var(--tdb-accent); color:#fff; }
.tdb-count { margin:10px 0 0; font-size:13px; color:var(--tdb-muted); }

.tdb-grid, .tdb-gallery {
  display:grid; gap:18px; margin:22px 0 40px;
  grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));
}
.tdb-gallery { grid-template-columns:repeat(auto-fill, minmax(calc(100% / var(--tdb-cols, 3) - 18px), 1fr)); }
.tdb-card { display:flex; flex-direction:column; text-align:left; padding:0; cursor:pointer;
  background:#fff; border:1px solid var(--tdb-line); border-radius:10px; overflow:hidden; font:inherit; color:inherit; }
.tdb-card:hover { border-color:var(--tdb-accent); }
.tdb-thumb { display:grid; place-items:center; padding:8px; background:#fff; aspect-ratio:13/10; overflow:hidden; }
.tdb-thumb img, .tdb-thumb svg { max-width:100%; max-height:100%; height:auto; width:auto; display:block; }
.tdb-cbody { display:flex; flex-direction:column; gap:6px; padding:12px 14px 14px; }
.tdb-ctitle { font-size:17px; font-weight:600; line-height:1.25; }
.tdb-cwhy { font-size:13.5px; color:var(--tdb-muted); line-height:1.45; }
.tdb-cmeta { font-size:11px; letter-spacing:.05em; text-transform:uppercase; color:var(--tdb-muted); margin-top:auto; }
.tdb-empty { color:var(--tdb-muted); }

.tdb-figure { margin:24px 0; }
.tdb-figure svg { width:100%; height:auto; }
.tdb-figure figcaption { font-size:13.5px; color:var(--tdb-muted); margin-top:6px; }

/* align-items must be flex-start. Left to stretch, the panel is locked to the
   height of the window, and anything taller — the sliders, the buttons, the
   readout — spills out below the white background and lands on top of the
   page behind it. */
.tdb-sheet { position:fixed; inset:0; z-index:9999; background:rgba(12,20,18,.55);
  display:flex; align-items:flex-start; justify-content:center; overflow-y:auto; }
.tdb-sheet[hidden] { display:none !important; }
body.tdb-open { overflow:hidden; }
.tdb-panel { background:#fff; width:100%; max-width:1180px; min-height:100%; padding:0 20px 48px; }
.tdb-phead { position:sticky; top:0; background:#fff; z-index:2; padding:18px 0 14px;
  border-bottom:1px solid var(--tdb-line); display:flex; justify-content:space-between; gap:16px; align-items:flex-start; }
.tdb-phead h2 { margin:0; font-size:clamp(20px,3vw,28px); line-height:1.15; }
.tdb-close { width:36px; height:36px; border-radius:8px; border:1px solid var(--tdb-line);
  background:#fff; font-size:19px; line-height:1; cursor:pointer; flex:none; }
.tdb-layout { display:grid; gap:24px; padding-top:22px; grid-template-columns:minmax(0,1.3fr) minmax(0,1fr); }
.tdb-layout > * { min-width:0; }
@media (max-width:900px){ .tdb-layout { grid-template-columns:1fr; } }
.tdb-stage { background:#fff; border:1px solid var(--tdb-line); border-radius:10px; padding:10px; }
.tdb-stage svg { display:block; width:100%; height:auto; }
.tdb-knobs { background:#f7f9f8; border:1px solid var(--tdb-line); border-radius:10px; padding:14px 16px; margin-top:14px; }
.tdb-knobs[hidden] { display:none; }
.tdb-knobs h3 { margin:0 0 10px; font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:var(--tdb-accent); }
.tdb-knob { margin-bottom:12px; }
.tdb-knob:last-child { margin-bottom:0; }
.tdb-knob label { display:flex; justify-content:space-between; font-size:13px; font-weight:500; margin-bottom:5px; }
.tdb-knob label i { font-style:normal; color:var(--tdb-accent); font-weight:600; }
.tdb-knob input[type=range] { width:100%; accent-color:var(--tdb-accent); }
.tdb-segs { display:flex; gap:6px; flex-wrap:wrap; }
.tdb-seg { font-size:13px; padding:5px 11px; border-radius:6px; border:1px solid var(--tdb-line); background:#fff; cursor:pointer; }
.tdb-seg.on { background:var(--tdb-accent); border-color:var(--tdb-accent); color:#fff; }
.tdb-acts { display:flex; gap:8px; flex-wrap:wrap; margin-top:14px; }
.tdb-btn { font:inherit; font-size:13.5px; padding:9px 14px; border-radius:8px;
  border:1px solid var(--tdb-line); background:#fff; cursor:pointer; }
.tdb-btn:hover { border-color:var(--tdb-accent); color:var(--tdb-accent); }
.tdb-readout { margin-top:14px; font-size:14px; line-height:1.55; }
/* A visitor gets no teaching notes, and an empty column beside the chart reads
   as something broken rather than something withheld. Say so, and give back
   the width. */
.tdb-layout.tdb-solo { grid-template-columns: minmax(0, 1fr); }
.tdb-gate { background:var(--tdb-surface, #f7f9f8); border:1px solid var(--tdb-line);
  border-radius:10px; padding:14px 16px; font-size:14px; line-height:1.55; }
.tdb-gate a { font-weight:600; }
.tdb-notes section { margin-bottom:20px; }
.tdb-notes h3 { font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:var(--tdb-accent); margin:0 0 8px; }
.tdb-notes li { font-size:14.5px; line-height:1.55; margin-bottom:6px; }
.tdb-stem { background:#f7f9f8; border-left:3px solid var(--tdb-accent); border-radius:6px;
  padding:9px 12px; font-size:14px; margin:0 0 8px; }
.tdb-algebra { background:#f7f9f8; border-radius:6px; padding:10px 12px; font-size:12.5px;
  white-space:pre-wrap; overflow-x:auto; }
.tdb-stage.tdb-waiting { min-height:260px; background:
  linear-gradient(90deg,#f4f6f5 25%,#eceeed 37%,#f4f6f5 63%) 0 0/400% 100%;
  animation:tdb-shim 1.2s linear infinite; }
@keyframes tdb-shim { to { background-position:-400% 0; } }
@media (prefers-reduced-motion: reduce){ .tdb-stage.tdb-waiting { animation:none; } }

/* --- standing up to the site's own typography ---------------------------
   A theme that uppercases every heading turns a diagram's one-line
   explanation into shouting, so the bank sets its own case back explicitly
   rather than hoping. Same for the letter-spacing that comes with it. */
.tdb-app .tdb-ctitle, .tdb-gallery .tdb-ctitle,
.tdb-app .tdb-cwhy,   .tdb-gallery .tdb-cwhy,
.tdb-app .tdb-phead h2, .tdb-app .tdb-readout, .tdb-app .tdb-notes li,
.tdb-app .tdb-stem, .tdb-app .tdb-knob label, .tdb-figure figcaption {
  text-transform: none;
  letter-spacing: normal;
}
.tdb-app .tdb-ctitle, .tdb-gallery .tdb-ctitle { font-weight: 600; }

/* The WordPress admin bar is fixed above everything a plugin may claim, so
   the panel's own sticky header steps out from under it rather than fighting
   it. Only signed-in editors ever see this. */
body.admin-bar .tdb-phead { top: 32px; }
@media screen and (max-width: 782px) { body.admin-bar .tdb-phead { top: 46px; } }
body.admin-bar .tdb-sheet { top: 32px; }
@media screen and (max-width: 782px) { body.admin-bar .tdb-sheet { top: 46px; } }

/* --- the free gallery ---------------------------------------------------
   Every rule below is scoped to .tdb-* classes and the stylesheet is only
   enqueued on pages that actually run a shortcode, so nothing here can reach
   another page's layout. */
.tdb-galleryw { margin: 0; }
.tdb-topic { margin: 0 0 40px; }
.tdb-topich {
  font-size: clamp(18px, 2.2vw, 24px); margin: 0 0 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--tdb-line); text-transform: none; letter-spacing: normal;
}
.tdb-galleryw .tdb-gallery {
  display: grid; gap: 22px; margin: 0;
  grid-template-columns: repeat(auto-fill, minmax(clamp(260px, calc(100% / var(--tdb-cols, 3) - 22px), 460px), 1fr));
}
.tdb-fig { margin: 0; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.tdb-fig .tdb-ctitle { margin: 0; font-size: 17px; line-height: 1.25; }
.tdb-fig .tdb-thumb { aspect-ratio: auto; padding: 0; }
.tdb-fig .tdb-thumb svg { width: 100%; height: auto; max-height: none; }
.tdb-fig .tdb-cbody { padding: 0; gap: 6px; }
.tdb-cspec {
  margin: 0; font-size: 12px; color: var(--tdb-muted);
  font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: normal;
}

/* "Full width" means filling whatever column the page gives it — no viewport
   breakout. Pulling a block out to 100vw only lands correctly when its
   container happens to be centred in the window, and next to a sidebar it
   shoots off the left edge. Width belongs to the page's own layout setting,
   so that is where it is set. */
.tdb-wide {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.tdb-wide .tdb-gallery { gap: 24px; }

/* --- controls that survive the theme ------------------------------------
   A theme is entitled to style every button on the site, and this one paints
   button text white — which on the bank's white buttons meant a row of blank
   rectangles. Each control below therefore states its own colours at a
   specificity the theme cannot casually outrank, and only for the handful of
   properties that decide legibility. Everything stays scoped to .tdb-*. */
.tdb-app .tdb-btn,
.tdb-app button.tdb-btn,
.tdb-app .tdb-chip,
.tdb-app button.tdb-chip,
.tdb-app .tdb-seg,
.tdb-app button.tdb-seg,
.tdb-app .tdb-close,
.tdb-app button.tdb-close {
  background-color: #fff !important;
  background-image: none !important;
  color: var(--tdb-ink) !important;
  border: 1px solid var(--tdb-line) !important;
  text-shadow: none !important;
  box-shadow: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.3;
  opacity: 1 !important;
}
.tdb-app .tdb-chip, .tdb-app button.tdb-chip { font-size: 13px; }

/* the two states that are meant to be filled in */
.tdb-app .tdb-chip.on,
.tdb-app button.tdb-chip.on,
.tdb-app .tdb-seg.on,
.tdb-app button.tdb-seg.on {
  background-color: var(--tdb-accent) !important;
  border-color: var(--tdb-accent) !important;
  color: #fff !important;
}
.tdb-app .tdb-btn:hover,
.tdb-app button.tdb-btn:hover {
  color: var(--tdb-accent) !important;
  border-color: var(--tdb-accent) !important;
}

.tdb-app #tdb-q,
.tdb-app input[type="search"]#tdb-q {
  background-color: #fff !important;
  color: var(--tdb-ink) !important;
  border: 1px solid var(--tdb-line) !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  box-shadow: none !important;
}
.tdb-app #tdb-q::placeholder { color: var(--tdb-muted); opacity: 1; }

/* --- the teaching guide -------------------------------------------------- */
.tdb-app .tdb-meta { display:flex; gap:6px; flex-wrap:wrap; margin-top:7px; }
.tdb-app .tdb-tag {
  font-size:10.5px; letter-spacing:.06em; text-transform:uppercase; font-weight:600;
  padding:3px 7px; border-radius:4px; background:var(--tdb-surface,#f7f9f8);
  color:var(--tdb-muted); border:1px solid var(--tdb-line);
}
.tdb-app .tdb-tag.on { background:#d9ebe6; color:#0a4740; border-color:transparent; }
.tdb-app .tdb-tag.st { background:#fbf0d5; color:#8a5a00; border-color:transparent; }
.tdb-app .tdb-tag.spec {
  text-transform:none; letter-spacing:.02em; font-weight:500; font-variant-numeric:tabular-nums;
}
.tdb-app .tdb-notes ol { margin:0; padding-left:20px; display:flex; flex-direction:column; gap:7px; }
.tdb-app .tdb-notes ol li { font-size:14.5px; line-height:1.55; }
/* the mark tariff that comes with each exam question */
.tdb-app .tdb-stem span {
  display:block; font-size:11px; letter-spacing:.07em; text-transform:uppercase;
  color:var(--tdb-muted); font-weight:600; margin-bottom:4px;
}

/* --- the draggable handle ------------------------------------------------
   A transparent button parked over the ring the server drew. It is an HTML
   element rather than a shape inside the SVG because the SVG is replaced on
   every move, because Safari ignores touch-action on SVG children, and
   because a button can be tabbed to and driven with the arrow keys. */
.tdb-stagewrap { position: relative; }
.tdb-grips { position: absolute; inset: 0; pointer-events: none; }
.tdb-grip {
  position: absolute;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  padding: 0; border: 0; border-radius: 50%;
  background: transparent !important;
  box-shadow: none !important;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}
.tdb-grip:focus-visible {
  outline: 2px solid var(--tdb-accent);
  outline-offset: -6px;
}
body.tdb-dragging { cursor: grabbing; user-select: none; }
body.tdb-dragging .tdb-grip { cursor: grabbing; }

/* the sign-in prompt the gate shortcode puts in place of members-only content */
.tdb-gate { background:#f7f9f8; border:1px solid #d8dddb; border-radius:10px;
  padding:16px 18px; font-size:15px; line-height:1.55; }
.tdb-gate p { margin:0 0 10px; }
.tdb-gate p:last-child { margin-bottom:0; }
.tdb-gate .tdb-btn { display:inline-flex; margin-right:8px; text-decoration:none; }
