/* ===== Rules page (25 Oct): Part 1 · Overview =====
   Markup: index.html #page-rules → .wrap.rules. Behaviour: assets/js/rules.js (Funded plan tabs,
   active part pill). Structure follows the "Strix Rules Page Proposal" artifact (three part pills,
   overview heading + badges, three numbered phase cards with tables, nine "Rules for every plan"
   cards); the look is the site's own light design: white page, white cards with hairline borders
   and soft shadows, light blue table headers, Strix blue for the active pill / tab / number badge.
   Parts 2 (#rulebook) and 3 (#definitions) are anchors only until the next task fills them. */

#page-rules .sub {
  background: #fff;
}
.rules {
  position: relative;
  z-index: 1;
}

/* ---- three-part navigation: Overview · Rulebook · Definitions, three inline links just above the
   Part 1 label. No container, background, border or sticky behaviour: the row is only as tall as the
   links. The part in view (.on, set by rules.js) is Strix blue and a touch heavier; the rest dark grey. */
.rules__parts {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  width: max-content; /* the row is exactly the three links wide */
  max-width: 100%;
  margin: 0 0 16px; /* 28 Oct: the label below lost its 6px pill padding, so 16px keeps the 20-24px gap */
}
.rules__part {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  color: #4b4f73;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color 0.15s,
    text-decoration-color 0.15s;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
}
.rules__part:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}
.rules__part.on,
.rules__part.on:hover {
  color: var(--blue);
  font-weight: 600;
  text-decoration-color: transparent;
}
.rules__part:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 3px;
}
.rules__sep {
  color: #b4b8dc;
  font-size: 15px;
  line-height: 1;
  user-select: none;
}

/* ---- overview heading, second lede line, badges ---- */
.rules__sec {
  scroll-margin-top: var(--ticker-h, 0px); /* html's 100px scroll-padding-top clears the floating nav; the promo ticker, when live, adds its height */
}
.rules .lede + .lede {
  margin-top: 6px;
}
.rules__badges {
  margin-top: 22px;
}
.rules__badges span {
  background: #f6f7ff;
  border-color: #cfd3f7;
  color: var(--ink);
}

/* ---- phase cards ---- */
.rcard {
  background: #fff;
  border: 1px solid var(--line-d);
  border-radius: 20px;
  padding: 28px 30px 30px;
  box-shadow: 0 10px 40px rgba(20, 20, 120, 0.06);
  margin-top: 22px;
  scroll-margin-top: var(--ticker-h, 0px);
  min-width: 0;
}
.rcard__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 14px;
}
.rcard__n {
  align-self: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 15px;
  flex: none;
}
.rules .rcard__head h2 {
  margin: 0;
  font-weight: 600;
  line-height: 1.1;
}
.rcard__sub {
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}
.rules .rcard > p {
  font-size: 16px;
  line-height: 1.6;
  max-width: 72ch;
}
.rules .rcard > p + p {
  margin-top: 10px;
}

/* ---- tables (the site's .tbl: white, hairline border, light blue header) ---- */
.rules .tbl {
  margin-top: 18px;
}
.rules .tbl table {
  min-width: 620px;
}
.rules .tbl th {
  font-size: 13px;
  color: var(--ink);
  background: var(--lav);
}
.rules .tbl th,
.rules .tbl td {
  padding: 12px 16px;
  vertical-align: top;
}
.rules .tbl th:first-child,
.rules .tbl td:first-child {
  width: 38%;
  min-width: 240px;
}
.rules .tbl td:first-child {
  font-weight: 500;
  color: var(--ink-2);
}
.rules .tbl td[colspan] {
  white-space: normal;
}
.rules__note {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 72ch;
}
.rules__note + .rules__note {
  margin-top: 8px;
}
.rules__note a,
.rules .rule a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---- Funded plan tabs: Strix / Express / Strix Pro ---- */
.rules__tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line-d);
  border-radius: 999px;
  padding: 4px;
  margin-top: 18px;
  box-shadow: 0 6px 20px rgba(20, 20, 120, 0.06);
}
.rules__tabs button {
  font: inherit;
  padding: 9px 20px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.rules__tabs button:hover {
  color: var(--blue);
}
.rules__tabs button.on {
  background: var(--blue);
  color: #fff;
}
.rules__tabs button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.rules__plan[hidden] {
  display: none;
}

/* ---- CTA row inside the Live card ---- */
.rules__cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}
.rules__cta .btn--ghost {
  background: #fff;
}

/* ---- figures (4 Nov, rules-data.js): the state when the live figures could not be loaded ----
   Every bound figure is underlined dotted and a notice above the first card says why; nothing is
   blanked and nothing is invented. [hidden] is also pinned here because the Strix Pro switch hides
   table cells and inline spans, and a display rule on a cell would otherwise win over the attribute. */
