/* TierMC palette.
 *
 * ref.css is the reference site's own compiled stylesheet, adopted as-is so the
 * markup can be theirs exactly. It sets its colours inside `@layer theme`, which
 * an unlayered rule always beats - so this file simply restates the theme with
 * the TierMC scheme and nothing in ref.css can override it.
 *
 * Structure, spacing and geometry all come from ref.css untouched; only the
 * colours below are ours.
 */

:root,
.dark {
  /* --- surfaces --- */
  --background: #08090c;
  --foreground: #e9ebef;

  --card: #101319;
  --card-foreground: #e9ebef;

  --popover: #101319;
  --popover-foreground: #e9ebef;

  /* --- interactive surfaces: their --secondary/--accent sits behind tabs,
         buttons and row hover --- */
  --secondary: #1c212c;
  --secondary-foreground: #e9ebef;

  --muted: #151922;
  --muted-foreground: #868f9e;

  --accent: #1c212c;
  --accent-foreground: #e9ebef;

  --border: #21262f;
  --input: #21262f;
  --ring: #3a4150;

  /* --- brand ---
     Buttons are blue site-wide: every button draws its fill from --primary, so
     setting the token here recolours all of them at once. */
  --primary: #2563eb;
  --primary-foreground: #ffffff;
  --destructive: #ff6568;

  /* --- layout sections: the header, footer and card backgrounds --- */
  --layout-sections-color: #101319;
  --layout-item-outline: #21262f;

  /* --- text tiers used by the rows --- */
  --text-disabled: #5f6774;
  --color-slate-300: #e9ebef;
  --color-slate-400: #868f9e;
  --color-slate-600: #5f6774;
  --color-slate-700: #21262f;

  /* --- regions and tiers: already the TierMC values, restated so this file is
         the single place the palette lives --- */
  --na: #442228;
  --na-foreground: #d95c6a;
  --eu: #1c3e20;
  --eu-foreground: #89f19c;
  --as: #422c3f;
  --as-foreground: #af7f91;
  --au: #392e27;
  --au-foreground: #d5ad80;
  --sa: #193845;
  --sa-foreground: #5dccdc;
  --me: #4d4525;
  --me-foreground: #e5d386;

  --ht1: #6d5d2c; --ht1-foreground: #e8ba3a;
  --lt1: #584c25; --lt1-foreground: #d5b355;
  --ht2: #5e6979; --ht2-foreground: #c4d3e7;
  --lt2: #4a505a; --lt2-foreground: #a0a7b2;
  --ht3: #6b4b36; --ht3-foreground: #f89f5a;
  --lt3: #593722; --lt3-foreground: #c67b42;
  --ht4: #303144; --ht4-foreground: #81749a;
  --lt4: #2c2e40; --lt4-foreground: #655b79;
  --ht5: #2b2c3d; --ht5-foreground: #8f82a8;
  --lt5: #262a3a; --lt5-foreground: #655b79;

  --placement-1: #e5ba43;
  --placement-2: #808c9c;
  --placement-3: #b56326;
  --placement-other: #1e2634;

  /* --- gamemode tier board ---
     One coloured column head per tier, and a row fill that says whether the
     player is in the high or low half of their tier. Values are the reference's
     own, restated here so the palette stays in one place. */
  --tier-1: #41361b;
  --tier-1-foreground: #f0b857;
  --tier-2: #343843;
  --tier-2-foreground: #a9b1b9;
  --tier-3: #352620;
  --tier-3-foreground: #d59161;
  --tier-4: #161e2a;
  --tier-4-foreground: #b1c0cc;
  --tier-5: #161e2a;
  --tier-5-foreground: #b1c0cc;

  --hightier: #263244;
  --hightier-hover: #3e4f68;
  --lowtier: #161e2a;
  --lowtier-hover: #263242;
  --hightier-icon-foreground: #3d526f;
  --hightier-icon-foreground-hover: #637998;
  --lowtier-icon-foreground: #253449;
  --lowtier-icon-foreground-hover: #374d6c;
}

/* The reference paints the page background via --background; keep the body on
   the same token so nothing falls back to their near-black. */
body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-geist-sans), ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* TierMC wordmark in the header, replacing the reference's nav_skip.png. */
.nav-brand {
  width: auto;
  height: 40px;
  object-fit: contain;
}
/* "TierMC" beside the mark. This is the site name, so it uses the text colour
   rather than the muted tone the reference gives its nav links. */
.brand-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--foreground);
}

/* The column labels are white, not muted. The reference uses text-muted for
   these, so this is an intentional departure. */
#cols,
#cols-wide,
#cols-narrow {
  color: var(--foreground);
}

/* On Discords and API Docs the mode tabs are not shown at all: those pages do
   not belong to any gamemode, so there is nothing for the strip to switch. */
#mode-tabs[data-enabled="0"] {
  display: none;
}

/* ---------------- information modal ----------------
   Restored: the reference has an Information button in the card toolbar. The
   modal is built by openInfoModal() in tiers.js. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 5, 8, 0.72);
  backdrop-filter: blur(3px);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl, 14px);
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal h3 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--foreground); }
.modal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}
.modal-tab {
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.modal-tab.on {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ---------------- gamemode tabs: simple blue ----------------
   Styled here rather than with utility classes: the reference stylesheet only
   compiles the variants its own markup used, so anything like border-primary/40
   would simply not exist and the border would vanish. */
#mode-tabs {
  gap: 6px;
}
.mode-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 92px;
  padding: 10px 14px 9px;
  /* Neutral outline, not blue: blue is for things you press. Only the active
     tab is filled. */
  border: 2px solid var(--border);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: transparent;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.mode-tab:hover {
  background: var(--secondary);
  border-color: var(--ring);
  color: var(--foreground);
}
.mode-tab.on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.mode-tab-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
/* the active tab's icon reads on the blue fill */
.mode-tab.on img { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }

