/* Tint components, built only from /design/tokens.css. Used by the site, the launcher (/play/)
   and the web game's page. Rules and reasons: /design/DESIGN.md. */

/* ---------------- base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--t-page); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; overflow-x: hidden; overflow-x: clip; background: var(--t-page); color: var(--t-ink); font: var(--t-body); letter-spacing: var(--t-body-track);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none; }
input, textarea, code, .hash, .selectable { user-select: text; -webkit-user-select: text; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
img { height: auto; -webkit-user-drag: none; }
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--t-focus); outline-offset: 3px; }
::selection { background: var(--t-primary); color: #fff; }

.t-display { font: var(--t-display); letter-spacing: var(--t-display-track); }
h1, .t-title { font: var(--t-title); letter-spacing: var(--t-title-track); }
h2, .t-heading { font: var(--t-heading); letter-spacing: var(--t-heading-track); }
h3, .t-subhead { font: var(--t-subhead); letter-spacing: var(--t-subhead-track); }
.t-lead { font: var(--t-lead); letter-spacing: var(--t-lead-track); }
.t-small { font: var(--t-small); }
.t-ui { font: var(--t-ui); }
.t-warn { color: var(--t-warn); }
.t-danger { color: var(--t-danger); }
.t-link, .prose a { color: var(--t-accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
@media (hover: hover) { .t-link:hover, .prose a:hover { text-decoration-thickness: 2px; } }
.prose p + p { margin-top: var(--t-4); }
.prose p { max-width: var(--t-measure); }

/* icons: one sprite (/design/icons.svg), 24-unit outlines in currentColor */
.i { width: 24px; height: 24px; flex: none; }
.i-sm { width: 20px; height: 20px; }

/* ---------------- buttons ----------------
   One shape: a flat face with a darker block lip underneath. Hover lights the face; press sinks it
   by the lip. Labels are the pixel font at 16px. Heights: lg (the one main action), md, sm. */
.btn { --face: var(--t-secondary); --hover: var(--t-secondary-hover); --lipc: var(--t-secondary-lip);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--t-h-md); min-width: 0; margin: 0; padding: 0 22px var(--t-lip);
  font: var(--t-label); letter-spacing: 0; color: #fff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); white-space: nowrap;
  background: var(--face); border: 0; border-radius: var(--t-r-control); corner-shape: squircle;
  box-shadow: inset 0 calc(-1 * var(--t-lip)) 0 var(--lipc);
  cursor: pointer; -webkit-font-smoothing: none; -webkit-appearance: none; appearance: none;
  transition: background-color var(--t-quick); }
@media (hover: hover) { .btn:hover { background-color: var(--hover); } }
.btn:active { transform: translateY(2px); box-shadow: inset 0 -1px 0 var(--lipc); padding-bottom: 1px; }
.btn .i { margin-left: -4px; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .35)); }
.btn-primary { --face: var(--t-primary); --hover: var(--t-primary-hover); --lipc: var(--t-primary-lip); }
.btn-scene { --face: var(--t-scene); --hover: var(--t-scene-hover); --lipc: var(--t-scene-lip); }
.btn-danger { --face: var(--t-danger-face); --hover: var(--t-danger-hover); --lipc: var(--t-danger-lip); }
.btn-discord { --face: var(--t-discord); --hover: var(--t-discord-hover); --lipc: var(--t-discord-lip); }
.btn-lg { height: var(--t-h-lg); padding-inline: 32px; }
.btn-sm { height: var(--t-h-sm); padding-inline: 14px; }
.btn-icon { width: var(--t-h-md); padding-inline: 0; }
.btn-icon .i { margin: 0; }
.btn-lg.btn-icon { width: var(--t-h-lg); }
.btn-sm.btn-icon { width: var(--t-h-sm); }
.btn-wide { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { --face: var(--t-surface); --hover: var(--t-surface); --lipc: var(--t-sunken); cursor: default; transform: none; text-shadow: none; }
.btn[hidden] { display: none; }
.btn-discord .i { width: 26px; height: 26px; filter: none; }
.btn-discord.btn-sm .i { width: 20px; height: 20px; }
/* a row of buttons: one height, and the text buttons share one width */
.btn-row { display: flex; flex-wrap: wrap; gap: var(--t-3); }
.btn-row.even { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: max-content; max-width: 100%; }
.btn-row.even > .btn-icon { width: auto; }

/* ---------------- surfaces ---------------- */
.card { background: var(--t-surface); border: var(--t-hair); border-radius: var(--t-r-card); corner-shape: squircle; padding: var(--t-5); }
.card-pad-lg { padding: clamp(24px, 3vw, 40px); }
.tile { background: var(--t-surface); border: var(--t-hair); border-radius: var(--t-r-field); corner-shape: squircle; padding: var(--t-4); }
.pic { overflow: hidden; background: var(--t-surface); border: var(--t-hair); border-radius: var(--t-r-card); corner-shape: squircle; }
.pic img { width: 100%; height: 100%; object-fit: cover; }

/* chips: capsules for a short state ("Experimental", "0.1", "Coming") */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; font: 600 13px/1 var(--t-font); letter-spacing: .01em; white-space: nowrap;
  color: var(--t-ink); background: var(--t-raised); border-radius: var(--t-r-pill); }
