/* ============================================================
   AFL RULEBOOK — fresh redesign
   Scoped with rb- prefix; lives in its own stylesheet (loaded after
   style.css / darkmode.css) so the visual editor's style.css
   regeneration can't wipe it. Uses the site's design tokens so dark
   mode (neutral-ramp flip) is handled automatically; #fff is hardcoded
   only for white text sitting on the brand-red badges.
   ============================================================ */

/* ---- Reading progress bar (fixed, over everything) ---- */
.rb-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 1000;
  pointer-events: none;
}
.rb-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-primary-400), var(--color-primary-600));
  transition: width 0.08s linear;
}

/* ---- Hero ---- */
.rb-hero {
  position: relative;
  padding-block: 3.5rem 2.5rem;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(229, 28, 53, 0.10), transparent 55%),
    var(--color-neutral-250);
  border-bottom: 1px solid var(--color-neutral-300);
  overflow: hidden;
}
.rb-eyebrow {
  font-size: var(--fs-400);
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary-400);
  margin-bottom: 0.5rem;
}
.rb-hero-title {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--color-neutral-900);
  letter-spacing: -0.01em;
}
.rb-hero-title span {
  display: inline-block;
  color: var(--color-primary-400);
}
.rb-hero-lede {
  margin-top: 1rem;
  max-width: 60ch;
  font-size: var(--fs-650);
  line-height: 1.6;
  color: var(--color-neutral-800);
}
.rb-hero-meta {
  margin-top: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.rb-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.rb-author-pfp {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-neutral-100);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.rb-author-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.rb-author-name {
  font-weight: var(--fw-bold);
  color: var(--color-neutral-900);
}
.rb-author-role {
  font-size: var(--fs-300);
  color: var(--color-neutral-600);
}
.rb-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.rb-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: var(--color-neutral-100);
  border: 1px solid var(--color-neutral-300);
  font-size: var(--fs-400);
  font-weight: var(--fw-semi-bold);
  color: var(--color-neutral-900);
}
.rb-chip-k {
  font-size: var(--fs-300);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary-400);
}

/* ---- Layout ---- */
.rb-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 3rem;
  padding-block: 2.5rem 4rem;
  align-items: start;
}

/* ---- Sticky TOC ---- */
.rb-toc {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}
.rb-toc-head {
  font-size: var(--fs-300);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-neutral-600);
  margin-bottom: 0.75rem;
  padding-left: 0.9rem;
}
.rb-toc-nav {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--color-neutral-300);
}
.rb-toc-link {
  position: relative;
  display: block;
  padding: 0.4rem 0.9rem;
  margin-left: -2px;
  border-left: 2px solid transparent;
  font-size: var(--fs-500);
  font-weight: var(--fw-semi-bold);
  color: var(--color-neutral-600);
  text-decoration: none;
  line-height: 1.35;
  transition: color 0.15s, border-color 0.15s;
}
.rb-toc-link:hover {
  color: var(--color-neutral-900);
}
.rb-toc-link--sub {
  padding-left: 1.7rem;
  font-size: var(--fs-400);
}
.rb-toc-link.is-active {
  color: var(--color-primary-400);
  border-left-color: var(--color-primary-400);
  font-weight: var(--fw-bold);
}
.rb-toc-link[hidden] { display: none; }

/* ---- Article ---- */
.rb-article {
  min-width: 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-neutral-800);
}

