/* The interface kit (PLAN-UX-UI-2026-11 F2-01) — one dialog for the site.
 *
 * Every rule sits under the kit's own `.rr` root (the dialog carries
 * class="rr kit-dialog"), so the Reading Room tokens resolve on any page,
 * themed or not. Three radii only; no side accent bar; no z-index: a modal
 * <dialog> opened with showModal() lives in the browser's top layer, above
 * every stacking context on the page (the editor toolbar's included).
 * Markup: templates/_kit.html. Script: static/js/kit.js.
 */

.rr.kit-dialog {
  /* the page reset zeroes <dialog>'s auto margin, which pins a modal to the
     top-left corner (collection_v2's .followdlg note); auto centres it */
  margin: auto;
  padding: 0;
  border: 1px solid var(--rr-rule);
  border-radius: var(--rr-radius-card);
  background: var(--rr-paper);
  color: var(--rr-ink);
  font-family: var(--rr-font-body);
  width: calc(100% - 32px);
  max-width: 480px;
  max-height: calc(100% - 32px);
  overflow: hidden;
}
.rr.kit-dialog.kit-dialog--wide { max-width: 560px; }
.rr.kit-dialog:not([open]) { display: none; }
.rr.kit-dialog::backdrop {
  /* ::backdrop may not inherit tokens: ink at 45% */
  background: rgba(27, 26, 23, 0.45);
}

/* the box inside: a click here never counts as a click on the backdrop */
.rr .kit-dialog__inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 24px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.rr .kit-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.rr .kit-dialog__title {
  margin: 10px 0 0;
  font-family: var(--rr-font-display);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.25;
  color: var(--rr-ink);
}
.rr .kit-dialog__close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0 -10px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--rr-radius-pill);
  background: transparent;
  color: var(--rr-ink-2);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.rr .kit-dialog__close:hover { background: var(--rr-paper-sunken); color: var(--rr-ink); }
.rr .kit-dialog__body {
  font-size: 15px;
  line-height: 1.55;
  color: var(--rr-ink-2);
}
.rr .kit-dialog__body > :first-child { margin-top: 0; }
.rr .kit-dialog__body > :last-child { margin-bottom: 0; }
.rr .kit-dialog__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* buttons: 44px touch height, pill radius */
.rr .kit-btn {
  min-height: 44px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rr-rule-strong);
  border-radius: var(--rr-radius-pill);
  background: transparent;
  color: var(--rr-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.rr .kit-btn:hover { background: var(--rr-paper-sunken); }
.rr .kit-btn--primary { border-color: var(--rr-ink); background: var(--rr-ink); color: var(--rr-paper-raised); }
.rr .kit-btn--primary:hover { background: var(--rr-ink-2); }
.rr .kit-btn--danger { border-color: var(--color-error); background: var(--color-error); color: var(--rr-paper-raised); }
.rr .kit-btn:disabled { opacity: .5; cursor: not-allowed; }
.rr .kit-dialog__close:focus-visible,
.rr .kit-btn:focus-visible { outline: 2px solid var(--rr-accent); outline-offset: 2px; }

/* narrow screens: a full-width sheet pinned to the bottom */
@media (max-width: 519.98px) {
  .rr.kit-dialog {
    margin: auto 0 0;
    width: 100%;
    max-width: none;
    border-bottom: 0;
    border-radius: var(--rr-radius-card) var(--rr-radius-card) 0 0;
  }
  .rr.kit-dialog.kit-dialog--wide { max-width: none; }
  .rr .kit-dialog__inner { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .rr .kit-dialog__foot { flex-direction: column-reverse; align-items: stretch; }
}
