/* Harthwyn 26.01.280 — final responsive authority for managed front-facing pages.
   Owns Events/Save the Date, Messages, and managed page form containment after the 2027 card system. */

body.harthwyn-managed-page,
body.harthwyn-managed-page * {
  box-sizing: border-box;
}

html:has(body.harthwyn-managed-page),
body.harthwyn-managed-page {
  max-width: 100%;
  overflow-x: clip;
}

body.harthwyn-managed-page :where(
  .harthwyn-page-shell,
  .harthwyn-managed-page,
  .harthwyn-managed-page__content,
  .harthwyn-content-system-shell,
  .harthwyn-messages-center,
  .harthwyn-events-hub,
  .harthwyn-events-layout,
  .harthwyn-events-calendar-panel,
  .harthwyn-message-thread-list,
  .harthwyn-message-thread-view,
  .harthwyn-message-compose-card,
  .harthwyn-message-composer,
  .harthwyn-event-card,
  .harthwyn-event-editor-layout,
  .harthwyn-event-form,
  .harthwyn-event-form-panel
) {
  min-width: 0 !important;
  max-width: 100% !important;
}

body.harthwyn-managed-page :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  width: 100%;
  max-width: 100%;
}

body.harthwyn-managed-page :where(img, video, iframe, canvas, svg) {
  max-width: 100%;
  height: auto;
}

/* Events / Save the Date: card-first responsive behavior with no forced mobile horizontal page overflow. */
body.harthwyn-managed-page-key-family_events .harthwyn-events-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: clamp(16px, 2.4vw, 28px) !important;
}

@media (min-width: 1040px) {
  body.harthwyn-managed-page-key-family_events .harthwyn-events-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, .72fr) !important;
  }
}

body.harthwyn-managed-page-key-family_events .harthwyn-calendar-scroll,
body.harthwyn-managed-page-key-family_events .harthwyn-events-calendar-panel {
  max-width: 100% !important;
  overflow-x: clip !important;
}

body.harthwyn-managed-page-key-family_events .harthwyn-calendar-grid {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  gap: clamp(4px, .9vw, 9px) !important;
}

body.harthwyn-managed-page-key-family_events .harthwyn-calendar-cell {
  min-width: 0 !important;
  overflow: hidden !important;
}

body.harthwyn-managed-page-key-family_events .harthwyn-calendar-event-chip,
body.harthwyn-managed-page-key-family_events .harthwyn-calendar-holiday-list li,
body.harthwyn-managed-page-key-family_events .harthwyn-calendar-cell-top {
  min-width: 0 !important;
}

body.harthwyn-managed-page-key-family_events .harthwyn-events-sidebar,
body.harthwyn-managed-page-key-family_events .harthwyn-events-agenda__grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: clamp(12px, 2vw, 18px) !important;
}

@media (max-width: 767px) {
  body.harthwyn-managed-page-key-family_events .harthwyn-events-sidebar {
    order: -1 !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-events-command-center,
  body.harthwyn-managed-page-key-family_events .harthwyn-events-calendar-header,
  body.harthwyn-managed-page-key-family_events .harthwyn-events-agenda__header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-events-command-center__actions,
  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-nav-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-events-command-center__actions .harthwyn-button,
  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-nav-button {
    width: 100% !important;
    min-width: 0 !important;
    padding-inline: 8px !important;
    white-space: normal !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-day-name {
    font-size: clamp(.58rem, 2.6vw, .72rem) !important;
    letter-spacing: .02em !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-cell {
    min-height: clamp(58px, 17vw, 92px) !important;
    border-radius: 12px !important;
    padding: 6px !important;
    gap: 4px !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-date {
    font-size: clamp(.78rem, 3.4vw, .95rem) !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-badge {
    min-width: 18px !important;
    min-height: 18px !important;
    font-size: .66rem !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-event-chip {
    padding: 0 !important;
    width: 9px !important;
    height: 9px !important;
    border-radius: 999px !important;
    overflow: hidden !important;
    color: transparent !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-event-dot {
    width: 9px !important;
    height: 9px !important;
  }

  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-event-text,
  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-holiday-list,
  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-day-action--create {
    display: none !important;
  }
}

@media (max-width: 430px) {
  body.harthwyn-managed-page-key-family_events .harthwyn-events-command-center__actions,
  body.harthwyn-managed-page-key-family_events .harthwyn-calendar-nav-actions {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Events composer: one modal/sheet contract. */
.harthwyn-event-composer-drawer[role="dialog"] {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 760px) !important;
  overflow: hidden !important;
  z-index: 1000000 !important;
  isolation: isolate !important;
}

.harthwyn-event-composer-drawer[hidden] {
  display: none !important;
}

.harthwyn-event-composer-backdrop {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0 !important;
}

.harthwyn-event-composer-sheet {
  position: relative !important;
  grid-column: 2 !important;
  justify-self: end !important;
  align-self: center !important;
  width: min(760px, calc(100vw - 32px)) !important;
  max-width: 760px !important;
  height: min(900px, calc(100dvh - 32px)) !important;
  max-height: calc(100dvh - 32px) !important;
  margin: 16px !important;
  border-radius: 24px !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  z-index: 1 !important;
}

.admin-bar .harthwyn-event-composer-drawer[role="dialog"] {
  top: var(--wp-admin--admin-bar--height, 32px) !important;
  height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px)) !important;
}

.admin-bar .harthwyn-event-composer-sheet {
  height: min(900px, calc(100dvh - var(--wp-admin--admin-bar--height, 32px) - 32px)) !important;
  max-height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px) - 32px) !important;
}

.harthwyn-event-composer-topbar {
  position: relative !important;
  top: auto !important;
  z-index: 6 !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: start !important;
  gap: 12px !important;
}

.harthwyn-event-composer-topbar > div {
  min-width: 0 !important;
}

.harthwyn-event-composer-close {
  position: relative !important;
  inset: auto !important;
  display: inline-grid !important;
  place-items: center !important;
  width: 46px !important;
  min-width: 46px !important;
  height: 46px !important;
  min-height: 46px !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
  overflow: visible !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.harthwyn-event-composer-body {
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}

.harthwyn-event-save-actions,
.harthwyn-event-editor-embedded .harthwyn-sticky-actions {
  position: sticky !important;
  bottom: 0 !important;
  z-index: 7 !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 12px !important;
  background: rgba(255,255,255,.98) !important;
  border-top: 1px solid var(--hw-color-border, rgba(0,0,0,.12)) !important;
}

@media (max-width: 1024px) {
  .harthwyn-event-composer-drawer[role="dialog"] {
    grid-template-columns: minmax(0, 1fr) !important;
    place-items: center !important;
  }

  .harthwyn-event-composer-sheet {
    grid-column: 1 !important;
    justify-self: center !important;
  }
}

@media (max-width: 600px) {
  .harthwyn-event-composer-sheet {
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    align-self: stretch !important;
  }

  .admin-bar .harthwyn-event-composer-sheet {
    height: calc(100dvh - 46px) !important;
    max-height: calc(100dvh - 46px) !important;
  }

  .harthwyn-event-composer-topbar {
    padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)) !important;
  }

  .harthwyn-event-composer-body {
    padding: 16px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)) !important;
  }

  .harthwyn-event-save-actions,
  .harthwyn-event-editor-embedded .harthwyn-sticky-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    margin-inline: calc(-1 * max(12px, env(safe-area-inset-left))) calc(-1 * max(12px, env(safe-area-inset-right))) !important;
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)) !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
  }

  .harthwyn-event-save-actions > .harthwyn-button,
  .harthwyn-event-editor-embedded .harthwyn-sticky-actions > .harthwyn-button {
    width: 100% !important;
    min-width: 0 !important;
  }
}

