/* Sovereign — mobile/responsive layer.
   The artboards are desktop-first with inline styles, and the dc runtime re-renders
   the page through React, which serializes style attributes with spaces
   ("display: flex", "repeat(3, 1fr)"). All attribute-substring selectors below
   target that DOM-canonical form. Injected into every page by build.mjs. */

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

@media (max-width: 860px) {
  /* Collapse every inline layout grid to a single column, then restore the
     narrow label+content rows as a slimmer two-column grid (later rule wins). */
  [style*="grid-template-columns:"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 88px 1fr"] { grid-template-columns: 64px 1fr !important; }
  [style*="grid-template-columns: 72px 300px 1fr"] { grid-template-columns: 56px 1fr !important; }
  .sov-kv { grid-template-columns: 80px 1fr !important; }

  /* Flex rows wrap instead of overflowing; column stacks are unaffected. */
  [style*="display: flex"] { flex-wrap: wrap; }

  /* German compounds in headings hyphenate instead of overflowing
     (browser hyphenation dictionaries kick in via lang="de"). */
  :lang(de) h1, :lang(de) h2, :lang(de) h3 { hyphens: auto; }

  /* Code, terminals, JSON payloads: scroll inside their own box. */
  pre, code { max-width: 100%; }
  pre { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }

  /* Anything pinned to a fixed pixel width becomes fluid. */
  [style*="width: 560px"], [style*="width: 520px"], [style*="width: 480px"],
  [style*="width: 460px"], [style*="width: 440px"], [style*="width: 420px"],
  [style*="width: 400px"], [style*="width: 380px"], [style*="width: 360px"],
  [style*="width: 340px"], [style*="width: 320px"] {
    width: 100% !important;
    max-width: 100% !important;
  }
  [style*="min-width: 300px"], [style*="min-width: 320px"], [style*="min-width: 340px"],
  [style*="min-width: 360px"], [style*="min-width: 380px"], [style*="min-width: 400px"],
  [style*="min-width: 420px"], [style*="min-width: 440px"] {
    min-width: 0 !important;
  }
}

/* Burger button and slide-down menu (injected by mobile-nav.js).
   Hidden on desktop; the media query below swaps them in for the inline links. */
.sov-burger { display: none; }
.sov-mobile-menu { display: none; }

/* Language switcher (injected by mobile-nav.js): EN / FR / DE. */
.sov-lang { display: flex; align-items: center; gap: 2px; }
.sov-lang a {
  color: var(--text-secondary, #8a8a8a);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 4px 6px;
  border-radius: 6px;
}
.sov-lang a:hover { color: var(--text-primary, #171717); }
.sov-lang a.active { color: var(--text-primary, #171717); font-weight: 600; }
.sov-lang-row { display: flex; gap: 6px; padding: 13px 4px 2px; }
.sov-lang-row a {
  color: var(--text-secondary, #8a8a8a);
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.05em;
  padding: 2px 8px 2px 0;
}
.sov-lang-row a.active { color: var(--text-primary, #171717); font-weight: 600; }

@media (max-width: 640px) {
  /* Nav: single row with logo + CTA + burger; links live in the burger menu. */
  header[data-screen-label="nav"] { height: auto !important; min-height: 56px; }
  header[data-screen-label="nav"] > div {
    flex-wrap: wrap;
    padding: 12px 16px !important;
    gap: 12px !important;
  }
  header[data-screen-label="nav"] > div > nav { display: none !important; }
  .sov-lang { display: none; }

  .sov-burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px 9px;
    margin-left: 4px;
    background: transparent;
    border: 1px solid var(--border-default, #e4e4e4);
    border-radius: 8px;
    cursor: pointer;
  }
  .sov-burger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary, #171717);
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .sov-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .sov-burger.open span:nth-child(2) { opacity: 0; }
  .sov-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .sov-mobile-menu.open {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 6px 16px 14px;
    border-top: 1px solid var(--border-default, #e4e4e4);
    background: var(--background, #fff);
  }
  .sov-mobile-menu a {
    display: block;
    padding: 13px 4px !important;
    font-size: 16px !important;
    border-bottom: 1px solid var(--border-default, #e4e4e4);
  }
  .sov-mobile-menu a:last-child { border-bottom: none; }

  /* Long mono strings (hashes, keys, endpoints) break instead of overflowing. */
  [style*="font-family: var(--font-mono)"], .sov-kv, code {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
