/* ── Wiki Race — page layout ─────────────────────────────────── */

.wr-body {
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #14110e;
  background-image:
    linear-gradient(rgba(14, 11, 9, 0.55), rgba(9, 7, 6, 0.7)),
    url('assets/feature-images/background.png');
  background-size: auto, cover;
  background-position: center;
  display: flex;
  flex-direction: column;
}

.wr-container {
  width: min(1000px, 96vw);
  margin: 0 auto;
  padding: 12px 0 32px;
  flex: 1 0 auto;
}

.wr-body > .site-footer {
  margin-top: auto;
  flex-shrink: 0;
}

/* ── Header ── */
.wr-header {
  text-align: center;
  margin-bottom: 10px;
}

/* Same treatment as .srt-title (Quill 8 = OSRS NPC dialogue font) */
.wr-title {
  font-family: 'Quill 8', 'RuneScape Bold', Arial, serif;
  color: var(--osrs-gold);
  font-size: 48px;
  margin: 6px 0 2px;
  text-shadow: 2px 2px 0 var(--osrs-black);
}

.wr-puzzle-number {
  color: rgba(255, 207, 63, 0.85);
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 1.05rem;
}

/* ── Race HUD ── */
.wr-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 14px;
  margin-bottom: 8px;
}

.wr-route {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 320px;
}

.wr-route-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wr-route-label {
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 207, 63, 0.7);
}

.wr-route-page {
  font-family: 'RuneScape Bold', Arial, sans-serif;
  font-size: 1.15rem;
  color: var(--osrs-yellow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wr-route-target {
  color: var(--osrs-gold);
  text-shadow: 0 0 6px rgba(230, 165, 25, 0.35);
}

.wr-route-arrow {
  color: var(--osrs-gold);
  font-size: 1.4rem;
  flex: 0 0 auto;
}

.wr-hud-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.wr-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
}

.wr-stat-label {
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 207, 63, 0.7);
}

.wr-stat-value {
  font-family: 'RuneScape Bold', Arial, sans-serif;
  font-size: 1.25rem;
  color: #fff;
}

.wr-hud-actions {
  display: flex;
  gap: 8px;
}

.wr-giveup-btn {
  color: #e07a7a;
}

.wr-giveup-btn:hover {
  border-color: var(--osrs-red);
  color: #ff9c9c;
}

.wr-giveup-confirm {
  border-color: var(--osrs-red);
  color: #ff9c9c;
}

.wr-giveup-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── Path breadcrumb ── */
.wr-path {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin-bottom: 8px;
  scrollbar-width: thin;
}

.wr-path:empty {
  display: none;
}

.wr-path-chip {
  flex: 0 0 auto;
  background: #26241f;
  border: 1px solid var(--osrs-ui-border);
  border-radius: 12px;
  padding: 3px 10px;
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.92rem;
  color: rgba(255, 230, 166, 0.85);
  white-space: nowrap;
}

.wr-path-chip.current {
  border-color: var(--osrs-gold);
  color: var(--osrs-gold);
}

.wr-path-sep {
  flex: 0 0 auto;
  color: rgba(255, 207, 63, 0.5);
  font-size: 0.85rem;
}

/* ── Article viewport ── */
.wr-article-panel {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.wr-article {
  height: min(66vh, 700px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 22px 28px;
  box-sizing: border-box;
  background: #211f1b;
  scrollbar-width: thin;
  scrollbar-color: var(--osrs-brown) #1b1a17;
}

.wr-article-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 17, 14, 0.72);
}

.wr-article-loading[hidden] {
  display: none !important;
}

.wr-article-loading-inner {
  font-family: 'RuneScape Bold', Arial, sans-serif;
  color: var(--osrs-gold);
  font-size: 1.3rem;
  text-shadow: 1px 1px 0 var(--osrs-black);
  animation: wr-pulse 1.1s ease-in-out infinite alternate;
}

@keyframes wr-pulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

/* ── Article content (scoped restyle of MediaWiki markup) ────── */
.wr-article-title {
  font-family: 'RuneScape Bold', Arial, sans-serif;
  color: var(--osrs-gold);
  font-size: 1.9rem;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--osrs-brown);
}

.wr-article,
.wr-article p,
.wr-article li,
.wr-article td,
.wr-article th,
.wr-article dd,
.wr-article dt,
.wr-article caption,
.wr-article figcaption {
  font-family: 'RuneScape', Arial, sans-serif;
  color: #e8dcc0;
  font-size: 1.02rem;
  line-height: 1.5;
}

