/* The glass look (preview, iPhone and iPad): the menus float over the page, frosted and see-through, like
   the phones' own apps. Switched on per device in Settings → Your account → Appearance (html.glass, set by
   public/js/appearance.js only on an iPhone or iPad). The work itself (calendar, notes, invoices) stays solid.
   "Reduce transparency" on the device, or a browser that can't blur, gets solid bars instead. */

html.glass {
  --glass-bg: color-mix(in srgb, var(--surface) 58%, transparent);
  --glass-bg-strong: color-mix(in srgb, var(--surface) 74%, transparent);
  --glass-edge: rgba(255, 255, 255, .55);
  --glass-line: rgba(16, 24, 40, .08);
  --glass-shadow: 0 10px 30px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .08);
  --glass-blur: blur(22px) saturate(1.8);
  --glass-lens: color-mix(in srgb, var(--surface) 70%, rgba(255, 255, 255, .5));
}
@media (prefers-color-scheme: dark) {
  html.glass:not([data-theme="light"]) { --glass-edge: rgba(255, 255, 255, .14); --glass-line: rgba(255, 255, 255, .06); --glass-shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3); --glass-lens: color-mix(in srgb, var(--surface-2) 75%, rgba(255, 255, 255, .12)); }
}
html.glass[data-theme="dark"] { --glass-edge: rgba(255, 255, 255, .14); --glass-line: rgba(255, 255, 255, .06); --glass-shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3); --glass-lens: color-mix(in srgb, var(--surface-2) 75%, rgba(255, 255, 255, .12)); }

/* A soft wash of the accent colour behind everything, so the glass has something to show through. */
html.glass body {
  background:
    radial-gradient(60vmax 50vmax at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(50vmax 45vmax at 0% 100%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* The shared glass: frosted, with a bright top edge like a lens. */
html.glass .sidebar, html.glass .more-sheet, html.glass dialog {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 var(--glass-edge), var(--glass-shadow);
}
html.glass dialog, html.glass .more-sheet { background: var(--glass-bg-strong); border-radius: 22px; }
html.glass dialog::backdrop, html.glass .more-backdrop { background: rgba(10, 12, 16, .22); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* iPad: the menu is a floating glass panel down the side. */
@media (min-width: 821px) {
  html.glass .sidebar {
    top: 12px;
    height: calc(100vh - 24px);
    margin: 12px 0 12px 12px;
    border-radius: 24px;
  }
  html.glass .nav a.active { background: var(--glass-lens); box-shadow: inset 0 1px 0 var(--glass-edge), 0 1px 3px rgba(16, 24, 40, .1); color: var(--text); }
  html.glass .nav a.active svg { color: var(--accent); }
  html.glass .sidebar .me { border-top-color: var(--glass-line); }
}

/* iPhone: the bottom bar stays at the bottom of the screen (the user's choice, 2026-12-04), frosted, with the open
   tab in a lens; the page shows softly through it as it scrolls. */
@media (max-width: 820px) {
  html.glass .sidebar {
    border-width: 1px 0 0;
    border-radius: 0;
    box-shadow: inset 0 1px 0 var(--glass-edge), 0 -4px 18px rgba(16, 24, 40, .06);
  }
  html.glass .nav a, html.glass .nav-more { border-radius: 22px; }
  html.glass .nav a.active, html.glass .nav-more.active, html.glass .nav-more[aria-expanded="true"] {
    background: var(--glass-lens); color: var(--accent);
    box-shadow: inset 0 1px 0 var(--glass-edge), 0 1px 3px rgba(16, 24, 40, .12);
  }
}

/* A colour chosen for the menu (Appearance → Menu colour) tints the glass rather than covering it. */
html.glass.menu-tinted .sidebar { background: color-mix(in srgb, var(--menu-bg) 72%, transparent); }

/* Solid instead: the device asks for less transparency, or can't blur. */
@media (prefers-reduced-transparency: reduce) {
  html.glass .sidebar, html.glass .more-sheet, html.glass dialog { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
  html.glass.menu-tinted .sidebar { background: var(--menu-bg); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html.glass .sidebar, html.glass .more-sheet, html.glass dialog { background: var(--surface); }
}
