/* ══════════════════════════════════════════════
   M5 · UNIVERSAL CHROME · v1
   Top bar + Left sidebar + Bottom status bar
   Loaded by every public-facing page for cohesion.
   Active state is driven by body[data-m5-section].
   ══════════════════════════════════════════════ */

/* ── reset chrome (suppress any inline chrome bleeds) ── */
.m5c-hidden{display:none !important;}

/* ── tokens (kept here so single source) ── */
:root{
  --m5c-bg:#050810;
  --m5c-cyan:#00D6FF;
  --m5c-cyan2:#6feaff;
  --m5c-gold:#C9A84C;
  --m5c-gold2:#f5d979;
  --m5c-teal:#5fcfcf;
  --m5c-purple:#B83CFF;
  --m5c-green:#22cc66;
  --m5c-border:rgba(255,255,255,.07);
  --m5c-border-2:rgba(255,255,255,.14);
  --m5c-text-1:rgba(255,255,255,.96);
  --m5c-text-2:rgba(255,255,255,.72);
  --m5c-text-3:rgba(255,255,255,.42);
  --m5c-text-4:rgba(255,255,255,.22);
}

/* ── canvas slot (cosmos shader paints into this) ── */
#m5c-canvas{position:fixed;inset:0;width:100%;height:100%;z-index:0;pointer-events:none;}

/* ══ TOP BAR ══ */
.m5c-bar{position:fixed;top:0;left:0;right:0;height:44px;z-index:500;
  display:flex;align-items:center;justify-content:space-between;padding:0 20px;
  background:rgba(5,8,16,.92);backdrop-filter:blur(20px);
  border-bottom:1px solid var(--m5c-border);font-family:'Inter',sans-serif;}
