/* ============================================================================
 * JoJo Cal Salepage — Responsive layer
 * Loaded globally right after ds.css (via partials/head-meta.php). Adds the
 * mobile/tablet breakpoints the inline-styled 1:1 desktop design lacked.
 *
 * The public pages style layout with inline `style="...var(--token)..."`, so
 * inline declarations WIN over this sheet. Where we must beat an inline value
 * we use `!important`; where we beat a site.css class (this file loads first)
 * we also use `!important`. Token redefinitions inside @media on :root need no
 * !important — a matching media query re-declares the custom property.
 *
 * Breakpoints: 820px (tablet / nav collapse), 640px (phone), 380px (small).
 * ========================================================================== */

/* ---- Nav: base layout (moved off the header.php inline style so the mobile
 *   media query can flip `display`; inline display would otherwise win) ------ */
.jc-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex-wrap: wrap;
}
.jc-nav-toggle { display: none; }

/* ---- Tablet & down: hamburger nav ----------------------------------------- */
@media (max-width: 820px) {
  header .container { gap: 12px !important; }

  .jc-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-body);
    cursor: pointer;
    flex-shrink: 0;
  }
  .jc-nav-toggle:hover { border-color: var(--brand); color: var(--brand); }

  /* Dropdown panel anchored under the sticky header */
  .jc-nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 10px 16px 16px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
  }
  .jc-nav-links.is-open { display: flex; }
  .jc-nav-links a {
    padding: 12px 14px !important;
    font-size: 1rem !important;
    border-radius: var(--radius-md) !important;
  }
}

/* ---- Phone: typography scale + spacing ------------------------------------ */
@media (max-width: 640px) {
  :root {
    --fs-display: 2.2rem;
    --fs-h1: 1.9rem;
    --fs-h2: 1.55rem;
    --fs-h3: 1.3rem;
    --fs-h4: 1.15rem;
  }

  .section { padding: 48px 16px; }
  .container { padding: 0 16px; }

  /* Auto-fit grids whose min-track (340px) exceeds a narrow phone's content
   * width would overflow → force a single column. */
  .jc-grid-2 { grid-template-columns: 1fr !important; gap: 32px !important; }
  .jc-blog-grid { gap: 16px !important; }

  /* Inline `grid-column:span 2` items (e.g. the dashboard-preview hero card)
   * force an implicit 2nd column when their auto-fit grid has collapsed to 1
   * track → 2-col-wide overflow. Reset any spanning item to a single column. */
  [style*="grid-column:span"] { grid-column: auto !important; }

  /* Shrink the header CTA so logo + toggle + CTA fit one row on small phones */
  header .container .btn-primary {
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
  }

  /* Keep media inside stacked hero/blocks from overflowing */
  .jc-grid-2 img { max-width: 100%; height: auto; }
}

/* ---- Small phones --------------------------------------------------------- */
@media (max-width: 380px) {
  :root {
    --fs-display: 1.95rem;
    --fs-h1: 1.65rem;
  }
  .section { padding: 40px 14px; }
  .container { padding: 0 14px; }
}
