/*
 * Clef embed (css/embed.css): the /embed page only, after css/clef.css (tokens, .btn, .chip, .probs, .logo, .nil).
 * One card that fills the frame. html[data-theme="dark"] swaps the tokens; html.is-compact keeps one line per
 * question. js/embed.js sets both from the query (?theme=light|dark|auto, ?compact=1) before the first paint
 * it can reach; until it runs the card stays hidden for a moment so a dark frame never flashes white.
 */

html.em { background: var(--paper); }
html.em:not([data-ready]) body { opacity: 0; animation: em-show 0s .9s forwards; }
@keyframes em-show { to { opacity: 1; } }

html[data-theme='dark'] {
  color-scheme: dark;
  --paper: #141211;
  --alabaster: #1a1816;
  --concrete: #24211f;
  --haze: #1f1c1a;
  --ink: #f5f1ec;
  --text: #e8e2db;
  --body: #d2cbc3;
  --muted: #a39b93;
  --faint: #7d7670;
  --line: #2e2a27;
  --line-2: #3b3632;
  --orange-text: #ff8b5a;
  --orange-deep: #ff7a45;
  --rust: #f0a882;
  --cream: #1d1714;
  --cream-2: #241a15;
  --amber: #6b4524;
  --amber-soft: #4a3220;
  --sand: #33291f;
  --sand-2: #6e5843;
  --chip: #35231a;
  --chardon: #3a2418;
}
html[data-theme='dark'] .logo { box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); }
html[data-theme='dark'] .em-logo { box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }

html.em body { min-height: 100vh; min-height: 100dvh; background: var(--paper); color: var(--body); font-size: 15px; }

.em-card { flex: 1 0 auto; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); overflow: hidden; }
.em-in { display: grid; gap: 14px; padding: 14px 16px; }

/* head: the mark and the phase pill */
.em-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.em-head-r { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.em-play-mini { display: none; align-items: center; gap: 4px; min-height: 32px; font-size: 13px; font-weight: 600; color: var(--orange-deep); white-space: nowrap; }
.em-play-mini:hover { text-decoration: underline; text-underline-offset: 3px; }
.em-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); min-height: 32px; }
.em-logo { width: 22px; height: 22px; border-radius: 6px; box-shadow: 0 0 0 1px rgba(21, 20, 20, .08); }
.em-name { font: 600 13.5px/1 var(--display); letter-spacing: .32em; margin-right: -.32em; }
.em-phase { display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px 0 8px; border-radius: 999px; background: var(--chip); color: var(--rust); font: 600 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.em-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); animation: pulse 1.6s var(--ease) infinite; }
.em-phase.is-wait .em-dot { background: var(--faint); animation: none; }

/* round, countdown, pool: three small figures split by hairlines */
.em-meta { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: end; border-block: 1px solid var(--line); padding-block: 9px; }
.em-stat { display: grid; gap: 5px; min-width: 0; padding: 0 14px; border-left: 1px solid var(--line); }
.em-stat:first-child { padding-left: 0; border-left: 0; }
.em-k { font: 600 10.5px/1.2 var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.em-v { font: 500 15px/1.2 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 18px; }
.em-pool .em-v { font-size: 13px; color: var(--body); white-space: normal; overflow: visible; }

/* questions */
.em-qs { display: grid; gap: 12px; }
.em-q { display: grid; gap: 8px; min-width: 0; }
.em-q + .em-q { padding-top: 12px; border-top: 1px dashed var(--line-2); }
.em-q-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.em-q-title { font: 600 14px/1.35 var(--display); letter-spacing: -.01em; color: var(--ink); text-wrap: pretty; min-width: 0; }
.em-chip { flex: none; height: 20px; padding: 0 7px; font-size: 10px; }
.em-q .probs { gap: 5px; }
.em-q .prob { row-gap: 4px; }
.em-q .prob-name { font-size: 13.5px; line-height: 1.2; }
.em-q .prob-val { font-size: 13px; }
.em-q .prob-bar { height: 3px; }
.em-q.is-skel { gap: 10px; }
.em-q.is-skel .em-q-title { font: 400 13.5px/1.4 var(--sans); color: var(--muted); }
.em-skel { display: block; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--concrete), var(--line), var(--concrete)); background-size: 200% 100%; animation: nil-shimmer 1.6s linear infinite; }
.em-skel + .em-skel { width: 70%; }

/* foot: one line on the baseline, one button out */
.em-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.em-note { flex: 1 1 200px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.em-note b { color: var(--body); font-weight: 600; }
.em-play { flex: none; }

/* compact: a header line, then one row per question (title, top answer) over a split bar */
.is-compact .em-in { gap: 10px; padding: 10px 14px 14px; }
.is-compact .em-meta { display: flex; flex-wrap: wrap; row-gap: 4px; padding-block: 0; border: 0; }
.is-compact .em-pool { display: none; }
.is-compact .em-stat { grid-auto-flow: column; align-items: baseline; gap: 6px; padding: 0 10px; }
.is-compact .em-stat:first-child { padding-left: 0; }
.is-compact .em-v { font-size: 13.5px; }
.is-compact .em-qs { gap: 8px; }
.is-compact .em-q { gap: 6px; }
.is-compact .em-q + .em-q { padding-top: 8px; }
.is-compact .em-q-head { align-items: center; }
/* the whole question stays readable: it wraps to a second line on a narrow frame instead of being cut off */
.is-compact .em-q-title { font-size: 13.5px; line-height: 1.3; }
.em-pick { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); white-space: nowrap; }
.em-pick-name { font-weight: 600; }
.em-pick-val { font: 600 12.5px/1 var(--mono); color: var(--orange-text); }
.em-split { display: flex; gap: 2px; height: 4px; }
.em-split > i { display: block; flex: var(--p, 1) 1 0; min-width: 2px; border-radius: 999px; background: var(--sand-2); }
.em-split > i.is-top { background: var(--orange); }
.is-compact .em-foot { display: none; }
.is-compact .em-play-mini { display: inline-flex; }

@media (max-width: 400px) {
  .is-compact .em-long { display: none; }
  /* the pool figure takes its own row, so "No entries yet" or a stake with its entry count is never cut */
  .em-meta { grid-template-columns: auto auto; row-gap: 10px; }
  .em-pool { grid-column: 1 / -1; padding-left: 0; border-left: 0; }
  .is-compact .em-pool { display: none; }
}
@media (max-width: 360px) {
  .em-in { padding: 14px 14px; }
  .em-stat { padding: 0 10px; }
}
