/* =====================================================================
   ASHES - rules page.

   Its own stylesheet because it is the only page that is a DOCUMENT rather
   than an interface, and it needs document typography: a measure, a reading
   rhythm, a gutter. Loaded only by rules.html.
   ===================================================================== */

/* reading progress */
.read-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: transparent; z-index: 70; pointer-events: none;
}
.read-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--ac2), var(--ac), var(--gold));
  box-shadow: 0 0 12px rgba(249, 115, 22, .7);
}

.rules-main { position: relative; z-index: 1; padding-bottom: 90px; }

/* --- masthead ------------------------------------------------------- */
.rules-hero {
  padding: 54px 0 40px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line);
  background: radial-gradient(760px 340px at 12% -30%, rgba(249, 115, 22, .13), transparent 70%);
}
.rules-h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5.2vw, 56px);
  letter-spacing: -.025em;
  line-height: 1.03;
  max-width: 22ch;
  text-wrap: balance;
}
.rules-lede {
  margin-top: 18px; max-width: 66ch;
  font-size: 17px; color: var(--fg-2); line-height: 1.68;
}

.rules-stats {
  display: flex; flex-wrap: wrap;
  margin-top: 30px; max-width: 560px;
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; background: rgba(255, 255, 255, .02);
}
.rules-stats > div {
  flex: 1 1 0; min-width: 108px;
  padding: 14px 16px; border-right: 1px solid var(--line);
}
.rules-stats > div:last-child { border-right: 0; }
.rules-stats b {
  display: block; font-family: var(--font-display);
  font-size: 21px; font-variant-numeric: tabular-nums;
}
.rules-stats span {
  font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--fg-3);
}

/* --- spirit callout ------------------------------------------------- */
.rules-spirit {
  display: flex; gap: 18px; align-items: flex-start;
  padding: 22px 24px; margin-bottom: 26px;
  border: 1px solid rgba(249, 115, 22, .34);
  border-left: 3px solid var(--ac);
  border-radius: var(--r);
  background: linear-gradient(100deg, rgba(249, 115, 22, .11), transparent 66%);
}
.rules-spirit-mark {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px; display: grid; place-content: center;
  color: var(--ac);
  border: 1px solid rgba(249, 115, 22, .35);
  background: rgba(249, 115, 22, .1);
}
.rules-spirit h2 { font-family: var(--font-display); font-size: 18px; margin-bottom: 7px; }
.rules-spirit p { font-size: 14.5px; color: var(--fg-2); max-width: 74ch; line-height: 1.65; }

/* --- tools row: search + listen ------------------------------------- */
.rules-tools {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 26px;
}
.rules-search {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; flex: 1 1 320px; max-width: 520px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(0, 0, 0, .38);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.rules-search:focus-within {
  border-color: var(--ac);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .13);
}
.rules-search-icon { color: var(--fg-3); display: flex; flex: none; }
.rules-search input {
  flex: 1; min-width: 0; padding: 12px 0;
  border: 0; background: none; color: var(--fg);
  font: inherit; font-size: 14.5px;
}
.rules-search input:focus { outline: none; }
.rules-search input::-webkit-search-cancel-button { display: none; }
#ru-clear {
  border: 0; background: rgba(255, 255, 255, .06); color: var(--fg-3);
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-content: center; flex: none;
}
#ru-clear:hover { color: var(--fg); background: rgba(255, 255, 255, .12); }
.rules-count { flex-basis: 100%; font-size: 13px; color: var(--ac-soft); }

/* --- read aloud ----------------------------------------------------- */
.rules-listen {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  padding: 11px 18px; border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--fg-2);
  font-size: 13.5px; font-weight: 600;
  transition: border-color .18s var(--ease), color .18s var(--ease), background .18s var(--ease);
}
.rules-listen:hover { border-color: var(--ac); color: var(--fg); background: rgba(249, 115, 22, .09); }
.rules-listen.is-playing {
  border-color: var(--ac); color: var(--ac);
  background: rgba(249, 115, 22, .13);
}
.rules-listen[hidden] { display: none; }

/* The rule currently being spoken. Highlighted rather than just scrolled to,
   because someone using this may not be following the text at all. */
.rule.is-speaking {
  background: rgba(249, 115, 22, .1);
  box-shadow: inset 3px 0 0 var(--ac);
}

