/* Written by Richard Christopher, Copyright 2026 Mindfull */
/*
 * THE SHARED PARTS: the row, the list, the states, the notice, the Details disclosure, the small
 * controls and the field (`row.js`, `list.js`, `states.js`, `notice.js`, `disclosure.js`, `controls.js`;
 * a field is three class names on a page's own label, caption and control). They began
 * as Feed's and every page draws with them now, so their look is declared here, once, and holds
 * wherever a part stands: no rule below needs a page around it.
 *
 * A page says where a part sits and how much room it has, never what it looks like. Tokens only
 * (global.css); spacing on the 4px scale; sans throughout, and the mono face only for an identifier
 * (`.feed-id`).
 *
 * THE KIT'S CONTROLS KEEP THEIR OWN LOOK. What is said of a `cloudcanvas-ui-*` class here is where it
 * sits and how big it is. The kit's sheet is added to the document after this one, so a rule that sizes
 * a kit button names two classes.
 */

/* The two sizes every part is drawn to: a control's corner, and the least height of a target. */
:root { --feed-radius: 6px; --feed-target: 30px; }
@media (pointer: coarse), (max-width: 760px) { :root { --feed-target: 44px; } }

/* Hidden means not there, whatever a rule below gave the element to lay out with. */
:is(.feed-list, .feed-state, .feed-notice) [hidden], :is(.feed-state, .feed-notice)[hidden] { display: none !important; }

/* ------------------ ICON BUTTON, AND A CONTROL THAT IS OFF ------------------ */
.feed-icon-button.cloudcanvas-ui-button {
  display: inline-grid; place-items: center; flex: none;
  width: var(--feed-target); height: var(--feed-target); min-height: var(--feed-target); padding: 0;
  color: var(--text-dim); background: transparent; border-color: transparent; border-radius: var(--feed-radius);
  transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}
/* Hidden means not there: the rule above lays the button out at the weight of the kit's own `[hidden]` rule, and is read after it. */
.feed-icon-button.cloudcanvas-ui-button[hidden] { display: none; }
.feed-icon-button.cloudcanvas-ui-button:hover:not([aria-disabled="true"]) { color: var(--text); background: var(--accent-wash); border-color: transparent; }
/*
 * A control that is off keeps its focus (`controls.js`), and looks as an off control does: in a part
 * wherever it stands, and anywhere on the Feed page, whose own controls are made the same way.
 */
:is(.feed-page, .feed-list, .feed-notice) [aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* ------------------ FIELD ------------------ */
/* A field under its caption: the one look a text field, a date and a select take, on whichever page draws one. */
.feed-field { display: grid; gap: var(--space-1); min-width: 0; }
.feed-field.is-inline { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--space-2); min-height: var(--feed-target); }
.feed-field-label { color: var(--text-dim); font-size: var(--text-base); }
.feed-field-control {
  box-sizing: border-box; width: 100%; min-width: 0; min-height: var(--feed-target); padding-inline: var(--space-3);
  color: var(--text); font: inherit; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--feed-radius);
}
.feed-field-control:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* A field that holds the kit's select (`select-field`, beside the page's own field class): its label over the control, the control as wide as the field. The kit draws the control. */
.select-field .cloudcanvas-ui-select { display: grid; justify-content: stretch; align-items: stretch; gap: var(--space-1); min-height: 0; }
.select-field .cloudcanvas-ui-select-label { color: var(--text-dim); font-size: var(--text-base); }
.select-field .cloudcanvas-ui-select-control { box-sizing: border-box; width: 100%; max-width: none; min-height: var(--feed-target); }