.chip-warn { color: var(--t-warn); background: rgba(240, 184, 79, .12); }
.chip-on { background: var(--t-primary); }

/* ---------------- fields and switches ---------------- */
.field { display: block; width: 100%; height: var(--t-h-md); padding: 0 var(--t-4); font: var(--t-ui); color: var(--t-ink);
  background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-field); corner-shape: squircle; -webkit-appearance: none; appearance: none; }
.field::placeholder { color: var(--t-ink); opacity: 1; } /* no grey text: fields carry no placeholder; a label or a glyph says what goes in */
@media (hover: hover) { .field:hover { border-color: var(--t-line-strong); } }
.field:focus-visible { outline: 0; border-color: var(--t-accent); box-shadow: 0 0 0 1px var(--t-accent); }
.switch { flex: none; position: relative; width: 52px; height: 32px; padding: 0; cursor: pointer; background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-pill);
  -webkit-appearance: none; appearance: none; transition: background-color var(--t-move); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform var(--t-move); }
.switch[aria-checked="true"] { background: var(--t-primary); border-color: var(--t-primary); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* a slider: the progress capsule with the switch's white knob (--p 0..1 is the filled part, set by the page) */
.range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 32px; margin: 0; background: none; cursor: pointer; --p: .5; }
.range::-webkit-slider-runnable-track { height: 8px; background: linear-gradient(90deg, var(--t-accent) calc(var(--p) * 100%), var(--t-sunken) 0); border: var(--t-hair); border-radius: var(--t-r-pill); }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; margin-top: -9px; border: 0; border-radius: 50%; background: #fff; }
.range::-moz-range-track { height: 8px; background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-pill); }
.range::-moz-range-progress { height: 8px; background: var(--t-accent); border-radius: var(--t-r-pill); }
.range::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }
.range:focus-visible { outline: 2px solid var(--t-focus); outline-offset: 3px; border-radius: var(--t-r-pill); }

/* ---------------- segmented tabs (inside a page) ---------------- */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-pill); }
.seg button { height: 36px; padding: 0 16px; font: var(--t-ui); background: none; border: 0; border-radius: var(--t-r-pill); cursor: pointer; }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--t-raised); }

/* ---------------- progress ---------------- */
.progress { position: relative; height: 8px; overflow: hidden; background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-pill); }
.progress > i { position: absolute; inset: 0; background: var(--t-accent); border-radius: inherit; transform-origin: 0 50%; transform: scaleX(var(--p, 0)); transition: transform 200ms linear; }
.progress.busy > i { transform: none; width: 30%; animation: t-busy 1.2s cubic-bezier(.5, 0, .5, 1) infinite; }
@keyframes t-busy { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* ---------------- notes inside a page (a warning, an error) ---------------- */
.note { display: grid; gap: var(--t-3); padding: var(--t-4); background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-field); corner-shape: squircle; }
.note[hidden] { display: none; }
.note-warn { border-color: rgba(240, 184, 79, .45); }
.note-error { border-color: rgba(240, 122, 104, .5); }
.note-error .note-text { color: var(--t-danger); }

/* ---------------- empty state ---------------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--t-4); padding: var(--t-8) var(--t-5); }
.empty .slot { width: 64px; height: 64px; display: grid; place-items: center; background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-field); corner-shape: squircle; }
.empty .slot img { width: 32px; height: 32px; image-rendering: pixelated; }

/* ---------------- dialog ---------------- */
.dialog { width: min(480px, calc(100vw - 32px)); padding: 28px; color: var(--t-ink); background: var(--t-surface); border: var(--t-hair); border-radius: var(--t-r-dialog); corner-shape: squircle; }
.dialog::backdrop { background: rgba(0, 0, 0, .66); }
.dialog[open] { animation: t-in var(--t-move); }
.dialog h2 { font: var(--t-subhead); margin-bottom: var(--t-3); }
.dialog .btn-row { margin-top: var(--t-5); justify-content: flex-end; }
@keyframes t-in { from { opacity: 0; transform: scale(.97); } }

/* ---------------- sheet: details and short tasks over a page ----------------
   <dialog class="dialog sheet"><div class="sheet-in"><button class="btn btn-sm btn-icon sheet-x">…</button>…</div></dialog>
   A dialog on wide screens; on phones a panel that rises from the bottom edge, flush with it, with a
   grab bar. A tap on the backdrop closes it. Content stacks with one gap; actions go last, full width on phones. */
