/* Projects is intentionally a single-pane Sonoma list view. */
.finder-window { container-type: inline-size; }
.finder-body { flex: 1; min-height: 0; display: block; overflow: hidden; }
.finder-body > .window-content {
  width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 0; overflow: auto;
  scrollbar-color: rgba(215,215,218,.62) transparent; scrollbar-width: thin;
}
.finder-body > .window-content::-webkit-scrollbar { width: 11px; height: 11px; }
.finder-body > .window-content::-webkit-scrollbar-track { background: transparent; }
.finder-body > .window-content::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 9px; background: rgba(215,215,218,.56); background-clip: padding-box; }

.finder-window > .titlebar { gap: 7px; padding-inline: 10px; }
.finder-window > .titlebar .nav-group {
  width: 64px; flex: 0 0 64px; height: 100%; margin-top: 0; margin-left: 14px;
  transform: translateY(2px);
}
.finder-window > .titlebar .nav-arrows { gap: 6px; }
.finder-window > .titlebar .window-title {
  min-width: 72px; margin: 0 4px 0 20px; white-space: nowrap;
}
.finder-window > .titlebar .titlebar-spacer { flex: 1 1 auto; min-width: 8px; }
.finder-window > .titlebar .search-group {
  order: 3; width: 44px; min-width: 44px; flex: 0 1 44px; height: 100%; margin-top: 0;
  transform: translateY(3px);
  transition: flex-basis .22s ease, width .22s ease;
}
.finder-window > .titlebar .search-group:focus-within { width: 126px; flex-basis: 126px; }
.finder-window > .titlebar .search-group:focus-within .search-wrapper,
.finder-window > .titlebar .search-group:focus-within .search-input { width: 100%; }
.finder-window > .titlebar .nav-label,
.finder-window > .titlebar .search-label { margin-top: 3px; }
.finder-toolbar-actions { order: 2; display: none; align-items: center; height: 100%; gap: 1px; flex: 0 0 auto; }
.finder-window.file-preview-open > .titlebar .finder-toolbar-actions { display: flex; }
.finder-window.file-preview-open > .titlebar .search-group { display: none; }
.finder-toolbar-button {
  appearance: none; width: 38px; height: 42px; padding: 3px 0 0; border: 0; border-radius: 6px;
  color: rgba(238,238,240,.65); background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; cursor: pointer;
}
.finder-toolbar-button:hover:not(:disabled) { color: rgba(255,255,255,.95); background: rgba(255,255,255,.045); }
.finder-toolbar-button:disabled { opacity: .28; cursor: default; }
.finder-toolbar-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.finder-toolbar-button svg .solid { fill: currentColor; stroke: none; }
.finder-toolbar-button span { font-size: 7px; line-height: 1; font-weight: 500; }