/* ---------------- mode icons ----------------
   The mode art is 1080x1080 pixel art. Rendering it as plain pixel art (no
   smoothing) keeps the edges crisp at the small sizes used in the tabs, the tier
   chips and the tier slots, and centring it stops any icon sitting off-axis.
   One rule per context so every icon reads the same wherever it appears. */
#mode-tabs img.mode-icon,
#mode-tabs a img,
.overall_player__slots-wrapper img,
#discords img,
.dc-logo img,
.tt-logo img,
.tc-logo img {
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
}
/* tabs */
#mode-tabs a img,
#mode-tabs img.mode-icon {
  width: 26px;
  height: 26px;
  display: block;
}
/* tier chips in a ranking row */
.overall_player__slots-wrapper img { width: 20px; height: 20px; display: block; }
/* discords cards */
.dc-logo img { width: 28px; height: 28px; display: block; }
.tt-logo img { padding: 4px; }

/* ---------------- buttons: one simple blue style ----------------
   Every button on the site resolves to the same shape and the same blue, so
   nothing looks one-off. Text is white on the fill. */
.btn,
.invite-btn,
.api-back,
.modal-tab.on,
#info-btn,
button[data-slot="popover-trigger"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.12s;
}
.btn:hover,
.invite-btn:hover,
.modal-tab.on:hover,
#info-btn:hover,
button[data-slot="popover-trigger"]:hover { filter: brightness(1.12); }
.btn:active,
.invite-btn:active,
#info-btn:active { filter: brightness(0.94); }

/* The Information button is red on purpose: it opens an explainer sheet rather
   than doing something, so it should not read as one more primary action. Its
   hover/active brightness comes from the rules above; only the fill changes. */
#info-btn {
  background: #dc2626;
  color: #ffffff;
}

/* Quiet buttons stay blue but unfilled, so they read as secondary. */
.modal-tab,
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.modal-tab:hover { background: var(--secondary); color: var(--foreground); }
.modal-close {
  padding: 0;
  width: 32px;
  height: 32px;
  font-size: 19px;
}
.modal-close:hover { background: var(--secondary); color: var(--foreground); }

/* The tier tiles, mode chips and API rows are links, not buttons: they stay
   neutral so the blue is reserved for things you actually press. */
.mode-info-btn {
  border: 0;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
}
.mode-info-btn:hover { filter: brightness(1.12); }
.mode-info-btn .info-dot {
  background: var(--primary-foreground);
  color: var(--primary);
}
/* The title ladder: one row per title with its threshold. */
.ladder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.ladder-row:last-child { border-bottom: 0; }
.ladder-row .point-pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--foreground);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.mode-points-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.mode-points-row:last-child { border-bottom: 0; }

/* ---------------- api docs page ---------------- */
.api-doc {
  padding: 8px 0 24px;
  color: var(--foreground);
}
.api-doc h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.api-lede {
  margin: 0 0 22px;
  font-size: 15px;
  color: var(--muted-foreground);
}
.api-section { margin-bottom: 26px; }
.api-section h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--foreground);
}
.api-endpoint {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 11px 14px;
  margin-bottom: 7px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  background: var(--card);
  color: var(--foreground);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.api-endpoint:hover { border-color: var(--ring); background: var(--secondary); }
.api-endpoint code {
  flex: 0 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--primary);
  white-space: nowrap;
}
.api-endpoint span {
  font-size: 13px;
  color: var(--muted-foreground);
}
.api-note {
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted-foreground);
}
.api-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--foreground);
}
@media (max-width: 640px) {
  .api-endpoint { flex-direction: column; gap: 4px; }
  .api-endpoint code { white-space: normal; }
}

/* ---------------- discords page ----------------
   The card markup is unchanged; these are its styles, moved here because the
   page now loads ref.css + palette.css like every other page. */
#discords {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0 24px;
}
.discord-main {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl, 14px);
  background: linear-gradient(180deg, var(--secondary), var(--card));
  text-decoration: none;
  color: var(--foreground);
  transition: border-color 0.15s, transform 0.15s;
}
a.discord-main:hover { border-color: var(--ring); transform: translateY(-2px); }
.discord-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.discord-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl, 14px);
  background: var(--card);
  text-decoration: none;
  color: var(--foreground);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
a.discord-card:hover {
  border-color: var(--ring);
  background: var(--secondary);
  transform: translateY(-2px);
}
/* The real Discord icon, not a masked tile - the masked version could fail to
   paint and left an empty blue square. */
.discord-glyph {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.dc-logo {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--secondary);
}
.dc-logo img { width: 28px; height: 28px; object-fit: contain; }
/* The letter tile is a fallback ONLY, for when the mode icon fails to load.
   Without this rule it showed alongside the icon - the stray "S" next to SMP. */
.dc-logo .fallback-logo { display: none; }
.dc-logo.no-logo img { display: none; }
.dc-logo.no-logo .fallback-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--muted-foreground);
}
.dc-name { min-width: 0; flex: 1 1 auto; }
.dc-name h2,
.dc-name h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground);
}
.dc-name p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted-foreground);
}
.dc-cta { flex: 0 0 auto; }
.invite-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.invite-missing {
  font-size: 12px;
  color: var(--muted-foreground);
  font-style: italic;
}
/* A notice banner, used when no invites are configured. */
.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;
}
@media (max-width: 640px) {
  .discord-grid { grid-template-columns: 1fr; }
  .discord-main { flex-direction: column; align-items: flex-start; }
}