/* ------------------ LIST ------------------ */
.feed-list { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.feed-list-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  min-height: var(--feed-target); padding-inline: var(--space-2) var(--space-1);
}
/* A list that offers nothing of its own has no bar. */
.feed-list-bar:not(:has(.feed-list-lead > *, .feed-list-actions > *)) { display: none; }
.feed-list-lead, .feed-list-actions { display: flex; align-items: center; min-width: 0; }
.feed-list-lead { flex: 0 1 auto; }
/* A choice in the bar ("Show"): the kit's select, its label beside the control on one line. */
.feed-list-lead .cloudcanvas-ui-select { flex-wrap: nowrap; justify-content: flex-start; gap: var(--space-2); }
.feed-list-lead .cloudcanvas-ui-select-label { flex: none; color: var(--text-dim); font-size: var(--text-base); }
.feed-list-lead .cloudcanvas-ui-select-control { flex: 0 1 auto; }
.feed-list-actions { flex: none; gap: var(--space-1); }
/* What a list says of itself in its bar: a count, or one quiet sentence. */
.feed-list-count { padding-inline: var(--space-2); color: var(--text-dim); font-size: var(--text-base); }
.feed-list-scroll { grid-row: 2; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.feed-list-rows { margin: 0; padding: 0; list-style: none; }
.feed-list .feed-list-more { display: block; margin: var(--space-2) var(--space-4); }

/* A row: marker, title and time on the first line; preview and count on the second. One height. */
.feed-list .feed-row {
  display: grid; grid-template-columns: var(--space-2) minmax(0, 1fr) auto; grid-template-rows: auto auto;
  column-gap: var(--space-3); row-gap: var(--space-1); align-items: center;
  width: 100%; min-height: 52px; padding: var(--space-2) var(--space-4);
  color: var(--text); font: inherit; text-align: start;
  background: transparent; border: 0; border-radius: 0; cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-out);
}
.feed-list .feed-row:hover { color: var(--text); background: var(--bg-sunken); }
.feed-list .feed-row[aria-current="true"] { background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent); }
.feed-list .feed-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.feed-row-marker { grid-column: 1; grid-row: 1; width: var(--space-2); height: var(--space-2); border-radius: var(--radius-full); color: transparent; }
.feed-row-marker[data-tone] { box-shadow: inset 0 0 0 1.5px currentColor; }
.feed-row-marker[data-tone][data-filled="true"] { background: currentColor; }
.feed-row-marker[data-tone="accent"] { color: var(--accent); }
.feed-row-marker[data-tone="success"] { color: var(--ok); }
.feed-row-marker[data-tone="warning"] { color: var(--warn); }
.feed-row-marker[data-tone="danger"] { color: var(--fail); }
.feed-row-title {
  grid-column: 2; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: var(--weight-medium); line-height: var(--leading-tight);
}
.feed-row[data-unread="true"] .feed-row-title { font-weight: var(--weight-bold); }
.feed-row-time { grid-column: 3; grid-row: 1; color: var(--text-dim); font-size: var(--text-base); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-row-preview {
  grid-column: 2; grid-row: 2; min-width: 0; min-height: 1lh; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-dim); font-size: var(--text-base);
}
.feed-row-flag { grid-column: 3; grid-row: 2; display: flex; justify-content: flex-end; }

/* A row that opens a new group: the one hairline between what came before it and what follows. */
.feed-row-item[data-divider="true"] { border-block-start: 1px solid var(--border); }

/* A row with actions of its own: the row's button, then its actions, on one line at the row's one height. */
.feed-row-item[data-actions="true"] { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.feed-row-actions { display: flex; align-items: center; gap: var(--space-1); padding-inline-end: var(--space-2); }
/* The open row is marked across its whole line, its actions included. */
.feed-row-item[data-actions="true"]:has(> .feed-row[aria-current="true"]) { background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent); }
.feed-list .feed-row-item[data-actions="true"] > .feed-row[aria-current="true"] { background: transparent; box-shadow: none; }
/* A row's actions are lighter than the region's: the one in words is tinted, any other is quiet until it is under the pointer. */
.feed-list .feed-row-action {
  min-height: var(--feed-target); padding-inline: var(--space-3); font-size: var(--text-base); white-space: nowrap;
  color: var(--text-dim); background: transparent; border-color: transparent; border-radius: var(--feed-radius);
}
.feed-list .feed-row-action:hover:not([aria-disabled="true"]) { color: var(--text); background: var(--accent-wash); border-color: transparent; }
.feed-list .feed-row-action.is-primary { color: var(--accent); font-weight: var(--weight-medium); background: var(--accent-wash); }
.feed-list .feed-row-action.is-primary:hover:not([aria-disabled="true"]) { color: var(--accent); border-color: var(--accent); }

