/* The Agate rules section (/angrea/agate). Layout chrome (atlas-layout /
   atlas-sidebar / atlas-content) comes from atlas.css; this styles the curated
   sidebar nav, the reference lists, and the shared stat block. Uses the Angrea
   brass theme variables. */

/* ---- sidebar nav ---- */
.agate-sidenav { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; }
.agate-navsec { margin: 0; }
.agate-navsec > summary {
  list-style: none; cursor: pointer; padding: 7px 12px; border-radius: 7px;
  font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary, #999);
}
.agate-navsec > summary::-webkit-details-marker { display: none; }
.agate-navsec > summary::before { content: "▸ "; color: var(--brass, #b8860b); }
.agate-navsec[open] > summary::before { content: "▾ "; }
.agate-navsec > summary:hover { color: var(--brass-light, #d4a574); }
.agate-navsub { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px 8px; }
/* nested subgroup (e.g. "Character Options" under "Characters") — reuses the
   chapter arrow/details mechanics, de-emphasized one step since it isn't a
   top-level chapter. */
.agate-navsec-sub > summary {
  font-size: 0.86em; text-transform: none; letter-spacing: 0;
  color: var(--text-primary, #e0e0e0);
}
.agate-navsec-sub > summary:hover { color: var(--brass-light, #d4a574); }
.agate-navsub .agate-navsub { padding-inline-start: 14px; }

.agate-navlink {
  display: block; padding: 6px 12px; border-radius: 7px; text-decoration: none;
  color: var(--text-primary, #e0e0e0); font-size: 0.92em;
  border-inline-start: 2px solid transparent; transition: background 0.15s ease, color 0.15s ease;
}
.agate-navlink:hover { background: rgba(184, 134, 11, 0.08); color: var(--brass-light, #d4a574); }
.agate-navlink.active {
  background: rgba(184, 134, 11, 0.16); color: var(--brass-light, #d4a574);
  border-inline-start-color: var(--brass, #b8860b);
}
/* top-level (section-less) links sit flush */
.agate-navsec > .agate-navlink { font-size: 0.98em; }

/* ---- content ---- */
/* Same mechanism Atlas's .content-section uses: .atlas-content is a flex row
   (main.css) that centers a single child, but only if that child is narrower
   than the flex container — cap the width so there's leftover space to center
   into, matching Atlas's 70rem cap. */
.agate-rules { inline-size: 100%; max-inline-size: 70rem; padding-inline: 4rem;}

/* reference list */
.agate-ref-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding: 1rem; inline-size: 100%;}
.agate-ref-head h1 { margin: 0; color: var(--brass-light, #d4a574); }
.agate-ref-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#agate-q {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--bg-tertiary, #333);
  background: var(--bg-secondary, #1c1c1c); color: var(--text-primary, #e0e0e0); font: inherit; min-width: 220px;
}
.agate-filter-wrap { position: relative; }
.agate-filter-btn {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--bg-tertiary, #333);
  background: var(--bg-secondary, #1c1c1c); color: var(--text-primary, #e0e0e0); font: inherit; cursor: pointer;
}
.agate-filter-btn:hover { border-color: var(--brass, #b8860b); }
.agate-filter-btn.active { border-color: var(--brass, #b8860b); color: var(--brass-light, #d4a574); }
.agate-filter-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 220px;
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  border: 1px solid var(--bg-tertiary, #333); border-radius: 10px; background: var(--bg-secondary, #1c1c1c);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}
/* `display: flex` above otherwise beats the UA stylesheet's `[hidden] { display:
   none }` at equal specificity (author origin always wins), so toggling the
   `hidden` attribute in JS would have no visual effect without this. */
.agate-filter-panel[hidden] { display: none; }
.agate-filter-row { display: flex; flex-direction: column; gap: 4px; font-size: 0.86em; color: var(--text-secondary, #999); }
.agate-filter-row select {
  padding: 6px 8px; border-radius: 6px; border: 1px solid var(--bg-tertiary, #333);
  background: var(--bg-primary, #141414); color: var(--text-primary, #e0e0e0); font: inherit;
}
.agate-filter-actions { display: flex; justify-content: flex-end; }
.agate-filter-clear {
  background: none; border: none; color: var(--text-secondary, #999); font-size: 0.82em;
  cursor: pointer; text-decoration: underline;
}
.agate-filter-clear:hover { color: var(--brass-light, #d4a574); }
.agate-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.agate-groups { display: flex; flex-direction: column; gap: 26px; }
.agate-cat-heading {
  margin: 0 0 10px; padding-bottom: 4px; border-bottom: 1px solid var(--bg-tertiary, #333);
  color: var(--brass-light, #d4a574); font-size: 1em; text-transform: uppercase; letter-spacing: 0.08em;
}
.agate-card {
  display: flex; flex-direction: column; gap: 3px; text-decoration: none;
  border: 1px solid var(--bg-tertiary, #333); border-radius: 11px; background: var(--bg-secondary, #1c1c1c);
  padding: 12px 14px; transition: border-color 0.15s ease, transform 0.1s ease; color: var(--text-primary, #e0e0e0);
}
.agate-card:hover { border-color: var(--brass, #b8860b); transform: translateY(-1px); }
.agate-card-title { font-weight: 600; }
.agate-card-cat { font-size: 0.74em; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brass, #b8860b); }
.agate-card-sum { font-size: 0.86em; color: var(--text-secondary, #999); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agate-empty { color: var(--text-secondary, #999); }
.agate-back { display: inline-block; margin-bottom: 14px; text-decoration: none; color: var(--text-secondary, #999); font-size: 0.9em; }
.agate-back:hover { color: var(--brass-light, #d4a574); }

/* ---- stat block (shared shape with the Scriptorium preview) ---- */
.agate-element { --agc: var(--brass, #b8860b); }
.agate-title { margin: 0 0 2px; color: var(--brass-light, #d4a574); }
.agate-kind { margin: 0 0 8px; font-size: 0.74em; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-secondary, #999); }
.agate-summary { margin: 0 0 14px; color: var(--text-primary, #e0e0e0); }
.agate-section { margin: 16px 0; }
.agate-section > h3 { margin: 0 0 6px; font-size: 0.74em; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-secondary, #999); }
.agate-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.agate-pill { font-size: 0.82em; padding: 2px 9px; border-radius: 999px; background: rgba(184, 134, 11, 0.14); color: var(--text-primary, #e0e0e0); }
.agate-pill-k { color: var(--text-secondary, #999); }
.agate-prereq em { color: var(--brass-light, #d4a574); font-style: normal; font-weight: 700; }
.agate-effects, .agate-tiers { margin: 6px 0; padding-left: 20px; }
.agate-muted { color: var(--text-secondary, #999); }
.agate-action { border: 1px solid var(--bg-tertiary, #333); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.agate-action h4 { margin: 0 0 6px; color: var(--brass-light, #d4a574); }
.agate-damage { border-collapse: collapse; margin: 8px 0; font-size: 0.9em; width: 100%; max-width: 420px; }
.agate-damage th, .agate-damage td { border: 1px solid var(--bg-tertiary, #333); padding: 3px 10px; text-align: left; }
.agate-traits { display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; margin: 6px 0; }
.agate-traits dt { color: var(--text-secondary, #999); }
.agate-traits dd { margin: 0; }
.agate-branch-tree { margin: 10px 0; }
.agate-branch-tree > summary {
  cursor: pointer; list-style: none; font-weight: 600; font-size: 0.82em;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--brass-light, #d4a574);
}
.agate-branch-tree > summary::-webkit-details-marker { display: none; }
.agate-branch-tree > summary::before { content: "▸ "; color: var(--brass, #b8860b); }
.agate-branch-tree[open] > summary::before { content: "▾ "; }
.agate-tree {
  list-style: none; margin: 6px 0 0; padding: 2px 0 2px 16px;
  border-left: 1px solid var(--bg-tertiary, #333);
  display: flex; flex-direction: column; gap: 5px;
}
.agate-feat-link { color: var(--text-primary, #e0e0e0); }
.agate-feat-link:hover { color: var(--brass-light, #d4a574); }

/* prose page loading/error states (reused from angrea-page) sit fine here. */
.agate-rules .angrea-page-loading { color: var(--text-secondary, #999); font-style: italic; }

/* ---- asides (the shared "callout" directive, blocks.ts — labeled "Callout /
   aside" there) ---- Agate pages don't load enhanced-features.css (that's
   Atlas's own callout styling), so these render fully unstyled here today.

   .content-section (main.css) is the opaque bordered/background card each
   `:::section` renders as, and it's already `position: relative`. It never
   contained floated children (no flow-root/clearfix), so a callout floated
   near a section's end escaped past its bottom border into the *next*
   section's opaque background — `display: flow-root` below is the actual
   fix for that, independent of viewport width.

   Three tiers:
     - Wide (>=107.5em, ~1720px+): once the fixed sidebar and the 70rem-capped
       column are accounted for, there's real leftover space beyond it at
       this width and up (1920 etc.) — position the aside outside the section
       box entirely, in that margin, instead of floating inside it. (Measured:
       100em/1600px still overflowed — 107.5em/1720px is where it clears.)
     - Medium (mobile breakpoint..107.5em): not enough outside room at
       ordinary laptop widths — float it inside the section next to the
       preceding text, same as any floated aside, now properly contained.
     - Mobile (<=56.25em, matches the layout's own sidebar-collapse point):
       ordinary full-width bordered box in flow. */
.agate-rules .content-section { display: flow-root; }

.callout {
  float: inline-end;
  clear: inline-end;
  inline-size: 15rem;
  margin: 1rem 0 1rem 1.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: 8px;
  border-inline-start: 3px solid var(--brass, #b8860b);
  background: var(--bg-secondary, #1c1c1c);
  font-size: 0.9em;
  line-height: 1.5;
}
.callout > :first-child { margin-block-start: 0; }
.callout > :last-child { margin-block-end: 0; }

.callout-warning { border-color: #e0a030; }
.callout-danger  { border-color: #c0392b; }
.callout-success { border-color: #4caf50; }

@media (min-width: 107.5em) {
  .callout {
    float: none;
    position: absolute;
    inset-inline-start: 100%;
    inset-block-start: 12.5rem;
    margin-inline-start: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

@media (max-width: 56.25em) {
  .callout {
    float: none;
    inline-size: auto;
    margin: 0 0 1.25rem;
  }
}
