/* Contract: contracts/web/rules.md
 * The column view: the Finder's columns in the grid's place. web/finder.js.
 *
 * Loaded after every other generation, and only ever reaching outside its own
 * classes under body.finder or body.in-finder, so the grid layout is exactly
 * what it was when the preference says so. The rows are a size up from the
 * Finder's own (14px on 30px rather than 13 on 24): these are pointed at
 * with a trackpad by somebody who has lost work to a missed drop before,
 * which is the reason web/css/14-project-folders.css gives for its tiles.
 */

:root {
  /* The Finder's folder blue, and only for folders: the archive's own accent
     still marks what is selected and what can be pressed. */
  --folder: light-dark(#3b8be0, #5ea9f2);
  --fcol-w: 248px;
  --frow-h: 30px;
}

/* ---------- which surface is on screen ---------- */
.finder { display: none; }
body.in-finder .finder { display: flex; }
body.in-finder .results { display: none !important; }
/* The filter row and the count narrow and measure a SEARCH, and the grid is
   where a search answers. With the columns up there is nothing for them to act
   on — the same rule, for the same reason, as the three surfaces before this. */
body.in-finder #filters { display: none; }
body.in-finder #count, body.in-finder #near-matches { visibility: hidden; }
/* Every other surface replaces the columns exactly as it replaces the grid. */
body.in-requests .finder, body.in-work .finder, body.in-projects .finder { display: none !important; }
/* The grid's folder strip says what the columns already say. */
body.finder .ptree { display: none !important; }

.finder {
  min-width: 0; min-height: 0; flex-direction: column;
  background: var(--panel);
}

/* ---------- the bar above the columns ---------- */
.finder-bar {
  display: flex; align-items: center; gap: 10px; flex: none;
  height: 44px; padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.finder-nav { display: flex; gap: 2px; }
.finder-navbtn {
  width: 34px; height: 30px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-dim);
  font: 400 24px/1 ui-sans-serif, system-ui, sans-serif; cursor: pointer;
}
.finder-navbtn:hover:not(:disabled) { background: var(--panel-2); color: var(--ink); }
.finder-navbtn:disabled { opacity: .35; cursor: default; }
.finder-title {
  margin: 0 auto 0 0; min-width: 0;
  font-size: 15px; font-weight: 640;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.finder-new { height: 32px; padding: 0 12px; font-size: 13px; flex: none; }
/* The grid's pills, at home in a bar rather than floating over pictures. */
.finder-pill { margin: 0; padding: 6px 12px; box-shadow: none; flex: none; white-space: nowrap; }

/* ---------- the columns ---------- */
.finder-cols {
  flex: 1; min-height: 0;
  display: flex; overflow-x: auto; overflow-y: hidden;
  background: var(--panel);
}
.fcol {
  position: relative; flex: none; width: var(--fcol-w); min-height: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
.fcol-list {
  flex: 1; min-height: 0; position: relative;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 5px 6px 28px; outline: none;
}

.fitem {
  display: flex; align-items: center; gap: 8px;
  height: var(--frow-h); padding: 0 8px; border-radius: 6px;
  font-size: 14px; color: var(--ink); cursor: default; outline: none;
  user-select: none; -webkit-user-select: none;
}
.fitem > .fico { width: 20px; height: 20px; flex: none; color: var(--folder); opacity: 1; }
.fitem-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fitem-n { flex: none; font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.fitem-chev { flex: none; width: 10px; font-size: 17px; line-height: 1; text-align: center; color: var(--ink-dim); }
.fitem-pic {
  flex: none; width: 24px; height: 24px; overflow: hidden;
  display: grid; place-items: center;
  border-radius: 4px; background: var(--panel-2);
}
.fitem-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fitem-ico { width: 16px; height: 16px; color: var(--ink-dim); }

/* The edge a column is sized by (web/finder-resize.js), and the Finder's two
   short lines at its foot that say it can be. */
.fcol-grip { position: absolute; top: 0; bottom: 0; right: -4px; width: 8px; z-index: 2; cursor: col-resize; touch-action: none; }
.fcol-grip::after {
  content: ''; position: absolute; left: 2px; bottom: 8px; width: 2px; height: 14px;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
.fcol-grip:hover::after, body.fcol-resizing .fcol-grip::after { border-color: var(--ink-dim); }
body.fcol-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }

/* A name being renamed in place: a field on the row, whatever colour the row is. */
.fitem-name.renaming {
  background: var(--bg); color: var(--ink); outline: 2px solid var(--accent); border-radius: 3px;
  padding: 0 3px; text-overflow: clip; cursor: text; user-select: text; -webkit-user-select: text;
}

/* Lit: grey along the path, the accent in the one column where the highlight
   is live — the Finder's own two shades, which is how it shows both where you
   are and what you have chosen there without either hiding the other. */
.fitem.on, .fitem.picked { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.fcol.active .fitem.on, .fcol.active .fitem.picked { background: var(--accent); color: var(--on-accent); }
.fcol.active .fitem.on > .fico, .fcol.active .fitem.on .fitem-n,
.fcol.active .fitem.on .fitem-chev, .fcol.active .fitem.picked .fitem-ico { color: var(--on-accent); }
.fitem:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.fcol-note { margin: 14px 10px; font-size: 12.5px; line-height: 1.5; color: var(--ink-dim); }
.fcol-more { height: 40px; }

/* While pictures are being dragged, every folder row that will take them says so. */
body.dragging-assets .fitem.dir { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- the path and the count along the bottom ---------- */
.finder-foot {
  display: flex; align-items: center; gap: 12px; flex: none;
  min-height: 30px; padding: 2px 12px;
  border-top: 1px solid var(--line); font-size: 12.5px;
}
.finder-path { display: flex; align-items: center; gap: 1px; flex: 1; min-width: 0; overflow-x: auto; }
.fpath-step {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  padding: 4px 7px; border: 1px solid transparent; border-radius: 6px;
  background: none; color: var(--ink-dim); font: inherit; white-space: nowrap; cursor: pointer;
}
.fpath-step .fico { width: 15px; height: 15px; color: var(--folder); opacity: 1; }
.fpath-step:hover { color: var(--ink); background: var(--panel-2); }
.fpath-step.here { color: var(--ink); cursor: default; }
.fpath-step.here:hover { background: none; }
.fpath-sep { color: var(--ink-dim); padding: 0 1px; }
body.dragging-assets .fpath-step:not(.here) { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.finder-status { flex: none; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

/* ---------- a folder, in the panel on the right ---------- */
.fprev { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 6px 10px; text-align: center; }
.fprev-face { width: 132px; height: 132px; display: grid; place-items: center; margin-bottom: 8px; }
.fprev-face .fico { width: 116px; height: 116px; color: var(--folder); opacity: 1; }
.fprev-face img { width: 132px; height: 132px; object-fit: cover; border-radius: 14px; background: var(--panel-2); }
.fprev-name { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.fprev-about { margin: 0; max-width: 34ch; font-size: 13px; line-height: 1.5; color: var(--ink-dim); }
.fprev-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.fprev-actions .danger { color: var(--danger); }
.fprev-hint { margin: 22px 8px 0; padding-top: 12px; text-align: center; }

/* ---------- narrow: one column at a time, and the path to go back up ---------- */
@media (max-width: 900px) {
  .finder-cols { overflow-x: hidden; }
  .fcol { display: none; flex: 1; width: auto !important; border-right: 0; }
  .fcol-grip { display: none; }
  .fcol:last-child { display: flex; }
  .finder-bar { height: 44px; padding: 0 10px; }
  .fitem { height: 40px; font-size: 15px; }
}

/* Phones have no sidebar (web/css/08-sharing.css): the place dropdowns in the
   filter line are the way between places there, so the line stays for them and
   only what narrows a search goes. The count sits under the camera button. */
@media (max-width: 720px), (max-height: 520px) {
  body.in-finder #filters { display: flex; }
  body.in-finder #kindsel, body.in-finder #filters .filterrest { display: none; }
  .finder-status { display: none; }
}

/* A drag held over a folder: it is about to open (springLoad in web/finder-drop.js). */
.fitem.springing, .frow.springing { animation: fspring .8s steps(4) 1; }
@keyframes fspring { 50% { background: color-mix(in srgb, var(--accent) 30%, transparent); } }
@media (prefers-reduced-motion: reduce) { .fitem.springing, .frow.springing { animation: none; } }

/* A shortcut written beside its menu item, the Finder's way: web/finder-menu.js, web/menus.js. */
.ctx button .ctxkey { float: right; margin-left: 24px; color: var(--ink-dim); font-size: 12px; letter-spacing: .04em; }

/* The owner's order (web/finder-order.js, web/manual-order.js): the number drawn
   before a name, never in it; where a dragged row will land; and the space below
   the last row, which takes a number away. */
.fitem-order {
  flex: none; min-width: 18px; padding: 0 5px; margin-right: 6px; border-radius: 9px;
  font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--panel-2); color: var(--ink-dim);
}
.fitem.on .fitem-order { background: rgba(255, 255, 255, .25); color: inherit; }
.fitem.order-before { box-shadow: inset 0 2px 0 var(--accent); }
.fitem.order-after { box-shadow: inset 0 -2px 0 var(--accent); }
.fcol.order-end { box-shadow: inset 0 -3px 0 var(--accent); }
