/*
 * Sitewide template fixes (enqueued after style.css by inc/sitewide-fixes.php).
 * Kept as a plain CSS file so it ships without a Sass build; fold into
 * sass/includes/ on the next build if preferred.
 */

/* ---- Reflow at 320px (WCAG 1.4.10) -------------------------------------
 * Silktide: two-dimensional-scrolling, extreme-zoom-scrolling
 * Content tables carry width="820" etc. from the classic editor; long URLs used
 * as link text do not wrap. */

.entry-content {
  overflow-wrap: anywhere;
}

/* Theme links are inline-block with overflow-wrap: break-word, which does not
   shrink their min-content width, so a long URL as link text sets the page width. */
.entry-content a {
  overflow-wrap: anywhere;
  max-width: 100%;
}

.entry-content .table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.entry-content .table-scroll:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}

.entry-content .table-scroll > table {
  margin-bottom: 0;
}

/* The editor's width/height attributes become a maximum, not a fixed size. */
.entry-content table {
  max-width: 100%;
  /* Keep whole words in cells; a table wider than the screen scrolls inside
     .table-scroll instead of squeezing columns letter by letter. */
  overflow-wrap: normal;
}

.entry-content table a {
  overflow-wrap: normal;
}

.entry-content table[style*="height"] {
  height: auto !important;
}

.entry-content img,
.entry-content video,
.entry-content iframe,
.entry-content embed,
.entry-content object {
  max-width: 100%;
}

.entry-content img,
.entry-content video {
  height: auto;
}

.entry-content .wp-caption {
  max-width: 100% !important; /* core sets an inline width */
}

.entry-content pre {
  overflow-x: auto;
  white-space: pre-wrap;
}

/* ---- Native <dialog> modals (replace Lity) ------------------------------
 * Silktide: modal-focus-trap */

dialog.sights-dialog {
  position: fixed;
  border: 0;
  padding: 2rem;
  width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  color: #000;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}

dialog.sights-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

dialog.sights-dialog h2 {
  margin-top: 0;
  padding-right: 2.5rem; /* room for the close button */
}

dialog.sights-dialog .dialog-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: #000;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

dialog.sights-dialog .dialog-close:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}

/* "Request Info" is now a <button>; match the old <a class="button"> sizing.
   Scoped to the dialog opener: the footer "Go" button is also a button.button
   inside .footer-buttons-list, and width: 100% there squeezes the email field. */
.footer-buttons-list button.button[data-dialog-open] {
  width: 100%;
  min-height: 44px;
}

/* ---- Search pop-up ------------------------------------------------------ */

.search-popup[hidden] {
  display: none !important;
}

.search-popup .search-close {
  min-width: 44px;
  min-height: 44px;
}