.wr-article h2,
.wr-article h3,
.wr-article h4,
.wr-article h5 {
  font-family: 'RuneScape Bold', Arial, sans-serif;
  color: var(--osrs-gold);
  margin: 20px 0 8px;
}

.wr-article h2 {
  font-size: 1.45rem;
  border-bottom: 1px solid var(--osrs-brown);
  padding-bottom: 4px;
}

.wr-article h3 { font-size: 1.2rem; }

.wr-article p { margin: 0 0 10px; }

.wr-article ul,
.wr-article ol {
  margin: 0 0 10px;
  padding-left: 24px;
}

/* Racing links (main-namespace articles) */
.wr-article a.wr-link {
  color: #6fb1ff;
  text-decoration: none;
  cursor: pointer;
}

.wr-article a.wr-link:hover {
  color: #a3ccff;
  text-decoration: underline;
}

/* The winning link glows gold */
.wr-article a.wr-link-target {
  color: var(--osrs-gold);
  text-shadow: 0 0 6px rgba(230, 165, 25, 0.55);
  font-family: 'RuneScape Bold', Arial, sans-serif;
}

.wr-article a.wr-link-target:hover {
  color: var(--osrs-yellow);
}

/* Out-of-bounds links (external, files, categories, other namespaces) */
.wr-article a.wr-link-blocked {
  color: #8a8577;
  text-decoration: none;
  cursor: not-allowed;
}

/* In-page anchors (table of contents, references) */
.wr-article a.wr-link-anchor {
  color: #b0a888;
  text-decoration: none;
}

.wr-article a.wr-link-anchor:hover {
  color: #d8cfa8;
}

.wr-article img {
  max-width: 100%;
  height: auto;
}

/* Tables: infoboxes and wikitables restyled to the site's dark panels */
.wr-article table {
  border-collapse: collapse;
  max-width: 100%;
  background: #26241f;
  border: 1px solid var(--osrs-ui-border);
  margin: 0 0 12px;
}

.wr-article table th,
.wr-article table td {
  border: 1px solid #3a3833;
  padding: 4px 8px;
  font-size: 0.95rem;
}

.wr-article table th {
  background: #2e2c29;
  color: var(--osrs-yellow);
  font-family: 'RuneScape Bold', Arial, sans-serif;
}

.wr-article .infobox {
  float: right;
  clear: right;
  width: min(300px, 100%);
  margin: 0 0 12px 16px;
  font-size: 0.9rem;
}

.wr-article .infobox th.infobox-header {
  background: #3a2f14;
  color: var(--osrs-gold);
  font-size: 1.05rem;
  text-align: center;
}

.wr-article .infobox-image {
  text-align: center;
  background: #211f1b;
}

/* Navboxes (link farms at the bottom of articles) can be huge — keep them contained */
.wr-article .navbox {
  clear: both;
  display: block;
  overflow-x: auto;
  font-size: 0.85rem;
  margin-top: 16px;
}

/* Table of contents box */
.wr-article #toc,
.wr-article .toc {
  display: inline-block;
  background: #26241f;
  border: 1px solid var(--osrs-ui-border);
  padding: 8px 14px;
  margin: 0 0 12px;
  font-size: 0.92rem;
}

.wr-article #toc ul,
.wr-article .toc ul {
  list-style: none;
  padding-left: 12px;
  margin: 4px 0;
}

/* Thumbnails — only real thumbs float; inline figures (e.g. messagebox icons) stay put */
.wr-article figure {
  margin: 0;
}

.wr-article figure[typeof~="mw:File/Thumb"],
.wr-article .thumb {
  float: right;
  clear: right;
  margin: 0 0 12px 16px;
  background: #26241f;
  border: 1px solid var(--osrs-ui-border);
  padding: 6px;
  max-width: min(280px, 100%);
  box-sizing: border-box;
}

.wr-article figcaption,
.wr-article .thumbcaption {
  font-size: 0.85rem;
  color: #bdb298;
  padding-top: 4px;
}

.wr-article .gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
}

.wr-article pre,
.wr-article code {
  background: #1b1a17;
  border: 1px solid var(--osrs-ui-border);
  color: #d8cfa8;
  font-size: 0.9rem;
}

.wr-article blockquote {
  border-left: 3px solid var(--osrs-brown);
  margin: 0 0 10px;
  padding: 4px 12px;
  color: #cfc4a4;
}

