/* ========================================================================== 
   Global (Groceries module) — Glassy Blue UI + Mobile Nav + PWA friendly
   Uses official gradient: #7b8fff → #84d3fa
   Each page will also include its own page CSS (index.css, login.css, etc.)
   ========================================================================== */

/* 0) Tokens */
:root{
  --ui-font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --ui-head: 'Poppins', var(--ui-font);

  /* default (day) theme background */
  --bg: linear-gradient(120deg, #7b8fff 0%, #84d3fa 100%);
  --glass-1: rgba(255,255,255,.16);
  --glass-2: rgba(255,255,255,.10);
  --glass-br: rgba(255,255,255,.28);
  --shadow-1: 0 10px 40px rgba(0,0,0,.25), 0 2px 10px rgba(0,0,0,.12);

  --ink: #fff;
  --muted: rgba(255,255,255,.85);

  --radius: 18px;
  --gap: 14px;
  --nav-height: 64px;

  /* iOS/Android safe-area insets (used on mobile) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* THEME: Midnight (your requested background override) */
:root[data-theme="midnight"]{
  --bg:
    radial-gradient(1200px 700px at 40% -200px, rgba(53,83,148,.45), transparent 70%),
    radial-gradient(900px 600px at 100% 0%, rgba(31,82,113,.35), transparent 60%),
    #0b1220;                 /* base canvas color */
  --ui-1: #38527a;
  --ui-2: #1b233a;
  --theme-color: #1b233a;

  /* a touch more contrast for midnight */
  --glass-1: rgba(255,255,255,.14);
  --glass-2: rgba(255,255,255,.08);
  --glass-br: rgba(255,255,255,.22);
  --muted: rgba(255,255,255,.80);
}

/* 1) Reset & base */
*,
*::before,*::after{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin:0;
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
}

/* Accessibility */
.skip-link{
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus{
  left: 8px; top: 8px; width: auto; height: auto; z-index: 9999;
  background: #000; color:#fff; padding:8px 10px; border-radius:10px;
}

/* 2) Layout wrapper (per your global override rule) */
main.main-content{
  display:block !important;
  padding:0;    /* keep zero; each page will add its own inner spacing */
  margin:0;
}

/* Container helper */
.container{ max-width: 1180px; margin: 0 auto; padding: 0 12px; }

/* 3) Glassy Header */
.site-header{
  position: sticky;
  top: 0;
  z-index: 10000; /* ensure taps are captured above cards/overlays */
  height: calc(var(--nav-height) + var(--safe-top));
  padding-top: var(--safe-top);               /* keeps content below notch */
  backdrop-filter: blur(14px) saturate(140%);
  background: var(--glass-2);
  border-bottom: 1px solid var(--glass-br);
  box-shadow: var(--shadow-1);
}
.site-header .container{
  height: calc(var(--nav-height));           /* visual header height */
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
.brand{
  display:flex; align-items:center; gap:10px; text-decoration:none; color:inherit;
}
.brand-logo{ width: 28px; height: 28px; display:block; }
.brand-name{ font: 700 18px/1 var(--ui-head); letter-spacing:.2px; }

/* Mobile nav toggle (checkbox hack) */
.nav-toggle{
  display:none; cursor:pointer;
  border:1px solid var(--glass-br);
  background: var(--glass-1);
  padding:6px 10px; border-radius:12px;
  min-width: 40px; min-height: 40px;           /* comfy hit target */
  align-items:center; justify-content:center;
}
.nav-toggle .material-symbols-outlined{ font-size:22px; line-height:1; }

.main-nav{
  display:flex; align-items:center; gap:10px;
}
.main-nav a{
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 10px; border-radius:12px; text-decoration:none; color:inherit;
  border:1px solid transparent;
  min-height: 40px;                             /* better tap target */
}
.main-nav a:hover{ background: var(--glass-1); border-color: var(--glass-br); }

/* User area */
.user-area{ display:flex; align-items:center; gap:10px; }
.user-area .avatar{
  width:28px; height:28px; border-radius:50%;
  border:1px solid var(--glass-br); background:#fff;
}
.user-area .uname{ font-weight:600; }
.user-area .login-btn{
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 12px; border-radius:12px; text-decoration:none; color:inherit;
  background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,.14));
  border:1px solid var(--glass-br); box-shadow: var(--shadow-1);
  min-height: 40px;
}
.user-area .logout{
  display:inline-flex; align-items:center; gap:6px; color:inherit; text-decoration:none;
  padding:6px 8px; border-radius:10px; border:1px solid var(--glass-br); background: var(--glass-2);
  min-width: 40px; min-height: 40px; align-items:center; justify-content:center;
}

/* 4) Footer */
.site-footer{
  margin-top: 24px;
  backdrop-filter: blur(12px) saturate(140%);
  background: var(--glass-2);
  border-top: 1px solid var(--glass-br);
  padding-bottom: var(--safe-bottom); /* keeps content above iOS home bar */
}
.site-footer .container{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding: 12px;
}
.site-footer a{ color:inherit; text-decoration:none; }
.site-footer a:hover{ text-decoration:underline; }

/* 5) Reusable UI bits */
.card{
  background: var(--glass-2);
  border: 1px solid var(--glass-br);
  border-radius: 20px;
  box-shadow: var(--shadow-1);
}
.btn{
  --pad: 10px 14px;
  display:inline-flex; align-items:center; gap:8px;
  padding: var(--pad); color:#fff; font-weight:600; border:0; border-radius:14px;
  background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,.14));
  border:1px solid var(--glass-br);
  cursor:pointer; box-shadow: var(--shadow-1);
  min-height: 40px;
}
.btn.ghost{ background: rgba(255,255,255,.10); }
.btn.xs{ --pad: 6px 10px; font-size:12px; min-height: 32px; }
.input{
  width:100%; padding:10px 12px; border-radius:12px; color:#fff;
  background: rgba(255,255,255,.18); border:1px solid var(--glass-br);
}
.badge{
  display:inline-block; padding:4px 8px; border-radius:10px;
  background: rgba(255,255,255,.20); border:1px solid var(--glass-br);
  font-size:12px;
}

