/* Web app additions on top of the desktop app's style.css. */

/* Versions… is for files in the vault (it keeps their earlier versions). */
.menu.ctx.outside .vault-only { display: none; }

/* Access, vault and other messages: a bar at the bottom of the window. */
.kk-banner {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1000;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: min(640px, calc(100vw - 32px)); padding: 10px 12px 10px 16px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.kk-banner span { flex: 1 1 260px; line-height: 1.4; }
.kk-banner .btn { flex: none; }

/* Unpin needs two clicks: the first turns the × into a red "Unpin" pill whose
   bar runs out (3 s, as UNPIN_ARM_MS in main.js); clicking it again unpins. */
.pins .unpin { position: relative; overflow: hidden; gap: 4px; grid-auto-flow: column; transition: background .15s, color .15s, padding .15s; }
.pins .unpin span { display: none; font-size: 11.5px; font-weight: 600; line-height: 1; }
.pins li.armed .unpin { visibility: visible; }
.pins .unpin.armed { padding: 3px 8px 4px 6px; color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); animation: unpin-pop .18s ease-out; }
.pins .unpin.armed span { display: inline; }
.pins .unpin.armed::after, #ctx-pin.armed::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--danger);
  transform-origin: left; animation: unpin-count 3s linear forwards;
}
.pins li.armed { box-shadow: inset 2px 0 0 var(--danger); }
.pins li.leaving { animation: unpin-leave .18s ease-in forwards; }
#ctx-pin { position: relative; overflow: hidden; }
#ctx-pin.armed { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
@keyframes unpin-count { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes unpin-pop { from { transform: scale(.85); } }
@keyframes unpin-leave { to { opacity: 0; transform: translateX(-12px); } }
@media (prefers-reduced-motion: reduce) {
  .pins .unpin.armed, .pins li.leaving { animation: none; }
}

/* ---------- Trash screen ---------- */
#kk-trash {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: start center; padding-top: 12vh;
  background: var(--backdrop); animation: fade .12s ease-out;
}
#kk-trash[hidden] { display: none; }
.kk-trash-card {
  width: min(600px, calc(100vw - 32px)); max-height: 72vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .15s ease-out; overflow: hidden;
}
.kk-trash-card header { display: flex; align-items: center; gap: 8px; padding: 14px 12px 0 18px; }
.kk-trash-card header > .i { width: 18px; height: 18px; color: var(--text-2); }
.kk-trash-card h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.kk-trash-card header .count { margin: 0; padding: 0; background: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kk-trash-close { margin-left: auto; }
.kk-trash-hint { margin: 6px 18px 12px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.kk-trash-hint code { font-size: 11.5px; }
.kk-trash-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; min-height: 0; border-top: 1px solid var(--border); }
.kk-trash-list li[data-name] {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; margin: 4px 0;
  transition: background .12s;
}
.kk-trash-list li[data-name]:hover { background: var(--hover); }
.kk-trash-list .kind { width: 16px; height: 16px; flex: none; color: var(--muted); }
.kk-trash-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kk-trash-text b { font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kk-trash-text small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kk-trash-list .btn { display: inline-flex; align-items: center; gap: 5px; flex: none; }
.kk-trash-list .btn .i { width: 13px; height: 13px; }
.kk-trash-list .kk-forever { padding: 0 7px; color: var(--muted); }
.kk-trash-list .kk-forever span:empty { display: none; }
.kk-trash-list li.leaving { animation: unpin-leave .18s ease-in forwards; }
.kk-trash-none { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 0 30px; color: var(--muted); font-size: 13px; }
.kk-trash-none .i { width: 28px; height: 28px; opacity: .6; }
.kk-trash-card footer { display: flex; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); }
.kk-empty { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); }
.kk-empty .i { width: 14px; height: 14px; }
.kk-empty:disabled { opacity: .4; cursor: default; }

/* Versions… (same card as the Trash screen) */
#kk-versions {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: start center; padding-top: 10vh;
  background: var(--backdrop); animation: fade .12s ease-out;
}
#kk-versions .kk-trash-list li.active { background: var(--active); }
.kk-version-preview {
  margin: 0; max-height: 30vh; overflow: auto; padding: 12px 16px; border-top: 1px solid var(--border);
  font: 12.5px/1.5 var(--mono, ui-monospace, monospace); color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Two-click delete (as for unpin): armed = red, with a bar that runs out in 3 s. */
.kk-trash-card .btn.armed { position: relative; overflow: hidden; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 14%, transparent); animation: unpin-pop .18s ease-out; }
.kk-trash-card .btn.armed::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--danger);
  transform-origin: left; animation: unpin-count 3s linear forwards;
}

/* ---------- phone-sized screens: the file list or the open file, one at a time ---------- */
@media (max-width: 700px) {
  #app, body.no-side #app { grid-template-columns: minmax(0, 1fr); }
  #sidebar { display: none; }
  body.show-list #sidebar {
    display: flex; visibility: visible; position: fixed; inset: 0; z-index: 30; width: 100%; border-right: 0;
  }
  /* What a phone has no use for: keyboard shortcut hints, the page strip and picture details column. */
  .shortcuts, #search-box kbd, #toggle-panel, #pdf-pages, #panel, #doc-zoom { display: none !important; }
  #topbar { padding: 0 6px; gap: 4px; }
  #title { font-size: 16px; }
  .seg#mode-seg button { padding: 0 8px; font-size: 0; gap: 0; }
  .seg#mode-seg button .i { width: 16px; height: 16px; }
  #image-btn { display: none; }
  #note-save, #media-save { height: 32px; padding: 0 14px; font-size: 14px; }
  #media-scroll { padding: 12px 8px 96px; }
  .kk-banner { bottom: 10px; }
  .kk-trash-card { max-height: 84vh; }
  #kk-versions, #kk-trash { padding-top: 6vh; }
}
/* Touch screens: bigger targets in the file list. */
@media (pointer: coarse) {
  #note-list li[data-path], #pin-list li[data-path] { min-height: 40px; }
}

/* pdf.js measures text on a canvas it adds to the page: keep it out of the layout, or the page grows
   past the window and the whole app shifts up (under the title bar) when a PDF page is scrolled to. */
.hiddenCanvasElement { position: absolute; top: 0; left: 0; width: 0; height: 0; display: none; }
/* The app never scrolls as a whole (only its panes do), not even when something asks it to. */
html, body { overflow: clip; }

/* Installed app on a computer: no title bar (the manifest's window-controls-overlay). The app's top
   bars take its place: they move the window (drag) and keep clear of the window buttons. */
@media (display-mode: window-controls-overlay) {
  .side-top, #topbar { app-region: drag; -webkit-app-region: drag; }
  .side-top :is(button, input, a, .seg), #topbar :is(button, input, a, .seg, select) { app-region: no-drag; -webkit-app-region: no-drag; }
  /* The window buttons sit at the top right (on a Mac, at the top left). */
  #topbar { padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 6px); }
  .side-top { padding-left: calc(16px + env(titlebar-area-x, 0px)); }
  body.no-side #topbar { padding-left: calc(10px + env(titlebar-area-x, 0px)); }
  /* The name fits its text, so the rest of the bar is free to drag the window by. */
  #title { flex: 0 1 auto; field-sizing: content; min-width: 4ch; max-width: 60%; }
  #status { flex: 1; min-width: 12px; align-self: stretch; display: flex; align-items: center; }
}

/* Several files opened from this computer: a list, not a folder (nothing to create in it). */
body.browsing-set #new-folder-btn { display: none; }
