/**
 * Frisby Mobile Responsive Overrides
 * Fixes layout issues on tool pages at small viewports.
 * Include after frisby-components.css and frisby-nav.css.
 */

/* ─── Global Mobile Fixes ───────────────────────────────────────── */
@media (max-width: 768px) {
  /* Prevent horizontal overflow */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  /* Make all textareas full-width and taller on mobile */
  textarea {
    width: 100% !important;
    min-height: 150px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Form inputs — prevent zoom */
  input, select, textarea {
    font-size: 16px;
  }

  /* Stack flex containers vertically */
  .frisby-results-scores {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Full-width buttons on mobile */
  button, .btn, [role="button"] {
    min-height: 44px; /* Touch target */
  }

  /* Reduce section padding */
  section, .section {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* ── Nav logo minimum touch target ── */
  .nav-logo, .frisby-nav-logo {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* ── Mobile nav off-screen fix ── */
  .mobile-nav {
    transform: translateX(100%);
  }
  .mobile-nav.open {
    transform: translateX(0);
  }

  /* ── Homepage: Inline grid-3 → single column ── */
  .grid-3,
  [class*="grid-3"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Homepage: pillar cards, how-steps, feature-cards, proof-cards ── */
  .pillar-card,
  .how-step,
  .feature-card,
  .proof-card {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ── Homepage: ad-tabs horizontal scroll fix ── */
  .ad-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
  }
  .ad-tab {
    flex: 0 0 auto !important;
    min-height: 44px;
    scroll-snap-align: start;
  }

  /* ── Pricing: comparison table horizontal scroll ── */
  .comparison-table-wrap,
  .table-responsive,
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  table {
    min-width: 500px;
  }

  /* ── Pricing: FAQ questions minimum touch target ── */
  .faq-q {
    min-height: 48px !important;
    padding: 12px 0 !important;
    font-size: 0.95rem !important;
  }

  /* ── Small text fixes: enforce minimum 12px ── */
  .trust-badge,
  .pc-tag,
  .price-badge,
  .badge {
    font-size: 0.75rem !important;
  }

  .footer-col h5 {
    font-size: 0.75rem !important;
  }

  /* ── Footer grid: stack on mobile ── */
  .footer-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* ── Auditor page: mode buttons, sample buttons ── */
  .mode-btn,
  .sample-doc-btn,
  .btn-gate {
    min-height: 44px !important;
    padding: 10px 16px !important;
    font-size: 0.85rem !important;
  }

  /* ── Auditor: breadcrumb links ── */
  .breadcrumb a,
  nav[aria-label="breadcrumb"] a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 4px;
  }

  /* ── Auditor: compliance buttons ── */
  .compliance-btn,
  .compliance-tag,
  button[class*="compliance"],
  .framework-btn {
    min-height: 44px !important;
    font-size: 0.82rem !important;
  }

  /* ── Scroll-to-top button ── */
  .frisby-scroll-top {
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
  }

  /* ── Cookie consent buttons ── */
  .cookie-btn,
  .exit-dismiss {
    min-height: 44px !important;
    padding: 10px 16px !important;
  }

  /* ── "Get Started" and CTA buttons ── */
  .btn.btn-primary,
  a.btn-primary,
  a.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Scan history panel ── */
  .sh-panel {
    width: 100% !important;
    max-width: 100vw !important;
    right: 0 !important;
    left: 0 !important;
  }

  .sh-close {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .sh-clear-btn {
    min-height: 44px !important;
  }

  .sh-trigger-btn {
    min-height: 44px !important;
    font-size: 0.85rem !important;
  }
}

/* ─── iPhone / Small Phone (375px) ─────────────────────────────── */
@media (max-width: 480px) {
  /* Footer stacks to single column */
  .footer-grid {
    grid-template-columns: 1fr !important;
  }

  /* Industries grid single column */
  .industries-grid {
    grid-template-columns: 1fr !important;
  }

  /* Pricing cards single column */
  .pricing-grid {
    grid-template-columns: 1fr !important;
  }

  /* Reduce hero padding */
  section.hero {
    padding: 3rem 16px !important;
  }
}

/* ─── Tool Page Specific ────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Gauge shrinks to fit */
  .frisby-gauge {
    width: 120px !important;
    height: 120px !important;
    margin: 0 auto;
  }

  .frisby-gauge-number {
    font-size: 1.5rem !important;
  }

  /* Score bars stack */
  .frisby-scorebar {
    gap: 8px !important;
  }

  /* Findings — full width titles */
  .frisby-finding-title {
    max-width: 180px !important;
    font-size: 0.82rem !important;
  }

  /* Badge text smaller */
  .frisby-badge {
    font-size: 0.65rem !important;
    padding: 2px 6px !important;
  }

  /* Pipeline stages compact */
  .frisby-pipeline {
    padding: 16px !important;
  }

  .frisby-pipeline-stage {
    padding: 8px 12px !important;
  }

  /* Highlighter — reduce height */
  .frisby-hl-doc {
    max-height: 300px !important;
  }

  .frisby-hl-text {
    font-size: 0.82rem !important;
    line-height: 1.6 !important;
  }

  /* Severity summary — 2x2 grid */
  .frisby-severity-summary {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Loading states */
  .frisby-loading {
    padding: 24px 12px !important;
  }
}

/* ─── Demo Page Specific ───────────────────────────────────────── */
@media (max-width: 768px) {
  /* Demo nav: show hamburger, hide desktop links */
  #navbar .nav-links {
    display: none !important;
  }
  #navbar .nav-links.open {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(10, 10, 15, 0.98);
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    gap: 0.5rem;
  }
  #navbar .nav-links.open a,
  #navbar .nav-links.open button {
    min-height: 44px;
    padding: 12px 16px !important;
    font-size: 1rem !important;
  }
  .nav-mobile-toggle {
    display: block !important;
  }

  /* Demo grid: single column */
  .demo-grid {
    grid-template-columns: 1fr !important;
  }

  /* Demo mode toggle buttons */
  .mode-toggle-btn {
    min-height: 44px !important;
    font-size: 0.82rem !important;
  }

  /* Demo sample buttons */
  .sample-btn {
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 0.82rem !important;
  }

  /* Demo industry card buttons */
  .industry-card {
    min-height: 44px !important;
    font-size: 0.82rem !important;
    padding: 10px 12px !important;
  }

  /* Demo hero note */
  .hero-note {
    font-size: 0.82rem !important;
  }

  /* Summary stats */
  .summary-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Compare inputs */
  .compare-inputs {
    grid-template-columns: 1fr !important;
  }
}

/* ─── Tablet Adjustments ────────────────────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
  .frisby-nav-inner {
    padding: 12px 16px;
  }

  /* Features grid — 2 columns on tablet */
  .frisby-features-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Pricing — 2 columns */
  .frisby-pricing-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Inline grids — 2 columns on tablet */
  .grid-3,
  [class*="grid-3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ─── Touch Interactions ────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .frisby-finding-header {
    padding: 16px !important;
    min-height: 56px;
  }

  .frisby-nav-link {
    padding: 12px 16px !important;
  }

  /* Remove hover effects that flash on tap */
  .frisby-finding:hover {
    border-color: #2a2a4a;
  }

  .frisby-feature-card:hover {
    transform: none;
  }

  .frisby-pricing-card:hover {
    transform: none;
  }

  /* Dropdown menu on tap instead of hover */
  .frisby-nav-dropdown-menu {
    /* JS handles tap toggle on mobile */
  }

  /* Highlight marks — larger tap area */
  .frisby-hl-mark {
    padding: 2px 4px !important;
  }
}

/* ─── Print Styles ──────────────────────────────────────────────── */
@media print {
  .frisby-nav,
  .frisby-mobile-menu,
  .frisby-nav-hamburger,
  .frisby-loading,
  .frisby-hl-toolbar,
  .frisby-scan-counter {
    display: none !important;
  }

  body {
    padding-top: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .frisby-finding {
    break-inside: avoid;
    border-color: #ccc !important;
    background: #f9f9f9 !important;
  }

  .frisby-gauge-number {
    color: #000 !important;
  }

  .frisby-hl-mark {
    background: yellow !important;
    color: #000 !important;
    border-bottom-color: #000 !important;
  }
}

/* ─── Safe Area (Notch devices) ─────────────────────────────────── */
@supports (padding: env(safe-area-inset-top)) {
  .frisby-nav {
    padding-top: env(safe-area-inset-top);
  }

  .frisby-mobile-menu-inner {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ─── Reduced Motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .frisby-gauge-progress,
  .frisby-scorebar-fill,
  .frisby-loading-dot,
  .frisby-loading-spinner {
    animation: none !important;
    transition: none !important;
  }

  .frisby-mobile-menu {
    transition: none !important;
  }
}