/* One line above the rows, for a list that is shown but cannot be trusted or changed just now. */
.feed-notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
  margin: 0; padding: var(--space-2) var(--space-4); font-size: var(--text-base); background: var(--warn-wash);
}

/* ------------------ STATES, DETAILS ------------------ */
.feed-state { display: grid; place-items: center; align-content: center; min-height: 160px; padding: var(--space-6) var(--space-5); }
.feed-state .cloudcanvas-ui-empty { max-width: 36ch; }
.feed-state[data-kind="loading"] .cloudcanvas-ui-empty-title { color: var(--text-dim); font-weight: var(--weight-normal); }
.feed-details { padding: 0 var(--space-4) var(--space-4); color: var(--text-dim); font-size: var(--text-base); }
.feed-details-body { display: grid; gap: var(--space-2); }
.feed-details-line, .feed-details-fact { margin: 0; overflow-wrap: anywhere; }
.feed-details-fact { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.feed-details-value { color: var(--text); }
.feed-id { font-family: var(--font-mono); }
/* A fact that opens what it is about: its value is a quiet link at a full target, not a boxed button, on its term's line. */
.feed-details-fact:has(> .feed-details-open) { align-items: baseline; }
.feed-details .feed-details-open {
  min-height: var(--feed-target); padding: 0; color: var(--info); font-size: inherit; text-align: start;
  text-decoration: underline; text-underline-offset: 2px; background: transparent; border: 0; border-radius: var(--feed-radius);
}
.feed-details .feed-details-open:hover:not(:disabled) { color: var(--text); background: transparent; }
.feed-details .feed-details-open.feed-id { font-family: var(--font-mono); }

@media (max-width: 760px) {
  /* The bar wraps before anything is cut: what a list offers takes a second line when the page is narrow enough to need it. */
  .feed-list-bar { flex-wrap: wrap; }
}

/* ------------------ THE REVIEW OF AN ACCESS CHANGE, AND A QUESTION THAT HOLDS ONE ------------------ */
/* What a change does to who can see shared work (`access-review.js`): lines of words, in the sharing form and in a move's question. */
.access-review { display: grid; gap: var(--space-2); min-width: 0; }
.access-review-heading { margin: 0; font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text-dim); }
.access-review-line { margin: 0; overflow-wrap: anywhere; }
/* A question with more to read than its sentence (`confirmation.js`): what it holds, then its two answers at the end, as the kit's own question has them. */
.confirmation-content { display: grid; gap: var(--space-4); min-width: 0; max-width: 60ch; }
.confirmation-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }

