/* ===========================================================================
   GreenCity Padel — components
   =========================================================================== */

/* --- card ----------------------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease-out);
}

/* Hairline highlight along the top edge — reads as glass catching light. */
.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
  pointer-events: none;
}

.card-tight { padding: var(--s-4); }
.card-flush { padding: 0; overflow: hidden; }

.card-hover { cursor: pointer; }
.card-hover:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card-hover:active { transform: translateY(0); }

.card-brand {
  border-color: var(--brand-a30);
  background: linear-gradient(160deg, var(--brand-a08), var(--surface) 60%);
  box-shadow: var(--sh-brand);
}

.card-danger { border-color: rgba(255, 90, 110, 0.28); background: linear-gradient(160deg, var(--danger-a15), var(--surface) 60%); }

.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  margin-bottom: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* --- section heading ------------------------------------------------------ */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-8) 0 var(--s-4);
}
.section-head:first-child { margin-top: 0; }
.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }

/* --- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 11px 18px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: transform var(--dur-1) var(--ease), background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--brand-grad);
  color: var(--brand-ink);
  box-shadow: var(--sh-brand);
}
.btn-primary:hover { filter: brightness(1.07); }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--line-2); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-outline { background: transparent; border-color: var(--brand-a30); color: var(--brand); }
.btn-outline:hover { background: var(--brand-a08); border-color: var(--brand); }

.btn-danger { background: var(--danger-a15); border-color: rgba(255, 90, 110, 0.3); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 90, 110, 0.24); }

.btn-lg  { padding: 15px 26px; font-size: var(--fs-md); }
.btn-sm  { padding: 8px 13px; font-size: var(--fs-sm); }
.btn-block { display: flex; width: 100%; }

.btn-icon {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border-color: var(--line);
  font-size: var(--fs-base);
}
.btn-icon:hover { background: var(--surface-3); }
.btn-icon.sm { width: 30px; height: 30px; font-size: var(--fs-sm); }

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  color: var(--brand-ink);
}
.btn-secondary.btn-loading::after, .btn-ghost.btn-loading::after { color: var(--text); }

/* --- segmented control ---------------------------------------------------- */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
}
.segmented button {
  padding: 8px 16px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  transition: all var(--dur-2) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: var(--brand-grad);
  color: var(--brand-ink);
}
.segmented.block { display: flex; width: 100%; }
.segmented.block button { flex: 1; }

/* --- form controls -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: var(--s-4); }
.label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.hint { font-size: var(--fs-xs); color: var(--text-3); }

.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: rgba(0, 0, 0, 0.42);
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.5; }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239db0a6' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
.select-sm { padding: 7px 30px 7px 11px; font-size: var(--fs-sm); background-position: right 10px center; }

.form-error {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--danger-a15);
  border: 1px solid rgba(255, 90, 110, 0.28);
  color: var(--danger);
  font-size: var(--fs-sm);
}

/* --- avatar --------------------------------------------------------------- */
.avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
  user-select: none;
}
.avatar.xs { width: 26px; height: 26px; font-size: 13px; }
.avatar.sm { width: 32px; height: 32px; font-size: 16px; }
.avatar.md { width: 52px; height: 52px; font-size: 26px; }
.avatar.lg { width: 68px; height: 68px; font-size: 34px; }
.avatar.xl { width: 92px; height: 92px; font-size: 46px; }
.avatar.ring { border-color: var(--brand-a30); box-shadow: 0 0 0 3px var(--brand-a08); }
.avatar.gold { border-color: var(--gold); box-shadow: 0 0 20px rgba(255, 201, 77, 0.28); }

.avatar-stack { display: flex; }
.avatar-stack .avatar:not(:first-child) { margin-left: -10px; }

