/* ═══ flow-dress.css — two dressing packs around the finished BeatFlow (KREMLIN) ═══
   RULES OF THIS FILE: it only ADDS paint. It never restyles .bf-machine / .bf-pane / .bf-chips / .bf-chip / .bf-adv* / .bf-nav (the settled parts), and it never sets
   display / position / width / height / margin on a client-owned class (.init-drawer, .init-open, .init-custom, #init-text, .init-sign, .opt-btn.init) — only
   background, border, colour, type, shadow, and its own pseudo-elements. Theming reads <body data-era> via eras.css vars (--accent --gold --paper --ink), with fallbacks.
   Motion: transform/opacity only. prefers-reduced-motion: stamp simply appears, nothing glides. Works from 320px up. */

/* ═════════════ 1. FOREIGN AFFAIRS — the cable treatment ═════════════
   Hook (the client wires it): add class  .foreign  to the telex paper element  →  <div class="bf-paper foreign" data-from="…" data-time="…" data-priority="…">.
   (.is-foreign and [data-foreign] are accepted too.)  flow-dress.js then adds the letterhead, the priority stamp and the wire-mark; remove the class and they go. */

/* its own document colour: cool blue-grey cable stock (era-tinted a few % toward --paper so 1922 still feels older than 1984) */
.bf-paper:is(.foreign, .is-foreign, [data-foreign]) {
  --bf-paper: color-mix(in srgb, #c3cfdb 88%, var(--paper, #efe6cf));
  --bf-ink: #15243b; --bf-rule: #28507f;
  background:
    repeating-linear-gradient(0deg, transparent 0 21px, rgba(40, 80, 127, .1) 21px 22px),
    linear-gradient(90deg, rgba(0,0,0,.1), transparent 6%, transparent 94%, rgba(0,0,0,.14)),
    linear-gradient(180deg, rgba(255,255,255,.28), transparent 14%),
    var(--bf-paper);
}
.bf-paper:is(.foreign, .is-foreign, [data-foreign]) .bf-text .ln.h { color: #28507f; border-bottom-color: #28507f; }
.bf-paper:is(.foreign, .is-foreign, [data-foreign]) .bf-caret { background: #15243b; }

/* the letterhead block: FROM / TIME / PRIORITY, a double rule, the issuing body for the era */
.fd-head { position: relative; z-index: 1; margin: 0 0 14px; padding: 0 0 10px; font-family: 'Courier New', ui-monospace, monospace; color: #15243b; border-bottom: 3px double #28507f; text-transform: uppercase; }
.fd-org { font: 800 10px/1.35 var(--sans, -apple-system, sans-serif); letter-spacing: .2em; color: #28507f; text-align: center; padding: 0 0 7px; }
.fd-org::before { content: "PEOPLE'S COMMISSARIAT FOR FOREIGN AFFAIRS"; }                       /* NKID → renamed in 1946 */
body[data-era="1953"] .fd-org::before, body[data-era="1964"] .fd-org::before, body[data-era="1984"] .fd-org::before, body[data-era="2027"] .fd-org::before { content: "MINISTRY OF FOREIGN AFFAIRS · USSR"; }
.fd-org::after { content: "CIPHERED CABLE"; display: block; margin-top: 3px; font-weight: 700; letter-spacing: .34em; font-size: 8.5px; opacity: .7; }
.fd-row { display: grid; grid-template-columns: 5.4em 1fr; gap: 0 8px; font: 600 11.5px/1.65 'Courier New', ui-monospace, monospace; letter-spacing: .06em; }
.fd-row b { font-weight: 800; color: #28507f; letter-spacing: .14em; }
.fd-row span { overflow-wrap: anywhere; }
.fd-row.pri span { font-weight: 800; color: #8d1420; }

/* the red priority stamp: slams in ONCE when the brief finishes typing. It lives in the paper (absolute), over the letterhead's right edge. */
.fd-stamp { position: absolute; z-index: 3; right: 46px; top: 106px; pointer-events: none; opacity: 0; transform: rotate(-9deg) scale(1); transform-origin: 50% 50%;
  padding: 5px 12px 4px; font: 900 14px/1 Impact, 'Arial Narrow Bold', 'Arial Black', sans-serif; letter-spacing: .12em; text-transform: uppercase; text-align: center; color: #b3111d;
  border: 3px solid #b3111d; border-radius: 4px; box-shadow: inset 0 0 0 1.5px rgba(179,17,29,.55); mix-blend-mode: multiply; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 1.7'/%3E%3C/filter%3E%3Crect width='120' height='60' filter='url(%23f)'/%3E%3C/svg%3E") center / 120px 60px; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 1.7'/%3E%3C/filter%3E%3Crect width='120' height='60' filter='url(%23f)'/%3E%3C/svg%3E") center / 120px 60px; }
.fd-stamp small { display: block; margin-top: 3px; font: 800 7.5px/1 var(--sans, sans-serif); letter-spacing: .3em; opacity: .85; }
.fd-stamp.set { opacity: .88; }                                                         /* static (revisits / reduced motion) */
.fd-stamp.slam { animation: fd-slam .42s cubic-bezier(.2, 1.4, .3, 1) both; }
@keyframes fd-slam { 0% { opacity: 0; transform: rotate(-9deg) scale(2.6); } 55% { opacity: .95; transform: rotate(-9deg) scale(.94); } 72% { transform: rotate(-9deg) scale(1.04); } 100% { opacity: .88; transform: rotate(-9deg) scale(1); } }
.bf-paper.fd-thud { animation: fd-thud .22s ease-out; }                                  /* the paper jumps a hair when the stamp lands (transform only) */
@keyframes fd-thud { 30% { transform: translateY(2px); } 100% { transform: none; } }

/* the wire-mark: a small seal pinned beside the chips row — the world is on the desk this month. Sits on .bf, outside the chips (chips untouched). */
.fd-wire { position: absolute; z-index: 7; top: 52px; right: 8px; width: 34px; height: 34px; pointer-events: none; opacity: 0; transform: scale(.6) rotate(-14deg); transition: opacity .35s, transform .45s cubic-bezier(.2, 1.3, .3, 1); filter: drop-shadow(0 3px 5px rgba(0,0,0,.6)); }
.fd-wire.on { opacity: 1; transform: none; }
.fd-wire .rim { transform-box: fill-box; transform-origin: center; animation: fd-wire 9s linear infinite; }
@keyframes fd-wire { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .fd-stamp.slam { animation: none; opacity: .88; } .bf-paper.fd-thud { animation: none; } .fd-wire { transition: none; } .fd-wire .rim { animation: none; }
}

/* ═════════════ 2. THE INITIATIVE — the leader's own pen ═════════════
   Hooks the client owns:  .init-drawer (the drawer)  .init-open (the opener / open state)  .init-custom (free-text order panel)  #init-text  .init-sign  .opt-btn.init (3 drafted moves)
   Plays left in hand: put data-left="2" data-max="2" on .init-drawer — flow-dress.js draws the nibs (first child of the drawer) and keeps them in step; or call FlowDress.nibs(drawerEl,{left,max}).
   Feeling: the leader's personal blotter — green leather, brass, ruled stationery, ink and a fountain pen — never desk paper. */

.init-drawer {
  --in-ink: #1b2a5e; --in-leather: #14261d; --in-brass: var(--gold, #d4a93c);
  color: #efe6cf;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.07), transparent 60%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.14) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, #1e3b2d, var(--in-leather) 55%, #0f1d16);
  border: 1px solid color-mix(in srgb, var(--in-brass) 60%, #000); border-top: 3px solid var(--in-brass);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.28), inset 0 2px 10px rgba(0,0,0,.5), 0 -10px 24px -12px #000;
}
/* the handle: a brass drawer pull on the opener */
:is(button, summary, a).init-open, .init-open:is(button, summary) { color: #1a1208; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
  background: linear-gradient(180deg, #f0d584, #c39a34 55%, #8f6c1c); border: 1px solid #5a430c; box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 3px 8px -3px #000; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
:is(button, summary, a).init-open::before { content: "✒"; margin-right: .5em; font-size: 1.1em; }

/* plays left: two nibs = two plays. Spent nibs are ghosted. */
.init-nibs { --left: 2; --max: 2; display: flex; justify-content: flex-end; align-items: center; gap: 7px; padding: 8px 12px 0; font: 800 8.5px/1 var(--sans, sans-serif); letter-spacing: .2em; text-transform: uppercase; color: color-mix(in srgb, var(--in-brass, #d4a93c) 75%, transparent); }
.init-nibs::before { content: "PLAYS IN HAND"; margin-right: auto; }
.init-nibs .nib { width: 15px; height: 26px; flex: none; background: var(--nib-img) center / contain no-repeat; opacity: .22; transform: rotate(18deg); }
.init-nibs .nib.on { opacity: 1; filter: drop-shadow(0 1px 0 rgba(0,0,0,.6)); }
.init-nibs { --nib-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 26'%3E%3Cpath d='M7.5 1 L13 12 Q14 17 11 22 L8.6 25 L8.6 17.6 a1.4 1.4 0 1 0 -2.2 0 L6.4 25 L4 22 Q1 17 2 12Z' fill='%23d4a93c' stroke='%237a5a14' stroke-width='.8'/%3E%3Cpath d='M7.5 1 V15' stroke='%237a5a14' stroke-width='.8'/%3E%3C/svg%3E"); }

/* the free-text order: ruled stationery — red margin, blue rules, a star watermark, handwriting */
.init-custom { background: transparent; }
#init-text {
  box-sizing: border-box; display: block; width: 100%; padding: 8px 14px 8px 44px; border: 1px solid rgba(0,0,0,.45); border-radius: 2px; resize: none; outline: none;
  font: 19px/28px 'Segoe Script', 'Bradley Hand', 'Lucida Handwriting', 'Snell Roundhand', 'Brush Script MT', cursive; color: var(--in-ink); caret-color: #8d1420; letter-spacing: .01em;
  background:
    linear-gradient(90deg, transparent 33px, rgba(176,18,31,.55) 33px 34.5px, transparent 34.5px),
    radial-gradient(circle at 50% 50%, rgba(176,18,31,.07) 0 22px, transparent 23px) 50% 12px / 60px 60px no-repeat,
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(40,80,160,.34) 27px 28px) 0 7px local,
    linear-gradient(180deg, #fbf6e6, #f3ecd4);
  box-shadow: inset 0 0 18px rgba(120,90,30,.2), 0 8px 16px -8px #000;
}
#init-text::placeholder { color: rgba(27,42,94,.42); font-style: italic; }
#init-text:focus { box-shadow: inset 0 0 18px rgba(120,90,30,.2), 0 0 0 2px var(--in-brass), 0 8px 16px -8px #000; }

/* SIGN IT: the fountain pen. A nib on the button, a signature flourish drawn under it. */
.init-sign { position: relative; overflow: visible; color: #fff3d0; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent, #b0121f) 85%, #fff), color-mix(in srgb, var(--accent, #b0121f) 60%, #000)); border: 2px solid var(--in-brass); box-shadow: 0 0 0 1px #000, 3px 3px 0 rgba(0,0,0,.55); }
.init-sign::before { content: ""; display: inline-block; width: 1.05em; height: 1.7em; margin-right: .6em; vertical-align: -.4em; transform: rotate(32deg); transform-origin: 50% 80%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 26'%3E%3Cpath d='M7.5 1 L13 12 Q14 17 11 22 L8.6 25 L8.6 17.6 a1.4 1.4 0 1 0 -2.2 0 L6.4 25 L4 22 Q1 17 2 12Z' fill='%23f2d27a' stroke='%237a5a14' stroke-width='.8'/%3E%3Cpath d='M7.5 1 V15' stroke='%237a5a14' stroke-width='.8'/%3E%3C/svg%3E") center / contain no-repeat; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.init-sign:hover::before, .init-sign:focus-visible::before, .init-sign:active::before { transform: rotate(32deg) translate(2px, 3px); }
.init-sign::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: -17px; height: 15px; pointer-events: none; opacity: .0; transform: translateX(-14px);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M2 14 C 18 -2 30 -2 36 10 S 52 20 62 8 S 80 -2 92 10 S 112 18 124 8 C 140 -4 158 2 170 12 L 198 6' fill='none' stroke='%23d4a93c' stroke-width='1.6' stroke-linecap='round'/%3E%3Cpath d='M40 17 H182' stroke='%23d4a93c' stroke-width='.8' opacity='.55'/%3E%3C/svg%3E") center / 100% 100% no-repeat; animation: fd-flourish .9s cubic-bezier(.2,.8,.2,1) .15s forwards; }
@keyframes fd-flourish { to { opacity: .95; transform: none; } }

/* the three drafted moves: the leader's own drafts on personal stationery — lined, red-margined, pen-initialled, taped on at a slight angle */
.opt-btn.init { position: relative; color: #1b2a5e; text-align: left; font-family: 'Segoe Script', 'Bradley Hand', 'Lucida Handwriting', Georgia, cursive; border: 1px solid rgba(0,0,0,.4); border-radius: 2px;
  background: linear-gradient(90deg, transparent 22px, rgba(176,18,31,.5) 22px 23.5px, transparent 23.5px), repeating-linear-gradient(180deg, transparent 0 25px, rgba(40,80,160,.26) 25px 26px), linear-gradient(180deg, #fbf6e6, #efe7cb);
  box-shadow: 0 6px 12px -6px #000, inset 0 0 12px rgba(120,90,30,.18); transform: rotate(-.5deg); }
.opt-btn.init:nth-of-type(even) { transform: rotate(.5deg); }
.opt-btn.init::before { content: ""; position: absolute; left: 50%; top: -7px; width: 46px; height: 14px; margin-left: -23px; background: rgba(214, 196, 140, .6); box-shadow: 0 1px 2px rgba(0,0,0,.3); transform: rotate(-2deg); pointer-events: none; }  /* a strip of tape */
.opt-btn.init::after { content: "✒"; position: absolute; right: 10px; top: 8px; font-size: 14px; color: rgba(27,42,94,.45); transform: rotate(35deg); pointer-events: none; }
.opt-btn.init small, .opt-btn.init .sub { font-family: Georgia, serif; font-style: italic; color: rgba(27,42,94,.7); }
.opt-btn.init:active { transform: rotate(0) scale(.985); }

@media (prefers-reduced-motion: reduce) { .init-sign::before, .init-sign::after { transition: none; animation: none; } .init-sign::after { opacity: .95; transform: none; } }