#page-rules [hidden] {
  display: none !important;
}
#page-rules .fig--unverified {
  text-decoration: underline dotted currentColor;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  color: var(--ink-2);
}
.rules__alert {
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid #e3c98a;
  border-radius: 14px;
  background: #fff8e6;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  max-width: 78ch;
}
.rules__alert p {
  margin: 0;
}
.rules__alert a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rules__alert-retry {
  font: inherit;
  font-weight: 600;
  color: var(--blue);
  background: #fff;
  border: 1px solid #cfd3f7;
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}
.rules__alert-retry:hover,
.rules__alert-retry:focus-visible {
  border-color: var(--blue);
}

/* ---- Rules for every plan: 3 / 2 / 1 column card grid ---- */
.rules__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.rule {
  background: #fff;
  border: 1px solid var(--line-d);
  border-radius: 16px;
  padding: 20px 22px 22px;
  box-shadow: 0 4px 18px rgba(20, 20, 120, 0.05);
  min-width: 0;
  transition:
    transform 0.15s,
    box-shadow 0.2s,
    border-color 0.2s;
}
.rule:hover {
  transform: translateY(-2px);
  border-color: #c9ccef;
  box-shadow: 0 12px 30px rgba(20, 20, 120, 0.1);
}
.rules .rule h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}
.rules .rule p {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: none;
}
.rules .rule p + p {
  margin-top: 8px;
}

/* ---- Part 2 · The rulebook and Part 3 · Key definitions: accordions ----
   <details class="ac"> items; rules.js animates them and mirrors the open state on the summary
   (aria-expanded) and the item (.is-open, which drives the icon). The rulebook is a stack of
   separate white cards with a chevron on the left; the definitions sit inside one .rcard as
   bordered rows with a plus on the right that turns into a minus when open. */
.rules__sec--part {
  margin-top: 64px;
}
.rules .rules__h {
  margin: 0;
  font-size: clamp(30px, 3.6vw, 44px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--blue-ink);
}
.rules .rules__sec--part .lede {
  margin-top: 12px;
  max-width: 66ch;
}
.rules .rules__sec--part .lede a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rb {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}
.ac {
  background: #fff;
  border: 1px solid var(--line-d);
  border-radius: 14px;
  min-width: 0;
  transition:
    border-color 0.15s,
    box-shadow 0.2s;
}
.ac:hover,
.ac:focus-within,
.ac.is-open {
  border-color: #b9bff2;
  box-shadow: 0 4px 18px rgba(43, 43, 245, 0.08);
}
.ac__h {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.3;
  color: var(--ink);
  border-radius: 14px;
  transition:
    color 0.15s,
    background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.ac:hover > .ac__h {
  background: #fafbff;
}
.ac.is-open > .ac__h {
  background: #f8f9ff;
  border-radius: 14px 14px 0 0;
  box-shadow: inset 0 -1px 0 #e6e8fb;
}
.ac__h::-webkit-details-marker {
  display: none;
}
.ac__h::marker {
  content: '';
}
.ac__h > span {
  flex: 1 1 auto;
  min-width: 0;
}
.ac:hover > .ac__h,
.ac.is-open > .ac__h {
  color: var(--blue);
}
.ac__h:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
.ac__i {
  flex: none;
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(43, 43, 245, 0.08);
  color: var(--blue);
  transition: background 0.15s;
}
.ac.is-open .ac__i {
  background: rgba(43, 43, 245, 0.14);
}
/* chevron: points right, turns to point down when open */
.ac__i--chev::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 9px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.25s;
}
.ac.is-open .ac__i--chev::before {
  transform: translate(1px, -2px) rotate(45deg);
}
/* plus: the upright bar turns 90deg onto the flat one, leaving a minus */
.ac__i--plus::before,
.ac__i--plus::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.25s;
}
.ac__i--plus::before {
  width: 14px;
  height: 2px;
  transform: translate(-50%, -50%);
}
.ac__i--plus::after {
  width: 2px;
  height: 14px;
  transform: translate(-50%, -50%);
}
.ac.is-open .ac__i--plus::after {
  transform: translate(-50%, -50%) rotate(90deg);
}
.ac__body {
  overflow: hidden;
}
.ac__in {
  padding: 18px 24px 24px;
  color: #3b3f66;
  font-size: 15.5px;
  line-height: 1.65;
}
.rules .ac__in p {
  max-width: 78ch;
}
.rules .ac__in p b {
  color: var(--ink);
  font-weight: 600;
}
.rules .ac__in .rules__note {
  margin-top: 16px;
  max-width: 78ch;
}
/* development placeholder: dashed box, clearly not rule text */
.ac__todo {
  border: 1px dashed #c3c7f0;
  border-radius: 10px;
  background: #fafbff;
  padding: 12px 14px;
  font-size: 14.5px;
}
.ac__todo b {
  color: var(--ink);
  font-weight: 600;
}
.df {
  display: grid;
  gap: 8px;
  padding: 14px;
  margin-top: 26px;
}
.df .ac {
  border-radius: 12px;
}
.df .ac__h {
  padding: 16px 18px;
  font-size: 16px;
  border-radius: 12px;
}
.df .ac__in {
  padding: 14px 20px 20px;
}
.rules__sec--part .rules__note {
  margin-top: 20px;
}
.ac__sub {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 18px 0 6px;
}
.ac__sub:first-child {
  margin-top: 0;
}
.ac__in > p + p {
  margin-top: 12px;
}
.ac__in > .tscroll + p {
  margin-top: 18px;
}

