/* ==========================================================================
   DownPortal — Consolidated Responsive Overrides & Mobile Layout
   ========================================================================== */

/* 1024px: Small Desktop / Tablet Landscape */
@media (max-width: 1024px) {
  .vip-pricing-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 992px: Tablet Portrait / Single Column Breakpoint */
@media (max-width: 992px) {
  .app-layout,
  .app-layout--full {
    grid-template-columns: 1fr;
    width: min(956px, calc(100% - 32px));
    max-width: 956px;
    margin-inline: auto;
  }

  .right-sidebar {
    display: none;
  }
}

/* 860px: Studio & Messaging Layout Adaptations */
@media (max-width: 860px) {
  .settings-studio-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .settings-studio-left {
    align-items: flex-start;
    text-align: left;
    border-bottom: 1.5px solid #e2e8f0;
  }

  .settings-avatar-wrapper {
    align-items: flex-start;
  }

  .pm-container {
    grid-template-columns: 1fr;
    max-height: none;
  }
}

/* 768px: Mobile Viewport Standard */
@media (max-width: 768px) {
  /* Header & Subnav Mobile Adaptation */
  .sa-header__main {
    height: 56px;
    min-height: 56px;
    gap: 8px;
    padding-inline: 12px;
  }

  .sa-mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: #e2e8f0;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
  }

  .sa-brand {
    flex-shrink: 1;
    min-width: 0;
    max-width: min(130px, 32vw);
  }

  .sa-brand img,
  .sa-brand__logo,
  .custom-logo {
    max-height: 32px;
    height: 32px;
    width: auto;
    max-width: 100%;
  }

  .sa-search-wrap {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  .sa-search {
    width: 100%;
    min-width: 0;
  }

  .sa-search__input {
    min-width: 0;
    height: 36px;
    font-size: 12.5px;
    padding-inline: 10px;
  }

  .sa-search__btn {
    height: 36px;
    padding-inline: 8px;
  }

  .sa-header__actions {
    display: none;
  }

  /* Search suggestions: pin to the viewport so they never overflow narrow screens. */
  .sa-search-dropdown {
    position: fixed;
    top: 62px;
    left: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .admin-bar .sa-search-dropdown {
    top: 94px;
  }

  .sa-search-dropdown-list {
    max-height: min(440px, 60vh);
  }

  /* Hover mega panels are desktop-only; touch users browse via the subnav strip and drawer. */
  .sa-megamenu {
    display: none !important;
  }

  .sa-subnav__link {
    padding: 0 10px;
  }

  .sa-search-kbd {
    display: none;
  }

  .sa-subnav {
    display: block;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .sa-subnav::-webkit-scrollbar {
    display: none;
  }

  /* Shell & Layout Constraints */
  .app-layout,
  .app-layout--full {
    grid-template-columns: minmax(0, 1fr);
    width: calc(100% - 32px) !important;
    min-width: 0;
    max-width: calc(100% - 32px) !important;
    column-gap: 0;
    box-sizing: border-box;
  }

  .shell.app-layout,
  .shell.app-layout--full {
    width: calc(100% - 32px) !important;
    max-width: calc(100% - 32px) !important;
  }

  .main-column,
  #post-feed,
  .post-card,
  .post-card__media-wrap {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Post Card Rhythm */
  .post-card {
    padding-block: 28px 32px;
  }

  .post-card__media-wrap {
    margin-block: 14px 18px;
    overflow: hidden;
  }

  .post-card__thumb-img {
    width: 100%;
    max-width: 100%;
  }

  .post-card__header {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .post-card__title-link {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .post-card__footer {
    flex-wrap: wrap;
    gap: 12px;
  }

  /* DDL Download Box */
  .ddl-download-box {
    width: 100%;
    margin-block: 12px 20px;
    padding: 12px 10px 10px;
  }

  .ddl-download-header {
    align-items: flex-start;
  }

  .ddl-row {
    align-items: flex-start;
    padding-block: 10px;
  }

  .ddl-row-info {
    flex-wrap: wrap;
    width: 100%;
  }

  .ddl-file-name {
    flex: 1 1 160px;
    min-width: 0;
  }

  .ddl-row-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Single Post Specs Table */
  .specs-key {
    width: 34%;
  }

  .specs-val {
    overflow-wrap: anywhere;
  }

  /* Related Releases & Comments */
  .related-releases-section {
    margin-top: 22px;
    padding-top: 16px;
  }

  .related-releases-grid {
    grid-template-columns: 1fr;
  }

  .comment-form-grid {
    grid-template-columns: 1fr;
  }

  /* Domain List Rows */
  .vip-pricing-grid,
  .fav-card-item,
  .req-row-item {
    grid-template-columns: 1fr;
  }

  .fav-card-item {
    gap: 12px;
  }

  .fav-thumb-link {
    width: 100%;
    height: 140px;
  }

  .fav-thumb {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  .fav-actions-col {
    justify-content: flex-end;
  }

  .req-row-item {
    gap: 8px;
  }

  .pm-sidebar {
    max-height: 180px;
  }
}

/* 640px: Form Grids & Uploader Columns */
@media (max-width: 640px) {
  .form-grid-2,
  .uploader-grid-2col {
    grid-template-columns: 1fr;
  }
}

/* 540px: Key-Value Field Rows */
@media (max-width: 540px) {
  .uploader-spec-row,
  .uploader-mirror-row {
    grid-template-columns: 1fr 34px;
  }

  .uploader-spec-row .uploader-spec-key,
  .uploader-mirror-row .uploader-mirror-host {
    grid-column: 1 / -1;
  }

  .comment-header-row {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .comment-time {
    white-space: normal;
    text-align: left;
    margin-left: 0;
  }
}

/* 480px: Small Mobile Handsets */
@media (max-width: 480px) {
  .sa-brand {
    max-width: min(96px, 26vw);
  }

  .sa-header__main {
    gap: 6px;
  }

  .sa-search__input {
    padding-inline: 10px;
    font-size: 12px;
  }

  .sa-back-to-top {
    right: 14px;
    bottom: 14px;
    width: 40px;
    height: 40px;
  }
}

/* 360px: Very Small Handsets */
@media (max-width: 360px) {
  .sa-header__main {
    gap: 4px;
    padding-inline: 8px;
  }

  .sa-mobile-menu-btn {
    width: 32px;
    height: 32px;
  }

  .sa-brand {
    max-width: min(80px, 24vw);
  }

  .sa-brand img,
  .sa-brand__logo,
  .custom-logo {
    max-height: 26px;
    height: 26px;
  }

  .sa-search__input {
    font-size: 11px;
    padding-inline: 8px;
  }

  .sa-search-dropdown {
    left: 8px;
    right: 8px;
  }
}