/* ------------------ THE FILE PREVIEW (`file-preview.js`, phase 29 P3), in the kit's dialog ------------------ */
/* Its controls, what it shows, the line that says how it went, and Download. What it shows scrolls in its own box, never the page. */
/* The dialog that holds one is wider than a question: the kit's own width token, so a page of a PDF reads at a useful size. */
.cloudcanvas-ui-dialog:has(.file-preview) { --cc-ui-dialog-width: 60rem; }
.file-preview { display: grid; gap: var(--space-3); box-sizing: border-box; width: 100%; min-width: 0; }
.file-preview-tools { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.file-preview-tools:empty { display: none; }
.file-preview-stage { min-width: 0; }
.file-preview-status { margin: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.file-preview-actions { display: flex; justify-content: flex-end; }
.file-preview-text, .file-preview-markdown, .file-preview-picture {
  box-sizing: border-box; max-height: min(60vh, 36rem); max-height: min(60dvh, 36rem); margin: 0; overflow: auto;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius);
}
.file-preview-text, .file-preview-markdown { padding: var(--space-3); }
/* Text as it was written, in the mono face, wrapped at the box's edge rather than scrolled sideways. */
.file-preview-text { font-family: var(--font-mono); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
/* A picture fits the box until it is zoomed; zoomed, it is a share of its own width and the box scrolls both ways. */
.file-preview-picture { display: grid; place-items: center; }
.file-preview-image { display: block; max-width: 100%; max-height: min(60vh, 36rem); max-height: min(60dvh, 36rem); object-fit: contain; }
.file-preview-image.is-zoomed { max-width: none; max-height: none; width: calc(var(--file-preview-natural, 20rem) * var(--file-preview-zoom, 1)); }
/* pdfjs's viewer scrolls a container it insists is placed absolutely: the frame is the box it fills. */
.file-preview-pdf { position: relative; height: min(65vh, 44rem); height: min(65dvh, 44rem); background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius); }
.file-preview-pdf-scroll { position: absolute; inset: 0; overflow: auto; }
.file-preview :is(.file-preview-text, .file-preview-markdown, .file-preview-picture, .file-preview-pdf-scroll):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* On a phone the dialog is a sheet at the foot: what it shows takes half the height, so its title and Close stay in view above it. */
@media (max-width: 760px) {
  .file-preview-text, .file-preview-markdown, .file-preview-picture, .file-preview-image { max-height: 45vh; max-height: 45dvh; }
  .file-preview-pdf { height: 45vh; height: 45dvh; }
}

/* ------------------ THE FILES OF A DEVICE RECORD (`file-list.js`, phase 29 P3; the Logger draws it too, C2) ------------------ */
/* A row is its kind's icon, its name over its kind and size, and Open, Download and Remove; Attach files and the one status line stand below. */
.file-list { display: grid; gap: var(--space-2); justify-items: start; min-width: 0; padding-top: var(--space-4); border-top: 1px solid var(--border); }
.file-list h3 { margin: 0; color: var(--text-dim); font-size: var(--text-base); font-weight: var(--weight-medium); }
.file-list[hidden], .file-list [hidden] { display: none; }
.file-list-rows { display: grid; width: 100%; margin: 0; padding: 0; list-style: none; }
.file-list-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-width: 0; padding-block: var(--space-2); border-bottom: 1px solid var(--border); }
.file-list-row > svg { flex: none; width: 20px; height: 20px; color: var(--text-dim); }
.file-list-text { display: grid; flex: 1 1 10rem; min-width: 0; }
.file-list-name { overflow-wrap: anywhere; font-weight: var(--weight-medium); }
.file-list-meta { color: var(--text-dim); font-size: var(--text-sm); }
.file-list-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.file-list-note, .file-list-status { margin: 0; color: var(--text-dim); font-size: var(--text-base); overflow-wrap: anywhere; }
.file-list-note:empty, .file-list-status:empty { display: none; }
.file-list-status.is-failed { color: var(--fail); }
/* Its buttons are words, quiet until pointed at: one look in the item view and in the Logger. */
.file-list-button.cloudcanvas-ui-button { min-height: var(--feed-target); padding-inline: var(--space-3); color: var(--text-dim); background: transparent; border-color: transparent; border-radius: var(--feed-radius); }
.file-list-button.cloudcanvas-ui-button:hover:not(:disabled) { color: var(--text); background: var(--accent-wash); border-color: transparent; }
.file-list [aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
/* Under a finger every control of the preview and of this list is 44px wide as well as 44px tall (final verify F7: Fit was 41px wide). */
@media (pointer: coarse) {
  .file-preview-tool.cloudcanvas-ui-button, .file-preview-actions .cloudcanvas-ui-button, .file-list-button.cloudcanvas-ui-button { min-width: 44px; min-height: 44px; }
}
