/* os/explorer.css — the inside of a File Explorer window.
 *
 * Scoped under `.win__body` (CONTRACTS.md: apps render into the window body and
 * app CSS goes inside it, so app padding and chrome padding cannot fight). The
 * window manager hands the body zero padding, `min-height: 0` and
 * `overflow: auto`; everything below owns the space between that surface and
 * the file list.
 *
 * Every rule is namespaced `fx-*`. Nothing here can reach the desktop, the
 * window chrome (css/os/window.css) or css/os/chrome.css.
 *
 * Everything is sized in rem against the OS root font size, and every control
 * is at least 32px on its short side so the file list stays operable by
 * keyboard and by thumb. Focus is never removed — it is restyled, because a
 * file manager where focus is invisible is a file manager operated by guesswork.
 */

.win__body .fx-root {
  --fx-line: rgba(23, 21, 31, .14);
  --fx-line-2: rgba(23, 21, 31, .28);
  --fx-paper-2: #EFE7D9;
  --fx-dim: rgba(23, 21, 31, .62);

  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  min-width: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
}

.win__body .fx-root *,
.win__body .fx-root *::before,
.win__body .fx-root *::after { box-sizing: border-box; }

.win__body .fx-sr {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ── toolbar ───────────────────────────────────────────────────────────────── */

.win__body .fx-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .5rem;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--fx-line);
  background: var(--paper-2);
}

.win__body .fx-nav { display: flex; gap: .25rem; }

.win__body .fx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0 .55rem;
  border: 1px solid var(--fx-line-2);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  /* One short transition, on the two properties that change on hover and
   * press. This is the module's entire motion surface — the reduced-motion
   * block at the foot of this file exists to switch exactly this off, and it
   * is worth having something real to switch off. */
  transition: background-color .13s ease, translate .13s ease;
}
.win__body .fx-btn:hover:not([disabled]) { background: #fff; }
.win__body .fx-btn:active:not([disabled]) { translate: 0 1px; }
.win__body .fx-btn[disabled] { opacity: .4; cursor: default; }
.win__body .fx-btn svg { width: 1rem; height: 1rem; flex: 0 0 auto; }
.win__body .fx-btn--wide { padding: 0 .7rem; }

.win__body .fx-btn:focus-visible,
.win__body .fx-row:focus-visible,
.win__body .fx-crumb:focus-visible,
.win__body .fx-place:focus-visible,
.win__body .fx-input:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}

/* ── breadcrumb ────────────────────────────────────────────────────────────── */