/* --- layout --------------------------------------------------------- */
.rules-layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 44px;
  align-items: start;
}
@media (max-width: 1000px) { .rules-layout { grid-template-columns: 1fr; gap: 22px; } }

.rules-side { position: sticky; top: 96px; display: grid; gap: 22px; }
@media (max-width: 1000px) { .rules-side { position: static; } }

.rules-toc { display: flex; flex-direction: column; gap: 1px; }
.rules-toc > b {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--fg-3); margin-bottom: 10px;
}
.rules-toc a {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 12px; font-size: 13.5px; color: var(--fg-3);
  border-left: 2px solid var(--line);
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.rules-toc a i {
  font-style: normal; font-size: 10px; flex: none;
  font-variant-numeric: tabular-nums; opacity: .6;
}
.rules-toc a:hover { color: var(--fg-2); background: rgba(255, 255, 255, .03); }
.rules-toc a.active {
  color: var(--ac); border-left-color: var(--ac); background: rgba(249, 115, 22, .08);
}
@media (max-width: 1000px) {
  .rules-toc { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .rules-toc > b { width: 100%; margin: 0; }
  .rules-toc a { border-left: 0; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
}

/* --- severity key --------------------------------------------------- */
.rules-key {
  padding: 15px 16px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(255, 255, 255, .02);
  display: grid; gap: 9px;
}
.rules-key > b {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--fg-3);
}
.rules-key .rk { display: flex; align-items: flex-start; gap: 9px; font-size: 12px; color: var(--fg-3); }
.rules-key .rk i {
  width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px;
  background: var(--sev); box-shadow: 0 0 8px var(--sev);
}
.rk.guideline { --sev: var(--fg-3); }
.rk.standard  { --sev: var(--ac); }
.rk.serious   { --sev: var(--warn); }
.rk.zero      { --sev: var(--live); }
@media (max-width: 1000px) { .rules-key { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }

/* --- sections ------------------------------------------------------- */
.rule-section { margin-bottom: 56px; scroll-margin-top: 100px; }
.rule-section[hidden] { display: none; }

.rs-head {
  display: flex; gap: 18px; align-items: flex-start;
  padding-bottom: 16px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
/* Outlined rather than filled: it is a landmark for scanning, not something
   competing with the heading beside it. */
.rs-num {
  font-family: var(--font-display);
  font-size: 42px; font-weight: 700; line-height: .88;
  color: transparent;
  -webkit-text-stroke: 1px rgba(249, 115, 22, .55);
  flex: none; font-variant-numeric: tabular-nums;
}
.rs-title h2 {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.6vw, 27px);
  letter-spacing: -.015em;
}
.rs-why { font-size: 14px; color: var(--fg-3); margin-top: 6px; max-width: 64ch; line-height: 1.55; }

/* --- a rule --------------------------------------------------------- */
.rs-rules { display: grid; gap: 0; }

.rule {
  display: grid; grid-template-columns: 62px minmax(0, 1fr);
  padding: 15px 18px 15px 0;
  border-radius: var(--r-sm);
  transition: background .16s var(--ease);
}
.rule[hidden] { display: none; }
.rule:hover { background: rgba(255, 255, 255, .022); }
.rule + .rule { border-top: 1px solid rgba(44, 35, 32, .75); }

/* The gutter carries the reference and a severity dot. A dot scans faster
   than a word; the written label is still in the tags below, so colour is
   never the only signal. */
.rule-gutter { display: flex; align-items: baseline; gap: 9px; padding-top: 3px; }
.rule-ref {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px; color: var(--fg-3); font-variant-numeric: tabular-nums;
}
.rule-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--sev); box-shadow: 0 0 9px var(--sev);
}
.rule.guideline { --sev: var(--fg-3); }
.rule.standard  { --sev: var(--ac); }
.rule.serious   { --sev: var(--warn); }
.rule.zero      { --sev: var(--live); }

.rule-text { font-size: 15px; line-height: 1.66; max-width: 74ch; }
.rule.zero .rule-text, .rule.serious .rule-text { font-weight: 500; }

.rule-note {
  margin-top: 10px; padding: 10px 14px;
  font-size: 13px; color: var(--fg-3); line-height: 1.6;
  border-left: 2px solid var(--sev);
  background: rgba(255, 255, 255, .025);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  max-width: 74ch;
}

.rule-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
}
.tag-sev { color: var(--sev); border: 1px solid var(--sev); opacity: .8; }
.tag-proposed {
  color: #c084fc;
  border: 1px dashed rgba(192, 132, 252, .55);
  background: rgba(192, 132, 252, .07);
}

