/* =============================================================
   Zenex Verified — site-wide mobile responsive
   Breakpoints: 1024px (tablet), 720px (mobile), 480px (small phone)
   ============================================================= */

/* Prevent horizontal scroll */
html {
  overflow-x: clip;
}

/* Primary forms & hero search must stay visible (scroll-reveal is decorative only) */
#main-content .form-card,
#main-content .property-detail-grid > aside,
.hero-spotlight,
.hero-search-form,
[data-hero-search] {
  opacity: 1;
  transform: none;
}

body.nav-open {
  overflow: hidden;
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* Scrollable data tables */
.admin-main table,
.vdoc-table-wrap,
.table-scroll {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* —— Tablet (≤1024px) —— */
@media (max-width: 1024px) {
  .marketplace-split {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .marketplace-split[data-view="split"] .marketplace-list {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .marketplace-list-scroll {
    max-height: min(52vh, 520px);
  }

  .marketplace-map-panel {
    position: relative;
    top: auto;
    height: min(52vh, 480px);
    min-height: 300px;
  }

  .marketplace-map {
    min-height: 300px;
  }

  .map-mall-grid {
    grid-template-columns: 1fr;
  }

  .map-mall-map {
    min-height: 320px;
  }

  .portals-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .portals-tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .appearance-page-hero-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar-inner {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .admin-main {
    padding: 1.5rem 1.25rem 3rem;
  }

  .admin-card {
    padding: 1.35rem;
  }

  .portal-shell {
    padding-top: 0;
  }
}

/* —— Mobile (≤720px) —— */
@media (max-width: 720px) {
  /* Forms */
  .form-grid .row-2,
  .row-2 {
    grid-template-columns: 1fr !important;
  }

  .form-field input,
  .form-field select,
  .form-field textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Page heroes (breadcrumb pages) */
  .page-hero {
    padding: clamp(4.25rem, 11vw, 5.5rem) 0 clamp(2rem, 5vw, 2.75rem);
  }

  .page-hero--compact {
    padding-bottom: clamp(1.75rem, 4vw, 2.5rem);
  }

  .page-hero h1 {
    max-width: none;
    font-size: clamp(1.45rem, 5.5vw, 1.85rem);
  }

  .page-hero p {
    font-size: 0.95rem;
    max-width: none;
  }

  .page-hero-main {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .page-hero-actions {
    width: 100%;
  }

  .page-hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .page-hero-crumb ol {
    font-size: 0.72rem;
  }

  /* Property detail */
  .property-hero {
    grid-template-columns: 1fr;
  }

  .property-hero img {
    max-height: 280px;
    object-fit: cover;
  }

  .property-summary {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  /* Property detail: sidebar first; form-first pages override below */
  .property-detail-grid:not(.verify-document-grid):not(.contact-page-grid) aside {
    order: -1;
  }

  .property-detail-grid > * {
    min-width: 0;
    max-width: 100%;
  }

  .form-card {
    padding: clamp(1.25rem, 4vw, 1.75rem);
    box-sizing: border-box;
    overflow-wrap: anywhere;
  }

  .verify-document-section {
    padding-bottom: 1rem;
  }

  .page-verify-document main,
  .page-contact main {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }

  /* Marketplace toolbar */
  .marketplace-toolbar {
    padding: 1rem 0;
  }

  .marketplace-toolbar .hero-search-form {
    margin-top: 1rem;
  }

  .marketplace-toolbar-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.65rem;
  }

  .view-toggle {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .view-toggle button {
    padding: 0.55rem 0.35rem;
    font-size: 0.78rem;
  }

  .sort-form,
  .sort-form select {
    width: 100%;
  }

  .listing-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .listing-row-media {
    aspect-ratio: 16 / 10;
    max-height: 220px;
  }

  .listing-row-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .listing-row-price {
    white-space: normal;
  }

  .listing-row-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .listing-row-actions .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  .marketplace-list-scroll {
    max-height: none;
  }

  .marketplace-map-panel {
    height: min(45vh, 400px);
  }

  /* Home — browse rail & budget */
  .browse-rail-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .browse-tile {
    flex: 0 0 min(72vw, 260px);
    flex-shrink: 0;
  }

  .price-chip-row {
    padding-left: 0;
    padding-right: 0;
  }

  /* FAQ */
  .faq-page-nav {
    position: static;
    flex-direction: column;
    align-items: stretch;
    background: transparent;
    padding: 0 0 1rem;
  }

  .faq-page-nav-link {
    width: 100%;
    justify-content: flex-start;
  }

  /* Portals showcase */
  .portal-panel {
    padding: 1.25rem;
  }

  /* Developer cards */
  .developer-card {
    flex-direction: column;
    text-align: center;
  }

  .developer-avatar {
    margin: 0 auto;
  }

  /* Portal workspace */
  .portal-list-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .portal-list-item img {
    width: 100%;
    height: auto;
    max-height: 160px;
  }

  .portal-chat-form {
    flex-direction: column;
  }

  .portal-chat-form .btn {
    width: 100%;
  }

  /* Admin — horizontal scroll nav */
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .admin-sidebar-title,
  .admin-sidebar-footer {
    display: none;
  }

  .admin-sidebar a {
    flex: 0 0 auto;
    white-space: nowrap;
    margin-bottom: 0;
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
  }

  .admin-topbar-user {
    display: none;
  }

  .admin-topbar-logo {
    max-height: 32px;
  }

  /* Verify document */
  .verify-doc-slots {
    padding: 1rem 0;
  }

  .verify-doc-pay__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .verify-doc-cta-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .verify-doc-cta-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Assistant — avoid covering full screen */
  .zenex-assistant-panel {
    width: min(400px, calc(100vw - 1.5rem));
    max-width: none;
    right: 0;
    left: auto;
    bottom: calc(100% + 0.75rem);
    max-height: min(70vh, 520px);
  }

  /* CTA panels */
  .cta-panel {
    margin-left: auto;
    margin-right: auto;
  }

  .cta-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.75rem;
  }

  .cta-content h2,
  .cta-content p {
    margin-left: auto;
    margin-right: auto;
  }

  .cta-content h2 { max-width: none; }

  .cta-content p { max-width: 38ch; }

  .cta-actions {
    justify-content: center;
    width: 100%;
    max-width: 360px;
    flex-direction: column;
  }

  .cta-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Buttons in card footers */
  .property-card-actions {
    flex-direction: column;
  }

  .property-card-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Unit ID section */
  .unit-id-hero {
    grid-template-columns: 1fr;
  }

  .flow-step {
    min-width: 0;
  }
}

/* —— Small phones (≤480px) —— */
@media (max-width: 480px) {
  .container {
    width: calc(100% - 1.25rem);
  }

  .hero-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero-tab {
    font-size: clamp(0.68rem, 2.5vw, 0.8rem);
    padding: 0.5rem 0.25rem;
  }

  .property-summary {
    grid-template-columns: 1fr;
  }

  .stats-grid > div {
    text-align: left;
  }

  .proof-compliance-item {
    grid-template-columns: 48px 1fr;
    gap: 0.65rem;
  }

  .milestone-track {
    grid-template-columns: 1fr;
  }

  .admin-card {
    padding: 1rem;
  }

  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .about-founder-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .about-founder-portrait {
    max-width: 420px;
    margin-inline: auto;
  }

  .about-founder-story h2 {
    max-width: none;
  }

  .about-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.75rem 1.25rem;
  }

  .about-mission-grid {
    grid-template-columns: 1fr;
  }

  .about-values-grid,
  .about-audience-grid {
    grid-template-columns: 1fr;
  }

  .about-cta-inner {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .about-cta-actions {
    width: 100%;
    flex-direction: column;
  }

  .about-cta-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .about-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
  .site-footer {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  .zenex-assistant {
    bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}
