/* ============================================================
   CLIENTOX BRAND COLLAB · MOBILE RESPONSIVE LAYER
   ============================================================
   Drop into every collab-*.html page with one line:
     <link rel="stylesheet" href="collab-mobile.css">
   Pair with collab-mobile.js for the hamburger menu.

   What it does:
   - Kills horizontal overflow at all viewports (box-sizing, max-w)
   - At <=720px: header reflows, nav hides (replaced by hamburger)
   - At <=720px: headlines, cards, grids, buttons scale down
   - Uses body.cc-mobile (added by JS) for specificity, no !important
     except where existing inline styles need to be overridden.

   Designed to be additive. Will not break desktop layouts.
   ============================================================ */

/* ------------------------------------------------------------
   GLOBAL · safe at all viewports
   ------------------------------------------------------------ */

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* Tables get a scrollable wrapper instead of breaking layout */
table {
  max-width: 100%;
}

/* Hamburger button (injected by collab-mobile.js, hidden by default) */
.cc-hamburger {
  display: none;
  width: 44px;
  height: 44px;
  color: #F3EEE4;
  background: rgba(250, 246, 238, 0.1);
  border: 1px solid rgba(250, 246, 238, 0.38);
  border-radius: 100px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  flex-shrink: 0;
  margin-left: auto;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.cc-hamburger:hover {
  background: rgba(250, 246, 238, 0.16);
  border-color: rgba(250, 246, 238, 0.5);
}

.cc-hamburger:focus-visible {
  outline: 2px solid var(--accent, #E85D2C);
  outline-offset: 3px;
}

.cc-hamburger span {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.22s ease, opacity 0.2s ease;
  display: block;
}

.cc-hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.cc-hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.cc-hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile slide-down panel (injected by JS) */
.cc-mobile-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 85vw;
  height: 100vh;
  background: #1F3B2D;
  color: #F3EEE4;
  padding: 80px 28px 28px;
  z-index: 999;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -10px 0 40px -10px rgba(0, 0, 0, 0.4);
  overflow-y: auto;
}

.cc-mobile-panel.open {
  display: block;
  transform: translateX(0);
}

.cc-mobile-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

.cc-mobile-panel-overlay.open {
  display: block;
}

.cc-mobile-panel a,
.cc-mobile-panel .cc-mobile-panel-item {
  display: block;
  width: 100%;
  padding: 14px 0;
  margin: 0;
  border: none;
  background: transparent;
  text-align: left;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: rgba(243, 238, 228, 0.85);
  text-decoration: none;
  border-bottom: 1px solid rgba(243, 238, 228, 0.1);
  transition: color 0.15s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cc-mobile-panel a:hover,
.cc-mobile-panel a:focus,
.cc-mobile-panel .cc-mobile-panel-item:hover,
.cc-mobile-panel .cc-mobile-panel-item:focus {
  color: #E85D2C;
}

.cc-mobile-panel a.danger,
.cc-mobile-panel .cc-mobile-panel-item.danger {
  color: rgba(243, 238, 228, 0.6);
  margin-top: 12px;
}

.cc-mobile-panel a.danger:hover,
.cc-mobile-panel .cc-mobile-panel-item.danger:hover {
  color: #E85D2C;
}

.cc-mobile-panel-close {
  position: absolute;
  top: 22px; right: 22px;
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid rgba(243, 238, 228, 0.25);
  border-radius: 50%;
  color: #F3EEE4;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cc-mobile-panel-close:hover {
  background: rgba(243, 238, 228, 0.06);
  border-color: rgba(243, 238, 228, 0.5);
}

.cc-mobile-panel-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(243, 238, 228, 0.45);
  margin-bottom: 12px;
}

/* ------------------------------------------------------------
   MOBILE BREAKPOINT · <=720px
   ------------------------------------------------------------ */

@media (max-width: 720px) {

  /* --- Show hamburger, prep nav for replacement --- */
  body.cc-mobile .cc-hamburger {
    display: flex;
  }

  body.cc-mobile header > nav,
  body.cc-mobile header .nav,
  body.cc-mobile header .nav-links,
  body.cc-mobile header .header-nav,
  body.cc-mobile .cc-nav {
    display: none;
  }

  /* --- Header reflow --- */
  body.cc-mobile header {
    padding: 14px 18px;
    gap: 12px;
    flex-wrap: nowrap;
  }

  body.cc-mobile nav.collab-nav {
    padding: 14px 0;
  }

  body.cc-mobile .collab-nav-inner {
    padding: 0 18px;
    gap: 12px;
  }

  /* Brand mark stays compact */
  body.cc-mobile header .brand,
  body.cc-mobile header .logo,
  body.cc-mobile header .cc-brand,
  body.cc-mobile .cc-brand,
  body.cc-mobile .collab-logo {
    font-size: 18px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
  }

  /* Brand pill (BRAND COLLAB / BILLBOARD) stays visible but compact */
  body.cc-mobile header .brand-pill,
  body.cc-mobile header .cc-brand-pill,
  body.cc-mobile header .product-pill,
  body.cc-mobile .cc-brand-pill,
  body.cc-mobile .collab-logo-tag {
    font-size: 8px;
    padding: 3px 8px;
    flex-shrink: 0;
  }

  /* --- Main content --- */
  body.cc-mobile main {
    padding: 24px 18px 60px;
    width: 100%;
    overflow-x: hidden;
  }

  body.cc-mobile .container,
  body.cc-mobile .wrap,
  body.cc-mobile [class*="container"],
  body.cc-mobile [class*="wrap"] {
    padding-left: 18px;
    padding-right: 18px;
    max-width: 100%;
  }

  /* --- Headlines scale down --- */
  body.cc-mobile h1 {
    font-size: clamp(28px, 7vw, 36px);
    line-height: 1.1;
    word-break: break-word;
  }

  body.cc-mobile h2 {
    font-size: clamp(22px, 5.5vw, 28px);
    line-height: 1.15;
  }

  body.cc-mobile h3 {
    font-size: clamp(18px, 4.5vw, 22px);
  }

  /* --- Generic head row (title left, action right) stacks --- */
  body.cc-mobile .head-row,
  body.cc-mobile .header-row,
  body.cc-mobile .page-head,
  body.cc-mobile [class*="-head-row"],
  body.cc-mobile [class*="head-row"] {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* --- Grids collapse to 1 column --- */
  body.cc-mobile .grid,
  body.cc-mobile .cards-grid,
  body.cc-mobile .campaigns-grid,
  body.cc-mobile [class*="grid"]:not([class*="cc-tab-count"]):not([class*="bb-map-grid"]) {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* --- Cards: full width, less padding --- */
  body.cc-mobile .card,
  body.cc-mobile .dark-card,
  body.cc-mobile .light-card,
  body.cc-mobile [class*="-card"],
  body.cc-mobile [class*="card-"] {
    padding: 22px 20px;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
  }

  /* Campaign list cards: avatar + info layout */
  body.cc-mobile .campaign-card,
  body.cc-mobile .brief-card,
  body.cc-mobile .creator-card,
  body.cc-mobile [class*="campaign-row"] {
    padding: 16px;
  }

  body.cc-mobile .campaign-card .meta,
  body.cc-mobile .campaign-card .actions {
    flex-wrap: wrap;
  }

  /* --- Top-of-page action bars (Your campaigns + New campaign btn) stack --- */
  body.cc-mobile .section-head,
  body.cc-mobile .section-header,
  body.cc-mobile [class*="section-head"] {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  body.cc-mobile .section-head > *,
  body.cc-mobile .section-header > * {
    width: 100%;
  }

  body.cc-mobile .section-head .btn,
  body.cc-mobile .section-head .btn-primary,
  body.cc-mobile .section-head button {
    text-align: center;
    justify-content: center;
  }

  /* --- Buttons: stretch full width when alone --- */
  body.cc-mobile .btn-primary,
  body.cc-mobile .btn-secondary,
  body.cc-mobile [class*="btn-primary"],
  body.cc-mobile [class*="btn-secondary"] {
    padding: 12px 20px;
    font-size: 14px;
  }

  /* Button rows stack */
  body.cc-mobile .btn-row,
  body.cc-mobile .actions-row,
  body.cc-mobile [class*="btn-row"],
  body.cc-mobile [class*="actions-row"] {
    flex-direction: column;
    gap: 10px;
  }

  body.cc-mobile .btn-row > .btn,
  body.cc-mobile .actions-row > button,
  body.cc-mobile [class*="btn-row"] > * {
    width: 100%;
    justify-content: center;
  }

  /* --- Forms: stack fields, full-width inputs --- */
  body.cc-mobile .form-row,
  body.cc-mobile .field-row,
  body.cc-mobile [class*="form-row"] {
    flex-direction: column;
    gap: 12px;
  }

  body.cc-mobile input[type="text"],
  body.cc-mobile input[type="email"],
  body.cc-mobile input[type="tel"],
  body.cc-mobile input[type="number"],
  body.cc-mobile input[type="password"],
  body.cc-mobile input[type="search"],
  body.cc-mobile input[type="url"],
  body.cc-mobile select,
  body.cc-mobile textarea {
    width: 100%;
    font-size: 16px;     /* prevents iOS Safari from auto-zooming on focus */
  }

  /* --- User pill (avatar + name + role) stays neat --- */
  body.cc-mobile .user-pill,
  body.cc-mobile [class*="user-pill"],
  body.cc-mobile [class*="user-info"] {
    max-width: 100%;
    flex-wrap: wrap;
  }

  /* --- Pricing / stats grid: 2 col -> 1 col below 480px --- */
  body.cc-mobile .stats-grid,
  body.cc-mobile [class*="stats"],
  body.cc-mobile [class*="-stats"] {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* --- Score / metric numbers shrink --- */
  body.cc-mobile [class*="score-num"],
  body.cc-mobile [class*="stat-num"],
  body.cc-mobile [class*="metric-num"] {
    font-size: 24px;
  }

  /* --- Tables: scrollable wrapper --- */
  body.cc-mobile table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Tabs: shrink padding, scroll horizontally if needed --- */
  body.cc-mobile .tabs,
  body.cc-mobile [class*="-tabs"] {
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  body.cc-mobile .tabs::-webkit-scrollbar,
  body.cc-mobile [class*="-tabs"]::-webkit-scrollbar {
    display: none;
  }

  /* --- Sidebars in admin pages collapse --- */
  body.cc-mobile .admin-layout,
  body.cc-mobile .dashboard-layout,
  body.cc-mobile [class*="-layout"]:has(.sidebar),
  body.cc-mobile .has-sidebar {
    grid-template-columns: 1fr;
  }

  body.cc-mobile .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid rgba(212, 201, 176, 0.4);
  }
}

/* ------------------------------------------------------------
   VERY SMALL · <=420px
   ------------------------------------------------------------ */

@media (max-width: 420px) {
  body.cc-mobile main {
    padding: 18px 14px 50px;
  }

  body.cc-mobile h1 {
    font-size: 26px;
  }

  body.cc-mobile .stats-grid,
  body.cc-mobile [class*="stats"] {
    grid-template-columns: 1fr;
  }

  body.cc-mobile .card,
  body.cc-mobile [class*="-card"] {
    padding: 18px 16px;
  }
}

/* ------------------------------------------------------------
   ACCESSIBILITY · respect reduced motion
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .cc-mobile-panel,
  .cc-hamburger span,
  .cc-mobile-panel-overlay {
    transition: none !important;
  }
}
