/* === M4D Mobile Header (reset with class-based toggle) === */
:root {
  --m4d-h: 56px;
  --m4d-safe-top: env(safe-area-inset-top, 0px);
  --m4d-border: rgba(255, 255, 255, .08);
  --m4d-blur: 12px;
}

body {
  scroll-padding-top: calc(var(--m4d-h) + var(--m4d-safe-top));
}

.m4d-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: saturate(120%) blur(var(--m4d-blur));
  -webkit-backdrop-filter: saturate(120%) blur(var(--m4d-blur));
  background: linear-gradient(180deg, rgba(8, 13, 26, .9), rgba(8, 13, 26, .65));
  border-bottom: 1px solid var(--m4d-border);
}

.m4d-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + var(--m4d-safe-top)) 14px 8px 14px;
  min-height: calc(56px + var(--m4d-safe-top));
}

.m4d-home {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e5e7eb;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.m4d-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: radial-gradient(circle, rgba(96, 165, 250, .9), rgba(96, 165, 250, .1));
  display: block;
}

.m4d-menu {
  appearance: none;
  background: none;
  border: 0;
  padding: 10px;
  margin: -10px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.m4d-burger,
.m4d-burger::before,
.m4d-burger::after {
  content: "";
  display: block;
  width: 22px;
  height: 2px;
  background: #e5e7eb;
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}

.m4d-burger::before {
  transform: translateY(-6px)
}

.m4d-burger::after {
  transform: translateY(4px)
}

.m4d-menu[aria-expanded="true"] .m4d-burger {
  transform: rotate(45deg)
}

.m4d-menu[aria-expanded="true"] .m4d-burger::before {
  transform: rotate(90deg)
}

.m4d-menu[aria-expanded="true"] .m4d-burger::after {
  opacity: 0
}

/* Drawer hidden by default on mobile; shown when header has .m4d-open */
.m4d-drawer {
  display: none;
  padding: 8px 10px 12px;
}

.m4d-header.m4d-open .m4d-drawer {
  display: block;
}

.m4d-drawer a {
  display: block;
  padding: 10px 12px;
  margin: 6px;
  border-radius: 12px;
  text-decoration: none;
  color: #e5e7eb;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--m4d-border);
  font-weight: 600;
}

/* Desktop: pills always visible; burger hidden */
@media (min-width:860px) {
  .m4d-menu {
    display: none !important;
    visibility: hidden !important;
  }

  .m4d-drawer {
    display: flex !important;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    padding: 0 14px 14px;
  }

  .m4d-header.m4d-open .m4d-drawer {
    display: flex !important;
  }

  .m4d-drawer a {
    display: inline-flex;
    margin: 0;
  }
}

/* Consistent spacing below header */


.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  clip-path: inset(50%);
}



/* If the first real content block is a panel/hero/card, remove extra top margin */


/* === Deterministic top spacing via class added by JS === */




/* === Deterministic spacing using a dedicated spacer element === */
.m4d-spacer {
  height: clamp(12px, 2.2vw, 28px);
  pointer-events: none;
}

/* Guard: if a page also has a margin on its first wrapper, neutralize it */
.m4d-spacer+ :is(main, .container, section, div) {
  margin-top: 0 !important;
}

.m4d-spacer+ :is(main, .container, section, div)> :is(.panel, .hero, .card):first-child {
  margin-top: 0 !important;
}


/* Desktop single-row layout */
@media (min-width:860px) {
  .m4d-header.m4d-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
  }

  .m4d-header.m4d-inline .m4d-top {
    padding-bottom: 0;
    min-height: calc(56px + var(--m4d-safe-top));
  }

  .m4d-header.m4d-inline #m4d-drawer {
    display: flex !important;
    gap: 10px;
    align-items: center;
    padding: 0 14px;
  }

  .m4d-header.m4d-inline .m4d-menu {
    display: none !important;
  }
}


