/* ============================================================
   COMPONENTS
   Anything used by more than one feature lives here. If it's only
   used by one screen, it belongs in that feature's own css file.
   ============================================================ */

/* ── Surfaces ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: var(--border-w) solid var(--rim);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}

/* ── Type roles ───────────────────────────────────────────── */
.label {
  font-size: 0.62rem;
  font-weight: var(--body-weight-strong);
  letter-spacing: 0.08em;
  color: var(--text-dimmer);
  text-transform: uppercase;
}

.section-label {
  font-size: 0.64rem;
  font-weight: var(--body-weight-strong);
  letter-spacing: 0.12em;
  color: var(--text-dimmer);
  text-transform: uppercase;
  padding: var(--s-4) var(--s-5) var(--s-2);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  border-radius: var(--r-md);
  padding: 13px var(--s-5);
  font-weight: var(--body-weight-strong);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--support));
  transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) ease;
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:focus-visible { outline-color: var(--text); }

.btn-ghost {
  border: var(--border-w) solid var(--rim-strong);
  border-radius: var(--r-md);
  padding: 12px var(--s-5);
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: var(--body-weight-strong);
  font-size: 0.84rem;
  transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.btn-link {
  font-size: 0.7rem;
  font-weight: var(--body-weight-strong);
  color: var(--accent-2);
  letter-spacing: 0.03em;
}
.btn-link:hover { opacity: 0.8; }

.btn-danger {
  width: calc(100% - var(--s-5) * 2);
  margin: var(--s-2) var(--s-5) var(--s-5);
  padding: 12px;
  border-radius: var(--r-md);
  border: var(--border-w) solid color-mix(in srgb, var(--accent) 34%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent-2);
  font-weight: var(--body-weight-strong);
  font-size: 0.8rem;
}
.btn-danger:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-dimmer);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.pill {
  font-size: 0.68rem;
  font-weight: var(--body-weight-strong);
  letter-spacing: 0.03em;
  color: var(--support);
  background: color-mix(in srgb, var(--support) 12%, transparent);
  border: var(--border-w) solid color-mix(in srgb, var(--support) 30%, transparent);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.pill--quiet {
  color: var(--text-dim);
  background: var(--surface-2);
  border-color: var(--rim-strong);
}

/* ── Progress bars ────────────────────────────────────────── */
.bar {
  height: 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
}
.bar--thin { height: 5px; }

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 1.1s var(--ease);
}
.bar-fill--rank {
  background: linear-gradient(90deg, var(--support), var(--support-2));
}

/* ── Hex avatars ──────────────────────────────────────────── */
/* The ring is a sibling BEHIND the avatar, never a child of it —
   a child would be cut away by the same clip-path that shapes the
   hexagon, which is why the wrapper itself isn't clipped. */
.hex {
  position: relative;
  display: block;
  flex-shrink: 0;
}
.hex-sm { width: 28px; height: 28px; }
.hex-md { width: 36px; height: 36px; }
.hex-lg { width: 68px; height: 68px; }

.hex-ring {
  position: absolute;
  inset: -3px;
  z-index: 0;
  clip-path: var(--hex);
  background: linear-gradient(135deg, var(--accent), var(--accent-dim) 50%, var(--accent));
}

.hex > img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: var(--hex);
}

.initials {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  clip-path: var(--hex);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: var(--body-weight-strong);
  letter-spacing: 0.04em;
  color: #fff;
}
.initials-sm { font-size: 0.62rem; }
.initials-md { font-size: 0.82rem; }
.initials-lg { font-size: 1.05rem; }

/* ── Bottom sheets ────────────────────────────────────────── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet-overlay);
  background: color-mix(in srgb, var(--bg) 66%, transparent);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) ease;
}
.sheet-overlay.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: var(--z-sheet);
  width: 100%;
  max-width: var(--app-w);
  transform: translate(-50%, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: var(--border-w) solid var(--rim);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  transition: transform var(--dur-slow) var(--ease);
}
.sheet.is-open { transform: translate(-50%, 0); }
.sheet--auto { height: auto !important; max-height: 82dvh; }

.sheet-hdr {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-shrink: 0;
  padding: var(--s-4);
  border-bottom: var(--border-w) solid var(--rim);
}
.sheet-title {
  flex: 1;
  font-weight: var(--body-weight-strong);
  font-size: 0.92rem;
}
.sheet-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-dimmer);
}
.sheet-close svg { width: 16px; height: 16px; }
.sheet-close:hover { color: var(--text); background: var(--surface-2); }

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* a small grab handle reads as "this can be dismissed" */
.sheet::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--rim-strong);
}

/* ── Theme picker ─────────────────────────────────────────── */
.theme-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5) var(--s-2);
}

.theme-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  text-align: left;
  padding: var(--s-3);
  border: var(--border-w) solid var(--rim);
  border-radius: var(--r-md);
  background: var(--surface-2);
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease,
              transform var(--dur-fast) var(--ease);
}
.theme-row:hover { border-color: var(--rim-strong); transform: translateX(2px); }
.theme-row.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}

.theme-chip {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.theme-row-text { flex: 1; min-width: 0; display: block; }
.theme-row-name {
  display: block;
  font-size: 1.02rem;
  line-height: 1.15;
  color: var(--text);
  text-transform: uppercase;
}
.theme-row-blurb {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--text-dimmer);
  line-height: 1.35;
}

.theme-row-tick {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent-2);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease);
}
.theme-row.is-active .theme-row-tick { opacity: 1; transform: scale(1); }

.theme-note {
  padding: 0 var(--s-5) var(--s-4);
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-dimmer);
  max-width: 46ch;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: var(--z-toast);
  transform: translate(-50%, -50%) scale(0.92);
  padding: var(--s-4) 26px;
  border-radius: var(--r-md);
  text-align: center;
  font-size: calc(1.05rem * var(--display-scale));
  color: var(--text);
  background: var(--surface-2);
  border: var(--border-w) solid var(--toast-accent, var(--accent));
  box-shadow: 0 10px 34px color-mix(in srgb, var(--toast-accent, var(--accent)) 45%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) ease, transform var(--dur) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ── Auth gate ────────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-gate);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  background: var(--bg);
}
.auth-gate-inner {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.auth-mark {
  font-size: 2.8rem;
  margin-bottom: var(--s-2);
  filter: drop-shadow(0 4px 20px color-mix(in srgb, var(--accent) 55%, transparent));
}
.auth-title {
  font-size: calc(2.4rem * var(--display-scale));
  color: var(--text);
}
.auth-tagline {
  margin: var(--s-2) 0 var(--s-6);
  font-size: 0.84rem;
  color: var(--text-dim);
}
.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border-radius: var(--r-md);
  border: var(--border-w) solid var(--rim);
  background: var(--surface-2);
  color: var(--text);
  font-weight: var(--body-weight-strong);
  font-size: 0.86rem;
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.btn-oauth:hover { border-color: var(--rim-strong); background: var(--surface-3); }
.btn-oauth:disabled { opacity: 0.6; cursor: progress; }
.auth-error {
  margin-top: var(--s-4);
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--accent-2);
}

/* ── Empty / error states ─────────────────────────────────── */
.state {
  padding: 28px var(--s-4);
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text-dimmer);
}
.state--error { color: var(--accent-2); }
