/* Grid: virtualized cells, section headers, file tiles in the four layouts (waterfall, justified, square,
   list), folder cards with their cover mosaics, the list tree, the selection ring and check badge, status
   lines, the name tooltip. Owner: layouts. Values are the design board's (Main.dc.html, Folder.dc.html,
   Phone.dc.html). Heights marked "= layout.js" must match the constants there (the caption boxes also get
   their height from tilerender.js). Cells are positioned with `transform` by grid.js, so hover lifts use the
   separate `translate` property. */

.vgrid { position: relative; container: vgrid / inline-size;
  --row-line: #1f2024; --row-hover: #1c1d21; --row-sel: rgba(59, 130, 246, .12);   /* the board's list rows */
  --focus-ring: rgba(59, 130, 246, .5);    /* keyboard focus on an unselected item */
  --tw: 0px; --tww: 24px; --lpad: 14px; --indent: 18px; }   /* list: triangle room and width, side padding, indent per level */
.vcell { position: absolute; left: 0; top: 0; contain: layout style; }
/* keyboard focus: the selection ring's place, softer while the item is not selected */
.vcell:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.fcard:focus-visible, .lrow:focus-visible, .tile:focus-visible { outline: none; }
.fcard:focus-visible:not(.sel) .mosaic { outline-color: var(--focus-ring); }
.tile:not(.sq):focus-visible:not(.sel) > .sqimg, .tile.sq:focus-visible:not(.sel) { outline-color: var(--focus-ring); }
.lrow:focus-visible:not(.sel) { box-shadow: inset 0 0 0 2px var(--focus-ring); }
.vblock { position: absolute; left: 0; right: 0; top: 0; }

