/* M3 v212: viewport, keyboard, touch and narrow-screen compatibility.
   Keep M2's theme; these rules only constrain sizing and interaction. */
:root {
  --kff-visible-height: 100vh;
  --kff-visible-top: 0px;
  --kff-dialog-top-gap: max(12px, env(safe-area-inset-top, 0px));
  --kff-dialog-bottom-gap: max(12px, env(safe-area-inset-bottom, 0px));
}
@supports (height: 100dvh) {
  :root { --kff-visible-height: 100dvh; }
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* M3 v216: keep the home header below the iPhone status bar/notch.
   Inset the normal-flow content once; fixed dialogs retain their own insets. */
html body #homePage > .container {
  padding-top: env(safe-area-inset-top, 0px) !important;
}

html body #kffAccessGate,
html body #quickAddNewsModal,
html body #governorateActivityEditor,
html body #previousIncidentsModal,
html body #homeNewsDetailModal,
html body #homeNewsImageViewer,
html body #kffBottomAdminFloat.kff-tools-sheet {
  top: var(--kff-visible-top) !important;
  bottom: auto !important;
  height: var(--kff-visible-height) !important;
  min-height: 0 !important;
  max-height: var(--kff-visible-height) !important;
  box-sizing: border-box !important;
}
html body #kffAccessGate {
  flex-direction: column !important;
  justify-content: flex-start !important;
  overflow-y: auto !important;
  padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
}
html body #kffAccessGate .kff-access-card {
  flex-shrink: 0 !important;
  margin-top: auto !important;
  margin-bottom: auto !important;
}
html body #quickAddNewsModal {
  padding: var(--kff-dialog-top-gap) max(12px, env(safe-area-inset-right, 0px)) var(--kff-dialog-bottom-gap) max(12px, env(safe-area-inset-left, 0px)) !important;
  -webkit-backdrop-filter: blur(6px);
}
html body #quickAddNewsModal .quick-news-box {
  max-height: calc(var(--kff-visible-height) - var(--kff-dialog-top-gap) - var(--kff-dialog-bottom-gap)) !important;
}
html body #quickAddNewsModal .quick-news-wizard {
  min-width: 0 !important;
  -webkit-overflow-scrolling: touch;
  scroll-padding-block: 12px;
}
html body #quickAddNewsModal .quick-news-toggle {
  gap: 12px !important;
  min-height: 44px !important;
  overflow-wrap: anywhere;
}
html body #quickAddNewsModal .quick-news-toggle input { flex: 0 0 auto; }
html body #quickAddNewsModal .quick-news-close-x,
html body #quickAddNewsModal .quick-news-remove-support-btn,
html body #quickAddNewsModal .quick-news-media-remove {
  min-width: 44px !important;
  min-height: 44px !important;
}
html body #quickAddNewsModal .quick-news-file-label input[type="file"] {
  /* Focusable with a keyboard as well as tappable through its label. */
  display: block !important;
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap !important;
}
html body #quickAddNewsModal .quick-news-file-label:focus-within {
  outline: 2px solid #8acbda;
  outline-offset: 3px;
}
html body #governorateActivityEditor .activity-editor-box {
  max-height: calc(var(--kff-visible-height) - 32px) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}
html body #kffBottomAdminPanel.kff-tools-sheet-panel {
  max-height: calc(var(--kff-visible-height) - var(--kff-dialog-top-gap)) !important;
  -webkit-overflow-scrolling: touch;
}
html body #previousIncidentsModal .archive-filter-sheet {
  top: var(--kff-visible-top);
  bottom: auto;
  height: var(--kff-visible-height);
  box-sizing: border-box;
}
html body #previousIncidentsModal .archive-filter-panel {
  max-height: min(720px, calc(var(--kff-visible-height) - var(--kff-dialog-top-gap)));
}
html body #homeNewsImageViewer .home-news-image-frame {
  max-height: calc(var(--kff-visible-height) - 110px) !important;
}

