/* ═══════════════════════════════════════════════════════════════════════
   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: #5b6a3a; 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%, #2a2150 0%, #14132c 55%, #0d0f1f 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, #8a6a1c, #ffe08a, #8a6a1c); }
.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: #8d94b4; }
.adv-text { margin-top: 7px; padding: 9px 12px; border-radius: 4px 14px 14px 14px; font: 14px/1.5 Georgia, serif; color: #cfd3e8; 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: "a subpoena is being typed" ── */
#loading.overlay { background: radial-gradient(ellipse at 50% 38%, rgba(30, 24, 70, .96), rgba(5, 6, 14, .98) 70%); gap: 26px; }
.tw { position: relative; width: 220px; height: 232px; display: flex; flex-direction: column; align-items: center; }
.tw-paper { position: relative; z-index: 1; width: 132px; height: 128px; padding: 10px 10px; background: linear-gradient(180deg, #f7edcd, #e8d8a8); border-radius: 3px 3px 0 0; box-shadow: 0 6px 14px rgba(0, 0, 0, .5);
  transform-origin: 50% 100%; animation: paper-feed 3.2s ease-in-out infinite; }
@keyframes paper-feed { 0% { transform: translateY(10px); } 12% { transform: translateY(0); } 88% { transform: translateY(0); } 100% { transform: translateY(10px); } }
.tw-head { font: 800 9px/1 Georgia, serif; letter-spacing: .4em; text-align: center; padding-bottom: 6px; border-bottom: 1px solid rgba(27, 24, 16, .5); color: #1b1810; }
.tw-ln { position: relative; height: 5px; margin-top: 9px; width: var(--w); } .tw-ln::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #2b2518 0 5px, transparent 5px 7px); opacity: .75; }
.tw-ln i { position: absolute; inset: -2px -2px -2px 0; background: #efe3bf; transform-origin: 100% 50%; animation: tw-type 3.2s steps(10) infinite; animation-delay: var(--d); }
@keyframes tw-type { 0%, 4% { transform: scaleX(1); } 26%, 96% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
.tw-stamp { position: absolute; right: 8px; bottom: 8px; padding: 2px 5px; border: 1.5px solid #a8201e; border-radius: 3px; color: #a8201e; font: 900 8px/1 Impact, 'Arial Black', sans-serif; letter-spacing: .1em; opacity: 0; transform: rotate(-12deg) scale(2); animation: tw-stamp 3.2s ease-out infinite; }
@keyframes tw-stamp { 0%, 80% { opacity: 0; transform: rotate(-12deg) scale(2.4); } 88% { opacity: .9; transform: rotate(-12deg) scale(1); } 96% { opacity: .9; } 100% { opacity: 0; } }
.tw-body { position: relative; z-index: 2; width: 220px; margin-top: -8px; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .6)); }
.tw-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 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; color: #cfd6f2; display: inline-block; text-align: center; }
.loading-line .tt-text { display: inline-block; }
.loading-line .tt-cover { position: absolute; inset: -2px -3px; background: #0a0b19; transform-origin: 100% 50%; animation: tt-wipe calc(var(--n) * 38ms) steps(var(--n)) both; border-left: 2px solid #ffd479; }
@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,
  .tw-paper, .tw-ln i, .tw-stamp, .tw-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; }
  .tw-ln i { transform: scaleX(0); }
}
