/* ============================================================================
   FROOTCITY — GLASS SYSTEM + RESET + LAYOUT PRIMITIVES
   Glass is applied where depth carries meaning: floating chrome, sheets,
   overlays and cards that sit above a living background. Never decoration.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: var(--fc-font-sans);
  font-size: var(--fc-t-md);
  line-height: var(--fc-lh-base);
  color: var(--txt-1);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1,h2,h3,h4,h5,p,figure { margin: 0; }
table { border-collapse: collapse; width: 100%; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
::selection { background: var(--fc-green-200); color: var(--fc-ink-900); }
[data-surface="night"] ::selection { background: var(--fc-green-800); color: #fff; }

/* Focus — visible, never removed */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--fc-r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* Scrollbars */
.scroll, .fc-scroll { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.scroll::-webkit-scrollbar, .fc-scroll::-webkit-scrollbar { width: 7px; height: 7px; }
.scroll::-webkit-scrollbar-thumb, .fc-scroll::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 99px;
}
.no-bar::-webkit-scrollbar { display: none; }
.no-bar { scrollbar-width: none; -ms-overflow-style: none; }

/* ---------------------------------------------------------------- GLASS -- */
.glass {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--glass-shadow);
  border-radius: var(--fc-r-lg);
  position: relative;
}
/* Specular top edge — what makes glass read as glass */
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.55) 0%, rgba(255,255,255,0) 42%);
  opacity: .8; mix-blend-mode: overlay;
}
[data-surface="night"] .glass::before {
  background: linear-gradient(180deg, rgba(255,255,255,.14) 0%, rgba(255,255,255,0) 46%);
  mix-blend-mode: normal;
}
.glass-soft { background: var(--glass-fill-soft); box-shadow: none; border-color: var(--glass-stroke-lo); }
.glass-hard { background: var(--glass-fill-hard); }
.glass-lg   { box-shadow: var(--glass-shadow-lg); }
.glass-flat::before { display: none; }
.no-blur { -webkit-backdrop-filter: none; backdrop-filter: none; }

/* Progressive enhancement: if no backdrop-filter, fall back to opaque */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .tbl th { background: var(--glass-fill-hard); }
  [data-surface="night"] .glass, [data-surface="night"] .tbl th { background: #131A11; }
}
/* Low-power devices opt out of blur via body flag (set by perf probe) */
body.lite .glass, body.lite .tbl th { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-fill-hard); }
body.lite [data-surface="night"] .glass, body.lite [data-surface="night"] .tbl th { background: #141B12; }

/* -------------------------------------------------------- LIVING BACKDROP */
.fc-backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--bg-base); }
.fc-orb {
  position: absolute; border-radius: 50%; filter: blur(64px); opacity: .55;
  will-change: transform;
}
.fc-orb.a { width: 62vmax; height: 62vmax; left: -22vmax; top: -20vmax; background: var(--bg-wash-a); animation: orbA 26s ease-in-out infinite alternate; }
.fc-orb.b { width: 52vmax; height: 52vmax; right: -18vmax; top: 18vmax; background: var(--bg-wash-c); opacity: .38; animation: orbB 32s ease-in-out infinite alternate; }
.fc-orb.c { width: 46vmax; height: 46vmax; left: 12vmax; bottom: -22vmax; background: var(--bg-wash-b); animation: orbC 29s ease-in-out infinite alternate; }
@keyframes orbA { to { transform: translate3d(9vmax, 6vmax, 0) scale(1.14); } }
@keyframes orbB { to { transform: translate3d(-8vmax, 10vmax, 0) scale(1.09); } }
@keyframes orbC { to { transform: translate3d(7vmax, -9vmax, 0) scale(1.12); } }
body.lite .fc-orb { animation: none; }
/* Fine grain — kills banding in the blurred washes */
.fc-grain {
  position: absolute; inset: -50%; opacity: .5; pointer-events: none;
  background-image: var(--grain-url); background-size: 180px 180px;
}
[data-surface="night"] .fc-grain { opacity: .22; }

/* ------------------------------------------------------------- APP SHELL */
#fc-root { position: relative; z-index: 1; height: 100dvh; overflow: hidden; }

.shell {
  position: relative; width: 100%; max-width: var(--fc-shell-max);
  margin: 0 auto; height: 100%;
  display: flex; flex-direction: column;
}
.shell--wide { max-width: 1600px; }
.shell--mid  { max-width: 1180px; }

/* Device frame for desktop presentation of phone apps */
@media (min-width: 900px) {
  body.framed .shell:not(.shell--wide):not(.shell--mid) {
    max-width: 420px; height: min(900px, calc(100dvh - 48px));
    margin: 24px auto; border-radius: 46px; overflow: hidden;
    border: 1px solid var(--glass-stroke);
    box-shadow: var(--glass-shadow-lg), 0 0 0 10px rgba(0,0,0,.16);
    background: linear-gradient(180deg, var(--glass-fill-soft), transparent);
  }
}

