/* docmodal.css
   Styles for the document modal module (src/docmodal.js).
   Every rule is scoped to a .dm- class so nothing leaks into the site.
   Light theme is the default, dark theme is driven by body[data-theme="dark"].
*/

.dm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 500;
}

.dm-dialog {
  background: #ffffff;
  color: #16233d;
  border-radius: 22px;
  width: min(760px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(12, 24, 48, .3);
}

/* Head */

.dm-head {
  padding: 22px 26px 14px;
  border-bottom: 1px solid #e8edf6;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.dm-head-text {
  min-width: 0;
}

.dm-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

.dm-sub {
  font-size: .82rem;
  color: #64749a;
  margin: 4px 0 0;
}

.dm-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #e0e6f2;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #48566f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
}

.dm-close:hover {
  background: #f1f4fa;
}

.dm-close:focus-visible,
.dm-btn:focus-visible {
  outline: 2px solid #1746c8;
  outline-offset: 2px;
}

/* Body */

.dm-body {
  padding: 20px 26px;
  overflow-y: auto;
  flex: 1;
  font-size: .9rem;
  line-height: 1.65;
}

.dm-body .dm-loading,
.dm-body .dm-error {
  margin: 0;
  color: #64749a;
}

.dm-body .dm-error {
  border: 1px solid #e8edf6;
  border-radius: 10px;
  padding: 12px 14px;
  background: #f5f7fc;
}

/* Rendered document. pre.dm-doc is the plain text mode,
   div.dm-doc is the markdown mode. */

pre.dm-doc {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem;
  margin: 0;
}

.dm-doc h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.1em 0 .4em;
}

.dm-doc h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1em 0 .35em;
}

.dm-doc h4 {
  font-size: .92rem;
  font-weight: 600;
  margin: 1em 0 .3em;
}

.dm-doc p {
  margin: .7em 0;
}

.dm-doc ul {
  padding-left: 1.2em;
  margin: .7em 0;
}

.dm-doc li {
  margin: .25em 0;
}

.dm-doc code {
  background: #f1f4fa;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: .82em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dm-doc pre {
  background: #f5f7fc;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  margin: .9em 0;
  line-height: 1.5;
}

.dm-doc pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: .8rem;
}

.dm-doc a {
  color: #1746c8;
}

.dm-doc hr {
  border: 0;
  border-top: 1px solid #e8edf6;
  margin: 1.2em 0;
}

/* Foot */

.dm-foot {
  padding: 16px 26px;
  border-top: 1px solid #e8edf6;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dm-btn {
  border-radius: 999px;
  border: 1px solid #d7deec;
  background: #fff;
  color: #16233d;
  padding: 9px 18px;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dm-btn:hover {
  background: #f1f4fa;
}

.dm-btn.is-primary {
  background: #1746c8;
  color: #fff;
  border-color: #1746c8;
}

.dm-btn.is-primary:hover {
  background: #123a9f;
  border-color: #123a9f;
}

/* Dark theme overrides */

body[data-theme="dark"] .dm-dialog {
  background: #131c2e;
  color: #e8eefb;
}

body[data-theme="dark"] .dm-head {
  border-bottom-color: #263349;
}

body[data-theme="dark"] .dm-foot {
  border-top-color: #263349;
}

body[data-theme="dark"] .dm-btn {
  background: #1c2740;
  color: #e8eefb;
  border-color: #2e3c56;
}

body[data-theme="dark"] .dm-btn:hover {
  background: #24314d;
}

body[data-theme="dark"] .dm-btn.is-primary {
  background: #1746c8;
  color: #fff;
  border-color: #1746c8;
}

body[data-theme="dark"] .dm-btn.is-primary:hover {
  background: #1d52dc;
  border-color: #1d52dc;
}

body[data-theme="dark"] .dm-close {
  background: #1c2740;
  color: #b6c4de;
  border-color: #2e3c56;
}

body[data-theme="dark"] .dm-close:hover {
  background: #24314d;
}

body[data-theme="dark"] .dm-doc code {
  background: #1b2437;
}

body[data-theme="dark"] .dm-doc pre {
  background: #1b2437;
}

body[data-theme="dark"] .dm-doc pre code {
  background: transparent;
}

body[data-theme="dark"] .dm-doc hr {
  border-top-color: #263349;
}

body[data-theme="dark"] .dm-sub {
  color: #93a3c4;
}

body[data-theme="dark"] .dm-body .dm-loading,
body[data-theme="dark"] .dm-body .dm-error {
  color: #93a3c4;
}

body[data-theme="dark"] .dm-body .dm-error {
  border-color: #263349;
  background: #1b2437;
}

/* Small screens */

@media (max-width: 560px) {
  .dm-head {
    padding: 16px;
  }

  .dm-body {
    padding: 16px;
  }

  .dm-foot .dm-btn {
    flex: 1 1 100%;
  }
}
