/* Nestabo Budget PWA: the full Liquid Glass layer (v26). Loaded after the app's own style, only by the PWA (Apps Script
   keeps serving frontend.html as it is). Glass stays on chrome only: header, floating bars, sheets, dialogs, banners.
   Rows and amounts stay on the solid --surface list. Solid first; glass inside @supports; reduced transparency,
   higher contrast and reduced motion honoured; light and dark. */

:root {
  /* a soft, low-saturation colour field so the glass has something to frost (never behind rows: they are solid) */
  --backdrop:
    radial-gradient(90% 50% at 12% 0%, rgba(120, 150, 230, 0.30), transparent 65%),
    radial-gradient(80% 45% at 95% 12%, rgba(240, 175, 150, 0.24), transparent 62%),
    radial-gradient(90% 55% at 50% 100%, rgba(140, 205, 190, 0.22), transparent 66%),
    radial-gradient(70% 40% at 0% 70%, rgba(190, 160, 235, 0.16), transparent 60%);
  /* tints sized so text stays at 4.5:1 even over a black row scrolling underneath (contrast audit: tools/contrast.js) */
  --g-tint: rgba(255, 255, 255, 0.56);
  --g-tint-sheet: rgba(250, 250, 252, 0.92);   /* sheets: iOS thick material, text behind is unreadable */
  --g-tint-bar: rgba(249, 249, 251, 0.80);
  --label-2-glass: #48484A;            /* secondary text on glass */
  --g-spec: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 42%);
  --g-depth: 0 0.5px 1px rgba(0, 0, 0, 0.06), 0 12px 36px -10px rgba(30, 40, 80, 0.22), 0 2px 8px -2px rgba(30, 40, 80, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --backdrop:
      radial-gradient(90% 50% at 12% 0%, rgba(70, 95, 170, 0.42), transparent 65%),
      radial-gradient(80% 45% at 95% 12%, rgba(150, 90, 80, 0.26), transparent 62%),
      radial-gradient(90% 55% at 50% 100%, rgba(50, 120, 110, 0.26), transparent 66%),
      radial-gradient(70% 40% at 0% 70%, rgba(110, 80, 160, 0.22), transparent 60%);
    --g-tint: rgba(30, 30, 34, 0.68);
    --g-tint-sheet: rgba(28, 28, 30, 0.92);
    --g-tint-bar: rgba(20, 20, 24, 0.80);
    --label-2-glass: #C7C7CC;
    --g-spec: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 40%);
    --g-depth: 0 0.5px 1px rgba(0, 0, 0, 0.6), 0 14px 40px -10px rgba(0, 0, 0, 0.75), 0 2px 8px -2px rgba(0, 0, 0, 0.5);
  }
}

/* the colour field: fixed behind everything, full viewport (replaces the top-only glow) */
html { background: var(--bg); }
body { background: transparent; }
body::before {
  content: ''; position: fixed; inset: 0; height: auto; z-index: -1; pointer-events: none;
  background: var(--backdrop), var(--bg);
}

/* depth and the specular top highlight on every glass surface */
.glass { box-shadow: var(--g-depth), 0 0 0 0.5px var(--g-edge), inset 0 1px 0 var(--g-rim), inset 0 -0.5px 0 var(--g-rim-low); }
.glass::before { background: var(--g-spec); }
header.glass { box-shadow: 0 0.5px 0 var(--separator); }

/* secondary text on glass chrome */
.glass p, .glass small, .glass .subtitle, header.glass p, .glass--sheet p, .glass--sheet label { color: var(--label-2-glass); }

/* rows and amounts: solid surfaces (data is for reading) */
.transaction-list, .list, .budget-card, .card { background: var(--surface); }

/* PWA dialogs and banners use the same glass */
#fb-signin { background: transparent; }
#fb-signin::before { content: ''; position: fixed; inset: 0; z-index: -1; background: var(--backdrop), var(--bg); }
#fb-signin .fb-card, #fb-offline { border: 0; }
/* The Google button is a cross-origin iframe: with the page's `light dark` scheme it paints an opaque white canvas in dark mode. */
#fb-signin-button, #fb-signin-button iframe { color-scheme: light; background: transparent; }
#fb-signin-button { align-items: center; }

