
/* ============================================================
   Responsive utility grid classes
   Used in JSX via className="grid-2" etc.
   Each collapses to single column on mobile.
   ============================================================ */
.grid       { display: grid; gap: 20px; }
.grid-2     { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3     { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4     { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5     { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.grid-6     { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.grid-asym-l { display: grid; grid-template-columns: 1.2fr 0.9fr; gap: 48px; align-items: center; }
.grid-asym-r { display: grid; grid-template-columns: 0.9fr 1.2fr; gap: 48px; align-items: center; }
.grid-footer { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 48px; }
.dash-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; }
.dash-metrics { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 16px; }

/* Allow grid children to shrink below their min-content (prevents overflow when long words present) */
.grid > *, .grid-2 > *, .grid-3 > *, .grid-4 > *, .grid-5 > *, .grid-6 > *,
.grid-asym-l > *, .grid-asym-r > *, .grid-footer > *, .grid-compact > *,
.dash-layout > *, .dash-metrics > * {
  min-width: 0;
}

/* Sticky column (used in 2-col layouts where one side stays fixed while other scrolls) */
.sticky-col { position: sticky; top: 120px; }

/* Nav system: desktop links vs mobile burger drawer */
.nav-desktop { display: flex; align-items: center; gap: 28px; font-size: 14px; font-weight: 500; }
.nav-desktop a { color: var(--ink); text-decoration: none; }
.nav-desktop a:hover { color: var(--accent); }

.nav-burger {
  display: none;
  width: 44px; height: 44px;
  border: 1.5px solid var(--ink);
  border-radius: var(--r-pill);
  background: var(--bg-card);
  cursor: pointer;
  align-items: center; justify-content: center;
  padding: 0;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.nav-burger:hover { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--ink); }
.nav-burger:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.nav-burger-icon { display: block; width: 18px; height: 2px; background: var(--ink); position: relative; }
.nav-burger-icon::before, .nav-burger-icon::after {
  content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: var(--ink);
}
.nav-burger-icon::before { top: -6px; }
.nav-burger-icon::after  { top: 6px; }
.nav-burger[aria-expanded="true"] .nav-burger-icon { background: transparent; }
.nav-burger[aria-expanded="true"] .nav-burger-icon::before { top: 0; transform: rotate(45deg); }
.nav-burger[aria-expanded="true"] .nav-burger-icon::after  { top: 0; transform: rotate(-45deg); }

.nav-drawer {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  display: none;
  flex-direction: column;
  padding: 96px 24px 40px;
  overflow-y: auto;
}
.nav-drawer.open { display: flex; }
.nav-drawer a:not(.btn) {
  display: block;
  padding: 18px 4px;
  font-family: var(--f-display);
  font-size: 28px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--ink), transparent 80%);
}
.nav-drawer a:not(.btn):active { color: var(--accent); }
.nav-drawer .nav-drawer-cta {
  margin-top: 32px;
  align-self: flex-start;
  max-width: 100%;
}

/* When drawer is open, keep burger visible & on top (it becomes the close button) */
.nav-burger { z-index: 70; }

/* ============================================================
   Mobile breakpoint (<= 768px)
   Targets utility classes added above — no !important, no
   attribute selectors. Inline styles need explicit JSX refactor.
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --gutter: 18px;
    --section: clamp(56px, 13vw, 96px);
  }

  body { font-size: 16px; }

  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6,
  .grid-asym-l, .grid-asym-r, .grid-footer,
  .dash-layout, .dash-metrics {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  /* 6-col stays 2-col on mobile to stay scannable */
  .grid-6 { grid-template-columns: repeat(2, 1fr); gap: 20px; }

  /* Icon/compact grids stay 2-col on mobile (allergens, small tiles) */
  .grid-compact { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* SwissMap (carte des cantons "Notre terrain de jeu") : tient dans le cadre.
     Sa grille interne repeat(5,1fr) inline n'a pas min-width:0 sur ses cellules
     → elles débordaient à droite. On les laisse rétrécir + on resserre. */
  .card[style*="padding: 48px"] { padding: 18px !important; }
  [style*="grid-template-columns: repeat(5, 1fr)"] { gap: 5px !important; }
  [style*="grid-template-columns: repeat(5, 1fr)"] > * { min-width: 0; }
  [style*="grid-template-columns: repeat(5, 1fr)"] > div {
    padding: 6px !important;
    min-height: 52px !important;
    overflow: hidden;
  }
  /* Le code canton (JU/NE/...) et la ville rétrécissent un peu pour tenir */
  [style*="grid-template-columns: repeat(5, 1fr)"] > div > div:last-child {
    font-size: 10px !important;
    line-height: 1.15 !important;
    word-break: break-word;
  }

  /* Nav: hide desktop, show burger */
  .nav-desktop { display: none; }
  .nav-burger  { display: inline-flex; }

  /* Header CTA: hidden on mobile (also in drawer) */
  header .nav-cta { display: none; }

  /* School portal DashHeader on mobile */
  .dash-header { padding: 12px 18px !important; }
  .dash-nav-desktop, .dash-user-desktop { display: none !important; }
  .dash-brand-badge { display: none !important; }

  /* School portal page paddings (inline patterns used across views) */
  [style*="padding: 32px 40px"] { padding: 20px 16px !important; }
  [style*="padding: 48px 40px"] { padding: 32px 16px !important; }
  [style*="padding: 28px 32px"] { padding: 18px 16px !important; }
  [style*="padding: 20px 28px"] { padding: 16px 16px !important; }
  [style*="padding: 20px 24px"] { padding: 14px 16px !important; }

  /* OrderTable on mobile: hide diet descriptions, tighten sticky col */
  .diet-desc { display: none; }
  [style*="position: sticky"][style*="left: 0"] {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  /* Display headings: force-reduce on mobile (override inline font-size) */
  h1.display { font-size: clamp(40px, 11vw, 64px) !important; }
  h2.display { font-size: clamp(32px, 8vw, 48px) !important; }
  h3.display { font-size: clamp(22px, 6vw, 32px) !important; }

  /* Hero CTA buttons: full-width, stacked */
  .hero-cta-row { flex-direction: column; align-items: stretch; }
  .hero-cta-row .btn { width: 100%; justify-content: center; }
  .hero-cta-row .hand { text-align: center; margin-left: 0 !important; margin-top: 8px; }

  /* Tweaks debug panel: hidden on mobile */
  .tweaks-panel { display: none; }

  /* Cards: shadow + radius tightened, internal padding eased via wrapper class */
  .card { box-shadow: 3px 3px 0 var(--ink); }
  /* When a section card has chunky inline padding, ease it on mobile */
  .card[style*="padding: 48"],
  .card[style*="padding:48"] { padding: 24px !important; }
  .card[style*="padding: 40"],
  .card[style*="padding:40"] { padding: 22px !important; }
  .card[style*="padding: 32"],
  .card[style*="padding:32"] { padding: 20px !important; }

  /* Marquee items: slightly smaller font on mobile */
  .marquee-item { font-size: 24px !important; }

  /* Disable sticky positioning on mobile (causes overlap when grid collapses) */
  .sticky-col { position: static; top: auto; }
}

@media (max-width: 480px) {
  :root { --gutter: 14px; --section: clamp(48px, 14vw, 80px); }
  body { font-size: 15px; }
  h1.display { font-size: clamp(36px, 12vw, 56px) !important; }
  h2.display { font-size: clamp(28px, 9vw, 40px) !important; }
  h3.display { font-size: clamp(20px, 6vw, 28px) !important; }
  .nav-drawer a:not(.btn) { font-size: 24px; padding: 16px 4px; }
}
