/* ═══════════════════════════════════════════════════════════════════════
   CAPITOL — polish.css              (#7  the small stuff)
   Ledger chips · Prince lesson box · meeting room · loading overlay · beat transition.
   Pair with polish.js (small helpers).  transform/opacity animation only; reduced-motion safe.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1 · Ledger chips: pulse + number bump ── */
.ledger-chip { position: relative; --lc: var(--mute); }
.ledger-chip::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 2px solid transparent; opacity: 0; pointer-events: none; }
.ledger-chip.pulse-good::after { border-color: #4ad295; animation: lc-pulse .9s ease-out; }
.ledger-chip.pulse-bad::after { border-color: #ff5a5f; animation: lc-pulse .9s ease-out; }
@keyframes lc-pulse { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.14, 1.5); } }
.ledger-chip.pulse-good, .ledger-chip.pulse-bad { animation: lc-hop .5s cubic-bezier(.3, 1.5, .4, 1); }
@keyframes lc-hop { 0% { transform: scale(1); } 35% { transform: scale(1.06); } 100% { transform: scale(1); } }
.ledger-chip .lv.bump { animation: lv-bump .5s cubic-bezier(.3, 1.6, .4, 1); display: inline-block; }
.ledger-chip.pulse-good .lv { color: #6ee8b0; } .ledger-chip.pulse-bad .lv { color: #ff8a8f; }
@keyframes lv-bump { 0% { transform: scale(1); } 40% { transform: scale(1.5) translateY(-2px); } 100% { transform: scale(1); } }

/* ── 2 · The Prince lesson box: ink-in flourish, quill, laurels ── */
.prince.ink { position: relative; overflow: visible; }
.prince.ink .w { display: inline-block; opacity: 0; transform: translateY(3px); animation: ink-word .5s ease-out both; animation-delay: calc(.7s + var(--k) * 70ms); }
@keyframes ink-word { 0% { opacity: 0; transform: translateY(3px); } 40% { opacity: .9; } 100% { opacity: 1; transform: none; } }
.prince.ink .prince-kicker { animation: ink-word .6s .15s ease-out both; }
.prince .laurel { position: absolute; top: 50%; width: 5.4cqw; max-width: 28px; min-width: 18px; height: auto; margin-top: -4.4cqw; color: var(--gold, #d4a93c); opacity: 0; animation: laurel-in .8s .3s cubic-bezier(.2, .9, .3, 1.2) both; }
.prince .laurel.l { left: -3.4cqw; transform-origin: 70% 100%; } .prince .laurel.r { right: -3.4cqw; transform: scaleX(-1); animation-name: laurel-in-r; transform-origin: 30% 100%; }
@keyframes laurel-in { from { opacity: 0; transform: scale(.3) rotate(-30deg); } to { opacity: .9; transform: none; } }
@keyframes laurel-in-r { from { opacity: 0; transform: scaleX(-1) scale(.3) rotate(-30deg); } to { opacity: .9; transform: scaleX(-1); } }
.prince .quill { position: absolute; right: 4cqw; bottom: 1.6cqw; width: 8cqw; max-width: 40px; min-width: 24px; opacity: 0; transform-origin: 10% 90%;
  animation: quill-write calc(var(--words) * 70ms + 1.2s) .6s ease-in-out both; pointer-events: none; }
@keyframes quill-write { 0% { opacity: 0; transform: translate(-30px, 10px) rotate(-20deg); } 8% { opacity: 1; } 18%, 34%, 50%, 66%, 82% { transform: translate(-16px, 2px) rotate(-8deg); } 26%, 42%, 58%, 74% { transform: translate(-10px, 6px) rotate(-14deg); }
  92% { opacity: 1; } 100% { opacity: 0; transform: translate(10px, -14px) rotate(8deg); } }

/* ── 3 · The meeting room ── */
.meeting { position: relative; margin-top: 18px; padding: 16px 14px 8px; border-radius: 18px; overflow: hidden; isolation: isolate;
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--accent,#b0121f) 40%, #0d0509) 0%, color-mix(in srgb, var(--accent,#b0121f) 16%, #0a0507) 60%, #080406 100%); border: 1px solid rgba(255, 255, 255, .1); box-shadow: 0 12px 28px rgba(0, 0, 0, .4); }
.meeting::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: linear-gradient(90deg, color-mix(in srgb, var(--gold,#d4a93c) 60%, #000), var(--gold,#d4a93c), color-mix(in srgb, var(--gold,#d4a93c) 60%, #000)); }
.meeting-label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font: 700 10px/1 -apple-system, sans-serif; letter-spacing: .26em; text-transform: uppercase; color: #ffd479; }
.meeting-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ffd479; box-shadow: 0 0 10px #ffd479; }
.adv-line { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 12px 6px 12px 8px; border-top: 1px solid rgba(255, 255, 255, .08); transition: transform .25s; }
.adv-line:first-of-type { border-top: 0; }
.adv-line::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: #ffd479; transform: scaleY(0); transform-origin: 50% 50%; transition: transform .3s cubic-bezier(.2, .9, .3, 1.2); }
.adv-line.speaking::before { transform: scaleY(1); }
.adv-face { position: relative; flex: 0 0 auto; width: 46px; height: 46px; }
.adv-face svg { display: block; width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 0 0 2px #0d0f1f, 0 0 0 3px rgba(255, 255, 255, .2); }
.adv-face::after { content: ""; position: absolute; inset: -4px; border-radius: 17px; border: 2px solid #ffd479; opacity: 0; pointer-events: none; }
.adv-line.speaking .adv-face::after { animation: face-ring 1.2s ease-out infinite; }
@keyframes face-ring { 0% { opacity: .9; transform: scale(.94); } 100% { opacity: 0; transform: scale(1.35); } }
.adv-line.speaking .adv-face svg { animation: face-talk .5s ease-in-out infinite alternate; }
@keyframes face-talk { from { transform: translateY(0) scale(1); } to { transform: translateY(-1.5px) scale(1.03); } }
.adv-play { flex: 0 0 auto; order: 3; width: 32px; height: 32px; margin-top: 6px; border-radius: 50%; border: 1px solid rgba(255, 212, 121, .5); background: rgba(255, 212, 121, .08); color: #ffd479; font-size: 11px; cursor: pointer; display: grid; place-items: center; padding: 0; position: relative; }
.adv-play::after { content: ""; position: absolute; inset: -1px; border-radius: 50%; border: 2px solid #ffd479; opacity: 0; }
.adv-line.speaking .adv-play { background: #ffd479; color: #2a1a04; animation: none; box-shadow: none; }
.adv-line.speaking .adv-play::after { animation: face-ring 1.2s ease-out infinite; }
.adv-body { flex: 1; min-width: 0; }
.adv-who { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
/* brass nameplate */
.adv-name { display: inline-block; padding: 3px 9px 2px; border-radius: 3px; font: 800 11px/1.2 Georgia, serif; letter-spacing: .1em; text-transform: uppercase; color: #2a1a04;
  background: linear-gradient(180deg, #ffeaa0 0%, #e0b040 48%, #b8861c 52%, #f0c85a 100%); box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 2px 4px rgba(0, 0, 0, .5); text-shadow: 0 1px 0 rgba(255, 255, 255, .35); }
.adv-title { font: 700 9px/1 -apple-system, sans-serif; letter-spacing: .18em; text-transform: uppercase; color: color-mix(in srgb, var(--paper,#e9dfc4) 55%, transparent); }
.adv-text { margin-top: 7px; padding: 9px 12px; border-radius: 4px 14px 14px 14px; font: 14px/1.5 Georgia, serif; color: var(--paper, #e9dfc4); background: rgba(255, 255, 255, .055); border: 1px solid rgba(255, 255, 255, .07); transition: background .25s, color .25s; }
.adv-line.speaking .adv-text { background: rgba(255, 212, 121, .12); border-color: rgba(255, 212, 121, .35); color: #fff; }

/* ── 4 · Loading overlay: THE TELEPRINTER (TASS) — paper with feed holes, tatty courier, a red star on the carriage ── */
#loading.overlay { background: radial-gradient(ellipse at 50% 38%, color-mix(in srgb, var(--accent, #b0121f) 22%, #0a0509), var(--night, #09090d) 72%); gap: 26px; }
.tp { position: relative; width: 236px; height: 262px; display: flex; flex-direction: column; align-items: center; }
.tp-paper { position: relative; z-index: 1; width: 156px; height: 152px; overflow: hidden; border-radius: 2px 2px 0 0; box-shadow: 0 6px 14px rgba(0,0,0,.55);
  background: linear-gradient(180deg, color-mix(in srgb, var(--paper, #e9dfc4) 94%, #fff), var(--paper, #e9dfc4)); }
.tp-paper::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.28), transparent 26%); }          /* in shadow where it leaves the platen */
.tp-feed { position: absolute; top: 0; bottom: 0; width: 13px; background: rgba(0,0,0,.07); overflow: hidden; }
.tp-feed.l { left: 0; border-right: 1px dashed rgba(0,0,0,.25); } .tp-feed.r { right: 0; border-left: 1px dashed rgba(0,0,0,.25); }
.tp-feed i { position: absolute; left: 0; right: 0; top: -12px; bottom: -12px; background: radial-gradient(circle at 50% 6px, #0a0509 2.3px, transparent 2.9px) 0 0 / 13px 12px; animation: tp-roll 1.3s linear infinite; }
@keyframes tp-roll { from { transform: translateY(0); } to { transform: translateY(12px); } }
.tp-sheet { position: absolute; inset: 0 16px 0 16px; padding: 14px 0 0; animation: tp-feed 4.4s ease-in-out infinite; }
@keyframes tp-feed { 0% { transform: translateY(14px); } 14% { transform: translateY(0); } 86% { transform: translateY(0); } 100% { transform: translateY(14px); } }
.tp-head { font: 800 8px/1 Courier New, Courier, monospace; letter-spacing: .3em; text-align: center; padding-bottom: 6px; border-bottom: 1px solid rgba(23,19,14,.5); color: var(--ink, #17130e); }
.tp-line { position: relative; margin-top: 9px; font: 700 8.6px/1.2 'Courier New', Courier, monospace; letter-spacing: .04em; color: #1a1612; white-space: nowrap; text-shadow: .4px 0 0 rgba(26,22,18,.5); }   /* tatty: uneven ink */
.tp-line i { position: absolute; inset: -2px -2px -2px 0; background: var(--paper, #e9dfc4); transform-origin: 100% 50%; animation: tp-type 4.4s steps(22) infinite; }
@keyframes tp-type { 0%, 6% { transform: scaleX(1); } 34%, 96% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
.tp-bar { position: relative; height: 5px; margin-top: 9px; width: var(--w); } .tp-bar::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #2b2518 0 4px, transparent 4px 6px); opacity: .65; }
.tp-bar i { position: absolute; inset: -2px -2px -2px 0; background: var(--paper, #e9dfc4); transform-origin: 100% 50%; animation: tp-type 4.4s steps(10) infinite; animation-delay: var(--d); }
.tp-body { position: relative; z-index: 2; width: 236px; margin-top: -10px; filter: drop-shadow(0 10px 18px rgba(0,0,0,.6)); }
.tp-star { animation: tp-carriage 2.6s ease-in-out infinite alternate; transform-box: fill-box; }
@keyframes tp-carriage { from { transform: translateX(-38px); } to { transform: translateX(38px); } }
.tp-keys .k { animation: key-press 2.2s ease-in-out infinite; transform-box: fill-box; }
@keyframes key-press { 0%, 86%, 100% { transform: translateY(0); opacity: .95; } 92% { transform: translateY(3px); opacity: .55; } }
.loading-line { position: relative; min-height: 18px; font: 700 12px/1.3 'Courier New', Courier, ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: color-mix(in srgb, var(--paper, #e9dfc4) 82%, transparent); display: inline-block; text-align: center; }
.loading-line .tt-text { display: inline-block; }
.loading-line .tt-cover { position: absolute; inset: -2px -3px; background: var(--night, #09090d); transform-origin: 100% 50%; animation: tt-wipe calc(var(--n) * 38ms) steps(var(--n)) both; border-left: 2px solid var(--accent, #b0121f); }
@keyframes tt-wipe { from { transform: scaleX(1); } to { transform: scaleX(0); } }
#loading .loader-gavel, #loading .loader-ring { display: none; }

/* ── 5 · Beat transition: ink-fade out, page-turn in ── */
.beat-out { animation: beat-out .2s ease-in both; }
@keyframes beat-out { to { opacity: 0; transform: translateY(-6px); } }
.beat-in { transform-origin: 0 50%; animation: page-turn .55s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes page-turn { from { opacity: 0; transform: perspective(900px) rotateY(-16deg) translateX(18px); } to { opacity: 1; transform: none; } }
.beat-in > * { animation: ink-fade .5s ease both; }
.beat-in > *:nth-child(1) { animation-delay: .04s; } .beat-in > *:nth-child(2) { animation-delay: .12s; } .beat-in > *:nth-child(3) { animation-delay: .2s; } .beat-in > *:nth-child(4) { animation-delay: .28s; }
.beat-in > *:nth-child(5) { animation-delay: .36s; } .beat-in > *:nth-child(6) { animation-delay: .44s; } .beat-in > *:nth-child(n+7) { animation-delay: .5s; }
@keyframes ink-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ledger-chip::after, .ledger-chip, .lv, .prince .w, .prince-kicker, .prince .laurel, .prince .quill, .adv-line.speaking .adv-face::after, .adv-line.speaking .adv-face svg, .adv-line.speaking .adv-play::after,
  .tp-sheet, .tp-feed i, .tp-line i, .tp-bar i, .tp-star, .tp-keys .k, .tt-cover, .beat-in, .beat-in > *, .beat-out { animation: none !important; }
  .prince.ink .w, .prince .laurel { opacity: 1; transform: none; } .prince .laurel.r { transform: scaleX(-1); } .prince .quill { display: none; }
  .tp-line i, .tp-bar i { transform: scaleX(0); }
}

/* Soviet look for the lesson box: Party-school plaque, italic maxim in « » */
.prince.lesson .prince-maxim { font-style: italic; }
.prince.lesson { border-color: color-mix(in srgb, var(--gold,#d4a93c) 55%, transparent); }