/* While searching, the big section numbers are noise. */
body.is-searching .rs-num { opacity: .25; }

/* --- acknowledgement ------------------------------------------------ */
.rules-ack {
  margin-top: 44px; padding: 26px;
  border: 1px solid rgba(249, 115, 22, .38);
  border-radius: var(--r-lg);
  background: linear-gradient(140deg, rgba(249, 115, 22, .12), transparent 70%);
}
.rules-ack h2 { font-family: var(--font-display); font-size: 21px; margin-bottom: 8px; }
.rules-ack p { font-size: 14.5px; color: var(--fg-2); max-width: 72ch; line-height: 1.65; }
.rules-ack-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; }
.rules-ack-state {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--fg-3);
}
.rules-ack-state.is-done { color: var(--good); }
.rules-ack-state.is-stale { color: var(--warn); }

.rules-foot {
  margin-top: 40px; padding-top: 26px;
  border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--fg-3);
  max-width: 78ch; line-height: 1.7;
}

/* --- back to top ---------------------------------------------------- */
.rules-top {
  position: fixed; right: 26px; bottom: 26px; z-index: 60;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-content: center;
  color: #180d06;
  background: linear-gradient(180deg, var(--ac), var(--ac2));
  box-shadow: 0 10px 26px -8px rgba(249, 115, 22, .8);
  transition: transform .2s var(--ease);
}
.rules-top:hover { transform: translateY(-3px); }
.rules-top svg { transform: rotate(-90deg); }
.rules-top[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .rules-top:hover { transform: none; }
}

/* =====================================================================
   FAST READ
   ---------------------------------------------------------------------
   Deliberately does not look like the document below it. The full rules
   are set as a document - serif rhythm, wide measure, quiet furniture.
   This is a set of cards: numbered, boxed, scannable, finishable. If the
   two looked alike, the short version would read as just another section
   and get skipped along with everything else.
   ===================================================================== */

.fast {
  margin: 26px 0 34px;
  padding: 24px 24px 26px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(249, 115, 22, .10), transparent 62%),
    var(--bg-2);
}

.fast-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.fast-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.15;
  margin: 8px 0 0;
  color: var(--fg);
  text-wrap: balance;
}
.fast-lede { margin: 7px 0 0; color: var(--fg-2); font-size: 14.5px; max-width: 56ch; }
.fast-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.fast-actions .btn.is-playing { color: var(--ac); border-color: var(--ac); }

/* The warning is the load-bearing sentence on this panel: it is what makes
   a summary honest. Given its own colour and a rule down the side so it
   cannot be mistaken for more explanatory text. */
.fast-warn {
  margin: 18px 0 20px;
  padding: 11px 15px;
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: rgba(245, 158, 11, .09);
  color: #fcd9a0;
  font-size: 13.5px;
  line-height: 1.55;
}

.fast-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}

.fast-card {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg);
  transition: border-color .18s var(--ease), transform .18s var(--ease);
}
.fast-card:hover { border-color: var(--line-soft); transform: translateY(-2px); }
.fast-card.is-speaking {
  border-color: var(--ac);
  box-shadow: 0 0 0 1px var(--ac), 0 0 34px -10px rgba(249, 115, 22, .55);
}

.fast-n {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1;
  color: var(--ac);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.fast-c h3 {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.3;
  color: var(--fg);
  text-wrap: balance;
}
.fast-c p {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg-2);
}

.fast-refs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.fast-ref {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-3);
  text-decoration: none;
  transition: color .15s, border-color .15s;
}
.fast-ref:hover { color: var(--ac); border-color: var(--ac); }
.fast-ref:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }

/* Arriving from a fast-read link, in the middle of 103 rules, with nothing
   marking which one you came for. */
.rule.is-target {
  animation: ruleFlash 2.6s var(--ease);
}
@keyframes ruleFlash {
  0%, 22% { background: rgba(249, 115, 22, .16); box-shadow: inset 3px 0 0 var(--ac); }
  100%    { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .fast-card:hover { transform: none; }
  .rule.is-target { animation: none; background: rgba(249, 115, 22, .13); }
}

@media (max-width: 620px) {
  .fast { padding: 18px 16px 20px; border-radius: var(--r); }
  .fast-grid { grid-template-columns: 1fr; }
}
