/* glass.css — meanbrian Liquid Glass for tinyfiles: the floating layer only (tab bar, round buttons, sheets,
   pop-ups, menus, toast). Content stays solid (styles.css). Tokens from the design system's theme block. */

/* ---------- tokens ---------- */
:root {
  --glass: rgba(255, 255, 255, .66); --glass-hi: rgba(255, 255, 255, .95);
  --glass-sh: 0 8px 28px rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .08);
  --glass-blur: blur(24px) saturate(180%); --pill: rgba(0, 0, 0, .07); --glass-menu: rgba(250, 250, 250, .86);
  --menu-sh: 0 16px 48px rgba(0, 0, 0, .28);
  --r-sheet: 38px; --r-sheet-wide: 28px; --r-bar: 32px;
  --btn: 44px; --sheet-inset: 6px;
  --ease: cubic-bezier(.32, .72, 0, 1); --ease-io: cubic-bezier(.65, 0, .35, 1); --t-sheet: .38s;
  /* floating buttons sit 12px above the bar; these are how far they drop when the bar shrinks to its pill */
  --fab-bottom: calc(82px + env(safe-area-inset-bottom)); --fab-drop: 76px; --up-drop: 30px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --glass: rgba(120, 120, 128, .26); --glass-hi: rgba(255, 255, 255, .28); --glass-sh: 0 8px 28px rgba(0, 0, 0, .5); --pill: rgba(255, 255, 255, .14); --glass-menu: rgba(44, 44, 48, .86); }
}
:root[data-theme="dark"] { --glass: rgba(120, 120, 128, .26); --glass-hi: rgba(255, 255, 255, .28); --glass-sh: 0 8px 28px rgba(0, 0, 0, .5); --pill: rgba(255, 255, 255, .14); --glass-menu: rgba(44, 44, 48, .86); }

/* the glass recipe */
.glass, .gbtn, .tabbar::before, #toast {
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 rgba(255, 255, 255, .05), var(--glass-sh);
}

/* ---------- round glass buttons: ✕ ✓ ‹ ＋ ⋯ ⌃ ---------- */
.gbtn {
  width: var(--btn); height: var(--btn); border-radius: 50%; border: 0; padding: 0; flex: none;
  display: grid; place-items: center; color: var(--ink); cursor: pointer; text-decoration: none;
  transition: transform .15s, background-color .2s, opacity .2s;
}
.gbtn svg { width: 20px; height: 20px; }
.gbtn:active { transform: scale(.94); }
.gbtn.red { color: var(--red); }
.gbtn.done { opacity: .55; cursor: default; }
.gbtn.done.ready { opacity: 1; background: var(--green); color: #fff; cursor: pointer; }

/* ---------- tab bar: a floating capsule that shrinks to a pill on a steady scroll down ---------- */
.tabbar {
  position: fixed; z-index: 20; display: flex; padding: 6px; border-radius: var(--r-bar); isolation: isolate;
  left: max(14px, calc(50% - 260px)); right: max(14px, calc(50% - 260px)); bottom: calc(10px + env(safe-area-inset-bottom));
}
/* the glass lives on a layer behind the tabs, so it can fade away on its own */
.tabbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  transition: opacity .5s var(--ease-io), transform .5s var(--ease-io);
}
.tab {
  position: relative; isolation: isolate; flex: 1; display: grid; justify-items: center; gap: 2px; padding: 4px 0;
  border: 0; background: none; color: var(--ink); text-decoration: none; cursor: pointer; font: inherit;
  transition: transform .5s var(--ease-io), opacity .36s var(--ease-io);
}
.tab::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 22px;
  transition: transform .5s var(--ease-io), background-color .5s var(--ease-io), border-radius .5s, box-shadow .5s;
}
.tab.on::before { background: var(--pill); }
.tab-ic { display: grid; place-items: center; height: 24px; transition: transform .5s var(--ease-io), opacity .36s var(--ease-io); }
.tab-ic svg { width: 24px; height: 24px; }
.tab-label { font-size: 10.5px; line-height: 13px; font-weight: 600; transition: transform .5s var(--ease-io), opacity .36s var(--ease-io); }
.tab.on .tab-ic, .tab.on .tab-label { color: var(--accent-fg); }
.tabbar::before, .tab, .tab::before, .tab-ic { will-change: transform, opacity; }
/* small: the bar's glass fades, other tabs fade, the current tab slides to the middle as a pill (--dx/--sx from glass.js) */
html.tabs-small .tabbar::before { opacity: 0; transform: scale(.9); }
html.tabs-small .tab:not(.on) { opacity: 0; transform: scale(.8); pointer-events: none; }
html.tabs-small .tab.on { transform: translate(var(--dx, 0px), 12px); }
html.tabs-small .tab.on::before { transform: scale(var(--sx, .6), .62); border-radius: calc(18px / var(--sx, .6)) / 29px; background: var(--glass-menu); box-shadow: var(--glass-sh); }
html.tabs-small .tab.on .tab-ic { transform: translateY(8px) scale(.78); }
html.tabs-small .tab .tab-label { opacity: 0; transform: translateY(4px); }
/* scroll edge: content fades out under the floating bar */
body::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; pointer-events: none;
  height: calc(96px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg) 85%, transparent) 60%);
}
html.kb-open .tabbar, html.kb-open body::after { display: none; }