/* 6) Mobile layout */
@media (max-width: 960px){
  .nav-toggle{ display:inline-flex; }

  .main-nav{
    position: fixed;
    right: 12px; left: 12px;
    top: calc(var(--nav-height) + var(--safe-top) + 10px); /* below safe area */
    display:block; padding:10px; border-radius:16px;
    background: var(--glass-2); border:1px solid var(--glass-br);
    transform: translateY(-8px); opacity:0; pointer-events:none;
    transition: transform .18s ease, opacity .18s ease;
  }
  .main-nav a{ display:flex; padding:10px 12px; margin:6px 0; }
  .nav-switch:checked ~ .nav-toggle + .main-nav{
    transform: translateY(0); opacity:1; pointer-events:auto;
  }
}

/* 7) Material Symbols baseline fix */
.material-symbols-outlined{
  font-variation-settings: 'FILL' 0,'wght' 400,'GRAD' 0,'opsz' 24;
  vertical-align: middle;
}

/* Selects (dark theme friendly) */
.store-mini,
.store-select select {
  background: var(--surface, rgba(255,255,255,0.08));
  color: var(--text, #eee);
  border: 1px solid rgba(255,255,255,0.15);
}
.store-mini option { color: #111; } /* options render in native popup */

/* 8) Defensive: hidden overlays shouldn't block header taps */
#scanTop[hidden],
#bindWrap:not(.show),
#toast:not(.show){
  pointer-events: none;
}

/* Make the gradient cover the whole page (fix bottom banding) */
html{
  min-height: 100%;
  background: var(--bg);            /* uses your theme's --bg (incl. midnight) */
  background-attachment: fixed;     /* optional: keeps it smooth while scrolling */
}

body{
  min-height: 100%;
  background: transparent;          /* let html's gradient show through */
}

/* === Mobile menu readability + backdrop (overwrite) === */
@media (max-width: 960px){
  /* keep header above the page */
  .site-header{ z-index: 1000; }

  /* the hamburger button sits above the menu & hosts the backdrop */
  .nav-toggle{
    position: relative;
    z-index: 1002; /* above the panel so it stays tappable */
  }

  /* the dropdown panel */
  .main-nav{
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    left: 12px; right: 12px;

    padding: 8px;
    border-radius: 16px;
    z-index: 1001;

    /* darker glass so text is readable */
    background: rgba(11,18,32,.92);
    color: #fff;
    border: 1px solid rgba(255,255,255,.18);
    box-shadow: 0 16px 60px rgba(0,0,0,.5);
    backdrop-filter: blur(16px);

    /* initial hidden state (same behavior as before) */
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform .18s ease, opacity .18s ease;
  }
  .main-nav a{
    color:#fff;
    display:flex;
    padding:10px 12px;
    margin:6px 0;
    border-radius:12px;
    font-weight:600;
  }
  .main-nav a:hover{ background: rgba(255,255,255,.08); }

  /* show the panel when the checkbox is checked */
  .nav-switch:checked ~ .nav-toggle + .main-nav{
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* full-screen dimmer; click anywhere to close (label toggles the checkbox) */
  .nav-toggle::after{
    content:"";
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }
  .nav-switch:checked + .nav-toggle::after{
    opacity: 1;
    pointer-events: auto; /* captures taps so the label toggles off */
  }
}

/* iOS anti-zoom */
@supports (-webkit-touch-callout: none){
  input, select, textarea { font-size:16px !important; min-height:44px; }
  .gro-btn { font-size:16px; padding:12px 16px; }
}
/* ensure the mobile submenu button is visible everywhere (safe) */
.gro-item [data-act="more"]{ display:inline-flex !important; }

/* --- Mobile menu tap-fix (header overlap) --- */
@media (max-width: 960px){
  /* put the dropdown ABOVE the sticky header */
  .main-nav{
    position: fixed;
    left: 12px;
    right: 12px;
    /* account for notch + header height */
    top: calc(env(safe-area-inset-top, 0px) + var(--nav-height) + 8px);
    z-index: 1001;                 /* higher than .site-header (z:50) */
    max-height: calc(100dvh - var(--nav-height) - env(safe-area-inset-top, 0px) - 24px);
    overflow: auto;                 /* scroll if long */
  }

  /* while menu is open, don't let the hamburger block taps */
  .nav-switch:checked ~ .nav-toggle{
    pointer-events: none;
    opacity: .65;
  }
}

