/* Malve Deck web styles. Only tokens from tokens.css: no raw colours here or in components. */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-16);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--mallow); }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: var(--text-36); font-weight: 300; letter-spacing: -.02em; }
h1 b { font-weight: 800; }
h2 { font-size: var(--text-18); font-weight: 600; line-height: 1.3; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--mallow); outline-offset: 2px; }
h1:focus { outline: none; }

.eyebrow { font-family: var(--font-data); font-size: var(--text-12); font-weight: 500; line-height: 1.4; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lead { color: var(--muted); font-size: var(--text-18); line-height: 1.4; }
.note { color: var(--muted); font-size: var(--text-14); }
.err { color: var(--danger); font-size: var(--text-14); font-weight: 500; }
.warn { color: var(--amber); font-size: var(--text-14); }
.label, label { color: var(--muted); font-size: var(--text-14); font-weight: 500; }
.loading { padding: var(--space-6) var(--space-4); color: var(--muted); }
.stack { display: grid; gap: var(--space-5); }
.stack-s { display: grid; gap: var(--space-2); }
.narrow { max-width: 560px; margin-inline: auto; }

/* Shell */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; max-width: 1180px; margin-inline: auto; padding: var(--space-5); padding-bottom: max(var(--space-5), env(safe-area-inset-bottom)); }
.topbar {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-5); padding-top: max(var(--space-2), env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: var(--space-2); margin-right: auto; font-weight: 600; }
.mark { width: 28px; height: 28px; border-radius: var(--radius-tag); }
.mark-lg { width: 72px; height: 72px; border-radius: var(--radius-sheet); }
.tab {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-control);
  color: var(--muted); font-size: var(--text-14); font-weight: 500; text-decoration: none;
}
.tab.active { color: var(--mallow); background: var(--mallow-soft); }
.icon { flex: none; display: block; }

/* Buttons and fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--button-md); padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-control);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform var(--dur-press) ease-out;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--leaf); color: var(--on-leaf); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-ghost { background: none; color: var(--muted); }
.btn-block { width: 100%; }
.card { padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.field { display: grid; gap: var(--space-1); }
input {
  min-height: var(--tap); padding: 0 var(--space-3); width: 100%;
  background: var(--surface-2); color: var(--text); font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius-control);
}
input:focus { outline: 2px solid var(--mallow); outline-offset: -1px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-4);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--text-14); font-weight: 500; text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius-pill); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--mallow-soft); border-color: var(--mallow); color: var(--mallow); }

/* Start page, signed out */
.welcome { display: grid; gap: var(--space-5); max-width: 480px; margin: var(--space-7) auto; }

/* Connection: in words, muted when all is well, amber when it is waiting. */
.connection[data-connected="true"] { color: var(--muted); font-size: var(--text-14); }
.connection[data-connected="false"] { display: grid; gap: var(--space-1); }
.connection-word { color: var(--amber); font-size: var(--text-14); font-weight: 600; }

/* Panel */
.panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.panel-test { display: grid; gap: var(--space-2); justify-items: end; }
.deck { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.deck-group { display: grid; gap: var(--space-3); align-content: start; }
.deck-group h2 { font-weight: 500; font-size: var(--text-12); line-height: 1.4; }
.keys { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(calc(var(--deck-key) * 1.45), 1fr)); }

/* Keys are surface with a 1 px line: they never glow, and no animation loops. */
.key {
  display: grid; align-content: start; justify-items: start; gap: var(--space-2);
  min-height: var(--deck-key); padding: var(--space-3); width: 100%;
  background: var(--surface); color: var(--text); font: inherit; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius-card); cursor: pointer;
  transition: transform var(--dur-press) ease-out;
  touch-action: manipulation;
}
.key:active { transform: scale(.97); }
.icon-tile {
  display: grid; place-items: center; width: var(--icon-tile); height: var(--icon-tile);
  background: var(--surface-2); border-radius: var(--radius-control);
}
.key-label { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.key-status { min-height: calc(var(--text-14) * 1.45 * 2); color: var(--muted); font-size: var(--text-14); line-height: 1.45; }
.key[data-state="pending"] { cursor: progress; }
.key[data-state="ok"] { animation: receipt var(--dur-receipt) ease-out 1; }
.key[data-state="ok"] .key-status { color: var(--leaf); font-weight: 500; }
.key[data-state="failed"] .key-status { color: var(--danger); font-weight: 500; }

@keyframes receipt {
  from { background: var(--leaf-soft); }
  to { background: var(--surface); }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .key { transition: none; }
  .btn:active, .key:active { transform: none; }
}

@media (max-width: 520px) {
  .content { padding: var(--space-4); }
  .topbar { padding-inline: var(--space-4); }
  .brand { font-size: 0; }
  .panel-test { justify-items: start; }
}
