/* Rules page: categories on the left, rules in the middle, "on this page" on the right. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* a little wider than the rest of the site so three columns fit */
.rules { display: grid; grid-template-columns: 275px minmax(0, 1fr) 215px; gap: 2.4rem; align-items: start;
  width: min(1320px, calc(100vw - 2rem)); margin-left: calc((100% - min(1320px, 100vw - 2rem)) / 2); }

/* ---- left: categories ---- */
.rules-nav, .rules-toc { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2b3350 transparent; }
.rules-nav { padding: 1rem .7rem; border-radius: 18px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01)), var(--panel); }
.rules-nav-title { margin: .1rem .8rem .8rem; font: 700 .72rem var(--font-display); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.rn-cat { margin-bottom: .15rem; }
.rn-head { display: flex; align-items: center; gap: .7rem; padding: .62rem .8rem; border-radius: 11px; color: var(--muted); font-weight: 500; font-size: .95rem; line-height: 1.3;
  transition: background .2s, color .2s, transform .2s; }
.rn-head:hover { text-decoration: none; color: var(--text); background: rgba(255,255,255,.04); transform: translateX(2px); }
.rn-icon { flex: none; display: grid; place-items: center; width: 22px; height: 22px; }
.rn-icon .ico { width: 18px; height: 18px; margin: 0; vertical-align: 0; }
.rn-name { flex: 1; min-width: 0; }
.rn-count { flex: none; font: 600 .75rem var(--font-display); color: #6b7390; }
.rn-cat.on > .rn-head { background: rgba(115, 11, 223, .2); color: #d9c2ff; box-shadow: inset 0 0 0 1px rgba(164, 92, 245, .3); }
.rn-cat.on .rn-count { color: #b48cf0; }
.rn-sub { display: none; list-style: none; margin: .35rem 0 .5rem 1.15rem; padding: 0 0 0 .3rem; border-left: 1px solid var(--line); }
.rn-cat.on .rn-sub { display: block; }
.rn-sub a { display: block; padding: .32rem .7rem; margin-left: -1px; border-left: 2px solid transparent; border-radius: 0 8px 8px 0; color: #7f87a0; font-size: .85rem; line-height: 1.35; transition: color .15s, background .15s, border-color .15s; }
.rn-sub a b { display: inline-block; min-width: 2.1rem; color: #59607a; font: 600 .74rem ui-monospace, Consolas, monospace; }
.rn-sub a:hover { text-decoration: none; color: var(--text); background: rgba(255,255,255,.03); }
.rn-sub a.cur { color: #d9c2ff; border-left-color: var(--accent-2); background: rgba(115, 11, 223, .12); }
.rn-sub a.cur b { color: var(--accent-2); }

/* ---- middle: search + rules ---- */
.rsearch { display: flex; align-items: center; gap: .8rem; padding: .2rem .5rem .2rem 1.1rem; margin-bottom: 1.6rem; border-radius: 14px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01)), var(--panel); color: var(--muted); transition: border-color .2s, box-shadow .2s; }
.rsearch:focus-within { border-color: rgba(164, 92, 245, .6); box-shadow: 0 0 0 4px rgba(115, 11, 223, .18); color: var(--accent-2); }
.rsearch input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; padding: .85rem 0; font-size: .98rem; color: var(--text); }
.rsearch input::placeholder { color: #6f7691; }
.rsearch-count { flex: none; padding: .25rem .6rem; border-radius: 8px; background: rgba(255,255,255,.05); font: 600 .72rem var(--font-display); color: #7a829c; white-space: nowrap; }
.rsearch-status { margin: -.6rem 0 1.4rem; color: var(--muted); font-size: .9rem; }
.rsearch-status b { color: var(--text); }

.rcat { display: none; }
.rcat.on { display: block; animation: rcat-in .35s ease backwards; }
@keyframes rcat-in { from { opacity: 0; transform: translateY(8px); } }
html:not(.js) .rcat { display: block; margin-bottom: 3rem; }
.rcat-head { display: flex; align-items: center; gap: 1rem; padding-bottom: 1.4rem; margin-bottom: .4rem; border-bottom: 1px solid var(--line); }
.rcat-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 14px; color: var(--accent-2); background: rgba(115, 11, 223, .16); border: 1px solid rgba(164, 92, 245, .32); }
.rcat-icon .ico { width: 26px; height: 26px; margin: 0; vertical-align: 0; }
.rcat-head h2 { margin: 0; font-size: clamp(1.7rem, 3.4vw, 2.3rem); letter-spacing: -.03em; background: linear-gradient(90deg, #cfb2ff, #a45cf5 60%, #f95bd8); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.rcat-head p { margin: .1rem 0 0; font-size: .9rem; }

.rule { position: relative; padding: 1.7rem 0 1.7rem 1.1rem; border-bottom: 1px solid var(--line); scroll-margin-top: 92px; transition: background .25s; }
.rule:last-child { border-bottom: 0; }
.rule::before { content: ""; position: absolute; left: 0; top: 1.5rem; bottom: 1.5rem; width: 2px; border-radius: 2px; background: linear-gradient(to bottom, var(--accent), var(--accent-2)); opacity: 0; transform: scaleY(.4); transition: opacity .25s, transform .25s; }
.rule:hover::before, .rule:target::before, .rule.flash::before { opacity: 1; transform: scaleY(1); }
.rule.flash { animation: rule-flash 1.6s ease; }
@keyframes rule-flash { 0% { background: rgba(115, 11, 223, .22); } 100% { background: transparent; } }
.rule h3 { display: flex; align-items: center; gap: .8rem; margin: 0 0 .8rem; font-size: 1.25rem; letter-spacing: -.02em; }
.rcode { flex: none; display: inline-block; padding: .18rem .5rem; border-radius: 7px; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: #9aa2ba;
  font: 700 .74rem ui-monospace, "Cascadia Code", Consolas, monospace; letter-spacing: .02em; }
.rule:hover .rcode { color: #e2d3ff; border-color: rgba(164, 92, 245, .5); background: rgba(115, 11, 223, .2); }
.rbody { margin: 0; color: #c2c8d8; font-size: 1.02rem; line-height: 1.8; max-width: 72ch; white-space: pre-line; }
.rbody.solo { display: flex; gap: .9rem; align-items: baseline; }
.rbody.solo .rtext { flex: 1; }
.rule mark { background: rgba(164, 92, 245, .35); color: #fff; padding: 0 .12em; border-radius: 4px; }
.rules-empty { padding: 3rem 0; text-align: center; color: var(--muted); }

/* searching: show every match across all categories */
.rules.searching .rcat { display: none; }
.rules.searching .rcat.hit { display: block; margin-bottom: 1.6rem; animation: none; }
.rules.searching .rcat-head { padding-bottom: .9rem; }
.rules.searching .rcat-head h2 { font-size: 1.35rem; }
.rules.searching .rcat-icon { width: 38px; height: 38px; border-radius: 11px; } .rules.searching .rcat-icon .ico { width: 20px; height: 20px; }
.rules.searching .rn-sub, .rules.searching .toc { display: none; }
.rules.searching .rules-toc { visibility: hidden; }
.rule[hidden] { display: none; }

/* ---- right: on this page ---- */
.rules-toc { padding-left: .3rem; }
.toc-title { display: flex; align-items: center; gap: .55rem; margin: 0 0 1rem; font: 700 .72rem var(--font-display); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.toc-title .ico { width: 15px; height: 15px; margin: 0; vertical-align: 0; }
.toc { display: none; list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc.on { display: block; }
.toc a { display: block; padding: .38rem 0 .38rem .95rem; margin-left: -1px; border-left: 2px solid transparent; color: #7f87a0; font-size: .87rem; line-height: 1.4; transition: color .15s, border-color .15s, transform .15s; }
.toc a:hover { text-decoration: none; color: var(--text); transform: translateX(2px); }
.toc a.cur { color: #d9c2ff; border-left-color: var(--accent-2); font-weight: 600; }

/* ---- smaller screens ---- */
@media (max-width: 1150px) {
  .rules { grid-template-columns: 250px minmax(0, 1fr); }
  .rules-toc { display: none; }
}
@media (max-width: 820px) {
  .rules { grid-template-columns: 1fr; gap: 1.2rem; width: 100%; margin-left: 0; }
  /* categories become a swipeable row of chips */
  .rules-nav { position: static; max-height: none; padding: .5rem; display: flex; gap: .4rem; overflow-x: auto; border-radius: 14px; }
  .rules-nav-title { display: none; }
  .rn-cat { flex: none; margin: 0; }
  .rn-head { white-space: nowrap; padding: .5rem .8rem; }
  .rn-sub, .rn-cat.on .rn-sub { display: none; }
  .rn-count { display: none; }
}
@media (prefers-reduced-motion: reduce) { .rcat.on, .rule.flash { animation: none; } }