/* --- chips & pills -------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 6px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}
.chip.plain { padding: 5px 12px; }
.chip.ok     { border-color: var(--brand-a30);            background: var(--brand-a08); }
.chip.warn   { border-color: rgba(255, 176, 32, 0.3);     background: var(--warn-a15); }
.chip.bad    { border-color: rgba(255, 90, 110, 0.3);     background: var(--danger-a15); }
.chip.muted  { opacity: 0.55; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill.win  { background: var(--brand-a15); color: var(--brand); }
.pill.loss { background: var(--danger-a15); color: var(--danger); }
.pill.live {
  background: var(--danger-a15);
  color: var(--danger);
}
.pill.live::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: breathe 1.4s ease-in-out infinite;
}
.pill.neutral { background: var(--surface-2); color: var(--text-2); }
.pill.gold { background: rgba(255, 201, 77, 0.15); color: var(--gold); }

/* --- rank badge ----------------------------------------------------------- */
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px 4px 7px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--rank-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--rank-color) 40%, transparent);
  color: var(--rank-color);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.4;
}
.rank-badge .rank-icon { font-size: 14px; line-height: 1; }
.rank-badge .rank-rating {
  padding-left: 7px;
  margin-left: 1px;
  border-left: 1px solid color-mix(in srgb, var(--rank-color) 30%, transparent);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.rank-badge.lg {
  padding: 8px 16px 8px 12px;
  font-size: var(--fs-base);
  gap: 9px;
}
.rank-badge.lg .rank-icon { font-size: 22px; }
.rank-badge.sm { padding: 2px 8px 2px 5px; font-size: 10px; }
.rank-badge.sm .rank-icon { font-size: 11px; }
.rank-badge.icon-only .rank-label,
.rank-badge.icon-only .rank-rating { display: none; }

/* Fallback for browsers without color-mix */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .rank-badge { background: var(--surface-2); border-color: var(--line-2); }
}

.rank-card {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4);
  border-radius: var(--r-lg);
  background:
    radial-gradient(420px 160px at 12% 0%, color-mix(in srgb, var(--rank-color) 16%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid color-mix(in srgb, var(--rank-color) 32%, transparent);
}
.rank-crest {
  display: grid;
  place-items: center;
  width: 62px; height: 62px;
  flex-shrink: 0;
  border-radius: 18px;
  background: color-mix(in srgb, var(--rank-color) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--rank-color) 45%, transparent);
  font-size: 30px;
}
.rank-name {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rank-color);
}
.rank-bar > i { background: var(--rank-color); }

/* --- stat tile ------------------------------------------------------------ */
.stat {
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  text-align: center;
}
.stat-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.stat-value {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.1;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat.accent { border-color: var(--brand-a30); background: linear-gradient(160deg, var(--brand-a08), transparent); }
.stat.accent .stat-value { color: var(--brand); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: var(--s-3);
}

/* --- progress bar --------------------------------------------------------- */
.bar {
  height: 7px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-grad);
  transition: width var(--dur-3) var(--ease-out);
}
.bar.thin { height: 4px; }

/* --- form strip (W/L history) --------------------------------------------- */
.form-strip { display: flex; gap: 4px; }
.form-strip span {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-display);
}
.form-strip .w { background: var(--brand-a15); color: var(--brand); }
.form-strip .l { background: var(--danger-a15); color: var(--danger); }

/* --- empty state ---------------------------------------------------------- */
.empty {
  display: grid;
  place-items: center;
  gap: var(--s-3);
  padding: var(--s-10) var(--s-5);
  text-align: center;
  color: var(--text-2);
}
.empty-icon {
  font-size: 44px;
  opacity: 0.55;
  filter: grayscale(0.3);
}
.empty-title { font-family: var(--font-display); font-weight: 700; color: var(--text); }
.empty p { font-size: var(--fs-sm); max-width: 34ch; }

/* --- skeleton ------------------------------------------------------------- */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-row { height: 68px; margin-bottom: var(--s-3); border-radius: var(--r); }