/* standalone on iPhone: notch, rounded corners and home indicator */
@media (display-mode: standalone) {
  header.glass { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  main, .main, .content { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
#fb-signin { padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }

/* reduced transparency / more contrast: solid chrome, no colour field */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  body::before, #fb-signin::before { background: var(--bg); }
  #fb-signin .fb-card, #fb-offline { background: var(--g-solid) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}
html.no-glass .glass, html.no-glass .glass--sheet, html.no-glass #fb-signin .fb-card, html.no-glass #fb-offline {
  background: var(--g-solid) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
html.no-glass body::before { background: var(--bg); }
html.no-glass .glass::before, html.no-glass .glass::after { display: none; }

@media (prefers-reduced-motion: reduce) {
  .glass, .bottom-sheet, #fb-offline { transition: none !important; }
}

/* picker wheel: the rows next to the selected one stay readable (AA) on the sheet */
.glass--sheet .wheel-item { color: var(--label-2-glass); }
.glass--sheet .wheel-item.selected { color: var(--label); }

/* filled and secondary buttons on sheets: AA in both modes (white on the dark-mode blue #409CFF is only 2.8:1) */
.glass--sheet .sheet-secondary-btn { background: var(--surface); }
@media (prefers-color-scheme: dark) {
  :root { --blue-fill: #0A6AD6; }
  .sheet-cta-btn:not(.is-danger), #wiz-next, .rec-freq button[aria-checked="true"] { background: var(--blue-fill); color: #FFFFFF; }
}

/* ===== v26b: large-title header with the brand mark; refresh lives here now (no bottom bar) ===== */
header.glass.fb-header {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(60px + max(8px, env(safe-area-inset-top)));
  padding-top: max(8px, env(safe-area-inset-top));
}
.fb-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.fb-mark { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 4px 12px -4px rgba(30, 40, 80, 0.35); }
header.fb-header h1 {
  font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.022em; line-height: 1.15;
  color: var(--label);
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  header.fb-header h1 {
    /* a quiet brand tint: label colour into a deep blue, dark enough for AA on the bar in both modes */
    background: linear-gradient(100deg, var(--label) 30%, var(--fb-title-end, #1F4FB8));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  }
}
@media (prefers-color-scheme: dark) { :root { --fb-title-end: #8DB8FF; } }
@media (prefers-contrast: more) { header.fb-header h1 { background: none; -webkit-text-fill-color: currentColor; } }
.fb-refresh { flex-shrink: 0; width: 44px; height: 44px; }
/* the bottom bar is gone: give the list its space back and drop the toast / offline banner to the bottom */
.container { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.toast { bottom: max(16px, env(safe-area-inset-bottom)); }
body.in-wizard .container { padding-bottom: 190px; }
body.in-wizard .toast { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 140px); }
#fb-offline { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 56px) !important; }

/* ===== v26b: swipe down to close sheets ===== */
.bottom-sheet { touch-action: pan-y; }
.bottom-sheet.is-dragging, .overlay.is-dragging { transition: none !important; }
.sheet-handle { width: 40px; cursor: grab; }

/* v26b: sheets are a thick material (stronger blur over a 92% tint); the solid fallback stays from the base style */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass--sheet { -webkit-backdrop-filter: blur(50px) saturate(160%); backdrop-filter: blur(50px) saturate(160%); }
}
.overlay.is-dragging { background: color-mix(in srgb, var(--scrim) var(--fb-scrim-k, 100%), transparent); }
.glass--sheet .split-status:not(.is-error) { color: var(--label-2-glass); }   /* AA over the worst case behind the sheet */
@media (prefers-color-scheme: light) { .glass--sheet .split-status.is-error { color: #B5000F; } }   /* #D70015 is 4.3:1 over the worst case */