.win__body .fx-crumbs {
  flex: 1 1 8rem;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .1rem;
  padding: 0 .2rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.win__body .fx-crumb {
  flex: 0 0 auto;
  min-height: 1.9rem;
  padding: 0 .45rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.win__body .fx-crumb:hover { background: rgba(23, 21, 31, .07); }
.win__body .fx-crumb[aria-current="true"] { color: var(--fx-dim); cursor: default; }
.win__body .fx-crumb[aria-current="true"]:hover { background: none; }
.win__body .fx-crumb-sep {
  flex: 0 0 auto;
  color: var(--fx-dim);
  font-size: .8rem;
  user-select: none;
}

/* ── body: places rail + list ──────────────────────────────────────────────── */

.win__body .fx-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.win__body .fx-places {
  flex: 0 0 11.5rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .5rem .4rem;
  border-right: 1px solid var(--fx-line);
  background: var(--paper-2);
  overflow-y: auto;
}

.win__body .fx-places-title {
  margin: .2rem .3rem .35rem;
  color: var(--fx-dim);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.win__body .fx-place {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  min-height: 2rem;
  padding: 0 .5rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: .84rem;
  text-align: left;
  cursor: pointer;
}
.win__body .fx-place:hover { background: rgba(23, 21, 31, .07); }
.win__body .fx-place[aria-current="true"] {
  border-color: var(--fx-line-2);
  background: var(--paper);
  font-weight: 700;
}
.win__body .fx-place svg { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }
.win__body .fx-place-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── the file list ─────────────────────────────────────────────────────────── */

.win__body .fx-list-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.win__body .fx-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: .35rem;
  margin: 0;
  list-style: none;
}

/* One row per entry. role="list" on the <ul> and role="listitem" on the <li>
 * means the roving tabindex below reads as a plain list to a screen reader
 * while still being a single tab stop for everyone else. */
.win__body .fx-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 2.5rem;
  padding: .2rem .5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.win__body .fx-row:hover { background: rgba(23, 21, 31, .05); }
.win__body .fx-row[aria-selected="true"] {
  border-color: var(--fx-line-2);
  background: var(--paper-2);
}
.win__body .fx-row[aria-selected="true"] .fx-name { font-weight: 700; }

.win__body .fx-art {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
}
.win__body .fx-art svg { width: 100%; height: 100%; display: block; }

.win__body .fx-text { min-width: 0; flex: 1 1 auto; }

.win__body .fx-name {
  display: block;
  font-size: .88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── the file preview ────────────────────────────────────────────────────────
 * The viewer replaces the list, not the window: the toolbar, the rail and the
 * status bar all stay put, so Back is always exactly where it was. */

.win__body .fx-viewer { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }

.win__body .fx-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: .9rem 1rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}
.win__body .fx-view:focus-visible { outline: 3px solid var(--violet); outline-offset: -3px; }

/* ── a business app ──────────────────────────────────────────────────────────
 * The icon is the manifest's own artwork at its own 96×112 aspect, so a row is
 * taller than a folder row and the list needs to let it. The accent tint comes
 * from the same record, as a currentColor the row sets inline. */

.win__body .fx-row--app { min-height: 3rem; }
.win__body .fx-row--app .fx-art { width: 1.6rem; height: 1.9rem; }

.win__body .fx-row.is-dragging { opacity: .45; }

/* While renaming, the row is a control in its own right — no hover tint, no
 * drag affordance, so nothing competes with the input for the click. */
.win__body .fx-row--renaming { cursor: text; }
.win__body .fx-row--renaming:hover { background: none; }
.win__body .fx-row--renaming .fx-text { display: flex; }

.win__body .fx-meta {
  display: block;
  color: var(--fx-dim);
  font-size: .74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.win__body .fx-badge {
  flex: 0 0 auto;
  padding: .1rem .45rem;
  border: 1px solid var(--fx-line-2);
  border-radius: 999px;
  background: var(--paper);
  color: var(--fx-dim);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Drag-and-drop is progressive: the attribute is always present so assistive
 * tech can announce it, and only the pointer path acts on it. */
.win__body .fx-row[draggable="true"] { cursor: grab; }
.win__body .fx-row.is-drop {
  border-color: var(--violet);
  border-style: dashed;
  background: rgba(109, 91, 208, .12);
}

.win__body .fx-list-wrap.is-dropping::after {
  content: "";
  position: absolute;
  inset: .35rem;
  border: 2px dashed var(--violet);
  border-radius: 10px;
  pointer-events: none;
}

/* ── inline rename ─────────────────────────────────────────────────────────── */

.win__body .fx-input {
  width: 100%;
  min-width: 0;
  padding: .15rem .3rem;
  border: 2px solid var(--violet);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
}

/* ── status bar ────────────────────────────────────────────────────────────── */

.win__body .fx-status {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .7rem;
  min-height: 2rem;
  padding: .25rem .7rem;
  border-top: 1px solid var(--fx-line);
  background: var(--paper-2);
  font-size: .76rem;
  color: var(--fx-dim);
}
.win__body .fx-status-count { font-weight: 600; }
.win__body .fx-status-msg { color: var(--ink); }

/* ── empty state ───────────────────────────────────────────────────────────── */

.win__body .fx-empty {
  display: grid;
  gap: .5rem;
  place-items: center;
  padding: 2.5rem 1rem;
  color: var(--fx-dim);
  text-align: center;
}
.win__body .fx-empty-art { width: 3.5rem; height: 3.5rem; opacity: .55; }
.win__body .fx-empty-title { font-weight: 700; color: var(--ink); }
.win__body .fx-empty-note { max-width: 26rem; font-size: .82rem; }

/* ── 390px: one column, rail becomes a scrollable strip above the list ─────── */

@media (max-width: 620px) {
.win__body .fx-body { flex-direction: column; }
.win__body .fx-places {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: .3rem;
    padding: .35rem .4rem;
    border-right: 0;
    border-bottom: 1px solid var(--fx-line);
    overflow-x: auto;
  }
.win__body .fx-places-title { display: none; }
.win__body .fx-place { width: auto; flex: 0 0 auto; }
.win__body .fx-bar { padding: .4rem; }
.win__body .fx-btn--wide .fx-btn-text { display: none; }
.win__body .fx-btn--wide { padding: 0 .5rem; }
}

@media (max-width: 420px) {
.win__body .fx-meta { display: none; }
.win__body .fx-row { min-height: 2.75rem; }
}

/* ── reduced motion ──────────────────────────────────────────────────────────
 * Two mechanisms, additive, never one replacing the other. The media query is
 * the real visitor preference and is the one that must hold with no script
 * running at all. [data-reduce-motion] is the manual override — the in-OS
 * "reduce motion" preference and the hook a test can force. A visitor whose OS
 * asks for less motion gets it either way. */

@media (prefers-reduced-motion: reduce) {
  .win__body .fx-root *,
  .win__body .fx-root *::before,
  .win__body .fx-root *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

[data-reduce-motion] .win__body .fx-root *,
[data-reduce-motion] .win__body .fx-root *::before,
[data-reduce-motion] .win__body .fx-root *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}

/* ── forced colours ────────────────────────────────────────────────────────── */

@media (forced-colors: active) {
.win__body .fx-row[aria-selected="true"] { outline: 2px solid Highlight; }
.win__body .fx-place[aria-current="true"] { outline: 2px solid Highlight; }
.win__body .fx-btn { border: 1px solid ButtonBorder; }
.win__body .fx-input { border: 2px solid CanvasText; }
}
