/* ==========================================================================
   MohidWebSrv — System layer
   Loaded after style.css. Component normalisation, accessibility and
   responsive polish. Everything here is additive: delete this file to revert.
   ========================================================================== */

/* --- 1. Accessible focus ring (the theme previously had none) -------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}
a[style*="border-radius: 999px"]:focus-visible,
a[style*="border-radius: var(--r-pill)"]:focus-visible,
.plg-card__cta:focus-visible,
button[data-mws="toggle-theme"]:focus-visible {
  border-radius: var(--r-pill);
  outline-offset: 4px;
}

/* --- 2. Skip to content --------------------------------------------------- */
.mws-skip { position: absolute; left: -9999px; top: 0; z-index: 100; }
.mws-skip:focus {
  left: 12px; top: 12px;
  padding: 10px 18px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: 700;
}

/* Visually hidden, still announced by screen readers */
.mws-vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* Stat tiles stay equal-width instead of sizing to their label */
@media (max-width: 620px) { .mws-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }

/* Widget preview slots (replaced the never-loading <x-import> image-slot) */
.mws-shot {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 16px;
  background: var(--bg-soft);
  box-sizing: border-box;
}
body[data-theme="light"] .mws-shot--dark { display: none; }
body:not([data-theme="light"]) .mws-shot--light { display: none; }
.mws-shot-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  background: var(--bg-soft);
  color: var(--faint);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
}
.mws-shot-empty span { font-size: 24px; opacity: 0.65; }

/* Chip grid keeps equal columns instead of a ragged wrap */
.mws-chip-grid > span { min-width: 0; }
@media (max-width: 900px) { .mws-chip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
@media (max-width: 380px) { .mws-chip-grid { grid-template-columns: 1fr !important; } }

/* --- 3. Typographic hygiene ---------------------------------------------- */
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
/* Headings with no explicit value land on the scale instead of the UA default */
h1, h2, h3, h4, h5, h6 { line-height: var(--lh-heading); }
.mws-shot-empty { color: var(--muted); font-size: var(--fs-base); }

.mws-eyebrow { max-width: 100%; flex-wrap: nowrap; }
.mws-eyebrow > span { flex: 0 0 auto; }

/* --- 4. Form controls ----------------------------------------------------- */
input, textarea, select, button { font-family: inherit; }
input, textarea, select { font-size: var(--fs-lg); }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
textarea { min-height: 132px; }
input:focus, textarea:focus { border-color: var(--brand) !important; }

/* --- 5. Media ------------------------------------------------------------- */
img, svg, video { max-width: 100%; height: auto; }

/* --- 6. Interaction affordances ------------------------------------------- */
button, [role="button"], summary { cursor: pointer; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }

/* --- 7. Tap targets on touch devices -------------------------------------- */
@media (hover: none) and (pointer: coarse) {
  #mws-footer-nav a,
  #mws-main-nav a { min-height: 44px; display: flex; align-items: center; }
}

/* --- 8. Mobile polish ----------------------------------------------------- */
@media screen and (max-width: 760px) {
  .mws-hero-deco { display: none !important; }

  .mws-hero-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .mws-hero-actions > a { justify-content: center; width: 100%; box-sizing: border-box; }

  .mws-eyebrow { flex-wrap: wrap; justify-content: center; text-align: center; }

  .mws-hero { min-height: auto !important; }
}

@media screen and (max-width: 480px) {
  .mws-eyebrow { letter-spacing: 2px !important; font-size: var(--fs-micro) !important; }
}

/* --- 9. Motion preferences ------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- 10. Print ------------------------------------------------------------ */
@media print {
  #site-header, #mws-hamburger, .mws-hero-deco { display: none !important; }
  body { background: #fff; color: #000; }
}