/* ---- scrollable tables: edge fades and a hint while more columns are off-screen ----
   rules.js sets data-scroll="none | start | mid | end" on each .tscroll from the inner .tbl's
   scroll position; without it nothing extra shows. The box keeps the table's rounded border; the
   fades are its pseudo-elements so they never scroll with the cells. */
.tscroll {
  margin-top: 18px;
  min-width: 0;
}
/* 27 Oct (Task 3.1): a sideways swipe that reaches the end of a table stays in the table instead of
   bouncing the page or triggering the browser's back gesture */
.rules .tbl {
  overscroll-behavior-x: contain;
}
/* 27 Oct (Task 3.1): every deep-link target on the page (sections, phase cards, rulebook blocks and
   definitions) clears the promo ticker when it is showing. html's 100px scroll-padding clears the
   floating nav; the ticker pushes the nav down by --ticker-h (ticker.css), and the rulebook /
   definition items had no margin for it, so #/rules#rb-… landed under the nav bar. */
#page-rules [id] {
  scroll-margin-top: var(--ticker-h, 0px);
}
.tscroll .tbl {
  margin-top: 0;
}
.tscroll__box {
  position: relative;
}
.tscroll__box::before,
.tscroll__box::after {
  content: '';
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 36px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}
.tscroll__box::before {
  left: 1px;
  border-radius: 13px 0 0 13px;
  background: linear-gradient(90deg, rgba(12, 15, 44, 0.1), rgba(12, 15, 44, 0));
}
.tscroll__box::after {
  right: 1px;
  border-radius: 0 13px 13px 0;
  background: linear-gradient(270deg, rgba(12, 15, 44, 0.12), rgba(12, 15, 44, 0));
}
.tscroll[data-scroll='start'] .tscroll__box::after,
.tscroll[data-scroll='mid'] .tscroll__box::after,
.tscroll[data-scroll='mid'] .tscroll__box::before,
.tscroll[data-scroll='end'] .tscroll__box::before {
  opacity: 1;
}
.tscroll__hint {
  display: none;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.tscroll__hint::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 8px;
  margin-right: 8px;
  vertical-align: middle;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 8'%3E%3Cpath d='M3 1 0 4l3 3M11 1l3 3-3 3M1 4h12' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 8'%3E%3Cpath d='M3 1 0 4l3 3M11 1l3 3-3 3M1 4h12' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tscroll[data-scroll='start'] .tscroll__hint,
.tscroll[data-scroll='mid'] .tscroll__hint,
.tscroll[data-scroll='end'] .tscroll__hint {
  display: block;
}
.tbl:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---- the twelve-plan rulebook tables: one header row (Metric | Strix 100K … Strix Pro 10K, as in the
   proposal), the label column pinned at every width, hairlines between columns (a shade stronger between
   the three plan groups), alternating row tints, nothing wraps or clips: the table grows and scrolls. ---- */
.rules .tbl {
  scrollbar-width: thin;
  scrollbar-color: #c3c7f0 #f3f4ff;
}
.rules .tbl::-webkit-scrollbar {
  height: 8px;
}
.rules .tbl::-webkit-scrollbar-track {
  background: #f3f4ff;
}
.rules .tbl::-webkit-scrollbar-thumb {
  background: #c3c7f0;
  border-radius: 4px;
}
.rules .tbl--wide table {
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
}
.rules .tbl--wide th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--lav);
  padding: 10px 12px;
  border-bottom: 1px solid #cfd3f7;
}
.rules .tbl--wide td {
  font-size: 13px;
  padding: 10px 12px;
}
.rules .tbl--wide th:not(:first-child),
.rules .tbl--wide td:not(:first-child) {
  border-left: 1px solid #eceefc;
  min-width: 104px;
}
.rules .tbl--wide th:nth-child(6),
.rules .tbl--wide th:nth-child(10),
.rules .tbl--wide td:nth-child(6),
.rules .tbl--wide td:nth-child(10) {
  border-left-color: #c9ccef;
}
.rules .tbl--wide thead th:first-child,
.rules .tbl--wide tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 190px;
  min-width: 190px;
  max-width: 190px;
  white-space: normal;
  background: #fff;
  border-right: 1px solid var(--line-d);
}
.rules .tbl--wide thead th:first-child {
  z-index: 2;
  background: var(--lav);
}
.rules .tbl--wide tbody tr:nth-child(even) td {
  background: #f8f9ff;
}
.rules .tbl--wide tbody tr:last-child td {
  border-bottom: 0;
}
.ac__in .tscroll + .tscroll {
  margin-top: 14px;
}