.m5c-bar-left{display:flex;align-items:center;gap:0;flex:1;min-width:0;}
.m5c-back{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:8px;border:1px solid var(--m5c-border-2);background:rgba(255,255,255,.04);color:rgba(255,255,255,.72);font-size:18px;line-height:1;cursor:pointer;margin-right:12px;padding:0 0 1px 0;font-family:inherit;transition:background .18s,color .18s,border-color .18s,transform .15s;flex-shrink:0;}
.m5c-back:hover{background:rgba(255,255,255,.10);color:#fff;border-color:rgba(255,255,255,.30);transform:translateX(-1px);}
.m5c-back:active{transform:translateX(-2px);}
.m5c-logo{display:flex;align-items:center;gap:10px;text-decoration:none;color:white;padding-right:16px;flex-shrink:0;}
.m5c-logo-svg{width:20px;height:20px;}
.m5c-logo-mark{font-size:16px;font-weight:700;letter-spacing:.04em;color:white;line-height:1;}
.m5c-logo-sub{font-size:9px;font-weight:600;letter-spacing:.32em;color:var(--m5c-gold);text-transform:uppercase;padding-top:1px;}
/* On narrow viewports drop the second crumb so the bar doesn't crush */
@media(max-width:520px){
  .m5c-crumb{display:none;}
  .m5c-bar-left .m5c-div:nth-of-type(1){display:none;}
}
.m5c-div{width:1px;height:16px;background:rgba(255,255,255,.12);margin:0 16px;flex-shrink:0;}
.m5c-crumb{font-size:10.5px;font-weight:500;letter-spacing:.14em;text-transform:uppercase;color:rgba(255,255,255,.55);text-decoration:none;white-space:nowrap;transition:color .18s;}
.m5c-crumb:hover{color:rgba(255,255,255,.92);}
.m5c-section-name{font-size:10.5px;font-weight:500;letter-spacing:.14em;text-transform:uppercase;color:rgba(255,255,255,.85);}
.m5c-section-name[data-c="cyan"]{color:var(--m5c-cyan);}
.m5c-section-name[data-c="gold"]{color:var(--m5c-gold);}
.m5c-section-name[data-c="teal"]{color:var(--m5c-teal);}
.m5c-section-name[data-c="purple"]{color:var(--m5c-purple);}
.m5c-bar-right{display:flex;align-items:center;gap:14px;flex-shrink:0;}
.m5c-reserve{font-size:10px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;
  background:transparent;color:var(--m5c-gold);padding:7px 14px;border-radius:99px;
  border:1px solid rgba(201,168,76,.32);text-decoration:none;transition:.2s;
  display:inline-flex;align-items:center;gap:7px;white-space:nowrap;font-family:inherit;}
.m5c-reserve::before{content:'';width:5px;height:5px;border-radius:50%;background:var(--m5c-gold);box-shadow:0 0 8px var(--m5c-gold);}
.m5c-reserve:hover{background:rgba(201,168,76,.08);border-color:var(--m5c-gold);color:var(--m5c-gold2);}
.m5c-member{display:flex;align-items:center;gap:8px;font-size:9.5px;font-weight:500;letter-spacing:.14em;text-transform:uppercase;color:rgba(255,255,255,.55);cursor:pointer;}
.m5c-member-dot{width:7px;height:7px;border-radius:50%;background:var(--m5c-cyan);box-shadow:0 0 6px var(--m5c-cyan);animation:m5c-pulse 2.5s ease-in-out infinite;}
@keyframes m5c-pulse{0%,100%{box-shadow:0 0 6px var(--m5c-cyan);}50%{box-shadow:0 0 14px var(--m5c-cyan),0 0 24px rgba(0,214,255,.3);}}

/* ══ SIDEBAR ══ */
.m5c-side{position:fixed;left:0;top:44px;bottom:30px;width:52px;z-index:480;
  background:rgba(5,8,16,.78);backdrop-filter:blur(20px);
  border-right:1px solid var(--m5c-border);
  display:flex;flex-direction:column;align-items:center;padding:16px 0;gap:4px;}
.m5c-sbi{position:relative;width:34px;height:34px;border-radius:9px;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;transition:background .2s,color .2s,transform .15s;
  color:rgba(255,255,255,.98);font-size:16px;font-weight:500;text-decoration:none;user-select:none;font-family:inherit;
  text-shadow:0 0 14px rgba(0,214,255,.18);}
.m5c-sbi:hover{background:rgba(255,255,255,.10);color:#fff;transform:scale(1.06);}
.m5c-sbi.active{background:rgba(0,214,255,.1);color:var(--m5c-cyan);}
.m5c-sbi.active::before{content:'';position:absolute;left:-1px;top:50%;transform:translateY(-50%);
  width:2px;height:18px;background:var(--m5c-cyan);border-radius:0 2px 2px 0;}
.m5c-sbi[data-c="gold"].active{background:rgba(201,168,76,.1);color:var(--m5c-gold);}
.m5c-sbi[data-c="gold"].active::before{background:var(--m5c-gold);}
.m5c-sbi[data-c="teal"].active{background:rgba(95,207,207,.1);color:var(--m5c-teal);}
.m5c-sbi[data-c="teal"].active::before{background:var(--m5c-teal);}
.m5c-sbi[data-c="purple"].active{background:rgba(184,60,255,.1);color:var(--m5c-purple);}
.m5c-sbi[data-c="purple"].active::before{background:var(--m5c-purple);}
.m5c-sbi[data-c="gold"]:hover{background:rgba(201,168,76,.1);color:var(--m5c-gold);}
.m5c-sbi[data-c="teal"]:hover{background:rgba(95,207,207,.1);color:var(--m5c-teal);}
.m5c-sbi[data-c="purple"]:hover{background:rgba(184,60,255,.1);color:var(--m5c-purple);}
.m5c-sep{width:22px;height:1px;background:rgba(255,255,255,.07);margin:4px 0;flex-shrink:0;}
.m5c-tip{position:absolute;left:44px;top:50%;transform:translateY(-50%);
  background:rgba(8,10,20,.96);border:1px solid var(--m5c-border-2);border-radius:8px;
  padding:7px 11px;white-space:nowrap;font-size:10px;letter-spacing:.08em;color:white;
  pointer-events:none;opacity:0;transition:opacity .15s;z-index:600;font-family:'Inter',sans-serif;}
.m5c-sbi:hover .m5c-tip{opacity:1;}

/* ══ STATUS BAR ══ */
.m5c-status{position:fixed;bottom:0;left:0;right:0;height:30px;z-index:490;
  background:rgba(5,8,16,.94);backdrop-filter:blur(14px);
  border-top:1px solid rgba(255,255,255,.055);
  display:flex;align-items:center;justify-content:space-between;
  padding:0 20px 0 64px;font-family:'Inter',sans-serif;}
.m5c-status-left,.m5c-status-right,.m5c-ticker{display:flex;align-items:center;gap:14px;}
.m5c-live{display:flex;align-items:center;gap:7px;font-size:9px;font-weight:700;letter-spacing:.16em;text-transform:uppercase;color:var(--m5c-green);}
.m5c-live::before{content:'';width:5px;height:5px;border-radius:50%;background:var(--m5c-green);box-shadow:0 0 8px var(--m5c-green);animation:m5c-pulse-green 2.1s ease-in-out infinite;}
@keyframes m5c-pulse-green{50%{opacity:.4;}}
.m5c-ticker{flex:1;margin:0 18px;overflow:hidden;}
.m5c-stat{font-size:9px;letter-spacing:.14em;text-transform:uppercase;color:rgba(255,255,255,.4);white-space:nowrap;}
.m5c-stat strong{color:rgba(255,255,255,.78);font-weight:600;}
.m5c-stat[data-c="gold"] strong{color:var(--m5c-gold);}

/* ══ PAGE INSETS (default content padding) ══ */
body[data-m5-chrome]{margin:0;}
body[data-m5-chrome] .m5c-content,
body[data-m5-chrome] main:not(.m5c-bar):not(.m5c-side):not(.m5c-status):not(.stage){
  position:relative;z-index:5;padding-top:44px;padding-bottom:30px;padding-left:52px;min-height:100vh;
  box-sizing:border-box;
}
@media(max-width:680px){
  .m5c-side{display:none;}
  .m5c-ticker{display:none;}
  .m5c-status{padding-left:20px;}
  body[data-m5-chrome] main:not(.m5c-bar):not(.m5c-side):not(.m5c-status):not(.stage),
  body[data-m5-chrome] .m5c-content{padding-left:0;}
  .m5c-section-name{display:none;}
}

/* hide any inline footer that pages add — chrome carries nav */
body[data-m5-chrome] #m5-footer{display:none !important;}

/* ══ FOOTER (subtle — pattern from legal.html) ══ */
.m5c-footer{position:relative;z-index:6;
  border-top:1px solid var(--m5c-border);
  padding:14px 48px;max-width:880px;margin:24px auto 0;
  display:flex;align-items:center;justify-content:space-between;
  flex-wrap:wrap;gap:14px;font-family:'Inter',sans-serif;}
/* Direct child of body (normal-scroll pages): sit inside the sidebar inset, above the 30px status bar */
body[data-m5-chrome] > .m5c-footer{margin:24px auto 30px;padding-left:64px;padding-right:48px;}
/* Inside a fixed scroll-host (e.g. Home's .stage centering content): stick to bottom */
body[data-m5-chrome] main.stage:has(> .m5c-footer),
body[data-m5-chrome] .stage:has(> .m5c-footer){justify-content:flex-start !important;}
.stage > .m5c-footer{margin-top:auto;margin-bottom:0;padding:12px 24px;}

.m5c-foot-copy{font-size:9px;color:rgba(255,255,255,.38);line-height:1.7;letter-spacing:.01em;flex:1 1 auto;min-width:0;}
.m5c-foot-copy a{color:rgba(255,255,255,.55);text-decoration:none;border-bottom:1px solid rgba(255,255,255,.12);transition:color .2s,border-color .2s;}
.m5c-foot-copy a:hover{color:rgba(255,255,255,.85);border-bottom-color:rgba(255,255,255,.4);}
.m5c-foot-role{display:inline-block;margin-top:4px;color:rgba(255,255,255,.5);max-width:760px;}
.m5c-foot-links{display:flex;gap:20px;flex-wrap:wrap;}
.m5c-foot-links a{font-size:9px;font-weight:500;letter-spacing:.1em;text-transform:uppercase;
  color:rgba(255,255,255,.35);text-decoration:none;transition:color .2s;}
.m5c-foot-links a:hover{color:rgba(255,255,255,.75);}

@media(max-width:760px){
  .m5c-footer{padding:20px 24px;}
  body[data-m5-chrome] > .m5c-footer{padding:20px 24px;margin-left:0;margin-right:0;}
  .m5c-foot-links{gap:14px;}
}

body[data-m5-chrome] .m5c-footer{display:flex !important;}

/* ══ SUPPRESS LEGACY INLINE CHROME on pages that opt in ══
   Many existing pages have their own #os-bar / #sidebar / #status-bar
   markup with inline styles. When data-m5-chrome is set on <body>,
   those legacy elements are hidden so the canonical injected chrome
   takes over visually — without needing to refactor each page. */
body[data-m5-chrome] > #os-bar,
body[data-m5-chrome] > .osbar,
body[data-m5-chrome] > header.osbar,
body[data-m5-chrome] > #sidebar,
body[data-m5-chrome] > nav#sidebar,
body[data-m5-chrome] > .sidebar,
body[data-m5-chrome] > nav.sidebar,
body[data-m5-chrome] > #status-bar,
body[data-m5-chrome] > .statusbar,
body[data-m5-chrome] > footer.statusbar,
body[data-m5-chrome] > #nav,
body[data-m5-chrome] > #loader-orb{
  display:none !important;
}

/* Default content offset so legacy #main areas sit correctly under the new chrome */
body[data-m5-chrome] #main,
body[data-m5-chrome] #scroll,
body[data-m5-chrome] .stage,
body[data-m5-chrome] .m5c-content{
  /* respect chrome's top + sidebar + status insets */
  padding-top:max(44px, var(--m5c-pad-top, 44px)) !important;
  padding-bottom:max(30px, var(--m5c-pad-bot, 30px)) !important;
}

/* ══════════════════════════════════════════════
   Brand-styled native form controls
   Overrides browser default blue with M5 gold.
   ══════════════════════════════════════════════ */
body[data-m5-chrome] select,
body[data-m5-chrome] input,
body[data-m5-chrome] textarea{
  color-scheme:dark;
  accent-color:#C9A84C;
}
body[data-m5-chrome] select option,
body[data-m5-chrome] datalist option{
  background:#0a0a10;
  color:#f0e8d4;
  padding:8px 12px;
}
body[data-m5-chrome] select option:checked,
body[data-m5-chrome] select option:hover,
body[data-m5-chrome] select option:focus{
  background:linear-gradient(#1a1408,#1a1408);
  color:#C9A84C;
  box-shadow:0 0 10px 100px #1a1408 inset;
}
/* Replace browser-default focus ring (blue) with brand gold */
body[data-m5-chrome] *:focus-visible{
  outline:1px solid rgba(201,168,76,.55);
  outline-offset:2px;
}
body[data-m5-chrome] button:focus-visible,
body[data-m5-chrome] a:focus-visible{
  outline-color:rgba(201,168,76,.7);
}

/* ══════════════════════════════════════════════
   MOBILE OVERRIDES (≤720px)
   Many M5 pages use a desktop pattern with body{overflow:hidden}
   + #main{position:fixed;left:52-292px} that breaks on phones.
   These rules release the lock, kill the sidebar offset, and
   collapse common multi-column grids into single column.
   ══════════════════════════════════════════════ */
@media(max-width:720px){
  /* Release page scroll-lock */
  body[data-m5-chrome],
  html:has(body[data-m5-chrome]){
    overflow:auto !important;
    height:auto !important;
    min-height:100vh;
  }
  /* #main / #scroll / .stage become normal-flow on mobile */
  body[data-m5-chrome] #main,
  body[data-m5-chrome] #scroll,
  body[data-m5-chrome] .stage,
  body[data-m5-chrome] .m5c-content{
    position:static !important;
    left:0 !important;
    right:auto !important;
    top:auto !important;
    bottom:auto !important;
    width:auto !important;
    height:auto !important;
    max-height:none !important;
    overflow:visible !important;
    padding:60px 18px 60px !important;
  }
  /* Knowledge-layout left-nav (Library, Dev_Docs, Knowledge_Base) stacks above content */
  body[data-m5-chrome] #left-nav{
    position:static !important;
    left:auto !important;
    top:auto !important;
    bottom:auto !important;
    width:100% !important;
    height:auto !important;
    border-right:none !important;
    border-bottom:1px solid rgba(255,255,255,.08) !important;
    margin-top:44px;
  }
  /* Collapse multi-column grids — covers most launch-page patterns */
  body[data-m5-chrome] .door-grid,
  body[data-m5-chrome] .doors,
  body[data-m5-chrome] .doors-row,
  body[data-m5-chrome] .doc-grid,
  body[data-m5-chrome] .featured-row,
  body[data-m5-chrome] .pack-grid,
  body[data-m5-chrome] .standard-grid,
  body[data-m5-chrome] .quick-grid,
  body[data-m5-chrome] .kpi-strip,
  body[data-m5-chrome] .col-2,
  body[data-m5-chrome] .col-1-1,
  body[data-m5-chrome] .col-3,
  body[data-m5-chrome] .pathway,
  body[data-m5-chrome] .idx-grid,
  body[data-m5-chrome] .map-layout,
  body[data-m5-chrome] .wsw-banner,
  body[data-m5-chrome] .firewall,
  body[data-m5-chrome] .flow,
  body[data-m5-chrome] .lawful,
  body[data-m5-chrome] .quad,
  body[data-m5-chrome] .cards3,
  body[data-m5-chrome] .grid2,
  body[data-m5-chrome] .grid3,
  body[data-m5-chrome] .agent-grid,
  body[data-m5-chrome] .pillar-stack,
  body[data-m5-chrome] .paper-grid,
  body[data-m5-chrome] .layer-stack,
  body[data-m5-chrome] .hero,
  body[data-m5-chrome] .feature-stack{
    grid-template-columns:1fr !important;
  }
  /* Heroes / titles — keep clamp() but bump line-height for narrow screens */
  body[data-m5-chrome] h1{
    line-height:1.05 !important;
    text-wrap:pretty;
  }
  /* Hide the desktop status / ticker on mobile (already done at 680 in chrome) */
  body[data-m5-chrome] .statusbar,
  body[data-m5-chrome] #status-bar{display:none !important;}
  /* Don't let WebGL/2D canvases steal touch + cause scroll glitches */
  body[data-m5-chrome] #canvas,
  body[data-m5-chrome] #cosmos{pointer-events:none !important;}
  /* Footer (m5c-footer) — already stacks via existing 760px rule, fine */
  /* CTA buttons grow to full width on phones */
  body[data-m5-chrome] .hero-cta,
  body[data-m5-chrome] .cta-row,
  body[data-m5-chrome] .pack-actions{
    flex-direction:column !important;
    align-items:stretch !important;
  }
  body[data-m5-chrome] .hero-cta .btn,
  body[data-m5-chrome] .cta-row .btn,
  body[data-m5-chrome] .pack-actions .btn{
    justify-content:center !important;
    width:100%;
  }
}
