@import url("./tokens.css?v=fieldmax2");
@import url("./fields.css?v=fieldmax2");

/**
 * Shared chrome for Class, Leaderboard and Account.
 *
 * Loaded AFTER each page's own stylesheet so it wins on source order.
 * Rooms share type, radius, dock and tactile press — not one green wash.
 * Layout grids live here so 16:9 dashboards stay aligned across surfaces.
 */

/* ——— Re-point the legacy palette at the token layer ————————————— */
:root {
  --green: var(--ry-green);
  --green-dark: var(--ry-green-dark);
  --green-soft: var(--ry-green-soft);
  --blue: var(--ry-blue);
  --blue-dark: var(--ry-blue-dark);
  --blue-soft: var(--ry-blue-soft);
  --yellow: var(--ry-amber);
  --orange: var(--ry-orange);
  --red: var(--ry-red);
  --purple: var(--ry-violet);
  --purple-dark: var(--ry-violet-dark);
  --teal: var(--ry-teal);
  --coral: var(--ry-coral);
  --ink: var(--ry-ink);
  --muted: var(--ry-muted);
  --line: var(--ry-line-cool);
  --surface: var(--ry-surface);
  --shadow: var(--ry-shadow);
  --button-shadow: inset 0 -3px rgba(0, 0, 0, 0.18);

  --shell-gutter: clamp(16px, 3.2vw, 36px);
  --shell-top: var(--ry-space-2);
  --dock-space: 84px;
  --stage-radius: var(--ry-radius-lg);
  --shell-max: 1440px;
}

html {
  background: transparent;
}

body {
  color: var(--ry-ink);
  background: transparent;
  font-family: var(--ry-font);
  font-size: var(--ry-fs-body);
  font-weight: var(--ry-fw-body);
  line-height: var(--ry-lh-body);
  -webkit-font-smoothing: antialiased;
}

body.room-class,
body.room-league,
body.room-account {
  background: transparent;
}

.app-shell {
  position: relative;
  z-index: 1;
  background: transparent !important;
}

body.room-class .app-shell,
body.room-league .app-shell,
body.room-account .app-shell {
  padding-top: 16px;
  padding-inline: clamp(20px, 4vw, 52px);
}

/* ——— Open the shell: no page-sized card floating on a gradient ——— */
.dashboard-stage,
.leaderboard-stage,
.account-stage {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  flex: 1 1 var(--shell-max);
  width: min(100%, var(--shell-max));
  max-width: var(--shell-max);
}

.status-bar {
  position: sticky;
  z-index: 30;
  top: 10px;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: calc(100% - 24px);
  max-width: var(--shell-max);
  min-height: 56px;
  margin: 12px auto 0;
  padding: 6px 12px 6px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--ry-cream) !important;
  box-shadow: 0 3px 0 rgba(26, 35, 48, 0.10);
  backdrop-filter: none;
  animation: none;
}

.status-bar::before {
  display: none !important;
}

.top-brand {
  margin-right: 0 !important;
  color: var(--ry-ink);
  font-family: var(--ry-font);
  font-weight: var(--ry-fw-heading);
  letter-spacing: var(--ry-tracking-heading);
}

.top-brand span {
  display: none;
}

.top-brand img {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  object-fit: cover;
}

.status-section-wrap {
  position: relative;
  justify-self: center;
  min-width: 0;
  max-width: 100%;
}

.status-bar .section-select {
  background: transparent;
  box-shadow: none;
}

.status-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--ry-ink);
  font-family: var(--ry-font);
  cursor: pointer;
}

p.status-section {
  cursor: default;
}

.status-section span {
  flex: 0 0 auto;
  color: var(--ry-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-section span::after {
  content: "|";
  margin-left: 8px;
  color: color-mix(in srgb, var(--ry-ink) 28%, transparent);
}

.status-section strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ry-ink);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-meter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.stat {
  flex-direction: row !important;
  align-items: center !important;
  gap: 4px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
}

.stat span {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  font-weight: 800;
}

.stat small {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
}

.stat::before {
  content: "";
  display: block;
  position: static !important;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 8px;
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.16);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  /* White lucide glyphs need a colored plate. Lesson CSS used them as
     -webkit-mask-image, which clips the plate away on cream headers. */
  -webkit-mask: none !important;
  mask: none !important;
}