/* Slightly denser pills on desktop to accommodate more items */
@media (min-width:860px) {
  .m4d-header.m4d-inline #m4d-drawer a {
    padding: 8px 10px;
    font-size: 13px;
  }

  .m4d-header.m4d-inline #m4d-drawer {
    gap: 8px;
  }

  /* Prevent wrap; allow graceful overflow scrolling if needed on narrow windows */
  .m4d-header.m4d-inline #m4d-drawer {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
  }
}


/* Mobile top spacing fix for first container */
@media (max-width:859px) {
  .m4d-spacer+ :is(main, .container, section, div) {
    margin-top: 0 !important;
  }

  body> :is(main, .container, section, div):first-child {
    margin-top: 0 !important;
  }
}


/* Remove top gap on Drafts Hub & Team Schedules mobile */
@media (max-width: 859px) {

  body[data-page="drafts"] main,
  body[data-page="schedule"] main {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
}


/* Page-specific mobile top gap removal for Drafts & Team Schedules */
@media (max-width: 859px) {
  body[data-page="drafts"] :is(main, .container, section, div):first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  body[data-page="schedule"] :is(main, .container, section, div):first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
}


/* Kill big top margin on Drafts & Schedules containers for mobile */
@media (max-width: 859px) {

  body[data-page="drafts"] .container,
  body[data-page="schedule"] .container {
    margin-top: 8px !important;
    /* instead of 32px from page CSS */
  }
}


/* Hard reset for burger button so page-level `button{ width:100% }` rules don't blow it up */
.m4d-header .m4d-menu {
  all: unset;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
  cursor: pointer;
}

.m4d-header .m4d-burger,
.m4d-header .m4d-burger::before,
.m4d-header .m4d-burger::after {
  background: currentColor;
}


/* === Mobile nav overlay (modal) === */
.m4d-overlay[hidden] {
  display: none !important;
}

.m4d-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.m4d-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, .55);
  backdrop-filter: saturate(120%) blur(6px);
}

.m4d-overlay-sheet {
  position: relative;
  margin-top: calc(var(--m4d-safe-top) + 56px + 8px);
  background: linear-gradient(180deg, rgba(8, 13, 26, .98), rgba(8, 13, 26, .92));
  border: 1px solid var(--m4d-border);
  border-radius: 14px;
  padding: 10px;
  width: min(680px, 92vw);
  max-height: calc(100dvh - (var(--m4d-safe-top) + 56px + 20px));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.m4d-overlay-sheet a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: #e5e7eb;
  border: 1px solid var(--m4d-border);
  margin: 6px 0;
  font-weight: 600;
}

.m4d-overlay-sheet a[aria-current="page"] {
  background: rgba(96, 165, 250, .14);
  color: #dbeafe;
}

@media (min-width:860px) {
  .m4d-overlay {
    display: none !important;
  }
}

/* breathing room under the header */
.m4d-spacer {
  height: clamp(12px, 2.2vw, 28px);
  pointer-events: none;
}

@media (min-width: 860px) {

  /* Center the nav pills in the header */
  .m4d-header .m4d-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
  }

  .m4d-header .m4d-home {
    justify-self: start;
  }

  .m4d-header.m4d-inline #m4d-drawer {
    justify-self: center;
  }
}


/* === Center pills on desktop (force over earlier flex rules) === */
@media (min-width: 860px) {
  .m4d-header.m4d-inline .m4d-top {
    display: grid !important;
    /* beat earlier flex */
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
  }

  .m4d-header .m4d-home {
    justify-self: start;
  }

  .m4d-header.m4d-inline #m4d-drawer {
    justify-self: center !important;
    /* center the pill row */
    margin: 0 auto;
    /* belt + suspenders */
  }
}

/* === Visible breathing room under sticky header === */
.m4d-spacer {
  height: clamp(20px, 3.0vw, 40px);
  /* more obvious gap on all screens */
  pointer-events: none;
}

@media (min-width: 860px) {
  .m4d-spacer {
    height: clamp(28px, 3.5vw, 48px);
  }
}

/* Neutralize any page styles that zero the top margin right after the spacer */
.m4d-spacer+ :is(main, .container, section) {
  margin-top: 0 !important;
}

.m4d-spacer+ :is(main, .container, section)> :is(.panel, .hero, .card):first-child {
  margin-top: 0 !important;
}