/*
 * Shared modules - core: dialogs, switches, buttons for module UI.
 * Everything is prefixed mws- and sets its own box model, fonts and spacing, so it looks the
 * same next to Bootstrap (classic) or the mosaic template. Colors come from --mws-*
 * custom properties (defaults inline in <head>, a template may override them):
 * --mws-bg --mws-surface --mws-text --mws-muted --mws-line --mws-accent --mws-on-accent
 * --mws-accent-text --mws-focus; shape: --mws-radius, --mws-radius-btn; fonts:
 * --mws-font, --mws-font-head.
 */
:root {
  --mws-radius: 14px;
  --mws-radius-btn: 999px;
  --mws-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mws-font-head: var(--mws-font);
  --mws-ease: cubic-bezier(.16, 1, .3, 1);
}

.mws-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.mws-icon { width: 20px; height: 20px; flex: none; }

/* ---- dialog ---- */
.mws-dlg {
  box-sizing: border-box; width: min(760px, calc(100vw - 32px)); max-width: none; max-height: min(88dvh, 920px);
  margin: auto; padding: 0; border: 0; border-radius: var(--mws-radius); overflow: hidden;
  background: var(--mws-bg); color: var(--mws-text); box-shadow: 0 40px 100px -20px rgb(0 0 0 / .55);
  font: 400 1rem/1.6 var(--mws-font); text-align: left; letter-spacing: normal;
  opacity: 0; transform: translateY(40px) scale(.96);
  transition: opacity .3s ease, transform .55s var(--mws-ease), overlay .55s allow-discrete, display .55s allow-discrete;
}
.mws-dlg *, .mws-dlg *::before, .mws-dlg *::after { box-sizing: border-box; }
.mws-dlg[open] { display: flex; flex-direction: column; opacity: 1; transform: none; }
@starting-style { .mws-dlg[open] { opacity: 0; transform: translateY(40px) scale(.96); } }
.mws-dlg::backdrop {
  background: rgb(8 8 8 / 0); backdrop-filter: blur(0);
  transition: background-color .4s ease, backdrop-filter .4s ease, overlay .4s allow-discrete, display .4s allow-discrete;
}
.mws-dlg[open]::backdrop { background: rgb(8 8 8 / .66); backdrop-filter: blur(8px); }
@starting-style { .mws-dlg[open]::backdrop { background: rgb(8 8 8 / 0); backdrop-filter: blur(0); } }
/* the page behind an open dialog stops scrolling (set by core.js only where that keeps the
   scroll position: not on pages whose html box is fixed to the window height) */
html.mws-lock { overflow: hidden; }
.mws-dlg-head { flex: none; display: flex; align-items: center; gap: 16px; padding: 16px 16px 16px clamp(20px, 3.4vw, 36px); border-bottom: 1px solid var(--mws-line); }
.mws-dlg-title { display: flex; align-items: center; gap: 12px; margin: 0 auto 0 0; font: 600 clamp(1.3rem, 1.1rem + .8vw, 1.7rem)/1.2 var(--mws-font-head); color: inherit; letter-spacing: -0.01em; text-transform: none; }
.mws-dlg-title .mws-icon { width: 26px; height: 26px; color: var(--mws-accent-text); }
.mws-dlg-close { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border-radius: var(--mws-radius-btn); border: 1px solid var(--mws-line); background: transparent; color: inherit; cursor: pointer; }
.mws-dlg-close:hover { background: var(--mws-surface); border-color: var(--mws-text); }
.mws-dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px clamp(20px, 3.4vw, 36px) 32px; }
.mws-dlg-body p { margin: 0 0 16px; }
.mws-dlg-body ul { margin: 0 0 16px; padding-left: 1.25em; }
.mws-dlg-body h3 { font: 700 1.05rem/1.4 var(--mws-font); margin: 28px 0 10px; color: inherit; text-transform: none; letter-spacing: 0; }
.mws-dlg-body h3:first-child { margin-top: 0; }
.mws-dlg-body a { color: var(--mws-accent-text); text-decoration: underline; text-underline-offset: .2em; }
.mws-note { color: var(--mws-muted); }
@media (max-width: 640px) {
  .mws-dlg { width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--mws-radius) var(--mws-radius) 0 0; transform: translateY(100%); opacity: 1; }
  .mws-dlg[open] { transform: none; }
  @starting-style { .mws-dlg[open] { transform: translateY(100%); } }
}

/* ---- buttons ---- */
.mws-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 22px;
  border: 1px solid transparent; border-radius: var(--mws-radius-btn); font: 650 .95rem/1.1 var(--mws-font); letter-spacing: 0;
  text-decoration: none; cursor: pointer; transition: background-color .2s, border-color .2s, color .2s;
}
.mws-btn-accent { background: var(--mws-accent); color: var(--mws-on-accent); }
.mws-btn-accent:hover { filter: brightness(1.08); }
.mws-btn-line { background: transparent; color: var(--mws-text); border-color: var(--mws-line); }
.mws-btn-line:hover { border-color: var(--mws-text); }
.mws-link { display: inline-flex; align-items: center; min-height: 32px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: .2em; cursor: pointer; text-align: left; }
.mws-btn:focus-visible, .mws-link:focus-visible, .mws-dlg-close:focus-visible, .mws-dlg :focus-visible { outline: 3px solid var(--mws-focus); outline-offset: 2px; }

/* ---- switches ---- */
.mws-toggles, .mws-dlg-body .mws-toggles { display: grid; column-gap: 32px; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--mws-line); }
@media (min-width: 740px) { .mws-toggles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mws-toggles li { padding: 16px 0; border-bottom: 1px solid var(--mws-line); }
.mws-switch { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; column-gap: 12px; min-height: 32px; margin: 0; cursor: pointer; font-weight: 650; }
.mws-switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.mws-switch .mws-icon { width: 22px; height: 22px; color: var(--mws-accent-text); }
.mws-track { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--mws-surface); border: 2px solid var(--mws-muted); transition: background-color .2s, border-color .2s; }
.mws-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--mws-muted); transition: transform .25s var(--mws-ease), background-color .2s; }
.mws-switch input:checked ~ .mws-track { background: var(--mws-accent); border-color: var(--mws-accent); }
.mws-switch input:checked ~ .mws-track::after { transform: translateX(18px); background: var(--mws-on-accent); }
.mws-switch input:focus-visible ~ .mws-track { outline: 3px solid var(--mws-focus); outline-offset: 3px; }
.mws-switch input:disabled, .mws-switch:has(input:disabled) { cursor: default; }
.mws-switch:has(input:disabled) { opacity: .75; }
.mws-hint { margin: 4px 0 0 36px; color: var(--mws-muted); font-size: .9rem; line-height: 1.45; }
:root[data-mws-shape="sharp"] { --mws-radius: 0; --mws-radius-btn: 0; }
:root[data-mws-shape="sharp"] .mws-track, :root[data-mws-shape="sharp"] .mws-track::after { border-radius: 0; }

@media (prefers-reduced-motion: reduce) {
  .mws-dlg, .mws-dlg::backdrop, .mws-track, .mws-track::after { transition-duration: .01ms !important; }
}
@media (forced-colors: active) {
  .mws-btn, .mws-dlg-close, .mws-track { border: 1px solid CanvasText; }
}