/* ---------- section headers: "Folders · 23" + cover switch, "Files · 225" (height = HEAD_H) ---------- */
.ghead { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ghead-t { font-size: 13.5px; font-weight: 650; letter-spacing: -.005em; }
.ghead-n { color: var(--faint); font-variant-numeric: tabular-nums; }
.ghead-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ghead-l { color: var(--faint); font-size: 12px; }
.seg.seg-text button { width: auto; height: 28px; padding: 0 12px; font-weight: 500; }

/* ---------- file tiles: waterfall, justified, square ----------
   A tile is its picture box (.sqimg, data-part="pic": thumbnail, badges, the video preview) and, with
   "Thumbnail details" on, its caption (.tcap under the picture; square tiles: .sqcap inside the card). */
.tile { display: flex; flex-direction: column; text-decoration: none; color: var(--text); transition: translate .16s ease; }
.tile > .sqimg { position: relative; display: block; flex: 1 1 auto; min-height: 0; overflow: hidden; border-radius: 9px; background: var(--ph);
  outline: 2px solid transparent; outline-offset: 2px; transition: box-shadow .16s ease, outline-color .12s; }
.tile.jr > .sqimg { border-radius: 8px; }
.tile img.th { width: 100%; height: 100%; display: block; object-fit: cover; opacity: 0; transition: opacity .2s; }
.tile img.th.ld { opacity: 1; }
.tile.wait > .sqimg { background: linear-gradient(100deg, var(--ph) 30%, var(--raised) 50%, var(--ph) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -150% 0; } }
@media (hover: hover) {
  .tile:hover { translate: 0 -2px; }
  .tile:not(.sq):hover > .sqimg { box-shadow: 0 10px 26px rgba(0,0,0,.5); }
  body.drag-selecting .tile:hover > .sqimg { box-shadow: none; }   /* no lift while a rubber band is drawn (actions) */
}

/* the caption under the picture (R2): name, then "1143 × 2048 · 8.4 MB" (height = CAPTION_H, set inline) */
.tcap { flex: none; display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 7px 2px 0; overflow: hidden; }
.tcn { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcd { font-size: 11px; line-height: 15px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the folder over the name (Everything inside): right-to-left with an ellipsis, so the deepest folders stay visible */
.tdir { font-size: 11px; line-height: 15px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.tile.sel .tcn { color: var(--accent-text); }

/* captions off: the board's caption on hover, over the picture: name + details */
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; padding: 22px 10px 8px;
  font-size: 11.5px; line-height: 1.35; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.72));
  opacity: 0; transition: opacity .16s ease; pointer-events: none; }
.tile .cn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cd { opacity: .8; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile:hover .cap, .tile:focus-visible .cap { opacity: 1; }

/* files without a thumbnail: a type card (captions off: the name always shown on it) */
.tcard { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--dim); padding-bottom: 18px; }
.tile.capd .tcard { padding-bottom: 0; }
.tcard .ic { width: 34px; height: 34px; stroke-width: 1.3; }
.tcard .ext { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.tile.noimg .cap, .tile:not(.t-image):not(.t-video) .cap { opacity: 1; background: none; color: var(--muted); text-align: center; }
.tile.noimg .cd, .tile:not(.t-image):not(.t-video) .cd { display: none; }

/* videos: play badge and duration (R4) */
.tile .play { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0,0,0,.5); color: #fff; pointer-events: none; }
.tile .play .ic { width: 20px; height: 20px; margin-left: 2px; }
.tile .dur { position: absolute; right: 6px; bottom: 6px; font-size: 11px; font-variant-numeric: tabular-nums; padding: 1px 6px;
  border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; pointer-events: none; transition: opacity .16s; }
.tile:hover .dur { opacity: 0; }

/* square grid: a card with the 1:1 picture and the caption inside it (height = SQUARE_CAP_H / SQUARE_CAPTION_H) */
.tile.sq { border-radius: 9px; overflow: hidden; background: var(--ph); outline: 2px solid transparent; outline-offset: 2px;
  transition: translate .16s ease, box-shadow .16s ease, outline-color .12s; }
.tile.sq > .sqimg { border-radius: 0; outline: none; }
@media (hover: hover) {
  .tile.sq:hover { box-shadow: 0 10px 26px rgba(0,0,0,.5); }
}
.sqcap { flex: none; display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 7px 9px 0; background: var(--panel-2); overflow: hidden; }
.sqcap .tcn { font-size: 11.5px; font-weight: 400; }
.sqcap.c-details { padding-top: 8px; }
.tile.sq .tcard { padding-bottom: 0; }

/* selection: accent ring around the picture (square: the card), and a check badge on file tiles */
.tile:not(.sq).sel > .sqimg, .tile.sq.sel { outline-color: var(--accent); }
.tile.sel::after { content: ""; position: absolute; top: 8px; left: 8px; z-index: 2; width: 22px; height: 22px; border-radius: 50%; pointer-events: none;
  background: var(--accent-strong) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E") center / 12px no-repeat;
  box-shadow: 0 2px 8px rgba(0,0,0,.4); }

.tile:not(.sq).flash > .sqimg, .tile.sq.flash, .fcard.flash .mosaic, .lrow.flash { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ---------- list: a framed table, column titles (= LIST_HEAD_H), rows (= LIST_ROW_H) ----------
   Columns: thumbnail, Name, Size, Dimensions, Duration (l-dur: the list has a video), Type, the date.
   The list tree (l-tree): room on the left for the disclosure triangles; nested rows indent by --depth. */
.lframe { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.lhead, .lrow { --lc: 56px minmax(0, 1fr) 80px 110px 60px 104px; display: grid; grid-template-columns: var(--lc); gap: 12px; align-items: center;
  padding: 0 var(--lpad) 0 calc(var(--lpad) + var(--tw)); }
.l-dur .lhead, .l-dur .lrow { --lc: 56px minmax(0, 1fr) 80px 110px 60px 60px 104px; }
.vgrid:not(.l-dur) .ldur { display: none; }
.vgrid.l-tree { --tw: 22px; }
.lrow.ltr { padding-left: calc(var(--lpad) + var(--tw) + var(--depth, 0) * var(--indent)); }
.lhead { height: 36px; background: var(--pane); border-bottom: 1px solid var(--line); color: var(--faint); font-size: 11.5px; }
.lsort { justify-self: start; display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; padding: 0; border: 0; background: none; color: inherit;
  font: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; }
.lsort:hover, .lsort[aria-pressed=true] { color: var(--text); }
.ldir { font-size: 11px; }
.lrow { color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--row-line); transition: background .12s; }
.lrow.sel { background: var(--row-sel); }
@media (hover: hover) {
  .lrow:not(.sel):hover { background: var(--row-hover); }
}
.lthumb { position: relative; width: 40px; height: 40px; border-radius: 6px; overflow: hidden; background: var(--ph);
  display: grid; place-items: center; color: var(--faint); }
.lthumb img { width: 100%; height: 100%; display: block; object-fit: cover; opacity: 0; transition: opacity .2s; }
.lthumb img.ld { opacity: 1; }
.lthumb.lfold { background: var(--panel); }
.lrow.t-video .lthumb::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3E%3Cpath d='M6 4.5v7l5.5-3.5z'/%3E%3C/svg%3E") center / 12px no-repeat; }
.lname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow.t-folder .lname { color: var(--text); font-weight: 500; }
.lsize, .ldim, .ldur, .ltype, .ldate { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lhead > * { color: inherit; }
.lcounts { font-size: 12px; }
.lsub { display: none; font-size: 11.5px; line-height: 15px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcounts.fic { display: flex; align-items: center; gap: 8px; }

/* the disclosure triangle: a button left of the thumbnail (touch: 44 px wide, the row's height) */
.ltw { position: absolute; top: 0; bottom: 0; left: calc(var(--lpad) + var(--tw) - var(--tww) - 2px + var(--depth, 0) * var(--indent)); width: var(--tww);
  display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--faint); cursor: pointer; }
.ltw:hover { color: var(--text); }
.ltw .ic { transition: transform .15s ease; }
.ltw.open .ic { transform: rotate(90deg); }
.ltw.busy .ic { opacity: 0; }
.ltw.busy::after { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@media (pointer: coarse) {
  .vgrid { --tww: 44px; }
  .vgrid.l-tree { --tw: 34px; }
  /* the list's column titles: the whole 36 px title row and 11 px each side (LIST_HEAD_H is part of the layout maths; the toolbar Sort menu is the full-size way) */
  .lsort { position: relative; }
  .lsort::before { content: ""; position: absolute; inset: -10px -11px; }
}

@container vgrid (max-width: 720px) {
  .lhead, .lrow { --lc: 52px minmax(0, 1fr) 72px 96px 52px; }
  .l-dur .lhead, .l-dur .lrow { --lc: 52px minmax(0, 1fr) 72px 96px 52px 52px; }
  .lhead > .ldate, .lrow > .ldate { display: none; }
}
/* phones: thumbnail, name with its details under it (dimensions, length, type; a folder's counts), size */
@container vgrid (max-width: 480px) {
  .lhead, .lrow, .l-dur .lhead, .l-dur .lrow { --lc: 44px minmax(0, 1fr) 64px; --lpad: 12px; --indent: 14px; gap: 10px; }
  .lhead > .ldim, .lhead > .ldur, .lhead > .ltype, .lhead > .ldate, .lrow > .ldim, .lrow > .ldur, .lrow > .ltype, .lrow > .ldate { display: none; }
  .lrow { grid-template-rows: auto auto; align-content: center; row-gap: 1px; }
  .lrow > .lthumb { grid-column: 1; grid-row: 1 / 3; }
  .lrow > .lname { grid-column: 2; grid-row: 1; line-height: 18px; }
  .lrow > .lsub { display: block; grid-column: 2; grid-row: 2; }
  .lrow > .lsub.fic { display: flex; align-items: center; gap: 8px; }
  .lrow > .lsize { grid-column: 3; grid-row: 1 / 3; }
}

/* ---------- folder cards: square cover mosaic, then name, deep counts and size (= FOLDER_LABEL_H / _SIZE_H) ---------- */
.fcard { display: flex; flex-direction: column; text-decoration: none; color: var(--text); transition: translate .18s ease; }
.mosaic { width: 100%; aspect-ratio: 1; flex: none; display: grid; grid-template: 1fr / 1fr; gap: 2px; border-radius: 10px; overflow: hidden;
  background: var(--mosaic); outline: 2px solid transparent; outline-offset: 3px; transition: box-shadow .18s ease, outline-color .12s; }
@media (hover: hover) {
  .fcard:hover { translate: 0 -2px; }
  .fcard:hover .mosaic { box-shadow: 0 10px 28px rgba(0,0,0,.45); }
}
.fcard.sel .mosaic { outline-color: var(--accent); }
.mosaic.n0 { place-items: center; background: var(--panel); }
.mosaic.n2 { grid-template-columns: 1fr 1fr; }
.mosaic.n3, .mosaic.n4 { grid-template: 1fr 1fr / 1fr 1fr; }
.mosaic.n3 img:first-child { grid-row: span 2; }   /* one large, two small */
.mosaic img { width: 100%; height: 100%; min-height: 0; display: block; object-fit: cover; background: var(--ph); opacity: 0; transition: opacity .2s; }
.mosaic img.ld { opacity: 1; }
.folder-ic { width: 44px; height: 44px; color: var(--dim); stroke-width: 1.3; }
.flabel { height: 48px; flex: none; padding: 10px 2px 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.fname { position: relative; padding-left: 20px; font-weight: 600; font-size: 13.5px; line-height: 19px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fname::before { content: ""; position: absolute; left: 0; top: 2.5px; width: 14px; height: 14px; background: var(--faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M1.75 4.25c0-.55.45-1 1-1h3.1l1.4 1.5h5.99c.55 0 1 .45 1 1v6.5c0 .55-.45 1-1 1H2.75c-.55 0-1-.45-1-1z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M1.75 4.25c0-.55.45-1 1-1h3.1l1.4 1.5h5.99c.55 0 1 .45 1 1v6.5c0 .55-.45 1-1 1H2.75c-.55 0-1-.45-1-1z'/%3E%3C/svg%3E") center / contain no-repeat; }
.fcard.sel .fname::before { background: var(--accent-icon); }
.fmeta { color: var(--muted); font-size: 12px; line-height: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* R18: the counts as small icons and numbers when the words do not fit the card ("▣ 1,669  ▶ 12  ▢ 3") */
.fmeta.fic { display: flex; align-items: center; gap: 8px; }
.fc { display: inline-flex; align-items: center; gap: 3px; flex: none; }
.fc .ic { width: 12px; height: 12px; stroke-width: 1.6; color: var(--faint); }
.fic.tight { gap: 4px; }
.fic.tight .fc { gap: 2px; }
.fc.fc-more { color: var(--faint); }
.fsize { color: var(--faint); font-size: 11px; line-height: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- header slot: "Space quick look · ← → ↑ ↓ move" (desktop) ---------- */
.khints { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; }
.khints kbd { font: inherit; border: 1px solid var(--line-2); border-radius: 6px; padding: 3px 8px; }
.khints kbd:not(:first-child) { margin-left: 8px; }

.status { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 36px 12px;
  color: var(--muted); text-align: center; }
.status.error { color: var(--danger); }

/* ---------- the full-name tooltip on captions (R19, js/features/layouts.js), on document.body ---------- */
.lay-tip { position: fixed; left: 0; top: 0; z-index: 50; max-width: min(360px, calc(100vw - 16px)); padding: 7px 10px;
  border-radius: 8px; background: var(--sheet); border: 1px solid var(--line-3); box-shadow: 0 12px 32px rgba(0,0,0,.45);
  font-size: 12px; line-height: 1.4; color: var(--text); pointer-events: none; opacity: 0; transition: opacity .12s ease; }
.lay-tip.on { opacity: 1; }
.lay-tip-t { font-weight: 600; overflow-wrap: anywhere; }
.lay-tip-m { color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- phones (Phone.dc.html): rounder covers, a larger name ---------- */
@media (max-width: 767px) {
  .mosaic { border-radius: 12px; }
  .flabel { padding-top: 8px; }
  .fname { font-size: 14px; line-height: 20px; }
  .ghead-l { display: none; }
  /* a phone-sized window has no keyboard to hint at (nor room for an empty header row) */
  .khints, .vtools:not(:has(> :not([hidden], .khints))) { display: none; }
}
