/* links.css — Studio's Links form, which links.js builds.

   Every colour, type size and control size is a role `styles.css` declares on
   `:root` and again under `[data-theme="dark"]`, so there is no dark block here.
   The one literal is the dialog's backdrop, because a custom property does not
   reach `::backdrop` in every browser this page supports. Spacing follows
   Studio's scale (4, 8, 12, 16, 24), and the form takes Studio's wide width.

   Nothing here is written from script. The shell's CSP (`style-src 'self'`)
   refuses style attributes, so state arrives as a class, `hidden` or `disabled`,
   and these rules draw it. */

/* `styles.css` already hides `[hidden]`; repeated for the elements below that set
   a display of their own, so this file does not lean on another's rule. */
.links-dialog [hidden] { display: none !important; }

/* ---------------------------------------------------------------- the card */

/* A native modal `<dialog>` in the top layer: a card on the panel surface with a
   hairline and Studio's 12-point radius, cross-faded in over a 40% black scrim,
   with no blur and no shadow. The header and footer stay put; the body scrolls. */
.links-dialog {
  width: min(560px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.links-dialog[open] { display: flex; animation: links-dialog-in .3s ease-in-out; }
.links-dialog::backdrop { background: rgba(0, 0, 0, .4); }
@keyframes links-dialog-in { from { opacity: 0; } }
.links-frame { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.links-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 24px 24px 0; }
.links-title { flex: 1 1 auto; min-width: 0; margin: 0; font: var(--type-h1); overflow-wrap: anywhere; }
.links-close { width: var(--icon-button); height: var(--icon-button); flex: 0 0 var(--icon-button); display: grid; place-items: center; padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-icon); font-size: 17px; line-height: 1; cursor: pointer; }
.links-close:hover:not(:disabled) { background: var(--hover); }
.links-close:disabled { color: var(--muted); cursor: progress; }

/* Studio's small loading indicator, beside the close button while the form saves.
   Neutral, as Studio's is: orange is kept for a chat turn at work. */
.links-spinner { width: 12px; height: 12px; flex: 0 0 12px; display: inline-block; border: 1.5px solid var(--line-strong); border-top-color: var(--loading); border-radius: 50%; animation: links-spin .8s linear infinite; }
@keyframes links-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .links-spinner { animation: none; border-top-color: var(--loading); }
}

.links-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; padding: 16px 24px; }
.links-lead { margin: 0; color: var(--ink-soft); font: var(--type-body); }
.links-unavailable { margin: 0; color: var(--ink-soft); font: var(--type-small); }

/* ------------------------------------------------------------- the editor */

/* Four parts, 24 points apart; inside a part, 16; inside a list, 8. */
.links-editor { display: flex; flex-direction: column; gap: 24px; }
.links-part { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.links-block { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.links-headline { margin: 0; color: var(--ink); font: var(--type-h3); overflow-wrap: anywhere; }

.links-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 14px; }
.links-eyebrow { margin: 0; color: var(--muted); font: var(--type-eyebrow); letter-spacing: var(--eyebrow-tracking); text-transform: uppercase; }
.links-count { flex: 0 0 auto; color: var(--muted); font: var(--type-caption); }
.links-none { margin: 0; color: var(--muted); font: var(--type-small); }
.links-caption { margin: 0; color: var(--muted); font: var(--type-caption); }
.links-small { margin: 0; color: var(--ink-soft); font: var(--type-small); }

/* A row: the value, then its action, with a soft hairline under each. */
.links-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.links-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.links-row-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.links-value { min-width: 0; color: var(--ink); font: var(--type-label); overflow-wrap: anywhere; user-select: text; }

/* The app's links: the path on the leading edge, where it opens from on the trailing. */
.links-app-link { align-items: baseline; padding: 8px 0; }
.links-path { min-width: 0; color: var(--ink); font: var(--type-label); overflow-wrap: anywhere; user-select: text; }
.links-opens { flex: 0 1 auto; color: var(--muted); font: var(--type-caption); text-align: right; }

/* The ADD field and its Add button, bottoms aligned. */
.links-add { display: flex; align-items: flex-end; gap: 8px; }
.links-field { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.links-input { width: 100%; height: var(--control-height); padding: 0 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-button); font: var(--type-body); }
.links-input:focus { border-color: var(--selected-line-strong); }
.links-input::placeholder { color: var(--muted); }
.links-input:disabled { color: var(--muted); background: var(--chip); cursor: progress; }

/* Studio's Secondary button with its `studioLabel` (Add), and the quiet one (Remove,
   Copy), which has no fill until hovered. Disabled, both are muted ink on the chip. */
.links-action { flex: 0 0 auto; height: var(--control-height); padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink); background-color: var(--selected-fill); border: 1px solid var(--selected-line); border-radius: var(--radius-button); font: var(--type-caption-strong); white-space: nowrap; cursor: pointer; }
.links-action:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.links-action:active:not(:disabled) { background-image: linear-gradient(var(--pressed), var(--pressed)); }
.links-action.quiet { background-color: transparent; border-color: transparent; }
.links-action:disabled { color: var(--muted); background-color: var(--chip); border-color: transparent; cursor: not-allowed; }
.links-copy.copied::before { content: "✓"; }

/* The association file, read-only and monospaced in an inset block that scrolls
   sideways rather than wrapping, as Studio's does; its addresses are selectable. */
.links-file { margin: 0; padding: 12px; overflow-x: auto; color: var(--ink); background: var(--inset); border-radius: var(--radius-icon); font: var(--type-mono); white-space: pre; user-select: text; }
.links-file:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.links-addresses { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.links-address { color: var(--ink); font: var(--type-mono); overflow-wrap: anywhere; user-select: text; }
.links-copy-failed { margin: 0; color: var(--bad-ink); font: var(--type-small); }

/* Studio's warning status badge: "Saved changes · next version". */
.links-badge { align-self: flex-start; margin: 0; padding: 4px 8px; color: var(--warn-ink); background: var(--warn-bg); border-radius: var(--radius-badge); font: var(--type-caption-strong); }

/* ------------------------------------------------------------- the footer */

/* Messages sit directly above the actions they are about and scroll within Studio's
   180 points, so the actions never leave. */
.links-foot { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; padding: 0 24px 24px; }
.links-messages { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.links-problem { margin: 0; color: var(--warn-ink); font: var(--type-small); }
.links-error { margin: 0; padding: 12px; color: var(--bad-ink); background: var(--bad-bg); border-radius: var(--radius-button); font: var(--type-small); }

/* Studio's dialog buttons: equal shares of the row, 28 points, body type — the
   dismissal in the Cancel role and the answer in the primary orange. */
.links-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.links-button { height: var(--control-height); min-width: 0; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: var(--radius-button); font: var(--type-body); white-space: nowrap; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
.links-button.cancel { color: var(--ink); background-color: var(--panel-muted); border-color: var(--line); }
.links-button.cancel:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.links-button.primary { color: var(--on-primary); background: var(--primary); }
.links-button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.links-button.primary:active:not(:disabled) { background: var(--primary-pressed); }
.links-button:disabled { color: var(--muted); background: var(--chip); background-image: none; border-color: transparent; cursor: not-allowed; }

@media (max-width: 560px) {
  .links-head { padding: 20px 16px 0; }
  .links-body { padding: 12px 16px; }
  .links-foot { padding: 0 16px 20px; }
}