@media (max-width: 380px) {
  .harthwyn-event-save-actions,
  .harthwyn-event-editor-embedded .harthwyn-sticky-actions {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Messages: one responsive split-pane contract. */
body.harthwyn-managed-page-key-family_messages .harthwyn-messages-center {
  width: min(1180px, calc(100vw - clamp(20px, 5vw, 64px))) !important;
  margin-inline: auto !important;
  overflow: visible !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-messages-layout {
  display: grid !important;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) !important;
  gap: clamp(14px, 2vw, 22px) !important;
  min-height: 0 !important;
  overflow: visible !important;
  border-radius: clamp(18px, 2vw, 26px) !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-list {
  position: sticky !important;
  top: 16px !important;
  align-self: start !important;
  min-width: 0 !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-view,
body.harthwyn-managed-page-key-family_messages .harthwyn-message-conversation,
body.harthwyn-managed-page-key-family_messages .harthwyn-message-compose-card {
  min-width: 0 !important;
  max-width: 100% !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-link__top,
body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-header,
body.harthwyn-managed-page-key-family_messages .harthwyn-message-compose-header,
body.harthwyn-managed-page-key-family_messages .harthwyn-message-media-tray-260199__heading {
  min-width: 0 !important;
  flex-wrap: wrap !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-toolbar-260199 {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  overflow: visible !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-toolbar-260199__group {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  min-width: 0 !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-toolbar-260199 button {
  min-width: 44px !important;
  min-height: 44px !important;
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-rich-editor-260199,
body.harthwyn-managed-page-key-family_messages .harthwyn-message-writing-surface-260161 {
  width: 100% !important;
  min-width: 0 !important;
  overflow-wrap: anywhere !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-media-actions-260202 {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 12px !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-media-action-260202 {
  min-width: 0 !important;
  width: 100% !important;
  white-space: nowrap !important;
}

body.harthwyn-managed-page-key-family_messages .harthwyn-message-media-action-260202 span {
  display: inline !important;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
}

@media (max-width: 980px) {
  body.harthwyn-managed-page-key-family_messages .harthwyn-messages-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-list {
    position: relative !important;
    top: auto !important;
  }

  body.harthwyn-managed-page-key-family_messages .harthwyn-message-media-actions-260202 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 560px) {
  body.harthwyn-managed-page-key-family_messages .harthwyn-messages-center {
    width: min(100%, calc(100vw - 20px)) !important;
  }

  body.harthwyn-managed-page-key-family_messages .harthwyn-messages-hero,
  body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-list__header,
  body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-header,
  body.harthwyn-managed-page-key-family_messages .harthwyn-message-compose-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  body.harthwyn-managed-page-key-family_messages .harthwyn-message-command-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.harthwyn-managed-page-key-family_messages .harthwyn-message-media-actions-260202 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.harthwyn-managed-page-key-family_messages .harthwyn-message-compose-card,
  body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-list,
  body.harthwyn-managed-page-key-family_messages .harthwyn-message-thread-view {
    padding: clamp(14px, 4vw, 18px) !important;
  }
}