.folder-grid.finder-list {
  display: block; position: relative; min-width: 0; min-height: 100%; padding: 0;
  background: repeating-linear-gradient(to bottom,
    rgba(54,53,57,.78) 0, rgba(54,53,57,.78) 22px,
    rgba(43,42,46,.78) 22px, rgba(43,42,46,.78) 44px);
  background-position: 0 25px;
}
.finder-list-header,
.folder-grid.finder-list .folder-item {
  display: grid;
  grid-template-columns: minmax(116px, 1fr) minmax(48px, 12%) minmax(64px, 18%) minmax(76px, 22%);
  align-items: center;
}
.finder-list-header {
  position: sticky; top: 0; z-index: 3; height: 25px; color: rgba(235,235,238,.73);
  background: rgba(39,38,42,.86); border-bottom: 1px solid rgba(255,255,255,.12); font-size: 10.5px;
  -webkit-backdrop-filter: blur(24px) saturate(140%); backdrop-filter: blur(24px) saturate(140%);
}
.finder-list-sort {
  appearance: none; min-width: 0; height: 100%; padding: 0 9px; border: 0; color: inherit; background: transparent;
  font: inherit; font-weight: 550; text-align: left; cursor: pointer; border-right: 1px solid rgba(255,255,255,.09);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.finder-list-sort > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder-list-sort:hover { color: #fff; background: rgba(255,255,255,.045); }
.finder-list-sort.active::after {
  content: ''; width: 6px; height: 6px; flex: 0 0 6px; opacity: .72;
  border-top: 1.25px solid currentColor; border-right: 1.25px solid currentColor;
  transform: translateY(1px) rotate(-45deg);
}
.finder-list-sort.active[data-direction="desc"]::after {
  transform: translateY(-1px) rotate(135deg);
}
.folder-grid.finder-list .folder-item {
  height: 22px; min-height: 22px; padding: 0; border-radius: 0; color: rgba(241,241,243,.88);
  background: transparent;
  cursor: default; -webkit-user-select: none; user-select: none; font-size: 10.5px;
}
.folder-grid.finder-list .folder-item:hover { background: rgba(255,255,255,.075); }
.folder-grid.finder-list .folder-item.selected { background: var(--accent-color, #1687f8); color: #fff; }
.finder-list-name { min-width: 0; display: flex; align-items: center; gap: 6px; padding: 0 9px; }
.folder-icon { width: 14px; height: 14px; flex: 0 0 14px; background: url('../assets/icons/Folder.png') center / contain no-repeat; }
img.file-icon { display: block; object-fit: contain; background: none; }
img.file-icon.image-preview { object-fit: cover; border-radius: 1px; box-shadow: 0 0 0 .5px rgba(255,255,255,.28); }
.generic-file-icon { position: relative; border-radius: 1px; background: linear-gradient(135deg, #f5f5f5 0 72%, #c8c8c8 73%); box-shadow: 0 0 0 .5px rgba(255,255,255,.35); }
.generic-file-icon::after { content: attr(data-extension); position: absolute; inset: auto 1px 1px; color: #555; font-size: 4px; font-weight: 700; text-align: center; }
.folder-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.folder-size, .folder-kind, .folder-date { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 10px; color: rgba(232,232,235,.66); }
.folder-item.selected :is(.folder-size,.folder-kind,.folder-date) { color: rgba(255,255,255,.92); }
.empty-state { height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: rgba(233,233,233,.35); font-size: 12px; }

.finder-preview { min-width: 0; min-height: 100%; height: 100%; display: flex; flex-direction: column; background: rgba(34,34,36,.34); }
.finder-preview-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 0; }
.finder-preview :is(video,img,iframe,embed) { display: block; border: 0; }
.finder-preview video { width: 100%; height: 100%; object-fit: contain; background: #090909; }
.finder-preview-image { width: 100%; height: 100%; object-fit: contain; }
.finder-preview-document { width: 100%; height: 100%; min-height: 320px; border-radius: 2px; background: #ededed; }
.finder-pdf-viewer {
  width: 100%; height: 100%; min-width: 0; min-height: 0; display: grid;
  grid-template-columns: 132px minmax(0, 1fr); background: #080808;
}
.finder-pdf-sidebar {
  min-width: 0; min-height: 0; padding: 12px 10px 18px; overflow: auto;
  background: rgba(42,42,44,.88); border-right: 1px solid rgba(255,255,255,.09);
  -webkit-backdrop-filter: blur(28px) saturate(135%); backdrop-filter: blur(28px) saturate(135%);
  scrollbar-color: rgba(220,220,222,.45) transparent; scrollbar-width: thin;
}
.finder-pdf-thumbnail {
  appearance: none; width: 100%; margin: 0 0 9px; padding: 5px 5px 4px; border: 0;
  border-radius: 6px; color: rgba(245,245,247,.8); background: transparent; cursor: pointer;
}
.finder-pdf-thumbnail:hover { background: rgba(255,255,255,.07); }
.finder-pdf-thumbnail.active { background: rgba(255,255,255,.15); }
.finder-pdf-thumbnail img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #111;
  border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 2px 7px rgba(0,0,0,.32);
}
.finder-pdf-thumbnail span { display: block; margin-top: 5px; font-size: 9px; line-height: 1; text-align: center; }
.finder-pdf-page-stage {
  min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: stretch;
  justify-content: flex-start; gap: 12px; padding: 12px 0; overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  scroll-snap-type: y proximity; background: #050505; outline: none;
}
.finder-preview .finder-pdf-page {
  display: none; width: calc(100% - 24px); height: auto; max-width: none; max-height: none;
  margin: 0 auto; flex: 0 0 auto; object-fit: contain; scroll-snap-align: start;
  box-shadow: 0 3px 18px rgba(0,0,0,.38);
}
.finder-window:not(.maximized) .finder-preview .finder-pdf-page.active { display: block; }
.finder-window.maximized .finder-pdf-page-stage {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  gap: 14px; padding: 14px 0; overflow-x: hidden; overflow-y: auto; scroll-snap-type: y proximity;
}
.finder-window.maximized .finder-preview .finder-pdf-page {
  display: block; width: calc(100% - 28px); height: auto; max-width: none; max-height: none;
  margin: 0 auto; flex: 0 0 auto; scroll-snap-align: start;
}
.finder-preview-audio { width: min(420px, 84%); display: flex; flex-direction: column; align-items: center; gap: 22px; }
.finder-preview-audio img { width: 112px; height: 112px; object-fit: contain; }
.finder-preview-audio audio { width: 100%; }
.finder-preview-meta {
  position: absolute; top: 12px; right: 12px; width: min(250px, 38%); padding: 9px 11px;
  color: rgba(246,246,247,.82); background: rgba(45,45,47,.86); border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px; box-shadow: 0 7px 22px rgba(0,0,0,.18); backdrop-filter: blur(18px) saturate(125%);
  font-size: 10px; line-height: 1.45;
}
.finder-preview-meta[hidden] { display: none; }
.finder-preview-meta strong { display: block; overflow-wrap: anywhere; color: #fff; font-size: 11px; margin-bottom: 4px; }
.finder-preview-description { margin: 0 0 8px; color: rgba(246,246,247,.83); white-space: normal; overflow-wrap: anywhere; }
.finder-preview-details { display: block; color: rgba(246,246,247,.58); }
@media (max-width: 650px) {
  .finder-window:not(.maximized) .finder-toolbar-actions { display: none; }
  .finder-preview-stage { padding: 10px; }
  .finder-preview-meta { width: min(220px, 62%); }
  .finder-pdf-viewer { grid-template-columns: 92px minmax(0, 1fr); }
  .finder-pdf-sidebar { padding: 8px 7px 12px; }
}

/* This is keyed to the project window rather than the browser viewport. It
   keeps the compact 420 px window usable even on a large desktop. */
@container (max-width: 470px) {
  .finder-window:not(.maximized) .finder-toolbar-actions { display: none; }
  .finder-window > .titlebar .window-title { flex: 0 0 auto; }
  .finder-window > .titlebar .titlebar-spacer { min-width: 2px; }
}