.sheet { padding: 0; width: min(520px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 48px)); overflow: hidden; }
.sheet-in { position: relative; display: flex; flex-direction: column; gap: var(--t-4); max-height: inherit; overflow-y: auto; overscroll-behavior: contain; padding: 28px; }
.sheet-in > h2:first-of-type, .sheet-body > h2:first-child, .sheet-top { padding-right: 44px; }
.sheet h2 { margin: 0; }
.sheet-x { position: absolute; top: 16px; right: 16px; z-index: 1; }
.sheet .sheet-acts { margin-top: var(--t-2); justify-content: flex-end; }
.sheet-body { display: flex; flex-direction: column; gap: var(--t-4); }
.sheet-top { display: flex; align-items: center; gap: var(--t-4); min-width: 0; }
.sheet-id { min-width: 0; display: grid; gap: 2px; overflow-wrap: anywhere; }
.sheet-id p { font: var(--t-ui); }
.sheet-switch { display: flex; align-items: center; justify-content: space-between; gap: var(--t-4); padding-top: var(--t-4); border-top: var(--t-hair); font: var(--t-ui); font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--t-2); }
/* body clips sideways without becoming a scroll box: with "hidden" it took over scrolling while a sheet
   locked the page, and the sticky sidebar slid away with it (launcher, 9 Nov) */
html:has(dialog[open]) { overflow: hidden; }
@media (max-width: 860px) {
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; max-height: calc(100dvh - max(24px, env(safe-area-inset-top))); border-width: 1px 0 0; border-radius: var(--t-r-dialog) var(--t-r-dialog) 0 0; }
  .sheet[open] { animation: t-sheet var(--t-enter); }
  .sheet-in { padding: 28px max(20px, env(safe-area-inset-right)) max(24px, calc(env(safe-area-inset-bottom) + 8px)) max(20px, env(safe-area-inset-left)); }
  .sheet-in::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; background: var(--t-line-strong); border-radius: var(--t-r-pill); }
  .sheet-x { top: 18px; right: max(14px, env(safe-area-inset-right)); }
  .sheet .sheet-acts { display: grid; grid-auto-flow: row; grid-template-columns: 1fr; width: 100%; }
  .sheet .sheet-acts > .btn { width: 100%; }
  .sheet .sheet-acts > .btn-primary { order: -1; }
}
@keyframes t-sheet { from { transform: translateY(100%); } }

/* ---------------- toast ---------------- */
.toast { position: fixed; z-index: var(--t-z-toast); left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px); text-align: center;
  padding: 12px 20px; font: var(--t-ui); color: var(--t-ink); background: var(--t-raised); border: 1px solid var(--t-line-strong); border-radius: var(--t-r-pill);
  transform: translate(-50%, 0); opacity: 1; transition: opacity var(--t-move), transform var(--t-move); pointer-events: none; }
.toast[hidden] { display: block; opacity: 0; transform: translate(-50%, 12px); }
.toast.error { color: var(--t-danger); }

/* ---------------- hash / code block ---------------- */
.hash { display: flex; align-items: center; gap: var(--t-2); min-width: 0; padding: 6px 6px 6px 14px; background: var(--t-sunken); border: var(--t-hair); border-radius: var(--t-r-field); corner-shape: squircle; }
.hash code { flex: 1; min-width: 0; font: var(--t-code); overflow-wrap: anywhere; }

/* ---------------- site chrome: the floating capsule nav ----------------
   Open at the very top of a page. Scrolling folds it to the mark and Play; hover, focus or a tap
   on it opens it again. Only transforms and opacity move. */
.nav-wrap { position: fixed; z-index: var(--t-z-nav); top: 0; left: 0; right: 0; display: flex; justify-content: center; pointer-events: none;
  padding: calc(14px + env(safe-area-inset-top)) 12px 0; }
.nav { pointer-events: auto; position: relative; display: flex; align-items: center; gap: 2px; height: var(--t-h-tab); padding: 4px; white-space: nowrap;
  background: #0a0b0d; border: var(--t-hair); border-radius: var(--t-r-pill);
  transform-origin: 50% 0; transition: transform var(--t-enter), opacity var(--t-move); }
.nav .mark { display: grid; place-items: center; width: 36px; height: 34px; border-radius: var(--t-r-pill); }
.nav .mark img { width: 22px; height: 22px; image-rendering: pixelated; }
.nav a.lnk { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; font: var(--t-ui); border-radius: var(--t-r-pill); transition: background-color var(--t-quick); }
@media (hover: hover) { .nav a.lnk:hover { background: var(--t-raised); } }
.nav a.lnk[aria-current="page"] { background: var(--t-raised); }
.nav .nav-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--t-r-pill); }
.nav .nav-ic .i { width: 20px; height: 20px; }
@media (hover: hover) { .nav .nav-ic:hover { background: var(--t-raised); } }
.nav .nav-play { display: inline-flex; align-items: center; gap: 8px; height: 34px; margin-left: 4px; padding: 0 16px 0 14px; font: var(--t-label); color: #fff;
  background: var(--t-primary); border-radius: var(--t-r-pill); -webkit-font-smoothing: none; text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); transition: background-color var(--t-quick); }