.stat.fire::before,
.stat.streak::before {
  background-color: var(--ry-orange);
  background-image: url("/assets/stat-icons/flame.svg");
}

.stat.gem::before {
  background-color: var(--ry-blue);
  background-image: url("/assets/stat-icons/gem.svg");
}

.stat.xp::before {
  background-color: var(--ry-blue);
  background-image: url("/assets/stat-icons/star.svg");
}

.stat.heart::before,
.stat.hearts::before {
  background-color: var(--ry-red);
  background-image: url("/assets/stat-icons/heart.svg");
}

.class-stat::before {
  background-color: var(--ry-orange);
  background-image: url("/assets/stat-icons/mail.svg");
}

.plan-stat::before {
  background-color: var(--ry-violet);
  background-image: url("/assets/stat-icons/book.svg");
}

.progress-stat::before {
  background-color: var(--ry-teal);
  background-image: url("/assets/stat-icons/chart.svg");
}

.status-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  color: #fff;
  border-radius: 50%;
  background: var(--ry-teal);
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.18);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}

/* ——— Type: hierarchy by weight and size, one family ——————————— */
h1,
h2,
h3,
.hero-copy strong,
.panel-head strong {
  font-family: var(--ry-font);
  letter-spacing: var(--ry-tracking-heading);
}

h1 {
  font-weight: var(--ry-fw-display);
  letter-spacing: var(--ry-tracking-display);
}

.eyebrow,
.ry-label {
  color: var(--ry-muted);
  font-size: var(--ry-fs-label);
  font-weight: var(--ry-fw-label);
  letter-spacing: var(--ry-tracking-label);
  text-transform: uppercase;
}

/* ——— Surfaces: tint and space first, not a card stack ——————— */
.panel,
.tabs-card,
.leaderboard-card,
.race-card,
.podium-card,
.custom-lesson-card,
.custom-lesson-box,
.add-lesson-panel,
.progress-panel,
.completed-panel,
.profile-panel,
.tab-panel {
  border-radius: var(--ry-radius-lg);
  box-shadow: none;
}

.quick-stats article,
.rank-row,
.learner,
.homework-card,
.step-chooser {
  border-radius: var(--ry-radius-md);
  box-shadow: none;
}

/* ——— 16:9 board: rail + stage, not a phone column ——————————— */
.dash-board {
  display: grid;
  gap: var(--ry-space-3);
  padding: 0 var(--ry-space-2) var(--ry-space-4);
}

.dash-rail,
.dash-work,
.league-arena,
.standings {
  min-width: 0;
}