/* Noise from wiki markup that has no place in the game */
.wr-article .mw-editsection,
.wr-article .rs-external-header-links,
.wr-article .mw-indicators,
.wr-article .metadata.mbox-small {
  display: none !important;
}

/* Gadget data the wiki hides with its own CSS/JS: switch-infobox resource
   blobs, collapsed "advanced" rows, and JS-only DPS calculator buttons */
.wr-article .hidden,
.wr-article .infobox-switch-resources,
.wr-article tr.advanced-data,
.wr-article .dps-calc,
.wr-article .dps-calc-button,
.wr-article .dps-calc-openbtn {
  display: none !important;
}

/* Switch-infobox variant tabs (Serpentine / Magma / Tanzanite etc.) —
   functional via wiki-race.js */
.wr-article .infobox-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 0 0 4px;
}

.wr-article .infobox-buttons .button {
  cursor: pointer;
  background: #2e2c29;
  border: 1px solid var(--osrs-ui-border);
  border-radius: 4px;
  padding: 2px 10px;
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.9rem;
  color: var(--osrs-yellow);
  user-select: none;
}

.wr-article .infobox-buttons .button:hover {
  border-color: var(--osrs-gold);
}

.wr-article .infobox-buttons .button-selected {
  background: #3a2f14;
  border-color: var(--osrs-gold);
  color: var(--osrs-gold);
}

/* Warning/notice banners: calmer than generic tables */
.wr-article .messagebox {
  background: #2a2320;
  border: 1px solid var(--osrs-brown);
  width: 100%;
}

.wr-article .messagebox.warn {
  background: #331f1c;
  border-color: #6b3a32;
}

.wr-article .messagebox th,
.wr-article .messagebox td {
  border: none;
  background: transparent;
}

.wr-article::after {
  content: '';
  display: block;
  clear: both;
}

/* ── Result modal ── */
.wr-dialog {
  position: relative;
  max-width: 480px;
}

.wr-result-dialog {
  max-width: 520px;
  padding: 20px 22px 18px;
}

/* Hierarchy: big celebration title → hero stat plaques → share CTA →
   route chips → leaderboard → countdown. Section labels stay quiet. */
.wr-result-head {
  text-align: center;
  margin: 2px 0 14px;
}

.modal .dialog h2.wr-result-heading {
  font-family: 'Quill 8', 'RuneScape Bold', Arial, serif;
  font-size: 38px;
  color: var(--osrs-gold);
  text-shadow: 2px 2px 0 var(--osrs-black);
  text-align: center;
  margin: 0 0 2px;
}

.modal .dialog p.wr-result-sub {
  text-align: center;
  margin: 0;
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 1rem;
  color: rgba(255, 207, 63, 0.7);
}

.wr-result-sub-page {
  color: var(--osrs-yellow);
  font-family: 'RuneScape Bold', Arial, sans-serif;
}

/* Stat plaques — the hero of the screen */
.wr-result-stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 0 0 16px;
}

.wr-result-stats:empty {
  display: none;
}

.wr-result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 108px;
  padding: 10px 18px 8px;
  background: #1b1a17;
  border: 2px solid var(--osrs-brown);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 2px 6px rgba(0, 0, 0, 0.5), 0 2px 0 rgba(0, 0, 0, 0.35);
}

.wr-result-stat-value {
  font-family: 'RuneScape Bold', Arial, sans-serif;
  font-size: 2.1rem;
  line-height: 1.1;
  color: var(--osrs-gold);
  text-shadow: 1px 1px 0 var(--osrs-black);
}

.wr-result-stat-label {
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 207, 63, 0.55);
}

.wr-result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 0 4px;
}

.wr-share-btn {
  min-width: 210px;
  padding: 10px 18px;
  font-size: 1.05rem;
}

/* Quiet small-caps section labels so the data outranks the headings */
.wr-result-path-title,
.wr-lb-title {
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-weight: normal;
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 207, 63, 0.55);
  text-align: center;
  margin: 0 0 8px;
}

.wr-result-path-wrap {
  margin-top: 16px;
}

.wr-result-path {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 6px;
}

.wr-result-chip {
  background: #26241f;
  border: 1px solid var(--osrs-ui-border);
  border-radius: 12px;
  padding: 2px 10px;
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.9rem;
  color: rgba(255, 230, 166, 0.85);
  white-space: nowrap;
}

