/* Official Rules modal — see inc/RulesModal.php. Plain CSS (not part of the
   webpack/Tailwind build) so it can ship without rebuilding app.css. */

html.rules-modal-open { overflow: hidden; }
html.rules-modal-open body {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

.rules-modal {
  --rm-accent: #B8922F;
  --rm-text: #1E1F20;
  --rm-muted: #535357;
  --rm-border: #E5E5E5;

  width: min(880px, calc(100% - 3rem));
  max-width: none;
  max-height: calc(100vh - 4rem);
  max-height: calc(100dvh - 4rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--rm-text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.rules-modal:not([open]) { display: none; }
.rules-modal[open] { display: flex; }

.rules-modal::backdrop {
  background: rgba(0, 0, 0, .7);
}

.rules-modal__inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-height: inherit;
}

/* Header */
.rules-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex: none;
  padding: 1.25rem 1.25rem 1rem 2rem;
  border-bottom: 1px solid var(--rm-border);
}
.rules-modal__title {
  margin: .25rem 0 0;
  font-family: 'Teko', 'Open Sans', sans-serif;
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  color: var(--rm-text);
}
.rules-modal__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;  /* WCAG 2.5.5 target size */
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--rm-text);
  cursor: pointer;
  transition: background-color .15s;
}
.rules-modal__close:hover { background: #F2F2F2; }

/* Scrolling body */
.rules-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 2rem 2rem;
}

/* Neutralise page-module spacing inside the modal */
.rules-modal__body .generic-content,
.rules-modal__body .featured-text,
.rules-modal__body .content-with-image { margin: 0; padding: 0; }
.rules-modal__body .container { max-width: none; width: 100%; padding: 0; margin: 0; }

/* Legal typography — the site's default p/a are 20px bold, too heavy for rules */
.rules-modal__body,
.rules-modal__body p,
.rules-modal__body li,
.rules-modal__body td,
.rules-modal__body .legaltype {
  font-family: 'Manrope', 'Open Sans', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  color: var(--rm-text);
  white-space: normal;
}
.rules-modal__body p { margin: 0 0 1rem; }
.rules-modal__body p:empty { display: none; }
.rules-modal__body strong,
.rules-modal__body b { font-weight: 700; }
.rules-modal__body h2,
.rules-modal__body h3,
.rules-modal__body h4 {
  font-family: 'Teko', 'Open Sans', sans-serif;
  font-weight: 600;
  line-height: 1.1;
  margin: 1.5rem 0 .5rem;
  text-transform: uppercase;
}
.rules-modal__body h2 { font-size: 1.75rem; }
.rules-modal__body h3 { font-size: 1.5rem; }
.rules-modal__body h4 { font-size: 1.25rem; }
.rules-modal__body ol,
.rules-modal__body ul { margin: 0 0 1rem; padding-left: 1.5rem; }
.rules-modal__body ol { list-style: decimal; }
.rules-modal__body ul { list-style: disc; }
.rules-modal__body ol ol { list-style: lower-alpha; }
.rules-modal__body li { margin-bottom: .5rem; }
.rules-modal__body a {
  font-size: inherit;
  font-weight: 700;
  line-height: inherit;
  color: var(--rm-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.rules-modal__body a:hover { color: var(--rm-accent); }

/* Footer */
.rules-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex: none;
  padding: 1rem 2rem;
  border-top: 1px solid var(--rm-border);
  background: #fff;
}
.rules-modal .rules-modal__back {
  padding: .75rem 2rem;
  font-size: 1rem;
  background: #fff;
  cursor: pointer;
}
.rules-modal .rules-modal__back:hover,
.rules-modal .rules-modal__back:focus-visible {
  background: #000;
  border-color: #000;
  color: #fff;
}

/* Visible keyboard focus everywhere in the dialog */
.rules-modal :focus-visible {
  outline: 3px solid var(--rm-accent);
  outline-offset: 2px;
}
.rules-modal__body:focus-visible { outline-offset: -3px; }


/* Mobile: full-screen sheet, respecting notches / home indicator */
@media (max-width: 639px) {
  .rules-modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .rules-modal__header {
    padding: calc(.75rem + env(safe-area-inset-top)) calc(.5rem + env(safe-area-inset-right)) .75rem calc(1.25rem + env(safe-area-inset-left));
  }
  .rules-modal__title { font-size: 1.625rem; }
  .rules-modal__body {
    padding: 1.25rem calc(1.25rem + env(safe-area-inset-right)) 1.5rem calc(1.25rem + env(safe-area-inset-left));
  }
  .rules-modal__body,
  .rules-modal__body p,
  .rules-modal__body li { font-size: .9375rem; }
  .rules-modal__footer {
    flex-direction: column;
    align-items: stretch;
    padding: .75rem calc(1.25rem + env(safe-area-inset-right)) calc(.75rem + env(safe-area-inset-bottom)) calc(1.25rem + env(safe-area-inset-left));
    text-align: center;
  }
  .rules-modal .rules-modal__back { width: 100%; padding: .625rem 1rem; border-width: 3px; }
}

/* Motion (only for people who haven't asked to reduce it) */
@media (prefers-reduced-motion: no-preference) {
  .rules-modal[open] { animation: rules-modal-in .2s ease-out; }
  .rules-modal[open]::backdrop { animation: rules-modal-fade .2s ease-out; }
  @media (max-width: 639px) {
    .rules-modal[open] { animation-name: rules-modal-up; animation-duration: .25s; }
  }
}
@keyframes rules-modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes rules-modal-up { from { transform: translateY(100%); } }
@keyframes rules-modal-fade { from { opacity: 0; } }

/* Windows high-contrast */
@media (forced-colors: active) {
  .rules-modal { border: 2px solid CanvasText; }
}

/* Rules sections are often authored as single-item <ol start="N"> (one per
   section) — treat those as headings. Normal multi-item lists are unaffected. */
.rules-modal__body .legaltype > ol:has(> li:only-of-type) { margin: 1.5rem 0 .5rem; }
.rules-modal__body .legaltype > ol > li:only-of-type {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}
