@import './tokens.css';

/* ─── Reset ─────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin:     0;
  padding:    0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height:           100%;
  overflow:         hidden;
  background:       var(--c-bg);
  color:            var(--c-text);
  font-family:      var(--font);
  font-size:        var(--fs-base);
  -webkit-font-smoothing: antialiased;
}

/* ─── App shell ─────────────────────────────────────────────────────────────── */

#app {
  position:    relative;
  width:       100%;
  height:      100%;
  overflow:    hidden;
}

.screen {
  display:        flex;
  flex-direction: column;
  width:          100%;
  height:         100%;
  padding-top:    var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left:   var(--safe-left);
  padding-right:  var(--safe-right);
  overflow-y:     auto;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display:         flex;
  align-items:     center;
  justify-content: center;
  gap:             var(--sp-2);
  width:           100%;
  padding:         var(--sp-4) var(--sp-6);
  border:          none;
  border-radius:   var(--r-full);
  font-family:     var(--font);
  font-size:       var(--fs-md);
  font-weight:     var(--fw-bold);
  cursor:          pointer;
  transition:      transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  user-select:     none;
  white-space:     nowrap;
}

.btn:active { transform: scale(0.95); }

.btn--primary {
  background:  var(--c-primary);
  color:       #fff;
  box-shadow:  var(--shadow-btn);
}
.btn--primary:hover  { background: var(--c-primary-dark); }
.btn--primary:active { box-shadow: none; }

.btn--outline {
  background:  transparent;
  color:       var(--c-text);
  border:      2px solid rgba(255,255,255,0.3);
}
.btn--outline:hover { border-color: rgba(255,255,255,0.6); }

.btn--ghost {
  background:  transparent;
  color:       var(--c-text-muted);
}

.btn--danger {
  background:  var(--c-accent);
  color:       #fff;
}

.btn:disabled {
  opacity:    0.4;
  cursor:     not-allowed;
  transform:  none !important;
  box-shadow: none !important;
}

/* ─── Inputs ────────────────────────────────────────────────────────────────── */

.input {
  width:          100%;
  padding:        var(--sp-4);
  background:     var(--c-bg-elevated);
  border:         2px solid transparent;
  border-radius:  var(--r-md);
  color:          var(--c-text);
  font-family:    var(--font);
  font-size:      var(--fs-md);
  outline:        none;
  transition:     border-color var(--t-fast);
}

.input:focus         { border-color: var(--c-primary); }
.input::placeholder  { color: var(--c-text-dim); }
.input.error         { border-color: var(--c-accent); }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  background:    var(--c-bg-card);
  border-radius: var(--r-lg);
  padding:       var(--sp-4);
  box-shadow:    var(--shadow-card);
}

/* ─── Player chip ───────────────────────────────────────────────────────────── */

.player-chip {
  display:        flex;
  align-items:    center;
  gap:            var(--sp-2);
  padding:        var(--sp-2) var(--sp-3);
  background:     var(--c-bg-elevated);
  border-radius:  var(--r-full);
  font-size:      var(--fs-sm);
}

.player-chip--ghost  { opacity: 0.5; }
.player-chip__icon   { font-size: var(--fs-base); }
.player-chip__name   { font-weight: var(--fw-bold); }
.player-chip__status { font-size: var(--fs-xs); color: var(--c-text-muted); }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */

#toast-container {
  position:       fixed;
  bottom:         calc(var(--sp-6) + var(--safe-bottom));
  left:           50%;
  transform:      translateX(-50%);
  z-index:        999;
  display:        flex;
  flex-direction: column;
  gap:            var(--sp-2);
  align-items:    center;
  pointer-events: none;
}

.toast {
  padding:       var(--sp-3) var(--sp-5);
  background:    var(--c-bg-elevated);
  border-radius: var(--r-full);
  font-size:     var(--fs-sm);
  font-weight:   var(--fw-bold);
  color:         var(--c-text);
  box-shadow:    var(--shadow-card);
  animation:     toast-in var(--t-normal) forwards;
}

.toast--error  { background: var(--c-accent); }
.toast--success { background: var(--c-success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Connection status bar ─────────────────────────────────────────────────── */

#status-bar {
  position:        fixed;
  top:             0;
  left:            0;
  right:           0;
  height:          3px;
  background:      var(--c-primary);
  transform:       scaleX(0);
  transform-origin: left;
  transition:      transform var(--t-normal), background var(--t-normal);
  z-index:         1000;
}

#status-bar.reconnecting {
  background: var(--c-accent);
  transform:  scaleX(1);
  animation:  pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── Divider ───────────────────────────────────────────────────────────────── */

.divider {
  display:     flex;
  align-items: center;
  gap:         var(--sp-3);
  color:       var(--c-text-dim);
  font-size:   var(--fs-sm);
}

.divider::before,
.divider::after {
  content:    '';
  flex:       1;
  height:     1px;
  background: rgba(255,255,255,0.1);
}

/* ─── Score delta animation ─────────────────────────────────────────────────── */

.score-delta {
  position:   absolute;
  color:      var(--c-primary);
  font-size:  var(--fs-lg);
  font-weight: var(--fw-bold);
  pointer-events: none;
  animation:  score-float 2s ease-out forwards;
}

@keyframes score-float {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}

/* ─── Utilities ─────────────────────────────────────────────────────────────── */

.text-muted    { color: var(--c-text-muted); }
.text-primary  { color: var(--c-primary); }
.text-accent   { color: var(--c-accent); }
.text-center   { text-align: center; }
.text-sm       { font-size: var(--fs-sm); }
.text-lg       { font-size: var(--fs-lg); }
.text-xl       { font-size: var(--fs-xl); }
.text-bold     { font-weight: var(--fw-bold); }
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-center { justify-content: center; }
.gap-2         { gap: var(--sp-2); }
.gap-4         { gap: var(--sp-4); }
.gap-6         { gap: var(--sp-6); }
.p-4           { padding: var(--sp-4); }
.p-6           { padding: var(--sp-6); }
.mt-2          { margin-top: var(--sp-2); }
.mt-4          { margin-top: var(--sp-4); }
.mt-6          { margin-top: var(--sp-6); }
.w-full        { width: 100%; }
.flex-1        { flex: 1; }
