/* Visual teaching layer, scoped to the Transformer series. */
.tr-series {
  --tr-blue: #426da8;
  --tr-blue-soft: #edf2fa;
  --tr-warm: #a55b28;
  --tr-warm-soft: #fbf0e4;
  --tr-green-soft: #eaf5ef;
  background: linear-gradient(180deg, #f4f9f3 0, var(--bg) 650px);
}
.tr-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.tr-mobile-explorer > summary { display: none; }
.tr-article > p, .tr-article > ol, .tr-article > ul { max-width: 72ch; }
.tr-article > p { line-height: 1.85; margin-block: .9rem; }
.tr-article > h1 { line-height: 1.17; letter-spacing: -.035em; text-wrap: balance; margin-top: .7rem; }
.tr-article { counter-reset: tr-section; }
.tr-article > h2 { counter-increment: tr-section; line-height: 1.35; margin-top: 3rem; padding-top: 1.3rem; border-top-color: color-mix(in srgb, var(--line) 65%, transparent); }
.tr-article > h2::before { content: counter(tr-section, decimal-leading-zero); font: 600 .75rem/1.6 ui-monospace, monospace; color: var(--brand); display: inline-block; vertical-align: middle; margin-right: .7rem; padding: .15rem .35rem; background: var(--tr-green-soft); border-radius: 4px; }
.tr-article > .callout { line-height: 1.85; padding: 1.2rem 1.35rem; margin: 1.6rem 0; background: var(--tr-green-soft); border-radius: 0 12px 12px 0; }
.tr-reading-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1.2rem 0; }
.tr-reading-tools a { color: var(--ink-muted); font-size: .78rem; font-weight: 700; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 100px; text-decoration: none; background: var(--card); }
.tr-reading-tools span { margin-right: .25rem; color: var(--brand); }
.tr-reading-tools a:hover { border-color: var(--brand); color: var(--brand); }
.tr-lab { margin: 2rem 0; border: 1px solid #c9d9cd; border-radius: 18px; background: var(--card); overflow: hidden; box-shadow: 0 10px 30px rgba(19,32,26,.035); scroll-margin-top: 7rem; }
.tr-lab > figcaption { display: grid; gap: .4rem; padding: 1.4rem 1.5rem 1.1rem; border-bottom: 1px solid #dce5dc; background: linear-gradient(120deg, var(--tr-green-soft), var(--card)); }
.tr-lab > figcaption strong { font: 700 1.2rem/1.45 'Syne', sans-serif; letter-spacing: -.015em; }
.tr-eyebrow { color: var(--brand); font: 800 .66rem/1.6 'Manrope',sans-serif; letter-spacing: .13em; text-transform: uppercase; }
.tr-flow { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1.25rem; align-items: stretch; }
.tr-node { position: relative; padding: 1.1rem .8rem; border: 1px solid #cbded1; border-radius: 11px; background: var(--tr-green-soft); text-align: center; display: flex; flex-direction: column; justify-content: center; gap: .55rem; min-width: 0; }
.tr-node + .tr-node::before { content: '→'; position: absolute; left: -1.12rem; top: calc(50% - .6rem); color: var(--ink-muted); font-size: 1rem; line-height: 1.2; }
.tr-node-label { font-size: .7rem; color: var(--ink-muted); line-height: 1.6; }
.tr-node strong { font: 700 .95rem/1.55 'Manrope',sans-serif; overflow-wrap: anywhere; }
.tr-tone-1 { background: var(--tr-blue-soft); border-color: #cfdaec; }
.tr-tone-2 { background: var(--tr-warm-soft); border-color: #ecd8bf; }
.tr-token-strip { margin: .55rem 0; min-width: 0; }
.tr-mini-label { display: block; font-size: .73rem; font-weight: 700; line-height: 1.6; margin-bottom: .65rem; color: var(--ink-muted); }
.tr-tokens { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
.tr-token { display: inline-flex; justify-content: center; align-items: center; min-width: 45px; min-height: 46px; padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font: 600 .88rem/1.45 ui-monospace,monospace; text-align: center; transition: background 220ms, border-color 220ms; }
.tr-token.is-lit, .tr-matrix-value.is-lit { background: var(--tr-green-soft); border-color: var(--brand); color: #076347; }
.tr-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; align-items: start; }
.tr-mini-matrix { min-width: 0; }
.tr-matrix-grid { display: grid; grid-template-columns: repeat(var(--cols),minmax(0,1fr)); gap: 5px; padding: .6rem; border-left: 2px solid var(--ink-muted); border-right: 2px solid var(--ink-muted); border-radius: 6px; }
.tr-matrix-value { min-height: 36px; display: flex; align-items: center; justify-content: center; padding: .25rem; background: #f4f2eb; border: 1px solid transparent; border-radius: 4px; font: .85rem/1.4 ui-monospace,monospace; overflow-wrap: anywhere; text-align: center; transition: background 220ms, color 220ms; }
.tr-formula { text-align: center; padding: 1rem; font-size: 1.1rem; background: var(--tr-blue-soft); border: 1px solid #d8e1f0; border-radius: 10px; overflow-x: auto; }
.tr-lab button { font: 700 .78rem/1.5 'Manrope',sans-serif; padding: .6rem .85rem; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--card); cursor: pointer; }
.tr-lab button:disabled { opacity: .4; cursor: default; }
.tr-lab .tr-token-button { font: 600 .88rem/1.45 ui-monospace,monospace; min-height: 46px; padding: .65rem .85rem; }
.tr-lab .tr-token-button:hover { border-color: var(--brand); }
.tr-lab .tr-token-button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: white; box-shadow: 0 0 0 2px var(--tr-green-soft); }
.tr-lab-body { padding: .4rem 1.5rem 1.4rem; }
.tr-lab .tr-controls { margin-bottom: 1.2rem; }
.tr-lab .tr-status { border-left: 3px solid var(--brand); font-size: .85rem; }
.tr-lab .tr-pair, .tr-lab .tr-flow { margin: 1rem 0; }
.tr-lab .tr-chart { display: flex; height: 150px; align-items: stretch; gap: 12px; padding: .5rem; background: linear-gradient(transparent calc(50% - .5px), #a8b7ae 50%, transparent calc(50% + .5px)); }
.tr-column { flex: 1; position: relative; min-width: 0; }
.tr-column-fill { position: absolute; left: 15%; width: 70%; height: 0; bottom: 50%; border-radius: 5px 5px 0 0; background: var(--brand); transition: height 250ms, bottom 250ms; }
.tr-column-fill.is-negative { background: var(--tr-blue); border-radius: 0 0 5px 5px; }
.tr-chart-values { display: flex; justify-content: space-around; font: .75rem/1.5 ui-monospace,monospace; margin-bottom: 1rem; }
.tr-prob-row { display: grid; grid-template-columns: 54px minmax(0,1fr) 54px; align-items: center; gap: .7rem; margin: .8rem 0; font: .75rem/1.5 ui-monospace,monospace; }
.tr-prob-track { display: flex; height: 25px; background: #eef1eb; border-radius: 5px; overflow: hidden; }
.tr-prob-track span { width: 0; transition: width 300ms; background: var(--brand); }
.tr-prob-track span + span { background: #c4823a; }
.tr-patch-grid { display: grid; grid-template-columns: repeat(var(--patch-cols),minmax(0,1fr)); gap: 2px; width: min(280px,100%); aspect-ratio: 1; margin: 1rem auto; padding: 6px; background: #d5e2db; border-radius: 8px; }
.tr-patch { background: #79aa9a; border-radius: 1px; }
.tr-patch:nth-child(3n) { background: #477c74; }
.tr-patch:nth-child(5n) { background: #cfb885; }
.tr-lab [data-token-state=pending] { opacity: .4; border-style: dashed; }
.tr-lab [data-token-state=new] { background: var(--tr-warm-soft); border-color: #c4823a; }
.tr-lab [data-token-state=cached] { background: var(--tr-green-soft); border-color: var(--brand); }
.tr-lab-fallback { line-height: 1.8; }
.tr-reading-tools a:focus-visible, .tr-lab :is(button,input,select):focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.tr-figure, .tr-demo { box-shadow: 0 7px 24px rgba(19,32,26,.025); }
.tr-figure a { color: var(--brand); }
.tr-table th { font-size: .76rem; }
.tr-check { border-color: #e2cfb5; padding: 1.2rem; }
.tr-check[open] { background: #fcf3e8; }
.tr-catalog { grid-template-columns: repeat(2,minmax(0,1fr)); }
.tr-article .tr-card { border-radius: 12px; border-top: 3px solid #b4d6c4; padding: 1.1rem; transition: box-shadow 180ms, border-color 180ms; }
.tr-card:hover { box-shadow: 0 6px 18px rgba(19,32,26,.06); }
.tr-article .tr-card strong { font-size: .9rem; line-height: 1.5; }
.tr-article .tr-card p { font-size: .78rem; line-height: 1.75; }
@media (max-width: 900px) {
  .tr-series .blog-post-layout, .tr-series .blog-post-layout.sidebar-collapsed { grid-template-columns: 1fr; gap: 1rem; }
  .tr-series .blog-sidebar { padding: .75rem 1rem; margin-bottom: .5rem; }
  .tr-mobile-explorer > summary { display: list-item; cursor: pointer; font-size: .85rem; font-weight: 700; color: var(--ink-muted); padding: .3rem 0; }
  .tr-series .sidebar-toggle { display: none; }
  .tr-series .blog-post-layout.sidebar-collapsed .blog-sidebar-body { display: block; }
  .tr-article h2, .tr-article h3, .tr-anchor, .tr-lab, #visual-experiment { scroll-margin-top: 11rem; }
}
@media (max-width: 600px) {
  .tr-lab > figcaption { padding: 1.1rem; }
  .tr-lab > figcaption strong { font-size: 1.08rem; }
  .tr-flow { grid-template-columns: 1fr; gap: 1rem; }
  .tr-node { padding: .8rem 1rem; flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; text-align: right; }
  .tr-node-label { text-align: left; max-width: 48%; }
  .tr-node strong { font-size: .85rem; max-width: 62%; }
  .tr-node + .tr-node::before { content: '↓'; left: calc(50% - .5rem); top: -.99rem; }
  .tr-pair { grid-template-columns: 1fr; }
  .tr-lab-body { padding: .2rem 1rem 1.1rem; }
  .tr-token { min-width: 36px; min-height: 42px; padding: .5rem .55rem; font-size: .78rem; }
  .tr-lab .tr-token-button { min-width: 44px; min-height: 44px; padding: .5rem .55rem; font-size: .78rem; }
  .tr-matrix-value { font-size: .73rem; }
  .tr-catalog { grid-template-columns: 1fr; }
  .tr-article > .callout { padding: 1rem; }
  .tr-reading-tools a { font-size: .7rem; padding: .5rem .65rem; }
  .tr-formula { padding: .7rem; font-size: .95rem; }
  .tr-article > h2 { margin-top: 2.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tr-series *, .tr-series *::before, .tr-series *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .tr-series .blog-sidebar, .tr-reading-tools { display: none !important; }
  .tr-series .blog-post-layout { display: block; }
  .tr-lab { box-shadow: none; }
}
