/* ==========================================================================
   iLoveHer.Life • RESPONSIVE REFLOW, TOUCH ERGONOMICS & OVERFLOW DEFENSE CSS
   "Her Safety Is The Standard"
   ========================================================================== */

/* Universal Word Break Integrity & Overflow Defense */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, p, span, a, label, strong, em, button {
  overflow-wrap: break-word;
  word-break: normal;
}

/* Base Touch Interaction Feel */
button, a, input, select, textarea, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:active, .btn:active, .dim-pill:active, .scale-btn:active, .card:active {
  transform: scale(0.985);
  transition: transform 0.08s ease;
}

/* ==========================================================================
   MOBILE & TABLET VIEWPORTS (< 920px)
   ========================================================================== */
@media (max-width: 919px) {
  body {
    /* Dynamic clearance for fixed bottom navigation + safe area home indicator */
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 20px);
  }

  .app-header {
    height: var(--header-height-mobile);
    padding-top: var(--safe-area-top);
  }

  .main-nav {
    display: none !important;
  }

  .bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    padding: 0 0.5rem var(--safe-area-bottom);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--color-border-subtle);
    box-shadow: 0 -4px 24px rgba(74, 18, 38, 0.08);
    align-items: center;
    justify-content: space-around;
  }

  .bottom-nav__item {
    flex: 1;
    min-height: 48px;
    min-width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 2px;
    position: relative;
    cursor: pointer;
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
  }

  #floating-reset-btn {
    bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 12px) !important;
    right: 14px !important;
  }

  /* Profile Pages Reflow */
  .profile-hero {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    padding: 1rem 0 !important;
  }

  .profile-sidebar {
    order: 2;
  }
}

/* ==========================================================================
   MOBILE SMALL VIEWPORTS (< 640px) - iPhone SE, Standard iPhones, Galaxy, Pixel
   ========================================================================== */
@media (max-width: 639px) {
  /* Fluid Scalable Typography */
  h1 { font-size: clamp(1.6rem, 5.5vw, 2rem); line-height: 1.25; }
  h2 { font-size: clamp(1.3rem, 4.5vw, 1.6rem); line-height: 1.3; }
  h3 { font-size: clamp(1.1rem, 3.8vw, 1.3rem); line-height: 1.35; }
  h4 { font-size: clamp(0.95rem, 3.2vw, 1.1rem); line-height: 1.4; }

  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* iOS Auto-Zoom Prevention: Inputs must be >= 16px */
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="number"],
  input[type="tel"],
  input[type="password"],
  select,
  textarea,
  .form-input,
  .search-input-field,
  .filter-select-input {
    font-size: 16px !important;
    min-height: 44px;
    border-radius: var(--radius-sm);
  }

  /* Button Touch Scaling */
  .btn {
    min-height: 44px;
    padding: 0.65rem 1.15rem;
    font-size: 0.9rem;
  }

  .btn-sm {
    min-height: 38px;
    padding: 0.45rem 0.85rem;
    font-size: 0.825rem;
  }

  .btn-lg {
    width: 100%;
    min-height: 48px;
    padding: 0.85rem 1.25rem;
    font-size: 0.975rem;
  }

  /* Search & Filter Toolbar Reflow */
  .search-console-card {
    padding: 1rem;
    margin-bottom: 1.25rem;
  }

  .search-input-container {
    flex-direction: column;
    gap: 0.65rem;
  }

  .search-input-container > * {
    width: 100%;
    min-width: 100% !important;
  }

  #topic-combobox-btn {
    min-height: 44px;
    padding: 0.65rem 1rem;
    width: 100%;
    justify-content: space-between;
  }

  /* Dimension Navigation Strip Horizontal Scroll */
  .dim-pills-wrap {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    gap: 0.45rem;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    scroll-padding-left: 1rem;
    scroll-snap-type: x mandatory;
  }

  .dim-pills-wrap::-webkit-scrollbar {
    display: none;
  }

  .dim-pill {
    flex-shrink: 0;
    scroll-snap-align: start;
    font-size: 0.8rem;
    padding: 0.4rem 0.85rem;
    min-height: 38px;
  }

  /* SafeCare and Safety Subnav Horizontal Strips */
  .safety-subnav-pills, .safecare-tabs-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: 0;
  }

  .safety-subnav-pills::-webkit-scrollbar, .safecare-tabs-nav::-webkit-scrollbar {
    display: none;
  }

  .safety-subnav-pill, .safecare-tab-btn {
    flex-shrink: 0;
    min-height: 40px;
    font-size: 0.825rem;
    padding: 0.45rem 0.95rem;
  }

  /* Metric / Signal Strip */
  .signal-strip {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
    margin: 0.75rem 0;
  }

  .signal-metric__val {
    font-size: 1.25rem;
  }

  /* Dimension Cards Grid */
  .dimension-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
    margin: 1.25rem 0;
  }

  .dimension-card {
    min-height: 200px;
    padding: 1.35rem;
  }

  /* Universal Nominee / Directory Card Media */
  .card-media {
    height: 180px;
  }

  /* 6-Point Standards Scale Grid on Mobile */
  .standards-scale {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.45rem;
  }

  .scale-btn {
    min-height: 64px;
    padding: 0.5rem 0.25rem;
  }

  .scale-btn__icon {
    font-size: 1.15rem;
  }

  .scale-btn__label {
    font-size: 0.72rem;
  }

  .scale-btn__sub {
    font-size: 0.6rem;
  }

  /* Modals as Responsive Bottom Sheets on Mobile */
  dialog.modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 94dvh !important;
    margin-bottom: 0 !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    box-shadow: 0 -8px 32px rgba(35, 25, 30, 0.25);
  }

  .modal-header {
    padding: 1rem 1.25rem;
  }

  .modal-body {
    padding: 1.25rem;
    max-height: calc(94dvh - 130px) !important;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 0.85rem 1.25rem;
    flex-direction: column-reverse;
    gap: 0.6rem;
  }

  .modal-footer > * {
    width: 100%;
    justify-content: center;
  }

  /* Ballot Decision Cards on Mobile */
  .ballot-decision-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem;
  }

  .ballot-decision-card {
    padding: 1.15rem 1rem !important;
  }

  /* Touch Hit Area Helper for Close Buttons */
  #close-review-modal,
  #close-scan-modal,
  #close-circle-modal,
  #close-topics-modal,
  #close-claim-modal,
  #close-incident-modal {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #floating-reset-btn button {
    font-size: 0.75rem;
    padding: 0.45rem 0.85rem;
    min-height: 38px;
  }

  .footer-doctrine {
    padding: 1.5rem 1rem;
    margin-bottom: 1.5rem;
  }

  .footer-doctrine h3 {
    font-size: 1.15rem;
  }

  .footer-doctrine p {
    font-size: 0.78rem;
  }
}

/* ==========================================================================
   TABLET VIEWPORTS (640px - 1023px)
   ========================================================================== */
@media (min-width: 640px) and (max-width: 1023px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .dimension-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .standards-scale {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ==========================================================================
   DESKTOP VIEWPORTS (>= 1024px)
   ========================================================================== */
@media (min-width: 1024px) {
  .dimension-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================================================
   ACCESSIBILITY & PREFERS-REDUCED-MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