/* --- toast ---------------------------------------------------------------- */
/* Stacking order, highest last:
   scoreboard (800) → confetti (850) → modal (900) → toast (950).
   The scoreboard is fullscreen, so anything that has to appear over it — the
   "leave this match?" prompt, the options menu, confirmations — must sit above
   it or it opens invisibly behind and the button looks broken. */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 18px);
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  align-items: center;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
@media (min-width: 900px) { .toast-host { bottom: 28px; } }

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 13px 17px;
  border-radius: var(--r);
  background: rgba(14, 22, 19, 0.96);
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-3);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-size: var(--fs-sm);
  animation: rise var(--dur-2) var(--ease-out) both;
  pointer-events: auto;
}
.toast.leaving { animation: fade-in var(--dur-2) var(--ease) reverse both; }
.toast-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
.toast.success { border-color: var(--brand-a30); }
.toast.error   { border-color: rgba(255, 90, 110, 0.4); }
.toast.warn    { border-color: rgba(255, 176, 32, 0.4); }

/* --- modal ---------------------------------------------------------------- */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  background: rgba(3, 6, 5, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-host.open { display: flex; animation: fade-in var(--dur-2) var(--ease) both; }

.modal {
  position: relative;
  width: min(520px, 100%);
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: pop var(--dur-3) var(--ease-spring) both;
}
.modal.wide { width: min(760px, 100%); }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-3);
  background: linear-gradient(var(--bg-3) 72%, transparent);
}
.modal-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; }
.modal-body { padding: 0 var(--s-5) var(--s-5); }
.modal-foot {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  padding: var(--s-3) var(--s-5) var(--s-5);
}
.modal-foot .btn { flex: 1; }
@media (min-width: 560px) { .modal-foot .btn { flex: 0 0 auto; } }

/* --- sheet (mobile-friendly bottom modal) --------------------------------- */
@media (max-width: 559px) {
  .modal-host.sheet { align-items: flex-end; padding: 0; }
  .modal-host.sheet .modal {
    width: 100%;
    max-height: 88dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding-bottom: var(--safe-b);
    animation: rise var(--dur-3) var(--ease-out) both;
  }
}

/* --- confetti ------------------------------------------------------------- */
.confetti-host {
  position: fixed;
  inset: 0;
  z-index: 850;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 15px;
  opacity: 0;
  will-change: transform, opacity;
}

/* --- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: var(--fs-sm); }
.table th {
  padding: 11px var(--s-3);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px var(--s-3);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-1) var(--ease); }
.table tbody tr:hover { background: var(--surface); }
.table tbody tr.is-me { background: var(--brand-a08); }
.table tbody tr.is-me td:first-child { box-shadow: inset 3px 0 0 var(--chip-brand, var(--brand)); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- divider -------------------------------------------------------------- */
.divider { height: 1px; background: var(--line); margin: var(--s-5) 0; border: none; }
.divider.tight { margin: var(--s-3) 0; }

/* --- tooltip-ish inline note ---------------------------------------------- */
.note {
  display: flex;
  gap: var(--s-2);
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.45;
}
.note.brand { border-color: var(--brand-a30); background: var(--brand-a08); }
.note.warn  { border-color: rgba(255, 176, 32, 0.3); background: var(--warn-a15); color: #ffd88a; }

/* --- emoji picker --------------------------------------------------------- */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: var(--s-2);
}
.emoji-grid button {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: all var(--dur-1) var(--ease);
}
.emoji-grid button:hover { background: var(--surface-2); transform: scale(1.08); }
.emoji-grid button.selected {
  border-color: var(--brand);
  background: var(--brand-a15);
  box-shadow: 0 0 0 2px var(--brand-a30);
}

/* --- switch --------------------------------------------------------------- */
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); cursor: pointer; }
.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 46px; height: 27px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background var(--dur-2) var(--ease);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform var(--dur-2) var(--ease-spring), background var(--dur-2) var(--ease);
}
.switch.on .switch-track { background: var(--brand-a30); border-color: var(--brand); }
.switch.on .switch-track::after { transform: translateX(19px); background: var(--brand); }