/* Search */
.rb-tools {
  margin-bottom: 2rem;
}
.rb-search {
  position: relative;
  display: flex;
  align-items: center;
}
.rb-search-icon {
  position: absolute;
  left: 0.9rem;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--color-neutral-600);
  pointer-events: none;
}
.rb-search-input {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-600);
  padding: 0.8rem 2.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-neutral-300);
  background: var(--color-neutral-100);
  color: var(--color-neutral-900);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.rb-search-input:focus {
  outline: none;
  border-color: var(--color-primary-400);
  box-shadow: 0 0 0 3px rgba(229, 28, 53, 0.15);
}
.rb-search-clear {
  position: absolute;
  right: 0.6rem;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 50%;
  background: var(--color-neutral-250);
  color: var(--color-neutral-900);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.rb-search-clear:hover { background: var(--color-neutral-300); }

.rb-no-results {
  padding: 1.5rem;
  border: 1px dashed var(--color-neutral-300);
  border-radius: 12px;
  text-align: center;
  color: var(--color-neutral-600);
  font-weight: var(--fw-semi-bold);
}

/* Sections */
.rb-section {
  scroll-margin-top: 90px;
  padding-top: 2.25rem;
  margin-top: 2.25rem;
  border-top: 1px solid var(--color-neutral-300);
}
.rb-section:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}
.rb-section[hidden] { display: none; }
.rb-section--sub { border-top: 0; padding-top: 0.5rem; margin-top: 1rem; }

.rb-section-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.rb-h2 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--color-neutral-900);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.rb-h2--sub {
  font-size: clamp(1.25rem, 2.4vw, 1.5rem);
  color: var(--color-primary-400);
}
.rb-h3 {
  font-size: 1.25rem;
  font-weight: var(--fw-bold);
  color: var(--color-neutral-900);
  margin: 1.6rem 0 0.6rem;
}
.rb-anchor {
  border: 0;
  background: transparent;
  color: var(--color-neutral-600);
  font-size: 1.15rem;
  font-weight: var(--fw-bold);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}
.rb-section-head:hover .rb-anchor,
.rb-anchor:focus-visible { opacity: 1; }
.rb-anchor:focus-visible { outline: 2px solid var(--color-primary-400); outline-offset: 2px; }
.rb-anchor:hover { color: var(--color-primary-400); background: var(--color-neutral-250); }
.rb-anchor.is-copied { opacity: 1; color: var(--color-primary-400); }

.rb-p { margin-bottom: 1.1rem; }
.rb-list {
  margin: 0 0 1.2rem;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rb-list li { padding-left: 0.25rem; }
.rb-list li::marker { color: var(--color-primary-400); }

/* Inline command chips */
.rb-cmd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--color-neutral-250);
  border: 1px solid var(--color-neutral-300);
  color: var(--color-primary-600);
  padding: 0.12em 0.5em;
  border-radius: 6px;
  white-space: nowrap;
}

/* Callout box */
.rb-callout {
  background: var(--color-primary-100);
  border: 1px solid var(--color-neutral-300);
  border-left: 4px solid var(--color-primary-400);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  margin: 0 0 1.5rem;
}
.rb-callout-head {
  font-weight: var(--fw-bold);
  font-size: 1.15rem;
  color: var(--color-neutral-900);
  margin-bottom: 0.6rem;
}
.rb-callout-list {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.rb-callout-list li::marker { color: var(--color-primary-400); }
.rb-callout-note {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--color-neutral-300);
  font-size: var(--fs-500);
  color: var(--color-neutral-800);
}

/* Penalty cards */
.rb-penalty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  background: var(--color-neutral-100);
  border: 1px solid var(--color-neutral-300);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.rb-penalty:hover {
  border-color: var(--color-primary-400);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}
.rb-penalty-name {
  font-weight: var(--fw-bold);
  font-size: 1.2rem;
  color: var(--color-neutral-900);
}
.rb-penalty-cost {
  flex-shrink: 0;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--color-primary-400);
  color: #fff;
  font-size: var(--fs-500);
  font-weight: var(--fw-semi-bold);
}
.rb-penalty-cost b { font-weight: 800; }

/* Figures / diagrams */
.rb-figure {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.rb-figure--single { grid-template-columns: 1fr; max-width: 560px; }
.rb-figure figure { margin: 0; }
.rb-figure img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--color-neutral-300);
  display: block;
  cursor: zoom-in;
  transition: transform 0.15s, box-shadow 0.15s;
}
.rb-figure img:hover {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}
.rb-figure figcaption {
  margin-top: 0.5rem;
  font-size: var(--fs-400);
  font-weight: var(--fw-semi-bold);
  color: var(--color-neutral-600);
  text-align: center;
}

