/* The crew inside the app (switch dv_crewapp; src/lib/crewapp.ts). Loaded last, only while the switch is On, never on the door, poster, badge, camera or big-screen pages.
   Three small things: (1) the moments, (2) Wick's flame while a button waits, (3) the night colours (only with the brand look as well; body.cw-night).
   Rules kept: only transform and opacity move; nothing changes the size or place of anything already on the page (a moment is fixed, takes no tap, and is placed by the
   script where it covers nothing); the shared variables only (no typeface, no raw colour for the crew: their colours are written on the drawings); with "reduce motion"
   every moment is a still picture and the flame stands still. */

/* ---------- 1. the moments ---------- */
.cw-m{position:fixed;z-index:70;pointer-events:none;display:flex;align-items:flex-end;opacity:0;animation:cw-life 1.9s linear both}
.cw-m__c{display:block;line-height:0}
.cw-m svg{display:block;overflow:visible}
@keyframes cw-life{0%{opacity:0}10%,82%{opacity:1}100%{opacity:0}}

/* Wick: a small window lights, a fine brass line joins two faces */
.cw-m--wick{align-items:center;gap:8px;padding:5px 12px 5px 10px;box-sizing:border-box;border-radius:var(--r,16px);background:var(--paper,#fff);border:1px solid var(--line,#E3DED3)}
.cw-m--wick .cw-m__c{animation:cw-lift 1.9s var(--ease,cubic-bezier(.2,.8,.2,1)) both}
.cw-win__dark{fill:none;stroke:var(--ink,#16130F);stroke-width:1.4;opacity:.35}
.cw-win__lit{fill:var(--sand,#F1E4D3);stroke:var(--thread,#B08D57);stroke-width:1.4;opacity:0;transform-box:fill-box}
.cw-face{fill:var(--green,#0E5A43);opacity:.9}
.cw-thread{fill:var(--thread,#B08D57);transform-box:fill-box;transform-origin:0 50%;transform:scaleX(0);animation:cw-draw .6s var(--ease,cubic-bezier(.2,.8,.2,1)) .6s both}
.cw-win--a .cw-win__lit{animation:cw-lit .4s ease-out .3s both}
.cw-win--b .cw-win__lit{animation:cw-lit .4s ease-out 1.1s both}
.cw-win .cw-face{transform-box:fill-box;transform-origin:50% 100%}
.cw-win--b .cw-face{animation:cw-wake .4s var(--ease,cubic-bezier(.2,.8,.2,1)) 1.1s both}
@keyframes cw-lit{from{opacity:0}to{opacity:1}}
@keyframes cw-draw{to{transform:scaleX(1)}}
@keyframes cw-wake{from{transform:scale(.88)}to{transform:scale(1)}}
@keyframes cw-lift{0%,45%{transform:translateY(0)}60%{transform:translateY(-5px)}78%,100%{transform:translateY(0)}}

/* Wick stands a little smaller inside his window card */
.cw-m--wick .cw-m__c svg{width:34px;height:auto}

/* Nib: holds the card up beside the sheet's title */
.cw-m--nib .cw-m__c{animation:cw-hop 1.9s var(--ease,cubic-bezier(.2,.8,.2,1)) both}
@keyframes cw-hop{0%{transform:translateY(8px)}15%{transform:translateY(0)}28%{transform:translateY(-5px)}40%,100%{transform:translateY(0)}}

/* the small Nib, beside a screen's title (the card turned over) */
.cw-m--small svg{width:40px;height:auto}

/* Ring: swings in, hanging from its strings */
.cw-m--ring .cw-m__c{transform-origin:50% 0;animation:cw-swing 1.9s ease-out both}
@keyframes cw-swing{0%{transform:rotate(-30deg)}22%{transform:rotate(20deg)}42%{transform:rotate(-11deg)}60%{transform:rotate(5deg)}78%,100%{transform:rotate(0)}}

/* Latch: the door opens (shut and open drawn one over the other) */
.cw-m--latch .cw-m__c{position:relative;animation:cw-hop 1.9s var(--ease,cubic-bezier(.2,.8,.2,1)) .1s both}
.cw-m--latch .cw-open{position:absolute;left:0;top:0;opacity:0;animation:cw-lit .35s ease-out .55s both}
.cw-m--latch .cw-shut{display:block;animation:cw-gone .35s ease-out .55s both}
@keyframes cw-gone{to{opacity:0}}

/* reduced motion: one still picture, complete (the line drawn, the window lit, the door open) */
.cw-m.is-still,.cw-m.is-still *{animation:none!important}
.cw-m.is-still{opacity:1}
.cw-m.is-still .cw-win__lit{opacity:1}
.cw-m.is-still .cw-thread{transform:none}
.cw-m.is-still .cw-open{opacity:1}
.cw-m.is-still .cw-shut{opacity:0}
@media(prefers-reduced-motion:reduce){.cw-m,.cw-m *{animation:none!important}.cw-m{opacity:1}.cw-win__lit{opacity:1}.cw-thread{transform:none}.cw-m--latch .cw-open{opacity:1}.cw-m--latch .cw-shut{opacity:0}}

/* the three empty screens: Wick, Ring and Latch stand still above the words (the picture is on the server; no script needed) */
.cw-empty .cw-char{margin-bottom:6px}
.cw-char__svg{display:inline-block;max-width:100%}

/* ---------- 2. Wick's flame while a button waits ----------
   The button's own small ring (app.js adds is-wait after a quarter of a second) is replaced by Wick's flame, which shows only from half a second: it stays invisible for the first
   quarter second after the button starts waiting. A wait shorter than half a second shows nothing. */
body.cw .btn.is-wait::after{width:12px;height:15px;border:0;border-radius:0;background:currentColor;-webkit-mask:var(--cw-flame) center/contain no-repeat;mask:var(--cw-flame) center/contain no-repeat;opacity:0;animation:cw-flame-in .2s ease-out .25s forwards,cw-flicker 1.3s ease-in-out .45s infinite}
body.cw .kit-say::before{content:"";display:inline-block;width:11px;height:14px;margin-right:7px;vertical-align:-2px;background:var(--green,#0E5A43);-webkit-mask:var(--cw-flame) center/contain no-repeat;mask:var(--cw-flame) center/contain no-repeat;animation:cw-flicker 1.3s ease-in-out infinite}
:root{--cw-flame:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 30'%3E%3Cpath d='M12 1q11 12 11 20a11 11 0 0 1-22 0q0-8 11-20z'/%3E%3C/svg%3E")}
@keyframes cw-flame-in{to{opacity:1}}
@keyframes cw-flicker{0%,100%{transform:scale(1) rotate(0)}30%{transform:scale(1.08,.94) rotate(-3deg)}60%{transform:scale(.94,1.06) rotate(2.5deg)}}
@media(prefers-reduced-motion:reduce){body.cw .btn.is-wait::after{animation:cw-flame-in .01s linear .25s forwards}body.cw .kit-say::before{animation:none}}

/* ---------- 3. the night colours (brand look as well): the shared night surface, brass on dark, every word at 7 to 1 or better ----------
   The night look (calm.css + night.css, switched off by its own switch) and the door pass (always dark) both paint #16130F and a handful of greys. Here they take the one dark
   surface (--night) and lighter greys; nothing about a size or a space changes. */
body.cw.cw-night{
  color-scheme:dark;
  --bg:var(--night,#0F1914); --paper:#16231C; --fill:#1C2D25; --tint:#1C2D25; --sage:#1A2A22; --sand:#1C2D25;
  --ink:#F6F3EC; --ink2:#E0DACE; --mute:#CFC8BA; --muted:#CFC8BA; --field:#B3AB9C;
  --line:rgba(246,243,236,.16); --line2:rgba(246,243,236,.28);
  --brass:var(--thread-on-dark,#C9A86A); --thread:var(--thread-on-dark,#C9A86A);
  --green-d:#8FDDBB; --blue-d:#8FDDBB; --mint-ink:#8FDDBB; --ok:#8FDDBB; --focus:#8FDDBB; --warn-ink:#F7C778; --coral-ink:#EBAE8B;
  background:var(--night,#0F1914);
}
html:has(body.cw-night){background:var(--night,#0F1914)}
body.cw-night .topbar--back,body.cw-night .apphead{background:var(--night,#0F1914)}
body.cw-night .tabbar,body.cw-night .tabbar--shape,body.cw-night.has-tab .tabbar__in{background:var(--night,#0F1914);border-color:var(--line)}
body.cw-night .totop,body.cw-night .sheet{background:var(--paper)}
body.cw-night .topbar__t,body.cw-night .topbar__brand,body.cw-night .topbar .iconbtn,body.cw-night .apphead__t{color:var(--ink)}
body.cw-night .apphead__hi,body.cw-night .page>.muted,body.cw-night .page>.fine,body.cw-night .page>.lead,body.cw-night .page>.prose,body.cw-night .block>.muted,body.cw-night .numbers span,
body.cw-night .find__none,body.cw-night .find__ask,body.cw-night .meet-note,body.cw-night .qshare__help,body.cw-night .l3-line,body.cw-night .pw__list span,body.cw-night .pw .muted{color:var(--mute)}
body.cw-night :is(.tabbar--shape .tab,.tab){color:var(--ink2)}
body.cw-night input::placeholder,body.cw-night textarea::placeholder{color:var(--field)}
body.cw-night :is(.toast,.skip,.pitch,.chart__tip,.md-crew){background:var(--fill);color:var(--ink)}
body.cw-night :is(.card,.hcard,.kpi,.joinbox,.teaser,.hostband,.hostlink,.note,.nudge,.pin,.tip,.inbox,.esum,.qa,.badge,.act,.erow__d,.md,.md__p,.elist li,.plist li:not(.lhead),.sk-card){background:var(--paper);border-color:var(--line)}
body.cw-night :is(input[type=text],input[type=email],input[type=tel],input[type=password],input[type=number],input[type=search],input[type=url],select,textarea){background:var(--fill);border-color:var(--field);color:var(--ink)}
body.cw-night :is(.btn--soft,.btn--ghost,.btn--white,.btn--tile){background:transparent;border-color:rgba(246,243,236,.8);color:var(--ink)}
body.cw-night .btn--text{color:var(--green-d)}
body.cw-night :is(.pill--live,.pill--ok,.nected,.md__live,.md__in,.youin small,.pp-link a,.pp-pubtrust){color:var(--green-d)}
body.cw-night :is(.fine.is-bad,.linkbtn--danger,.btn--text.btn--danger){color:var(--coral-ink)}
body.cw-night .dr-pass__card,body.cw-night .dr-pass__card::before{border-color:var(--thread-on-dark,#C9A86A)}
/* small coloured things whose own colours were set for a light page (the doubled class is to win over night.css's longer selectors): a solid dark tint under white words (white on these is 9 to 1 or better) */
body.cw.cw-night.cw-night .tab__badge{background:#8E1B14;color:#fff}
body.cw.cw-night.cw-night :is(.pill--live,.pill--ok,.md__live,.md__in,.nected){background:#1F3A2E;color:#fff}
body.cw.cw-night.cw-night :is(.seg a.is-on,.seg button.is-on,.mb-seg a.is-on,.fyseg__a.is-on){background:#2E4A3C;color:#fff}
body.cw.cw-night.cw-night :is(.dy-row__k,.eyebrow){color:var(--thread-on-dark,#C9A86A)}
/* the moment on a dark page: the crew are drawn in ink for paper, so each stands on a small paper card (the one the whole app uses), and keeps its own colours */
body.cw-night .cw-m{--cw-card:#F6F3EC;background:var(--cw-card);border:1px solid var(--thread-on-dark,#C9A86A);border-radius:var(--r,16px);box-sizing:border-box;padding:3px 4px}
body.cw-night .cw-m--wick{padding:5px 12px 5px 10px}
body.cw-night .cw-m--nib.cw-m--small{padding:2px}
