/* Component styles for the mode page and the player profile.
 *
 * These blocks were written against tiermc.css, which the mode and player pages
 * used to load. Those pages now share ref.css + palette.css with the rest of the
 * site, so the rules are restated here against the new palette variables:
 *   --panel -> --card      --panel-2 -> --secondary   --text -> --foreground
 *   --muted -> --muted-foreground   --dim -> --text-disabled
 *   --border-soft -> --border
 * The region and tier variables are shared with ref.css and palette.css.
 */

/* ---------------- status / errors ---------------- */
.notice {
  margin: 12px 0;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl, 14px);
  background: var(--secondary);
  color: var(--foreground);
  font-size: 14px;
}
.errbox {
  margin: 18px 0;
  padding: 14px 16px;
  border: 2px solid #5c2b31;
  border-radius: var(--radius-xl, 14px);
  background: #26161a;
  color: #ffb9b9;
  font-size: 14px;
}
.status {
  padding: 26px 4px;
  color: var(--muted-foreground);
  font-size: 14px;
}

/* ---------------- mode page header ---------------- */
.mode-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 26px 0 18px;
}
.mode-hero .mode-hero-logo { display: flex; align-items: center; justify-content: center; }
.mode-hero .mode-hero-logo img { width: 62px; height: 62px; object-fit: contain; }
.mode-hero .mode-hero-logo .fallback-logo { display: none; }
.mode-hero .mode-hero-logo.no-logo .fallback-logo { display: flex; }
.mode-hero .fallback-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 14px;
  background: var(--secondary);
  border: 1px solid var(--border);
  font-size: 26px;
  font-weight: 800;
  color: var(--muted-foreground);
}
.mode-hero h1 { margin: 0; font-size: 26px; letter-spacing: -0.5px; color: var(--foreground); }
.mode-hero p { margin: 4px 0 0; color: var(--muted-foreground); font-size: 14px; }
.mode-info-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--secondary);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.mode-info-btn:hover { filter: brightness(1.12); }
.mode-info-btn .info-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 800;
}

/* ---------------- mode page: the tier board ----------------
   Five columns, each headed by a coloured bar and holding one row per player.
   The board is 80rem wide minimum and scrolls sideways rather than squashing,
   which is what the reference does. */
#rankings { display: block; }
.tier-board-wrap {
  margin: 16px 0 24px;
  overflow-x: auto;
  overflow-y: hidden;
}
.tier-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  min-width: 80rem;
  padding-bottom: 8px;
}
/* the tier icon sits inside the coloured head */
.tier-head-icon { flex: 0 0 auto; object-fit: contain; image-rendering: pixelated; }
.tier-empty {
  padding: 10px 8px;
  color: var(--text-disabled);
  font-size: 12px;
  font-style: italic;
}
/* A retired tier still lists the player, just dimmed. */
.is-retired { opacity: 0.72; }
/* The row is 36px (h-9) with no padding of its own; the head and name are
   separated by the row's 8px gap. */
.tier-board [role="button"] { font-size: 14px; }
.tier-board [role="button"] img { flex: 0 0 auto; object-fit: cover; }
.tier-board [role="button"] > span.truncate {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- player profile: the reference's dialog ----------------
   A full-screen overlay holding a rounded card: the bust in a ring coloured by
   placement, the name, title badge, region and NameMC link, then the POSITION
   block and the TIERS grid. Markup and classes are the reference's own. */
.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.8);
  overflow-y: auto;
}
.profile-dialog {
  position: relative;
  width: 100%;
  max-width: 32rem;
  height: fit-content;
  padding: 32px 40px;
  border-radius: 24px;
  background: var(--card);
  color: var(--foreground);
}
.profile-close {
  float: right;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: -8px -16px 0 0;
  border: 0;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  cursor: pointer;
  transition: filter 0.12s;
}
.profile-close:hover { filter: brightness(1.15); }

/* --- head: ring, name, title badge, region, NameMC --- */
.profile-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  text-align: center;
}
.profile-avatar-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  height: 112px;
  margin: 0 auto;
  overflow: clip;
  padding-top: 14px;
  border: 2px solid var(--placement-other);
  border-radius: 999px;
  background: #1e293b;
}
.profile-avatar-ring img { width: 95px; height: 95px; object-fit: contain; object-position: center bottom; }
.profile-title-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(107, 114, 128, 0.3);
  color: var(--muted-foreground);
  font-size: 18px;
  font-weight: 500;
}
.profile-title-badge img { width: 30px; height: 30px; object-fit: contain; }
.profile-namemc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: 14px;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.profile-namemc:hover { background: var(--secondary); color: var(--secondary-foreground); filter: brightness(1.1); }
.profile-namemc-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 4px;
  border-right: 2px solid var(--muted);
}

/* A profile that could not load says so in a small self-dismissing notice, and a
   profile still loading shows a quiet line in the card. */
.profile-toast {
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--foreground);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.profile-loading {
  margin: 0;
  padding: 24px 8px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 15px;
}

/* Tier slots in a panel: a fixed 40x56 box that shows a tooltip on hover, so a
   retired or peaked tier explains itself without leaving the page. */
.tier-slot { position: relative; }
.tier-slot .tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: 40;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.12s, transform 0.12s;
}
.tier-slot:hover .tip { opacity: 1; transform: translate(-50%, 0); }

/* --- body: POSITION and TIERS --- */
.profile-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}
/* the reference's shared panel: a gradient card with a hairline outline.
   The tier grid must not clip its slot tooltips. */
.profile-box_styles {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.55), rgba(15, 23, 42, 0.35));
}
@media (max-width: 640px) {
  .profile-dialog { padding: 24px 18px; }
  .profile-box_styles { flex-wrap: wrap; }
}
/* ---------------- header search dropdown ----------------
   initSearch() fills #search-results; the panel hangs under the input. */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  max-width: 90vw;
  z-index: 300;
  display: none;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl, 14px);
  background: var(--card);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.search-results.open { display: block; }
.search-results a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--foreground);
  text-decoration: none;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover { background: var(--secondary); }
.search-results .avatar { width: 26px; height: 26px; border-radius: 6px; }
.search-results .sr-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .sr-pts { color: var(--muted-foreground); font-size: 12px; }

/* ---------------- responsive ----------------
   The tier board keeps its five columns at every width and scrolls instead of
   re-flowing, so there is nothing to override for it here. */
@media (max-width: 640px) {
  .tier-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-hero { flex-wrap: wrap; }
  .profile-sheet { padding: 32px 16px 18px; }
}