.work-empty {
  display: none;
  gap: var(--ry-space-1);
  min-height: 280px;
  padding: var(--ry-space-4);
  color: var(--ry-ink-soft);
  border-radius: var(--ry-radius-lg);
  background: color-mix(in srgb, var(--ry-coral-soft) 42%, #fff);
}

.work-empty strong {
  font-family: var(--ry-font);
  font-size: var(--ry-fs-title);
  font-weight: var(--ry-fw-display);
  letter-spacing: var(--ry-tracking-display);
  line-height: var(--ry-lh-display);
}

.work-empty span {
  max-width: 36ch;
  color: var(--ry-muted);
  font-weight: var(--ry-fw-body);
}

.dash-work:not(:has(.is-open)) .work-empty {
  display: grid;
  align-content: center;
}

/* ——— Heroes: each room a different wash ——— */
.league-hero {
  position: relative;
  overflow: hidden;
  margin: 0;
  color: #fff;
  border-radius: var(--ry-radius-lg);
  background:
    radial-gradient(circle at 88% 8%, rgba(255, 255, 255, 0.32), transparent 8rem),
    var(--ry-grad-hero-league);
  box-shadow:
    0 var(--ry-edge-lg) 0 var(--ry-league-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.account-hero {
  position: relative;
  overflow: hidden;
  margin: 0;
  color: #fff;
  border-radius: var(--ry-radius-lg);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.28), transparent 8rem),
    var(--ry-grad-hero-account);
  box-shadow:
    0 var(--ry-edge-lg) 0 var(--ry-coral-deep),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.class-hero {
  position: relative;
  overflow: hidden;
  margin: 0;
  color: #fff;
  border-radius: var(--ry-radius-lg);
  background:
    radial-gradient(circle at 92% 0%, rgba(255, 255, 255, 0.38), transparent 8rem),
    var(--ry-grad-hero-class);
  box-shadow:
    0 var(--ry-edge-lg) 0 var(--ry-class-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.class-hero p,
.class-hero h1 {
  color: #fff;
  text-shadow: 0 1px 0 rgba(122, 24, 32, 0.18);
}

.class-hero p {
  color: rgba(255, 255, 255, 0.82);
}

.league-badge,
.badge-tier {
  background: var(--ry-grad-hero-gold);
  box-shadow:
    0 var(--ry-edge) 0 var(--ry-amber-dark),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.progress-track,
.race-progress {
  border-radius: var(--ry-radius-pill);
  background: color-mix(in srgb, var(--ry-teal-soft) 70%, #fff);
  box-shadow: inset 0 1px 2px rgba(22, 48, 36, 0.1);
}

.progress-track span,
.race-progress span {
  background: linear-gradient(90deg, var(--ry-coral), var(--ry-teal) 70%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.32);
}

.room-league .progress-track span,
.room-league .race-progress span {
  background: linear-gradient(90deg, var(--ry-teal), var(--ry-coral));
}

.room-class .progress-track span {
  background: linear-gradient(90deg, var(--ry-coral), var(--ry-teal));
}

/* ——— Controls: the bottom edge is the shared tactile signature ——— */
.step-btn,
.refresh-button,
.tab,
.homework-card button,
.homework-controls button,
.custom-lesson-actions button {
  border-radius: var(--ry-radius-md);
  font-family: var(--ry-font);
  font-weight: var(--ry-fw-label);
  transition:
    background var(--ry-duration-fast) var(--ry-ease),
    box-shadow var(--ry-duration-fast) var(--ry-ease),
    transform var(--ry-duration-fast) var(--ry-spring);
}

.step-btn:active,
.refresh-button:active,
.tab:active,
.homework-card button:active,
.homework-controls button:active,
.custom-lesson-actions button:active {
  transform: translateY(var(--ry-edge));
}

.tab.active,
.homework-controls button.active,
.step-btn.active {
  color: #fff;
  background: var(--ry-coral);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-coral-deep);
}

.room-class .step-btn[data-step="invite"].active {
  background: var(--ry-coral);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-coral-deep);
}

.room-class .step-btn[data-step="plan"].active {
  background: var(--ry-teal);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-teal-deep);
}

.room-class .step-btn[data-step="homework"].active {
  background: var(--ry-coral);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-coral-deep);
}

.room-class .step-btn[data-step="progress"].active {
  background: var(--ry-teal);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-teal-deep);
}

.room-class .step-btn[data-step="add-lesson"].active {
  color: #fff;
  background: var(--ry-coral);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-coral-deep);
}

.room-class .step-btn[data-step="add-lesson"].active small {
  color: rgba(255, 255, 255, 0.78);
}

.room-league .tab.active,
.room-league .refresh-button {
  background: var(--ry-teal);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-teal-deep);
}

.room-account .tab.active {
  background: var(--ry-teal);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-teal-deep);
}

.refresh-button {
  color: #fff;
  background: var(--ry-coral);
  box-shadow: 0 var(--ry-edge) 0 var(--ry-coral-deep);
}