/* ---- tablets ---- */
@media (max-width: 1023px) {
  .rules__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---- phones and small tablets ---- */
@media (max-width: 768px) {
  /* the pills stay under the floating nav (24px offset + 56px bar) as one scrollable row: no wrapping,
     so the bar is 44px tall at every phone width and the three parts are always one tap away */
  .rules__parts {
    gap: 10px;
    margin-bottom: 20px;
    /* 27 Oct (Task 3.1): the three links fit every phone width (264px at 320); should they ever not,
       the row scrolls sideways instead of pushing the page wider */
    overflow-x: auto;
    scrollbar-width: none;
  }
  .rules__parts::-webkit-scrollbar {
    display: none;
  }
  .rules__tabs button,
  .rules__part {
    min-height: var(--m-tap, 44px); /* 44px tap height; the row stays as wide as the three words */
  }
  .rules__part {
    font-size: 14px;
  }
  .rules__sec,
  .rcard,
  .rules__sec--part {
    scroll-margin-top: var(--ticker-h, 0px);
  }
  .rules__sec--part {
    margin-top: 44px;
  }
  .ac__h {
    padding: 14px 16px;
    font-size: 16px;
    min-height: var(--m-tap, 44px);
  }
  .ac__in,
  .df .ac__in {
    padding: 14px 16px 18px;
    font-size: 16px;
    line-height: 1.6;
  }
  .df {
    padding: 8px;
  }
  .df .ac__h {
    padding: 13px 14px;
  }
  .ac__todo {
    font-size: 15px;
  }
  .rcard {
    padding: 20px 16px 22px;
    border-radius: 16px;
    margin-top: 16px;
  }
  .rcard__n {
    width: 36px;
    height: 36px;
  }
  /* the table scrolls sideways inside its box; the label column is a fixed 150px and sticks to the
     left edge so the row name stays in view while the account-size columns scroll under it.
     border-collapse: separate keeps the sticky cells' borders with them (collapsed borders stay put). */
  .rules .tbl table {
    min-width: 520px;
    border-collapse: separate;
    border-spacing: 0;
  }
  .rules .tbl th,
  .rules .tbl td {
    padding: 11px 12px;
  }
  .rules .tbl thead tr:first-child th:first-child,
  .rules .tbl tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    white-space: normal;
    background: #fff;
    border-right: 1px solid var(--line-d);
  }
  .rules .tbl thead tr:first-child th:first-child {
    background: var(--lav);
  }
  .rules .tbl--wide thead th:first-child,
  .rules .tbl--wide tbody td:first-child {
    width: 150px;
    min-width: 150px;
    max-width: 150px;
  }
  .rules .tbl td[colspan] {
    position: static;
  }
  .rules__tabs {
    display: flex;
  }
  .rules__tabs button {
    flex: 1 1 0;
    padding: 9px 8px;
    white-space: nowrap;
  }
  .rule {
    padding: 18px 16px 20px;
  }
  .rules .rule p,
  .rules__note {
    font-size: 15px;
  }
  .tscroll__hint {
    font-size: 14px;
  }
  .ac__in .tscroll {
    margin-inline: -16px; /* the wide tables use the block's full width on phones */
  }
  .ac__in .tscroll .tbl {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .ac__in .tscroll__box::before,
  .ac__in .tscroll__box::after {
    border-radius: 0;
  }
  .ac__in .tscroll__hint {
    padding-inline: 16px;
  }
}
@media (max-width: 600px) {
  .rules__grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .rule,
  .rules__part,
  .rules__tabs button,
  .ac,
  .ac__h,
  .ac__i::before,
  .ac__i::after {
    transition: none;
  }
  .rule:hover {
    transform: none;
  }
}
