/* ============================================================
   HOAproxy — Shared Mobile Optimizations
   Link this AFTER inline <style> blocks so it can override.
   ============================================================ */

/* --- Required field indicator --- */
label.req::after {
  content: " *";
  color: #b62525;
  font-weight: 700;
}

/* --- Prevent iOS zoom on input focus (requires >=16px font) --- */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* --- Touch-friendly tap targets (44px minimum per Apple HIG) --- */
@media screen and (max-width: 768px) {
  .btn, button, [type="button"], [type="submit"] {
    min-height: 44px;
    padding: 12px 16px;
  }

  .btn.sm {
    min-height: 40px;
    padding: 10px 14px;
  }

  .btn.danger {
    min-height: 40px;
    padding: 10px 14px;
  }

  input, select, textarea {
    min-height: 44px;
    padding: 12px;
  }

  /* Larger checkboxes for touch */
  input[type="checkbox"],
  input[type="radio"] {
    min-height: auto;
    width: 20px;
    height: 20px;
    padding: 0;
  }

  /* Touch feedback */
  .btn:active, button:active {
    opacity: 0.85;
    transform: scale(0.98);
  }
}

/* --- Hamburger Navigation --- */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  min-height: auto;
  line-height: 1;
}

.nav-hamburger span {
  display: block;
  width: 24px;
  height: 3px;
  background: var(--ink, #12233a);
  border-radius: 2px;
  margin: 4px 0;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-hamburger.open span:nth-child(1) {
  transform: rotate(45deg) translate(4px, 5px);
}
.nav-hamburger.open span:nth-child(2) {
  opacity: 0;
}
.nav-hamburger.open span:nth-child(3) {
  transform: rotate(-45deg) translate(4px, -5px);
}

@media screen and (max-width: 600px) {
  .nav-hamburger {
    display: block;
  }

  /* Hide nav links by default on mobile; show when .nav-open */
  .nav {
    display: none !important;
    flex-direction: column;
    width: 100%;
    gap: 6px;
    margin-top: 10px;
  }

  .nav.nav-open {
    display: flex !important;
  }

  .nav .btn, .nav a {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .nav a.btn.active, .nav a.active {
    background: var(--accent, #1662f3);
    color: #fff;
  }

  /* Top row: let it wrap so hamburger + brand fit, nav drops below */
  .top-row {
    flex-wrap: wrap;
  }

  /* actions group (about page, index page) */
  .actions {
    display: none !important;
    flex-direction: column;
    width: 100%;
    gap: 6px;
    margin-top: 10px;
  }

  .actions.nav-open {
    display: flex !important;
  }

  .actions .btn, .actions a {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

/* --- General mobile spacing --- */
@media screen and (max-width: 600px) {
  .shell {
    margin-top: 16px !important;
    margin-bottom: 32px !important;
  }

  .hero {
    padding: 16px !important;
    border-radius: 16px !important;
  }

  .card {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  h1, .hero-title {
    font-size: 1.5rem !important;
    line-height: 1.15 !important;
  }

  h2 {
    font-size: 1.05rem !important;
  }

  /* Reduce excessive padding on body-level elements */
  .card > h2:first-child,
  .card > h3:first-child {
    margin-top: 0;
  }
}

/* --- Two-column grids → single column on mobile --- */
@media screen and (max-width: 768px) {
  .grid,
  .guide-grid,
  .page-grid,
  .detail-grid,
  .result-grid,
  .hero-grid,
  .intent-grid {
    grid-template-columns: 1fr !important;
  }

  /* Sticky sidebar → static on mobile */
  .side-card {
    position: static !important;
  }
}

/* --- Tables: horizontal scroll wrapper on mobile --- */
@media screen and (max-width: 600px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  th, td {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
}

/* --- Maps: responsive heights --- */
@media screen and (max-width: 600px) {
  #map {
    height: min(50vh, 300px) !important;
  }

  #np-map {
    height: 220px !important;
  }

  #proposal-map {
    height: min(50vh, 320px) !important;
  }
}

/* --- Leaflet map controls: ensure not cut off --- */
@media screen and (max-width: 600px) {
  .leaflet-control-zoom {
    margin-top: 8px !important;
    margin-left: 8px !important;
  }
}

/* --- Form layouts on mobile --- */
@media screen and (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .claim-row {
    flex-direction: column;
  }

  .claim-row select,
  .claim-row input {
    min-width: 0 !important;
    width: 100%;
  }

  .search-row {
    grid-template-columns: 1fr !important;
  }

  .query-row {
    grid-template-columns: 1fr !important;
  }

  .lookup-row {
    flex-direction: column;
  }

  .lookup-row select {
    width: 100%;
    min-width: 0 !important;
  }

  .mode-toggle {
    flex-wrap: wrap;
  }

  .mode-toggle button {
    flex: 1;
    min-width: 0;
  }

  /* Row layouts → stack */
  .row {
    flex-direction: column;
  }

  /* Stat boxes */
  .stat-row {
    flex-direction: column;
  }

  .stat {
    min-width: 0 !important;
  }

  /* Banner layout */
  .banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .banner-actions {
    margin-left: 0;
    width: 100%;
  }

  /* Input row in verify-proxy */
  .input-row {
    flex-direction: column;
  }

  .input-row input,
  .input-row button {
    width: 100%;
  }

  /* Magic number box */
  .magic-number {
    font-size: 2.4rem !important;
  }

  .magic-stats {
    gap: 12px !important;
  }
}

/* --- Proxy sign page specifics --- */
@media screen and (max-width: 768px) {
  .doc-mount {
    min-height: 400px !important;
  }

  .doc-shell {
    padding: 8px !important;
  }

  .stepper {
    gap: 6px;
  }

  .step {
    font-size: 0.76rem;
    padding: 6px 10px;
  }

  .meta-strip {
    gap: 6px;
  }

  .meta-pill {
    font-size: 0.82rem;
    padding: 6px 10px;
  }
}

/* --- Terms & Privacy nav bar on mobile --- */
@media screen and (max-width: 600px) {
  nav {
    padding: 12px 16px !important;
    gap: 8px !important;
    flex-wrap: wrap;
  }

  nav .brand {
    font-size: 1.2rem;
  }

  nav .nav-link {
    font-size: 0.82rem;
  }
}

/* --- Verify email: centered card on mobile --- */
@media screen and (max-width: 600px) {
  body {
    padding: 16px;
  }
}

/* --- List overflow: ensure horizontal content doesn't break layout --- */
@media screen and (max-width: 600px) {
  .list {
    max-height: none !important;
  }

  .docs {
    max-height: none !important;
  }

  /* Long text should break */
  .doc-link,
  .hoa-name-link,
  .meta,
  .hash-block {
    word-break: break-word;
  }
}

/* --- Tab bar on mobile --- */
@media screen and (max-width: 600px) {
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 7px 14px;
  }
}

/* --- Proxy card actions: stack on mobile --- */
@media screen and (max-width: 600px) {
  .proxy-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Homepage: hide starter cards when search results are active --- */
@media screen and (max-width: 768px) {
  .starter-grid.mobile-hidden {
    display: none;
  }
}