/* ---------- floating ⌃ (centre) and ＋ (right), riding with the tab bar ---------- */
.fab-up, .fab-add {
  position: fixed; z-index: 21; bottom: var(--fab-bottom); opacity: 0; pointer-events: none;
  transform: scale(.8); transition: opacity .2s, transform .5s var(--ease-io);
}
.fab-up { left: calc(50% - var(--btn) / 2); }
.fab-add { right: max(16px, calc(50% - 260px + 2px)); }
.fab-up.show, .fab-add.show { opacity: 1; pointer-events: auto; transform: none; }
html.tabs-small .fab-up { transform: translateY(var(--up-drop)) scale(.8); }
html.tabs-small .fab-up.show { transform: translateY(var(--up-drop)); }
html.tabs-small .fab-add { transform: translateY(var(--fab-drop)) scale(.8); }
html.tabs-small .fab-add.show { transform: translateY(var(--fab-drop)); }
html.kb-open .fab-up, html.kb-open .fab-add { display: none; }

/* ---------- toast: a glass capsule above the bar (Undo after a restorable delete) ---------- */
#toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--fab-bottom) + 54px); transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  color: var(--ink); padding: 11px 18px; border-radius: 999px; font-size: 15px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.show.has-undo { pointer-events: auto; }
#toast span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.toast-undo { flex: none; border: 0; background: none; color: var(--accent-fg); font: 700 15px var(--body); padding: 4px 2px; cursor: pointer; }