.nav .nav-play .i { width: 16px; height: 16px; }
@media (hover: hover) { .nav .nav-play:hover { background: var(--t-primary-hover); } }
.nav .fold { display: flex; align-items: center; gap: 2px; transition: opacity var(--t-move), transform var(--t-move); }
/* folded: the links fade, and the two ends slide in over them (transforms only) */
.nav-wrap.folded .nav { transform: scale(.86); }
.nav-wrap.folded .nav .fold { opacity: 0; pointer-events: none; transform: scale(.96); }
.nav-wrap.folded .nav .mark { transform: translateX(var(--fold-x, 0px)); }
.nav-wrap.folded .nav .nav-play { transform: translateX(calc(-1 * var(--fold-x, 0px))); }
.nav .mark, .nav .nav-play { transition: transform var(--t-enter), background-color var(--t-quick); }
.nav-bg { position: absolute; inset: -1px; z-index: -1; pointer-events: none; }
.nav.split { background: none; border-color: transparent; isolation: isolate; }
.nav-bg i { position: absolute; top: 0; bottom: 0; background: #0a0b0d; border: var(--t-hair); transition: transform var(--t-enter); }
.nav-bg i:nth-child(1) { left: 0; width: 44px; border-right: 0; border-radius: 22px 0 0 22px; }
.nav-bg i:nth-child(3) { right: 0; width: 44px; border-left: 0; border-radius: 0 22px 22px 0; }
.nav-bg i:nth-child(2) { left: 22px; right: 22px; border-left: 0; border-right: 0; border-radius: 0; transform-origin: 50% 50%; }
.nav-wrap.folded .nav-bg i:nth-child(1) { transform: translateX(var(--fold-x, 0px)); }
.nav-wrap.folded .nav-bg i:nth-child(3) { transform: translateX(calc(-1 * var(--fold-x, 0px))); }
.nav-wrap.folded .nav-bg i:nth-child(2) { transform: scaleX(var(--fold-s, 1)); }

/* ---------------- site chrome: footer ---------------- */
.foot { margin-top: var(--t-9); padding: var(--t-6) var(--t-gutter) max(var(--t-6), env(safe-area-inset-bottom)); border-top: var(--t-hair); }
.foot-in { max-width: var(--t-page-w); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--t-3) var(--t-6); font: var(--t-small); }
.foot-links { display: flex; flex-wrap: wrap; gap: var(--t-2) var(--t-5); }
@media (hover: hover) { .foot-links a:hover { color: var(--t-accent); } }

/* phones: no grey tap flash or long-press menu, no double-tap zoom delay; a solid strip under the status bar
   (Safari blurs whatever scrolls under it otherwise) */
* { -webkit-tap-highlight-color: transparent; }
a, button, [role="button"], [role="tab"], label, summary, .tab, .btn { touch-action: manipulation; -webkit-touch-callout: none; }
@media (hover: none) { :focus-visible { outline: none; } }
.t-statusbar { position: fixed; z-index: 2147483000; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: var(--t-page); pointer-events: none; }

/* ---------------- "Get the app" (js/getapp.js): phones and tablets only ----------------
   The app's icon, its name and one line, Get, Close. On the launcher's Home it is a line in the page
   (.note); on the home page it floats at the bottom edge, over the page, clear of the home indicator. */
.getapp { display: flex; align-items: center; gap: var(--t-3); padding: 8px; background: var(--t-surface); border: var(--t-hair); border-radius: var(--t-r-field); corner-shape: squircle; }
.getapp.note { background: var(--t-sunken); }
.getapp-ic { flex: none; width: 44px; height: 44px; border-radius: 10px; corner-shape: squircle; }
.getapp-text { flex: 1; min-width: 0; display: grid; font: var(--t-ui); }
.getapp-text b { font-weight: 600; }
.getapp-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 359px) { .getapp-ic { display: none; } .getapp { padding-left: 14px; } }
.getapp-go { flex: none; }
.getapp-x { flex: none; }
.getapp-float { position: fixed; z-index: var(--t-z-toast); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; border-color: var(--t-line-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5); animation: t-getapp var(--t-enter) both; }
@keyframes t-getapp { from { opacity: 0; transform: translateY(16px); } }
/* never over the game */
.in-game .getapp { display: none; }
/* the home page's last lines stay reachable above it */
.getapp-on body:not(.launcher) { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
