/* Mobile Header & Sheet (Glassmorphism) */

:root {
  --mh-height: 60px;
  --mh-radius: 14px;
  --mh-bg: rgba(255, 255, 255, 0.5);
  --mh-border: rgba(255, 255, 255, 0.35);
  --mh-fg: #0f172a;
  --mh-muted: #475569;

  --sheet-bg: rgba(255, 255, 255, 0.55);
  --sheet-border: rgba(255, 255, 255, 0.35);
  --sheet-shadow: 0 -16px 32px rgba(0,0,0,0.18);
}

/* Respect prefers-color-scheme */
@media (prefers-color-scheme: dark) {
  :root {
    --mh-bg: rgba(15, 16, 18, 0.6);
    --mh-border: rgba(255, 255, 255, 0.12);
    --mh-fg: #f5f5f5;
    --mh-muted: #cbd5e1;

    --sheet-bg: rgba(20, 22, 24, 0.55);
    --sheet-border: rgba(255, 255, 255, 0.12);
    --sheet-shadow: 0 -16px 32px rgba(0,0,0,0.35);
  }
}

/* Override with site's dark mode (Dracula plugin or manual dark class) */
html.dark:root,
html[data-dracula-scheme="dark"]:root {
  --mh-bg: rgba(15, 16, 18, 0.6);
  --mh-border: rgba(255, 255, 255, 0.12);
  --mh-fg: #f5f5f5;
  --mh-muted: #cbd5e1;

  --sheet-bg: rgba(20, 22, 24, 0.55);
  --sheet-border: rgba(255, 255, 255, 0.12);
  --sheet-shadow: 0 -16px 32px rgba(0,0,0,0.35);
}

/* Light mode override (when user has dark browser but light mode is enabled) */
html:not(.dark):root {
  --mh-bg: rgba(255, 255, 255, 0.5);
  --mh-border: rgba(255, 255, 255, 0.35);
  --mh-fg: #0f172a;
  --mh-muted: #475569;

  --sheet-bg: rgba(255, 255, 255, 0.55);
  --sheet-border: rgba(255, 255, 255, 0.35);
  --sheet-shadow: 0 -16px 32px rgba(0,0,0,0.18);
}

/* Hide on desktop */
#mg-mobile-header { display: none; }

@media (max-width: 850px) {
  .mfp-content.off-canvas-cart {
    min-height: 100%;
  }
  /* body.has-mobile-custom-header {
    padding-top: calc(var(--mh-height) + env(safe-area-inset-top, 0px));
  } */

  #mg-mobile-header {
    position: sticky; /* remains at top while scrolling */
    top: 0;
    z-index: 10000;

    display: block;
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    background: var(--mh-bg);
    border-bottom: 1px solid var(--mh-border);
  }

  #mg-mobile-header .mg-mh-inner {
    height: calc(var(--mh-height) + env(safe-area-inset-top, 0px));
    padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px 8px;

    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    margin-bottom: 12px;
  }

  .mg-mh-left,.mg-mh-right { display: flex; align-items: center; gap: 8px; }

  button.mg-mh-btn.mg-mh-cart {
    margin-right: 15px;
  }

  .mg-mh-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 12px;
    color: var(--mh-fg); background: transparent; border: 1px solid transparent;
      /* Scope & normalization to avoid theme conflicts */
      #mg-mobile-header, #mg-mobile-header * { box-sizing: border-box; }
      #mg-mobile-header a { text-decoration: none; color: inherit; }
      #mg-mobile-header button { border: 0; background: transparent; }
      #mg-mobile-header input, #mg-mobile-header button { font: inherit; }
    -webkit-tap-highlight-color: transparent; user-select: none; padding: 0px; margin: 0px;
  }
  .mg-mh-btn:hover,.mg-mh-btn:focus-visible { background: rgba(0,0,0,0.05); }

  /* Cart badge */
  .mg-mh-btn.mg-mh-cart { position: relative; }
  .mg-mh-cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ad0000;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  }
  .mg-mh-cart-count.is-empty { display: none; }
  .mg-mh-center { min-width: 0; }


  /* removed toggle from header; toggle remains inside sheet */

  /* Bigger SVG icons */
  .mg-mh-icon { width: 26px; height: 26px; }

  /* Bottom Sheet */
  .mg-mh-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 10000; opacity: 0; transition: opacity .25s ease; }
  .mg-mh-overlay.is-open { opacity: 1; }

  .mg-mh-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999999;
    background: var(--sheet-bg);
    backdrop-filter: blur(14px) saturate(130%);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
    border-top: 1px solid var(--sheet-border);
    border-radius: 18px 18px 0 0;
    box-shadow: var(--sheet-shadow);

    transform: translateY(100%);
    transition: transform .3s ease;
  }
  .mg-mh-sheet.is-open { transform: translateY(0%); }
  .mg-mh-sheet-handle { width: 46px; height: 5px; background: rgba(255,255,255,.6); border-radius: 999px; margin: 8px auto; }

  .mg-mh-sheet-nav { padding: 6px 14px 20px; }
  .mg-mh-sheet-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .mg-mh-sheet-link { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; text-decoration: none; color: var(--mh-fg); border: 1px solid var(--sheet-border); background: rgba(255,255,255,0.65); }
  .mg-mh-sheet-link:hover { background: rgba(255,255,255,0.5); }
  .mg-mh-sheet-label { font-size: 12px; color: var(--mh-fg); }

  /* Toggle inside sheet (full-row) */
  .mg-mh-sheet-item--toggle { grid-column: 1 / -1; }
  .mg-mh-sheet-toggle-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--sheet-border); background: rgba(255,255,255,0.55); }
  .mg-mh-sheet-toggle-wrap .mg-mh-sheet-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .mg-mh-icon { display: inline-block; }

  /* Hide Flatsome default header on mobile */
  .header-wrapper,
  header#header,
  .header,
  .ux-header,
  .header-main,
  #masthead {
    display: none !important;
  }
}