/* ---------- sheets: tall, inset, ✕ · title · ✓ ---------- */
dialog.sheetd {
  position: fixed; margin: 0; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible;
  width: auto; max-width: none; height: auto; max-height: none;
  top: calc(env(safe-area-inset-top) + 10px); left: var(--sheet-inset); right: var(--sheet-inset); bottom: calc(var(--sheet-inset) + var(--kb, 0px));
}
dialog.sheetd::backdrop { background: rgba(0, 0, 0, .3); animation: fade-in var(--t-sheet) var(--ease); }
.sheetd .sheet {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border-radius: var(--r-sheet); box-shadow: var(--menu-sh);
  animation: sheet-up var(--t-sheet) var(--ease); transition: transform .3s var(--ease);
}
.sheetd.closing .sheet { transform: translateY(calc(100% + 40px)); transition: transform var(--t-sheet) var(--ease); }
.sh-grab { width: 36px; height: 5px; border-radius: 3px; background: var(--ink-2); opacity: .35; margin: 7px auto 0; flex: none; touch-action: none; }
.sh-head { display: grid; grid-template-columns: var(--btn) 1fr var(--btn); align-items: center; gap: 8px; padding: 6px 12px 8px; flex: none; touch-action: none; }
.sh-title { text-align: center; min-width: 0; }
.sh-title h2 { margin: 0; font: 600 17px/22px var(--body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-title .sub { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
}
html.kb-open .sh-body { padding-bottom: 16px; }
.btn.sh-primary { display: none; } /* ✓ in the header presses it */
.btn.sh-delete { background: var(--surface); color: var(--red); border-radius: 16px; font-weight: 400; margin-top: 8px; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
/* Mac / iPad: a centered dialog that fades in */
@media (min-width: 700px) {
  dialog.sheetd { top: 50%; left: 50%; right: auto; bottom: auto; width: min(560px, 92vw); transform: translate(-50%, calc(-50% - var(--kb, 0px) / 2)); }
  .sheetd .sheet { height: auto; max-height: min(86vh, 760px); border-radius: var(--r-sheet-wide); animation: fade-in .25s ease-out; }
  .sheetd.closing .sheet { transform: none; opacity: 0; transition: opacity .25s; }
}

/* ---------- pop-ups (confirm, discard, menus): glass by the button that opened them ---------- */
dialog.popd { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; }
dialog.popd::backdrop { background: transparent; }
.pop {
  position: absolute; padding: 14px; border-radius: var(--r-control); color: var(--ink);
  background: var(--glass-menu); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--menu-sh); animation: pop-in .18s var(--ease);
}
.pop:focus { outline: none; }
@keyframes pop-in { from { opacity: 0; transform: scale(.94); } }
.pop-title { margin: 0 0 4px; font-weight: 600; font-size: 15px; }
.pop-msg { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.pop-msg .red, .red { color: var(--red); }
.pop-row { display: flex; gap: 8px; margin-top: 12px; }
.pop-btn {
  flex: 1; min-height: 44px; border: 0; border-radius: 14px; background: var(--pill); color: var(--ink);
  font: 600 15px var(--body); cursor: pointer; position: relative; overflow: hidden; padding: 0 10px;
}
.pop-btn:disabled { opacity: .45; cursor: default; }
.pop-btn.red { background: var(--red); color: #fff; }
.pop-btn.strong { background: var(--ink); color: var(--bg); }
.pop > .pop-btn { width: 100%; margin-top: 12px; }
/* Hold to Delete: fills over 1 s while held */
.pop-btn.hold { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); touch-action: none; user-select: none; -webkit-user-select: none; }
.pop-btn.hold::before { content: ""; position: absolute; inset: 0; background: var(--red); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
.pop-btn.hold.holding::before { transform: scaleX(1); transition: transform 1s linear; }
.pop-btn.hold.holding { color: #fff; }
.pop-btn.hold span { position: relative; }
.pop-type { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
/* menus */
.pop:has(> .menu) { padding: 4px 14px; }
.menu { display: grid; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px;
  border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font: 400 17px var(--body);
  text-align: left; cursor: pointer; padding: 0 2px;
}
.menu-item:last-child, .menu-item:has(+ .menu-gap) { border-bottom: 0; }
.menu-item svg { width: 20px; height: 20px; flex: none; }
.menu-item.red { color: var(--red); }
.menu-gap { height: 6px; background: var(--pill); margin: 0 -14px; }


/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  .tabbar *, .tabbar::before, .tab::before, .fab-up, .fab-add, #toast, .gbtn { transition: opacity .2s !important; }
  html.tabs-small .tab.on, html.tabs-small .tab.on::before, html.tabs-small .tab.on .tab-ic { transform: none; }
  .sheetd .sheet, dialog.sheetd::backdrop, .pop { animation: none; }
  .sheetd.closing .sheet { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .gbtn, .tabbar::before, #toast, .pop { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }
}

/* ---------- side menu (drawer.js): a panel that slides in from the left over a dim ---------- */
dialog.drawerd { position: fixed; inset: 0; margin: 0; padding: 0; border: 0; width: 100%; height: 100%; max-width: none; max-height: none; background: transparent; color: var(--ink); overflow: hidden; }
dialog.drawerd::backdrop { background: rgba(0, 0, 0, .35); animation: fade-in .25s var(--ease); }
dialog.drawerd.closing::backdrop { opacity: 0; transition: opacity .25s; }
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(78vw, 320px); display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--menu-sh, var(--glass-sh)); border-radius: 0 26px 26px 0;
  padding: calc(env(safe-area-inset-top) + 10px) 0 calc(env(safe-area-inset-bottom) + 10px);
  animation: drawer-in .3s var(--ease); transition: transform .25s var(--ease);
}
.drawerd.closing .drawer { transform: translateX(-105%); }
@keyframes drawer-in { from { transform: translateX(-100%); } }
.dr-top { display: flex; align-items: center; gap: 12px; padding: 0 16px 8px; }
.dr-brand { font: 700 20px var(--body); letter-spacing: -.01em; }
.dr-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 10px; }
.dr-h { margin: 18px 10px 6px; font: 600 13px var(--body); color: var(--ink-2); }
.dr-item { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--ink); text-decoration: none; font: 400 16px var(--body); }
.dr-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-item:active { background: var(--raised); }
.dr-item.on { background: var(--raised); font-weight: 600; }
.dr-item.on .dr-ic { color: var(--accent-fg); }
.dr-ic { width: 22px; height: 22px; flex: none; color: var(--ink-2); }
.dr-ic svg { width: 22px; height: 22px; }
.dr-foot { display: flex; align-items: center; gap: 14px; margin: 8px 10px 0; padding: 12px; border-top: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: 14px; }
.dr-foot b { color: var(--ink); font-weight: 600; }
@media (hover: hover) { .dr-item:hover { background: var(--raised); } }
@media (prefers-reduced-motion: reduce) { .drawer, dialog.drawerd::backdrop { animation: none; } }

/* ---------- "Copied" banner (lib.js notice): slides down from the top, green, then eases away ---------- */
#notice {
  position: fixed; z-index: 60; margin: 0; border: 0; inset: auto; right: auto; bottom: auto; overflow: visible; left: 50%; top: calc(env(safe-area-inset-top) + 10px);
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px 10px 14px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font: 600 15px var(--body); box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  transform: translate(-50%, -140%); opacity: 0; pointer-events: none;
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.15), opacity .25s ease;
}
#notice.show { transform: translate(-50%, 0); opacity: 1; }
#notice svg { width: 18px; height: 18px; flex: none; }
@media (prefers-reduced-motion: reduce) { #notice { transition: opacity .2s; transform: translate(-50%, 0); } }
