/* =====================================================================
   Advoke CV — Cross-page responsive overrides
   Mobile-first adjustments for all layouts.
   ===================================================================== */

/* =====================================================================
   Breakpoint: ≤ 1200px
   ===================================================================== */
@media (max-width: 1200px) {
  :root {
    --editor-left-w: 220px;
    --editor-right-w: 460px;
  }

  .footer-grid {
    grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
    gap: var(--s-6);
  }
}

/* =====================================================================
   Breakpoint: ≤ 1024px
   ===================================================================== */
@media (max-width: 1024px) {
  .container { padding-inline: var(--s-5); }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: var(--s-10);
  }
  .hero-preview { order: -1; }
  .paper { max-width: 380px; }

  .guide-layout,
  .example-layout {
    grid-template-columns: 1fr;
    gap: var(--s-8);
  }
  .guide-toc,
  .example-sidebar {
    position: static;
    order: -1;
  }
  .guide-toc ul {
    display: flex;
    flex-wrap: wrap;
    border-left: 0;
    gap: var(--s-2);
  }
  .guide-toc a {
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 4px 12px;
    margin-left: 0;
  }

  .gallery-layout {
    grid-template-columns: 1fr;
    gap: var(--s-6);
  }
  .gallery-sidebar { position: static; }

  /* Editor: hide sidebar nav, stack panel + preview via tabs */
  .editor-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .editor-nav { display: none; }
  .editor-preview {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding: var(--s-4);
  }
  .editor-mobile-tabs { display: flex; }
  .editor-panel { padding: var(--s-5) var(--s-4) var(--s-16); }
}

/* =====================================================================
   Breakpoint: ≤ 900px
   ===================================================================== */
@media (max-width: 900px) {
  /* Collapse primary navigation into a mobile menu */
  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: var(--s-3) var(--s-5) var(--s-5);
    display: none;
    flex-direction: column;
    align-items: stretch;
  }
  .main-nav.open { display: flex; }
  .main-nav .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-1);
  }
  .main-nav .nav-list a {
    padding: var(--s-3) var(--s-2);
    font-size: var(--fs-base);
    border-bottom: 0;
    border-radius: var(--r-sm);
  }
  .main-nav .nav-list a:hover,
  .main-nav .nav-list a[aria-current="page"] {
    background: var(--surface-2);
    border-bottom-color: transparent;
  }
  .menu-toggle { display: inline-flex; }
  .header-actions .btn-primary { display: none; }

  .trust-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-6);
  }
  .footer-brand { grid-column: 1 / -1; }

  .split,
  .split-wide,
  .split-narrow {
    grid-template-columns: 1fr;
    gap: var(--s-6);
  }

  .form-row-2,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .editor-mobile-tabs { display: flex; }

  /* Prefer preview-first on small screens */
  .editor-preview { order: -1; }
}

/* =====================================================================
   Breakpoint: ≤ 640px
   ===================================================================== */
@media (max-width: 640px) {
  :root {
    --header-h: 56px;
  }

  .container { padding-inline: var(--s-4); }
  .section { padding-block: clamp(40px, 8vw, 64px); }
  .section-head { margin-bottom: var(--s-8); }

  h1 { font-size: clamp(1.5rem, 4vw + 0.5rem, 2.25rem); }
  h2 { font-size: clamp(1.25rem, 2vw + 0.5rem, 1.75rem); }

  .cta-row .btn { flex: 1 1 auto; justify-content: center; }

  .trust-grid { grid-template-columns: repeat(2, 1fr); gap: var(--s-4); }
  .trust-item strong { font-size: var(--fs-xl); }

  .showcase-grid,
  .example-grid,
  .guide-grid,
  .feature-grid,
  .steps,
  .guides-index-grid,
  .examples-index-grid,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .paper { max-width: 320px; padding: 20px 18px; }

  /* Template filter bar on mobile */
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-select { width: 100%; min-width: 0; }

  /* Preview modal full screen on mobile */
  .preview-modal-body { padding: var(--s-3); }
  .preview-modal-bar { padding: var(--s-2) var(--s-3); }

  .dialog { padding: var(--s-5); }
  .dialog .actions { flex-direction: column-reverse; }
  .dialog .actions .btn { width: 100%; }

  /* Editor panels */
  .panel-section { padding: var(--s-4); }
  .entry-head { padding: var(--s-3); }
  .entry-body { padding: var(--s-3) var(--s-4) var(--s-4); }

  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }

  .toast-region {
    left: var(--s-3);
    right: var(--s-3);
    bottom: var(--s-3);
    max-width: none;
  }

  /* Mobile-preview: shrink the resume page so it fits */
  .preview-canvas {
    transform: scale(0.55);
  }
  .preview-canvas-wrap {
    max-height: 70vh;
  }
}

/* =====================================================================
   Breakpoint: ≤ 480px
   ===================================================================== */
@media (max-width: 480px) {
  .hero-points { flex-direction: column; gap: var(--s-2); }
  .btn-lg { padding: 11px 18px; font-size: var(--fs-sm); }

  .paper { max-width: 280px; padding: 16px 14px; font-size: 9px; }
  .paper-name { font-size: 16px; }
  .paper-title { font-size: 10px; }
  .paper-contact { font-size: 8.5px; }

  .preview-canvas { transform: scale(0.42); }
}

/* =====================================================================
   Landscape phones
   ===================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .editor-app {
    height: auto;
    min-height: 100dvh;
  }
  .editor-shell {
    height: auto;
  }
}

/* =====================================================================
   Print — ensure responsiveness does not interfere
   ===================================================================== */
@media print {
  .main-nav,
  .menu-toggle,
  .header-actions,
  .editor-mobile-tabs {
    display: none !important;
  }
}

/* =====================================================================
   Reduced data mode: simplify heavy decorative gradients
   ===================================================================== */
@media (prefers-reduced-data: reduce) {
  .hero {
    background: var(--bg) !important;
  }
  .gallery-header,
  .guide-header,
  .example-header {
    background: var(--bg) !important;
  }
}