/* RATi Check-In. A tap board: topic cards of big emoji buttons that are also the live counts. */
:root {
  --bg: #eef4f5;
  --surface: #ffffff;
  --ink: #17262e;
  --muted: #56666f;
  --line: #d3dde1;
  --accent: #0d6f68;
  --accent-ink: #ffffff;
  --after: #b8650c;
  --track: #e2e9ec;
  --focus: #1f5fd1;
  --danger: #b3261e;
  --lv0: #8f9fa9;
  --lv1: #3f97c4;
  --lv2: #1f9a8a;
  --lv3: #e08a14;
  --font-display: ui-rounded, "SF Pro Rounded", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f171b; --surface: #17232a; --ink: #e6eef1; --muted: #9aabb3; --line: #2b3a41;
    --accent: #3fb3a8; --accent-ink: #062320; --after: #f0a24a; --track: #22313a; --focus: #7aa7ff; --danger: #ff8a80;
    --lv0: #8193a0; --lv1: #5fb4e0; --lv2: #3cc2ae; --lv3: #f4a540;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px; line-height: 1.45; overflow-x: hidden; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; line-height: 1.1; }
h1 { font-size: clamp(1.9rem, 5.5vw, 2.8rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; font-weight: 800; }
p { margin: 0; }
a { color: var(--accent); font-weight: 700; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 980px; margin: 0 auto; padding: 28px 16px 48px; display: grid; gap: 20px; }
.muted { color: var(--muted); }
.addr { user-select: all; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- board ---------- */
header { display: grid; gap: 8px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-weight: 700; color: var(--accent-ink); background: var(--accent); white-space: nowrap; }
.pill[data-phase="after"] { background: var(--after); color: #fff; }
.pill[data-phase="closed"] { background: var(--track); color: var(--ink); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
.pill[data-phase="closed"] .dot { animation: none; }
@keyframes pulse { 50% { opacity: .3; } }
.taps-total { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
header .ask { font-size: 1.15rem; color: var(--muted); }
header .key { font-size: 0.85rem; color: var(--muted); }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.topic { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 14px; min-width: 0; overflow: hidden; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.head h2 { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.head h2 .i { font-family: var(--font-emoji); font-weight: 400; }
.delta { flex: none; font-size: 0.85rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta b { color: var(--ink); }
.emojis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tap { --lv: var(--lv0); --p: 0%; overflow: hidden; isolation: isolate; position: relative; display: grid; justify-items: center; gap: 2px; padding: 10px 4px 8px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); cursor: pointer; transition: transform .12s ease, border-color .15s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.tap:hover { border-color: var(--lv); }
.tap:active { transform: scale(.92); }
.tap:disabled { cursor: not-allowed; opacity: .55; }
.tap .fill { position: absolute; inset: auto 0 0 0; height: var(--p); background: color-mix(in srgb, var(--lv) 30%, transparent); z-index: -1; transition: height .45s ease; }
.tap.has { border-color: color-mix(in srgb, var(--lv) 55%, var(--line)); }
.tap .e { font-family: var(--font-emoji); font-size: clamp(2rem, 7vw, 2.6rem); line-height: 1.1; }
.tap .w { font-size: 0.8rem; color: var(--muted); font-weight: 700; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.tap .n { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.tap.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }
.tap.boom { animation: boom .5s ease; }
@keyframes boom { 30% { transform: scale(1.18) rotate(-3deg); } 60% { transform: scale(.96) rotate(2deg); } }
.float { position: absolute; pointer-events: none; font-family: var(--font-emoji); font-size: 2rem; animation: rise 1.4s ease-out forwards; z-index: 2; }
@keyframes rise { from { transform: translate(0, 0) scale(.8); opacity: 1; } to { transform: translate(var(--dx), -160px) scale(1.3); opacity: 0; } }
.spark { position: absolute; pointer-events: none; font-family: var(--font-emoji); font-size: 1.1rem; animation: spark .9s ease-out forwards; z-index: 3; }
@keyframes spark { from { transform: translate(0, 0) scale(.4); opacity: 1; } to { transform: translate(var(--sx), var(--sy)) scale(1.1); opacity: 0; } }

.status { color: var(--muted); font-size: 0.9rem; min-height: 1.3em; }
.foot { display: grid; gap: 10px; font-size: 0.95rem; color: var(--muted); }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.sheet summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.sheet ul { margin: 10px 0 0; padding-left: 1.2em; display: grid; gap: 6px; }
.sheet .sheet-body { margin-top: 10px; display: grid; gap: 10px; }
.note { overflow-wrap: anywhere; }

.btn { font-weight: 700; border-radius: 10px; padding: 10px 16px; border: 2px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.btn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.join { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.qr { width: 132px; height: 132px; background: #fff; border-radius: 10px; padding: 6px; }
.qr svg { display: block; width: 100%; height: 100%; }
.join-url { font-family: ui-monospace, Menlo, monospace; font-size: 0.9rem; }

body.screen .foot, body.screen .key { display: none; }
body.screen .wrap { max-width: 1400px; }
body.screen .tap .e { font-size: 3.4rem; }
body.screen .board[data-count="4"], body.screen .board[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.screen .board[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.screen-join { display: none; }
body.screen .screen-join { display: flex; align-items: center; gap: 16px; }
body.screen .screen-join .qr { width: 120px; height: 120px; }
body.screen header { grid-template-columns: minmax(0, 1fr) auto; }
body.screen header > :not(.screen-join) { grid-column: 1; }
body.screen .screen-join { grid-column: 2; grid-row: 1 / span 3; font-weight: 700; font-size: 1.1rem; }

.empty { padding: 40px 16px; text-align: center; display: grid; gap: 12px; justify-items: center; }

/* Phone: the board fits one screen. Cards share the height; details open as a sheet over the page. */
@media (max-width: 640px) {
  body.board-page { height: 100%; }
  html:has(body.board-page) { height: 100%; }
  .board-page { font-size: 15px; }
  .board-page .wrap { height: 100%; padding-block: 10px; gap: 8px; display: flex; flex-direction: column; }
  .board-page header { gap: 4px; }
  .board-page h1 { font-size: 1.35rem; }
  .board-page header .ask { font-size: 0.85rem; line-height: 1.3; }
  .board-page header .key { font-size: 0.72rem; line-height: 1.3; }
  .board-page .pill { padding: 4px 10px; font-size: 0.8rem; }
  .board-page .taps-total { font-size: 0.8rem; }
  .board-page .board { flex: 1 1 auto; min-height: 0; grid-template-columns: 1fr; grid-auto-rows: minmax(0, 1fr); gap: 8px; }
  .board-page .topic { padding: 8px 10px; gap: 6px; border-radius: 14px; grid-template-rows: auto minmax(0, 1fr); }
  .board-page .topic h2 { font-size: 0.95rem; }
  .board-page .delta { font-size: 0.72rem; padding: 2px 8px; }
  .board-page .emojis { height: 100%; gap: 6px; }
  .board-page .tap { padding: 2px; gap: 0; border-radius: 10px; align-content: center; }
  .board-page .tap .e { font-size: min(8vw, 4.4dvh); }
  .board-page .tap .w { font-size: 0.65rem; }
  .board-page .tap .n { font-size: 0.85rem; }
  .board-page .status { min-height: 0; font-size: 0.8rem; }
  .board-page .status:empty { display: none; }
  .board-page .foot { gap: 4px; font-size: 0.72rem; flex: 0 0 auto; }
  .board-page .sheet { padding: 6px 10px; border-radius: 10px; }
  .board-page .sheet[open] > .sheet-body, .board-page .sheet[open] > ul { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 10; margin: 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 40px rgb(0 0 0 / .25); font-size: 0.9rem; max-height: 75%; overflow: auto; }
  .board-page .sheet[open] > ul { padding-left: 32px; }
  .join { grid-template-columns: 1fr; justify-items: start; }
}

/* ---------- make a board ---------- */
.make form { display: grid; gap: 22px; }
.make fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; margin: 0; display: grid; gap: 10px; background: var(--surface); min-width: 0; }
.make legend { font-weight: 800; font-family: var(--font-display); padding: 0 6px; }
.make label { display: grid; gap: 4px; font-weight: 700; font-size: 0.95rem; }
.make .pair { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr); gap: 8px; align-items: end; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.make input[type="text"] { font-weight: 400; width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
.make input.emoji { text-align: center; font-family: var(--font-emoji); font-size: 1.5rem; padding: 4px; }
.make .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.make .levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.make .error { color: var(--danger); font-weight: 700; }
.lede { color: var(--muted); max-width: 62ch; font-size: 1.1rem; }
.made { display: grid; gap: 16px; background: var(--surface); border: 2px solid var(--accent); border-radius: 16px; padding: 18px; }
.made .link-row { display: grid; gap: 6px; }
.made .warn { color: var(--danger); font-weight: 700; font-size: 0.9rem; }
.rules { color: var(--muted); font-size: 0.9rem; display: grid; gap: 6px; }
.rules ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  .tap, .tap .fill { transition: none; }
  .tap.bump, .tap.boom, .pill .dot { animation: none; }
  .float, .spark { display: none; }
}