.wr-result-chip.target {
  border-color: var(--osrs-gold);
  color: var(--osrs-gold);
  text-shadow: 0 0 5px rgba(230, 165, 25, 0.35);
}

.wr-result-chip-sep {
  color: rgba(255, 207, 63, 0.45);
  font-size: 0.85rem;
}

/* Leaderboard sits in its own clearly-separated block */
.wr-lb {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Leaderboard ── */
.wr-lb-name-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.wr-rsn-input {
  flex: 1 1 auto;
  min-width: 0;
  background: #1b1a17;
  border: 2px solid var(--osrs-ui-border);
  border-radius: 4px;
  color: var(--osrs-yellow);
  padding: 6px 10px;
  font-size: 1rem;
}

.wr-rsn-input:focus {
  outline: none;
  border-color: var(--osrs-gold);
}

.wr-lb-summary {
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.95rem;
  color: rgba(255, 207, 63, 0.8);
  margin-bottom: 8px;
}

.wr-lb-table {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wr-lb-row {
  display: grid;
  grid-template-columns: 36px 1fr 62px 70px;
  gap: 8px;
  align-items: center;
  background: #1f1e1b;
  border: 1px solid var(--osrs-ui-border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.95rem;
}

.wr-lb-row.header {
  background: transparent;
  border-color: transparent;
  color: rgba(255, 207, 63, 0.7);
  font-family: 'RuneScape Small', Arial, sans-serif;
}

.wr-lb-row.me {
  border-color: var(--osrs-gold);
  box-shadow: 0 0 0 1px var(--osrs-gold) inset;
}

.wr-lb-rank {
  color: var(--osrs-gold);
  font-family: 'RuneScape Bold', Arial, sans-serif;
}

.wr-lb-name {
  color: var(--osrs-yellow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wr-lb-clicks,
.wr-lb-time {
  color: #e8dcc0;
  text-align: right;
  font-family: 'RuneScape Small', Arial, sans-serif;
}

/* Extra specificity needed: shared styles.css has `.modal .dialog p { margin: 0 0 8px }` */
.modal .dialog p.wr-countdown {
  text-align: center;
  margin: 16px 0 0;
  font-family: 'RuneScape Small', Arial, sans-serif;
  font-size: 0.9rem;
  color: rgba(255, 207, 63, 0.55);
}

.modal .dialog p.wr-countdown #wr-countdown {
  color: rgba(255, 207, 63, 0.85);
}

/* ── Toast ── */
.wr-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c1a16;
  border: 2px solid var(--osrs-gold);
  border-radius: 6px;
  color: var(--osrs-yellow);
  font-family: 'RuneScape', Arial, sans-serif;
  padding: 8px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1200;
}

.wr-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Entry screen ── */
body:has(#wr-entry-screen:not([hidden])) .site-nav {
  position: relative;
  z-index: 1001;
}

.wr-entry-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.wr-entry-modal[hidden] {
  display: none !important;
}

.wr-entry-dialog {
  width: min(440px, 92vw);
  padding: 22px 20px 20px;
  background: var(--osrs-ui-bg);
  border: 2px solid var(--osrs-ui-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
}

.wr-entry-title {
  font-family: 'Quill 8', 'RuneScape Bold', Arial, serif;
  color: var(--osrs-gold);
  font-size: 58px;
  margin: 0 0 8px;
  text-shadow: 2px 2px 0 var(--osrs-black);
}

.wr-entry-sub {
  margin: 0 0 18px;
  font-size: 0.98rem;
  line-height: 1.4;
  color: rgba(255, 207, 63, 0.92);
  font-family: 'RuneScape', Arial, sans-serif;
}

.wr-entry-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wr-entry-btn {
  width: 100%;
}

#wr-entry-play {
  padding: 14px 20px;
  font-size: 1.25rem;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .wr-title { font-size: 38px; }
  .wr-entry-title { font-size: 44px; }
  .wr-article {
    height: calc(100dvh - 300px);
    min-height: 320px;
    padding: 12px 12px 20px;
  }
  .wr-article .infobox,
  .wr-article figure,
  .wr-article .thumb {
    float: none;
    margin: 0 auto 12px;
  }
  .wr-hud {
    padding: 8px 10px;
  }
  .wr-route-page { font-size: 1rem; }
  .wr-lb-row { grid-template-columns: 30px 1fr 52px 62px; }
}
