/* Community rules and privacy policy (#160): agreement at registration and
   guest start, the writing pause after a change, the public document pages
   and the administration card. Uses only existing tokens. */

/* ---- Registration and guest entry ---- */
.register-agreement { display: grid; gap: 0.35rem; }
.register-agreement .checkbox-label { display: flex; align-items: flex-start; gap: 0.55rem; font-weight: 600; }
.register-agreement .checkbox-label input { margin-top: 0.2rem; flex: none; }
.register-agreement-links { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.register-agreement-links a,
.guest-rules-note a { color: inherit; font-weight: 600; text-underline-offset: 0.15em; }
.guest-rules-note { flex-basis: 100%; margin: 0.35rem 0 0; color: var(--text-muted); font-size: 0.85rem; }

/* ---- Writing paused until the person agrees ---- */
.rules-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--unsure-line) 55%, var(--line));
  border-radius: 0.8rem;
  background: color-mix(in srgb, var(--unsure-line) 12%, var(--surface));
  color: var(--text);
  font-size: 0.9rem;
}
.rules-banner > span { flex: 1 1 16rem; min-width: 0; }
.rules-banner .secondary-button { padding-block: 0.35rem; }
.messages-shell > .rules-banner { margin-bottom: 1rem; }

/* The chat shell sizes one grid row per visible strip. */
.chat-shell > .rules-banner { grid-column: 1 / -1; }
.chat-shell:has(> .rules-banner:not(.hidden)) { grid-template-rows: auto minmax(0, 1fr); }
.chat-shell:has(> .rules-banner:not(.hidden)):has(> .lockdown-banner:not(.hidden)),
.chat-shell:has(> .rules-banner:not(.hidden)):has(> :is(.guest-banner, .new-look-note):not(.hidden)) { grid-template-rows: auto auto minmax(0, 1fr); }
.chat-shell:has(> .rules-banner:not(.hidden)):has(> .lockdown-banner:not(.hidden)):has(> :is(.guest-banner, .new-look-note):not(.hidden)) { grid-template-rows: auto auto auto minmax(0, 1fr); }

.rules-notice { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 1rem; }
.rules-notice > div { display: grid; gap: 0.2rem; }
.rules-gated #composer-form,
.rules-gated #dm-composer,
.rules-gated .composer-help { display: none !important; }
.conversation-main:has(#dm-composer.hidden) .rules-notice { display: none; }

/* ---- The dialog ---- */
.rules-dialog { width: min(40rem, calc(100vw - 2rem)); }
.rules-dialog > .form-stack { padding: 1.5rem; }
.rules-dialog h2 { margin: 0; }
.rules-dialog h2:focus { outline: none; }
.rules-change-summary { margin: 0; font-weight: 600; }
.rules-note { margin: 0; color: var(--text-muted); }
.rules-body {
  max-height: 50vh;
  overflow: auto;
  padding: 0.25rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--raised);
}
.rules-body:focus-visible { outline: 2px solid var(--signature-text); outline-offset: 2px; }
.rules-explanation { margin: 0; color: var(--text-muted); }
.rules-external a { font-weight: 700; }
.rules-leave { margin: 0; font-size: 0.85rem; }
.rules-dialog .error-text:empty { display: none; }

/* ---- Rendered documents (public page, dialog, admin preview) ---- */
.policy-content { line-height: 1.6; overflow-wrap: anywhere; }
.policy-content h1,
.policy-content h2 { margin: 1.4em 0 0.4em; font-size: 1.3rem; line-height: 1.25; }
.policy-content h3,
.policy-content h4 { margin: 1.2em 0 0.3em; font-size: 1.08rem; }
.policy-content p,
.policy-content ul,
.policy-content ol { margin: 0 0 0.9em; }
.policy-content ul,
.policy-content ol { padding-left: 1.4rem; }
.policy-content li + li { margin-top: 0.25em; }
.policy-content hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.policy-content a { color: var(--signature-text); text-underline-offset: 0.15em; }
.policy-content > :first-child { margin-top: 0.6em; }

/* ---- Public pages: /rules.php and /privacy.php ---- */
.policy-page {
  width: min(44rem, 100%);
  margin: 0 auto;
  padding: 2.5rem 1rem 2rem;
  font-size: 1.0625rem;
}
.policy-header { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.policy-eyebrow { margin: 0 0 0.4rem; color: var(--text-muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.policy-header h1 { margin: 0; font-family: var(--display-font); font-size: clamp(2rem, 6vw, 2.75rem); font-weight: 400; line-height: 1.1; }
.policy-updated { margin: 0.5rem 0 0; color: var(--text-muted); font-size: 0.9rem; }
.policy-back { margin: 2rem 0 0; }

/* ---- Account ---- */
.account-links { margin: 0; }

/* ---- Administration ---- */
.policies-card { display: grid; gap: 1.25rem; }
.policies-card .policy-form { padding-top: 1.25rem; border-top: 1px solid var(--line); }
.policy-source { margin: 0; padding: 0; border: 0; display: grid; gap: 0.4rem; }
.policy-title { padding: 0; font-size: 1.05rem; font-weight: 700; }
.policy-source-options,
.policy-change { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
.policy-change { margin: 0; padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: 0.8rem; flex-direction: column; }
.policy-change legend { padding: 0 0.3rem; font-weight: 600; }
.policy-summary { display: grid; gap: 0.3rem; }
.policies-card label:has(> input[type="radio"]) { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; min-height: 2.75rem; font-weight: 400; }
.policies-card label:has(> input[type="radio"]) input { width: auto; margin: 0; padding: 0; flex: none; accent-color: var(--signature-text); }
.policy-markdown { width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.9rem; line-height: 1.5; }
.policy-preview-row { display: flex; gap: 0.5rem; }
.policy-size { margin: 0; font-size: 0.85rem; }
.policy-size-over { color: var(--error); font-weight: 600; }
.policy-preview { max-height: 24rem; overflow: auto; padding: 0.25rem 1rem; border: 1px dashed var(--line); border-radius: 0.8rem; }
.policy-none-warning { margin: 0; padding: 0.55rem 0.8rem; border-radius: 0.6rem; background: color-mix(in srgb, var(--unsure-line) 12%, var(--surface)); }

@media (max-width: 760px) {
  .chat-shell > .rules-banner { border-radius: 0; border-width: 0 0 1px; font-size: 0.8rem; }
  .rules-notice { grid-template-columns: 1fr; row-gap: 0.6rem; }
  .rules-notice .primary-button { justify-self: start; }
}

@media (forced-colors: active) {
  .rules-banner, .rules-body, .policy-change { border-color: CanvasText; }
}