.pill {
  border-radius: var(--ry-radius-sm);
  font-weight: var(--ry-fw-label);
  letter-spacing: var(--ry-tracking-label);
  text-transform: uppercase;
}

:focus-visible {
  outline: 2px solid var(--ry-ink);
  outline-offset: 2px;
}

/* ——— Dock: icons first, coral underline on the active tab ——————— */
.bottom-dock {
  left: 0;
  right: 0;
  bottom: 0;
  justify-content: center;
  width: 100%;
  max-width: none;
  padding: 4px var(--ry-space-1) calc(4px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--ry-ink) 8%, transparent);
  border-radius: 0;
  background: color-mix(in srgb, var(--ry-cream) 94%, #ffffff);
  box-shadow: none;
  backdrop-filter: blur(12px);
  transform: none;
}

.room-class .bottom-dock,
.room-league .bottom-dock,
.room-account .bottom-dock {
  border-top-color: color-mix(in srgb, var(--ry-ink) 8%, transparent);
  background: color-mix(in srgb, var(--ry-cream) 94%, #ffffff);
}

.bottom-nav {
  justify-content: space-between;
  width: 100%;
  max-width: 1440px;
  min-height: 64px;
}

.bottom-nav a {
  --nav-hue: var(--ry-coral);
  --nav-hue-edge: var(--ry-coral-deep);
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  padding: 6px 2px 10px;
  color: var(--ry-ink-soft);
  border-radius: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.bottom-nav a::before {
  content: "";
  width: 26px;
  height: 26px;
  background-color: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

.bottom-nav a:nth-child(1)::before,
.bottom-nav a[data-dock="learn"]::before {
  -webkit-mask-image: url("./assets/dock/learn.svg");
  mask-image: url("./assets/dock/learn.svg");
}

.bottom-nav a:nth-child(2)::before,
.bottom-nav a[data-dock="class"]::before {
  -webkit-mask-image: url("./assets/dock/class.svg");
  mask-image: url("./assets/dock/class.svg");
}

.bottom-nav a:nth-child(3)::before,
.bottom-nav a[data-dock="sim"]::before {
  -webkit-mask-image: url("./assets/dock/sim.svg");
  mask-image: url("./assets/dock/sim.svg");
}

.bottom-nav a:nth-child(4)::before,
.bottom-nav a[data-dock="rank"]::before {
  -webkit-mask-image: url("./assets/dock/rank.svg");
  mask-image: url("./assets/dock/rank.svg");
}

.bottom-nav a:nth-child(5)::before,
.bottom-nav a[data-dock="account"]::before {
  -webkit-mask-image: url("./assets/dock/account.svg");
  mask-image: url("./assets/dock/account.svg");
}

.bottom-nav a:nth-child(1) { --nav-hue: var(--ry-coral); --nav-hue-edge: var(--ry-coral-deep); }
.bottom-nav a:nth-child(2) { --nav-hue: var(--ry-coral); --nav-hue-edge: var(--ry-coral-deep); }
.bottom-nav a:nth-child(3) { --nav-hue: var(--ry-teal); --nav-hue-edge: var(--ry-teal-deep); }
.bottom-nav a:nth-child(4) { --nav-hue: var(--ry-coral); --nav-hue-edge: var(--ry-coral-deep); }
.bottom-nav a:nth-child(5) { --nav-hue: var(--ry-teal); --nav-hue-edge: var(--ry-teal-deep); }

.bottom-nav span,
.bottom-nav a span {
  display: block;
  min-width: 0;
  height: auto;
  padding: 0;
  color: inherit;
  border-radius: 0;
  background: none !important;
  box-shadow: none !important;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.bottom-nav a:hover {
  color: var(--ry-ink);
  background: transparent;
}

.bottom-nav a.active {
  color: var(--ry-coral);
}

.bottom-nav a.active span {
  background: none;
  box-shadow: none;
  color: var(--ry-coral);
}

.bottom-nav a.active::after {
  content: "";
  position: absolute;
  left: 30%;
  right: 30%;
  bottom: 4px;
  height: 3px;
  border-radius: 99px;
  background: var(--ry-coral);
}

/* ——— Wide instrument strip: labels visible, tabular counts ——— */
@media (min-width: 1100px) {
  .status-bar {
    gap: 12px;
    min-height: 58px;
    padding: 6px 16px 6px 10px;
  }

  .stat {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    min-width: 0;
    min-height: 0;
    padding: 0;
  }

  .stat::before {
    position: static;
  }

  .stat span {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.1;
  }

  .dash-board--class {
    grid-template-columns: minmax(280px, 0.34fr) minmax(0, 1fr);
    align-items: start;
    min-height: calc(100dvh - 88px - var(--dock-space));
  }

  .dash-board--league {
    grid-template-columns: minmax(320px, 0.4fr) minmax(0, 1fr);
    align-items: stretch;
    min-height: calc(100dvh - 88px - var(--dock-space));
  }

  .dash-board--account {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
    grid-template-areas:
      "hero stats"
      "tabs tabs"
      "main main";
  }

  .dash-board--account .account-hero { grid-area: hero; }
  .dash-board--account .quick-stats { grid-area: stats; }
  .dash-board--account .tabs-row { grid-area: tabs; }
  .dash-board--account .tab-panel.active { grid-area: main; }

  .dash-rail {
    position: sticky;
    top: 84px;
    display: grid;
    gap: var(--ry-space-2);
    align-content: start;
    max-height: calc(100dvh - 96px - var(--dock-space));
    overflow-y: auto;
    padding-bottom: var(--ry-space-2);
  }

  .dash-work {
    padding: var(--ry-space-3);
    border-radius: var(--ry-radius-lg);
    background: color-mix(in srgb, #ffffff 78%, var(--ry-coral-soft));
  }

  .dash-work:not(:has(.is-open)) {
    min-height: calc(100dvh - 120px - var(--dock-space));
  }

  .league-arena {
    display: grid;
    align-content: start;
    gap: var(--ry-space-2);
  }

  .standings {
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: var(--ry-space-2);
    min-height: 0;
    padding: var(--ry-space-3);
    border-radius: var(--ry-radius-lg);
    background: color-mix(in srgb, #ffffff 80%, var(--ry-teal-soft));
  }

  .standings .rank-list {
    min-height: 0;
    overflow: auto;
  }
}

/* Google sign-in chip (Account + every header avatar) */
.ry-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ry-auth .status-avatar,
.ry-auth .top-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 800;
}

.ry-auth-signin,
.ry-auth-signout {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
}

.ry-auth-signin {
  color: #1f1f1f;
  border: 1px solid #dadce0;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.ry-auth-signout {
  color: var(--ry-muted, #3d5c66);
  border: 0;
  background: transparent;
}

.ry-auth-email {
  max-width: 16ch;
  overflow: hidden;
  color: var(--ry-ink, #163038);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ry-auth-note {
  flex: 1 1 100%;
  margin: 8px 0 0;
  color: var(--ry-muted, #3d5c66);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.ry-auth--full {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.ry-auth--full .ry-auth-note {
  flex: 1 0 100%;
  width: 100%;
}

.ry-auth--full .ry-auth-signin,
.ry-auth--full .ry-auth-signout {
  min-height: 44px;
  padding: 10px 18px;
  font-size: 0.92rem;
}

.status-avatar.has-photo,
.top-avatar.has-photo,
.avatar-card.has-photo {
  color: transparent;
}

@media (max-width: 1100px) {
  .status-meter .ry-auth-email {
    display: none;
  }
}

.lesson-topbar .ry-auth-email {
  display: none;
}

.ry-auth [hidden] {
  display: none !important;
}

html.ry-public .ry-auth,
html.ry-public [data-ry-auth],
html.ry-public [data-ry-signin],
html.ry-public [data-ry-signout] {
  display: none !important;
}