/* Search highlight */
.rb-hl {
  background: #ffe08a;
  color: #1b1e24;
  border-radius: 3px;
  padding: 0 0.1em;
}

/* ---- Floating action buttons ---- */
.rb-fab {
  position: fixed;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s, background 0.15s, opacity 0.2s;
}
.rb-fab svg { width: 1.3rem; height: 1.3rem; }
.rb-fab-top {
  right: 1.25rem;
  bottom: 1.25rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--color-neutral-900);
  color: var(--color-neutral-100);
  justify-content: center;
}
.rb-fab-top:hover { transform: translateY(-2px); }
.rb-fab-top[hidden] { display: none; }
.rb-fab-toc {
  display: none; /* desktop hidden; shown on mobile */
  left: 1.25rem;
  bottom: 1.25rem;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: var(--color-primary-400);
  color: #fff;
  font-family: inherit;
  font-size: var(--fs-500);
  font-weight: var(--fw-bold);
}
.rb-fab-toc:hover { transform: translateY(-2px); }

/* ---- Mobile TOC drawer ---- */
.rb-drawer { position: fixed; inset: 0; z-index: 1100; }
.rb-drawer[hidden] { display: none; }
.rb-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.rb-drawer-panel {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  max-height: 75vh;
  overflow-y: auto;
  background: var(--color-neutral-100);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 1.25rem 1.25rem 2rem;
  animation: rb-slideup 0.2s ease;
}
@keyframes rb-slideup {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.rb-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: var(--fw-bold);
  font-size: 1.15rem;
  color: var(--color-neutral-900);
  margin-bottom: 1rem;
}
.rb-drawer-close {
  border: 0;
  background: var(--color-neutral-250);
  color: var(--color-neutral-900);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

/* ---- Lightbox ---- */
.rb-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.85);
}
.rb-lightbox[hidden] { display: none; }
.rb-lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.rb-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
}

/* ---- Responsive ---- */
@media (max-width: 60em) {
  .rb-layout { grid-template-columns: 1fr; gap: 0; }
  .rb-toc { display: none; }
  .rb-fab-toc { display: inline-flex; }
  .rb-fab-top { bottom: 1.25rem; }
}
@media (max-width: 40em) {
  .rb-hero { padding-block: 2.25rem 1.75rem; }
  .rb-hero-meta { flex-direction: column; align-items: flex-start; }
  .rb-figure { grid-template-columns: 1fr; }
  .rb-penalty-name { font-size: 1.05rem; }
  .rb-article { font-size: 1rem; }
}

/* ---- Dark mode touch-ups (ramp flips automatically; refine a few) ---- */
html.dark-mode .rb-hero {
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(229, 28, 53, 0.14), transparent 55%),
    var(--color-neutral-250);
}
html.dark-mode .rb-hl { background: #d9a441; color: #14161a; }
html.dark-mode .rb-cmd { color: #ff8a97; }
html.dark-mode .rb-penalty-cost { color: #fff; }

/* ---- Referee manual additions (shared stylesheet) ---- */
.rb-crosslink {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
  padding: 0.55rem 1.15rem;
  border-radius: 100vmax;
  background: var(--color-primary-400, #e51c35);
  color: #fff;
  font-weight: var(--fw-semi-bold, 600);
  font-size: var(--fs-400, 0.95rem);
  text-decoration: none;
  box-shadow: 0 6px 18px rgb(229 28 53 / 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.rb-crosslink:hover,
.rb-crosslink:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgb(229 28 53 / 0.45);
  color: #fff;
}
.rb-crosslink svg {
  width: 1.05em;
  height: 1.05em;
}

.rb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 11rem;
  padding: 1.25rem 1.5rem;
  border: 2px dashed var(--color-neutral-300, #cbd0d8);
  border-radius: 0.75rem;
  background: var(--color-neutral-200, #f2f3f5);
  color: var(--color-accent-400, #4a5160);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}
html.dark-mode .rb-placeholder {
  background: rgb(255 255 255 / 0.05);
  border-color: rgb(255 255 255 / 0.2);
  color: hsl(230 12% 72%);
}
