/* Breakpoints layered on the mobile-first base. Loaded last so these win. */

/* Hard guard: nothing may force the document wider than the viewport. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Small phones: let the spotlight stack so the countdown isn't squeezed. */
@media (max-width: 520px) {
  .spotlight-main {
    flex-direction: column;
  }

  .countdown-ring {
    width: 100%;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions > .btn {
    flex: 1 1 auto;
  }

  /* Keep the search prominent; filters drop to two readable columns. */
  .field-search {
    flex: 1 1 100%;
  }

  .field {
    flex: 1 1 calc(50% - 12px);
    min-width: 0;
  }

  .active-filters-clear {
    margin-left: 0;
  }

  /* Hero stays comfortable: reduce panel padding, keep tap targets. */
  .hero {
    padding: 18px;
  }

  .footer-links {
    gap: 6px 10px;
  }
}

/* Very small phones (≤360): overview tiles still read as two clean columns. */
@media (max-width: 380px) {
  .overview-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

/* The floating status toast spans the width on a phone, where a 420px card
   pinned to one corner would crowd the content it sits over. */
@media (max-width: 600px) {
  .status {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }
}

/* Modal/drawer become full-height sheets on small screens (internal scroll). */
@media (max-width: 600px) {
  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }

  /* The width modifiers on the utility dialogs must not survive here, or a
     legend would sit as a narrow column inside a full-height sheet. */
  .modal-panel,
  .modal-panel.is-narrow,
  .modal-panel.is-medium {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .drawer-panel {
    width: 100vw;
    border-radius: 0;
  }

  /* Keep the More menu inside the viewport on narrow screens. */
  .more-menu-list {
    left: auto;
    right: 0;
    max-width: calc(100vw - 24px);
  }
}

/* Tablet+: two cards per row; overview tiles flow into a balanced grid. */
@media (min-width: 640px) {
  .launch-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-tiles {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .insights-chips {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

/* Comfortable desktop: aim for a balanced four-per-row overview (4 × 2). */
@media (min-width: 900px) {
  .overview-tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Normal desktop: hero side-by-side, sticky schedule toolbar. */
@media (min-width: 860px) {
  .hero {
    grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.9fr);
  }

  .toolbar {
    position: sticky;
    top: 12px;
    z-index: 20;
  }
}

/* Wide desktop: three cards per row. */
@media (min-width: 1180px) {
  .launch-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Footer: stacked on mobile, side-by-side on desktop; links always wrap. */
.footer {
  flex-direction: column;
}

.footer-links {
  flex-wrap: wrap;
}

@media (min-width: 720px) {
  .footer {
    flex-direction: row;
    align-items: flex-end;
  }
}