/* Content column */
.page { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.page-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.pad   { padding: 0 var(--fc-s-4); }
.pad-t { padding-top: var(--fc-s-4); }
.pad-b { padding-bottom: var(--fc-s-4); }
.stack > * + * { margin-top: var(--fc-s-3); }
.stack-sm > * + * { margin-top: var(--fc-s-2); }
.stack-lg > * + * { margin-top: var(--fc-s-6); }
.row { display: flex; align-items: center; gap: var(--fc-s-3); }
.row-b { display: flex; align-items: center; justify-content: space-between; gap: var(--fc-s-3); }
/* Flex children default to min-width:auto and refuse to shrink below their
   content, which pushes a fixed-width control out of the row instead. The
   two declarations belong together: min-width:0 alone lets the box shrink
   while the TEXT keeps its width and spills — that swap turned one clipped
   button into ten spilled labels across the admin and command decks. */
.row-b > * { min-width: 0; overflow-wrap: anywhere; }
.row-t { display: flex; align-items: flex-start; gap: var(--fc-s-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { display: grid; place-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--fc-s-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--fc-s-3); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--fc-s-2); }
.grid-auto { display: grid; gap: var(--fc-s-3); grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.grid-kpi  { display: grid; gap: var(--fc-s-3); grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }

/* Smallest supported phone (320 × 568). Columns step down rather than crush:
   a 3-up grid at 320px leaves 88px per cell, which is below a usable tile. */
@media (max-width: 359px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
  .grid-kpi { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .rail--md { grid-auto-columns: 142px; }
  .rail--lg { grid-auto-columns: 200px; }
  :root { --fc-s-4: 12px; }          /* tighter gutter, still on the 4pt grid */
}
/* Large phones get a fourth product column instead of stretched cards. */
@media (min-width: 414px) {
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
}

/* Horizontal rails (Blinkit/Zepto-grade merch surfaces) */
.rail {
  display: grid; grid-auto-flow: column; gap: var(--fc-s-3);
  overflow-x: auto; scroll-snap-type: x proximity;
  padding: var(--fc-s-1) var(--fc-s-4) var(--fc-s-2);
  margin: 0 calc(var(--fc-s-4) * -1);
  scroll-padding-left: var(--fc-s-4);
}
.rail > * { scroll-snap-align: start; }
.rail--sm { grid-auto-columns: 108px; }
.rail--md { grid-auto-columns: 158px; }
.rail--lg { grid-auto-columns: 232px; }
.rail--xl { grid-auto-columns: 84%; }

/* Text utilities */
.t-2xs{font-size:var(--fc-t-2xs)} .t-xs{font-size:var(--fc-t-xs)} .t-sm{font-size:var(--fc-t-sm)}
.t-md{font-size:var(--fc-t-md)} .t-lg{font-size:var(--fc-t-lg)} .t-xl{font-size:var(--fc-t-xl)}
.t-2xl{font-size:var(--fc-t-2xl)} .t-3xl{font-size:var(--fc-t-3xl)} .t-4xl{font-size:var(--fc-t-4xl)}
.w-m{font-weight:var(--fc-w-medium)} .w-s{font-weight:var(--fc-w-semi)} .w-b{font-weight:var(--fc-w-bold)}
.c-1{color:var(--txt-1)} .c-2{color:var(--txt-2)} .c-3{color:var(--txt-3)}
.c-acc{color:var(--accent)} .c-danger{color:var(--fc-danger)} .c-ok{color:var(--fc-success)}
.c-warn{color:var(--fc-warn)} .c-prem{color:var(--fc-premium)}
.serif { font-family: var(--fc-font-display); letter-spacing: -.01em; }
.mono { font-family: var(--fc-font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.up { text-transform: uppercase; letter-spacing: .09em; }
.tight { line-height: var(--fc-lh-tight); }
.snug { line-height: var(--fc-lh-snug); }
.ta-c { text-align: center; } .ta-r { text-align: right; }
.clamp-1 { display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; overflow:hidden; min-width:0; word-break:break-word; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.clamp-2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.clamp-3 { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.strike { text-decoration: line-through; }
.hide { display: none !important; }
.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;
}
.pointer { cursor: pointer; }
.mt-0{margin-top: 0!important} .mt-1{margin-top: var(--fc-s-1)} .mt-2{margin-top: var(--fc-s-2)}
.mt-3{margin-top: var(--fc-s-3)} .mt-4{margin-top: var(--fc-s-4)} .mt-5{margin-top: var(--fc-s-5)}
.mt-6{margin-top: var(--fc-s-6)} .mt-7{margin-top: var(--fc-s-7)}
.mb-2{margin-bottom: var(--fc-s-2)} .mb-3{margin-bottom: var(--fc-s-3)} .mb-4{margin-bottom: var(--fc-s-4)}
.gap-1{gap: var(--fc-s-1)} .gap-2{gap: var(--fc-s-2)} .gap-4{gap: var(--fc-s-4)} .gap-6{gap: var(--fc-s-6)}
.rel { position: relative; }
.full { width: 100%; }
.divider { height:1px; background: var(--line); border:0; margin: var(--fc-s-4) 0; }
.dot-sep::before { content:"·"; margin: 0 6px; opacity:.5; }