@media (max-width: 1024px), (any-pointer: coarse) {
  html body #kffAccessGate .kff-access-input,
  html body #loginModal input,
  html body #homeNewsEditor input,
  html body #homeNewsEditor textarea,
  html body #governorateActivityEditor input,
  html body #governorateActivityEditor textarea,
  html body #governorateActivityEditor select {
    font-size: 16px !important;
  }
  html body #quickAddNewsModal select.quick-news-input {
    -webkit-appearance: menulist !important;
    appearance: auto !important;
  }
}
@media (max-width: 380px) {
  html body #quickAddNewsModal .quick-news-review-row {
    grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr) !important;
  }
  html body #previousIncidentsModal .archive-filter-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}
html.kff-short-viewport body #quickAddNewsModal .quick-news-head {
  padding-top: 10px !important;
  padding-bottom: 8px !important;
}
html.kff-short-viewport body #quickAddNewsModal .quick-news-wizard-progress { margin-top: 8px !important; }
html.kff-short-viewport body #quickAddNewsModal .quick-news-wizard-actions {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}
html.kff-short-viewport body #quickAddNewsModal .quick-news-close-x { top: 8px !important; }
html.kff-short-viewport body #quickAddNewsModal .quick-news-status {
  max-height: 54px;
  overflow-y: auto;
  flex-shrink: 0;
}

/* m11: compact governorate news preview; full metadata stays in the detail view. */
html body #governorateActivityPage .gov-featured-news.gov-featured-compact {
  display: grid !important;
  grid-template-columns: minmax(220px, 34%) minmax(0, 1fr) !important;
  grid-template-areas: "media content" !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: 16px !important;
  border-color: rgba(111,157,189,.28) !important;
  background: #0b2032 !important;
  box-shadow: 0 8px 22px rgba(0,0,0,.12) !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact.no-media {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas: "content" !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-media {
  grid-area: media !important;
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 220px !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-media img,
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-media video {
  object-fit: cover !important;
  object-position: center !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-content {
  grid-area: content !important;
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 16px 18px 10px !important;
  gap: 8px !important;
  justify-content: flex-start !important;
  background: #0b2032 !important;
  overflow: visible !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-topline {
  width: 100% !important;
  margin: 0 !important;
  min-height: 24px !important;
  gap: 8px !important;
  justify-content: space-between !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-sector {
  font-size: 12px !important;
  line-height: 1.5 !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-title {
  font-size: 20px !important;
  line-height: 1.55 !important;
  font-weight: 700 !important;
  margin: 0 !important;
  -webkit-line-clamp: 2 !important;
  overflow-wrap: anywhere !important;
  text-shadow: none !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-meta {
  margin: 0 !important;
  gap: 6px 14px !important;
  max-height: none !important;
  overflow: visible !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  font-weight: 500 !important;
  color: #c4d1dc !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-meta > span {
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  overflow-wrap: anywhere !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-open {
  align-self: flex-end !important;
  width: auto !important;
  min-width: 100px !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-color: rgba(111,157,189,.28) !important;
  background: rgba(111,157,189,.06) !important;
  color: #d8e5ef !important;
}
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-modified-alert,
html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-badge {
  width: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 3px 7px !important;
  font-size: 11px !important;
  line-height: 1.45 !important;
  font-weight: 500 !important;
  border-radius: 7px !important;
  border: 1px solid rgba(205,186,128,.22) !important;
  background: rgba(205,186,128,.09) !important;
  color: #d6c690 !important;
  white-space: nowrap !important;
}
@media (max-width: 700px) {
  html body #governorateActivityPage .gov-featured-news.gov-featured-compact {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "media" "content" !important;
  }
  html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-media {
    height: 160px !important;
  }
  html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-content {
    padding: 12px 14px 10px !important;
    gap: 7px !important;
  }
  html body #governorateActivityPage .gov-featured-news.gov-featured-compact .gov-featured-title {
    font-size: 17px !important;
  }
  html body #governorateActivityPage .gov-featured-news.gov-featured-compact.no-media {
    grid-template-areas: "content" !important;
  }
}
