/* ============================================================
   RTS MEMBER DASHBOARD — section styles. Mobile-first.
   Brand values come exclusively from tokens.css. Same visual
   system as the public site: yellow fill/highlight-only, brown
   text-safe accent, grey zones, dark panels for heritage moments.
   ============================================================ */

body { background: var(--zone); }

/* ---- Header (compact, app-like — not the marketing header) ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 0.65rem;
}
.app-header__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.logo-ink { filter: invert(1) brightness(0.9); }
.app-header__wordmark {
  font-weight: 800;
  font-size: var(--text-tiny);
  letter-spacing: 0.14em;
}
.app-header__badge {
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-deep);
  border: 1.5px solid var(--accent-deep);
  border-radius: 99px;
  padding: 0.3em 0.8em;
  display: none;
}
.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.app-header__cta { padding: 0.55em 1.1em; }
@media (min-width: 640px) {
  .app-header__badge { display: inline-block; }
}

.app-main { padding-block: var(--space-5) var(--space-7); }
/* minmax(0, 1fr) everywhere in this grid chain — without it, a grid
   item's default min-width:auto lets wide content (e.g. the badge
   grid) blow the column past its container instead of scrolling. */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}
.dash-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  align-content: start;
}
@media (min-width: 900px) {
  .dash-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    align-items: start;
  }
  .dash-grid > .span-2 { grid-column: 1 / -1; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  min-width: 0;
}
.panel__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

/* ---- Skeleton loading state ---- */
.skel {
  background: linear-gradient(90deg,
    var(--surface-2) 25%, var(--line-strong) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skel-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
}
@keyframes skel-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; background: var(--surface-2); }
}

/* ---- Profile header ---- */
.profile-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--dark);
  color: var(--on-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.profile-card__avatar {
  width: 4.5rem;
  height: 4.5rem;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-size: 2.2rem;
}
.profile-card__name { font-size: var(--text-h2); }
.profile-card__meta {
  margin-top: var(--space-1);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em 1em;
  color: var(--on-dark-dim);
  font-family: var(--font-mono);
  font-size: var(--text-small);
}
.profile-card__points {
  margin-left: auto;
  text-align: right;
}
.profile-card__points-value {
  font-size: var(--text-h1);
  color: var(--on-dark-accent);
  line-height: 1;
}
.profile-card__points-label {
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  letter-spacing: var(--track-label);
  color: var(--on-dark-dim);
}
@media (max-width: 520px) {
  .profile-card { flex-wrap: wrap; }
  .profile-card__points { margin-left: 0; text-align: left; }
}

/* ---- Rank ladder ---- */
.rank-ladder { display: grid; gap: 0.5rem; margin-top: var(--space-3); }
.rank-rung {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.5em 0.7em;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.rank-rung.is-current {
  border-color: var(--accent-deep);
  background: color-mix(in srgb, var(--accent) 22%, var(--bg));
  color: var(--ink);
  font-weight: 700;
}
.rank-rung__pct { margin-left: auto; opacity: 0.7; }

/* ---- Attendance grid (contribution-graph style) ----
   min-width on cells + 1fr tracks would force the row wider than its
   panel on narrow screens; scope the scroll to the row, not the page. */
.attendance {
  display: grid;
  grid-template-columns: 2.4rem repeat(12, minmax(1.4rem, 1fr));
  gap: 0.35rem;
  align-items: center;
  overflow-x: auto;
  max-width: 100%;
}
.attendance__rowlabel {
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  color: var(--ink-faint);
  position: sticky;
  left: 0;
  background: var(--surface);
}
.attendance__cell {
  aspect-ratio: 1;
  width: 1.4rem;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.attendance__cell.is-on { background: var(--accent); border-color: var(--accent-deep); }
.attendance__legend {
  margin-top: var(--space-3);
  display: flex;
  gap: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  color: var(--ink-dim);
}
.attendance__legend span { display: inline-flex; align-items: center; gap: 0.4em; }
.attendance__swatch {
  width: 0.8em; height: 0.8em; border-radius: 3px;
  background: var(--accent); border: 1px solid var(--accent-deep);
  display: inline-block;
}

/* ---- Leaderboard ---- */
.leaderboard { list-style: none; display: grid; gap: 0.35rem; }
.leaderboard__row {
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 0.55em 0.6em;
  border-radius: var(--radius-sm);
}
.leaderboard__row.is-you {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg));
  border: 1px solid var(--accent-deep);
  font-weight: 700;
}
.leaderboard__rank {
  font-family: var(--font-mono);
  font-weight: 800;
  width: 2ch;
  text-align: right;
  color: var(--accent-deep);
}
.leaderboard__name { flex: 1; }
.leaderboard__points { font-family: var(--font-mono); }

/* ---- Badges ---- */
.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr));
  gap: var(--space-2);
  width: 100%;
}
.badge {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 1.6rem;
  position: relative;
  cursor: default;
}
.badge.is-earned {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
  border-color: var(--accent-deep);
}
.badge.is-locked { filter: grayscale(1); opacity: 0.4; }
.badge__tooltip {
  position: absolute;
  bottom: calc(100% + 0.4em);
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: var(--on-dark);
  font-size: var(--text-tiny);
  font-family: var(--font-mono);
  padding: 0.4em 0.6em;
  border-radius: 6px;
  /* Fixed width + wrap, not nowrap — an absolutely-positioned nowrap
     label still contributes its full width to the ancestor's
     scrollWidth even at opacity:0, which forced page-level
     horizontal scroll on mobile. */
  width: max-content;
  max-width: 11rem;
  white-space: normal;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) linear;
  z-index: 5;
}
.badge:hover .badge__tooltip,
.badge:focus-visible .badge__tooltip { opacity: 1; }

/* ---- Next event countdown ---- */
.countdown {
  background: var(--dark);
  color: var(--on-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.countdown__label {
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  letter-spacing: var(--track-label);
  color: var(--on-dark-accent);
}
.countdown__clock {
  display: flex;
  gap: var(--space-3);
  margin-block: var(--space-3);
}
.countdown__unit { text-align: center; }
.countdown__unit-value {
  font-family: var(--font-mono);
  font-size: var(--text-h2);
  font-weight: 700;
  line-height: 1;
}
.countdown__unit-label {
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  color: var(--on-dark-dim);
}
.countdown__cafe { color: var(--on-dark-dim); font-size: var(--text-small); }

/* ---- Perks ---- */
.perks { display: grid; gap: var(--space-3); }
.perk {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2em 1em;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}
.perk:last-child { border-bottom: none; padding-bottom: 0; }
.perk__sponsor { font-weight: 800; grid-row: span 2; align-self: center; }
.perk__tier {
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  color: var(--accent-deep);
  letter-spacing: 0.08em;
}
.perk__desc { color: var(--ink-dim); font-size: var(--text-small); }

/* ---- Mock-data provenance banner ---- */
.mock-banner {
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.6em 1em;
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  color: var(--ink-dim);
  margin-bottom: var(--space-4);
}
.mock-banner strong { color: var(--accent-deep); }
