/* Ayni library 0.4.0, dialogs family: dialog.panel, small and big, modal and modeless. Load it after ayni-base.css
   (the Panel) and ayni-buttons.css (its buttons are .btn). Behaviour: ayni-dialogs.js. Rules: guidelines ch. 10. */

/* ---------- The dialog ---------- */
/* RULE: dialog size. A dialog is small by default: as wide as its content needs, 300 to 460 px; .big marks a big one
   (forms, lists, editors), 880 x 640 px. Neither is ever larger than the screen: the body scrolls inside, so the title
   row and the bottom row stay in reach. */
dialog.panel { margin: auto; width: fit-content; min-width: min(300px, calc(100vw - 32px)); max-width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); }
dialog.panel.big { width: min(880px, calc(100vw - 32px)); max-width: none; height: min(640px, calc(100dvh - 32px)); }
dialog.panel:not([open]) { display: none; }
dialog.panel:modal { box-shadow: var(--elev-dialog); }
dialog.panel::backdrop { background: var(--scrim); }
dialog.panel:not(:modal) { position: fixed; inset: auto 24px 24px auto; margin: 0; z-index: 50; }
/* Ayni focuses the dialog itself when it has no field to start in: no ring around the whole dialog */
dialog.panel:focus-visible { outline: none; }

/* RULE: a floating dialog shows its title row and bottom row plain, on the dialog's own colour */
dialog.panel > header, dialog.panel > form > header, dialog.panel > footer, dialog.panel > form > footer { background: none; border: 0; }
dialog.panel > header, dialog.panel > form > header { padding-top: 10px; justify-content: flex-end; }   /* no title: Close still at the right */
/* A long title wraps; it never runs under the buttons */
dialog.panel > header h2, dialog.panel > form > header h2 { min-width: 0; overflow-wrap: anywhere; }
dialog.panel > .body, dialog.panel > form > .body { padding-top: 4px; flex: 1 1 auto; min-height: 0; }   /* the body takes the free height: a full-screen dialog's bottom row sits at the bottom */
/* An empty title row or bottom row does not show; a dialog without a title row starts its body at the top edge */
dialog.panel > header:empty, dialog.panel > footer:empty, dialog.panel > form > header:empty, dialog.panel > form > footer:empty { display: none; }
dialog.panel > .body:first-child, dialog.panel > form > .body:first-child, dialog.panel > header:empty + .body { padding-top: var(--panel-pad); }
/* A phone (narrow, or short when turned sideways): a line marks the bottom row, which stays at the bottom edge while
   the body scrolls */
@media (max-width: 640px), (max-height: 520px) {
  dialog.panel > footer, dialog.panel > form > footer { border-top: var(--panel-border); }
}

/* RULE: a small dialog floats on every screen; a big dialog fills the screen below 1024 px, with no border, corners or
   shadow, and its title row and bottom row become tinted strips with a line */
@media (max-width: 1023.98px) {
  dialog.panel.big { width: 100%; height: 100%; max-width: none; max-height: none; inset: 0; margin: 0; border: 0; border-radius: 0;
    box-shadow: none; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  dialog.panel.big > header, dialog.panel.big > form > header { background: var(--panel-head-bg); border-bottom: var(--panel-border); padding-top: 8px; }
  dialog.panel.big > footer, dialog.panel.big > form > footer { background: var(--panel-head-bg); border-top: var(--panel-border); }
  dialog.panel.big > .body, dialog.panel.big > form > .body { padding-top: var(--panel-pad); }
  /* The page behind a full-screen dialog does not scroll, and its scrollbar does not show beside it */
  html:has(dialog.panel.big:modal) { overflow: hidden; }
}

/* ---------- Content ---------- */
/* The text of a confirmation or a message built in code keeps its line breaks */
dialog.panel .body > p.text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
/* A message with its icon (info, warn), in a dialog's body only: an app's own .msg (a chat bubble) keeps its look */
dialog.panel .body > .msg { display: flex; gap: 12px; align-items: flex-start; }
dialog.panel .body > .msg .icon { --icon: 28px; }
dialog.panel .body > .msg.warn .icon { color: var(--warn); } dialog.panel .body > .msg.info .icon { color: var(--accent); }

/* ---------- Moving ---------- */
/* RULE: a floating modal dialog moves by its title row (ayni-dialogs.js); while it moves nothing in it gets selected */
@media (min-width: 640.02px) { dialog.panel:modal > header, dialog.panel:modal > form > header { cursor: grab; } }
dialog.panel.dragging, dialog.panel.dragging * { cursor: grabbing !important; user-select: none; }

@media (prefers-reduced-motion: no-preference) { dialog.panel[open] { animation: dialog-rise .14s ease-out; } @keyframes dialog-rise { from { opacity: 0; transform: translateY(6px); } } }

/* The clip's panel (Ayni.attachPanel): where it sits is the app's */
.attach
{
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 6px;
    max-width: 420px;
    padding: 22px 10px 18px; border-radius: var(--radius-l);
    background: var(--card); box-shadow: var(--elev-dialog);
}
.att
{
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    border: none; background: none; font: inherit; font-size: 0.8rem; color: var(--text-dim); cursor: pointer;
}
.att .ai
{
    width: 54px; height: 54px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--on-accent); background: var(--c);
}
.att .ai svg   { width: 24px; height: 24px; }
.att:hover .ai { filter: brightness(1.08); }
.att[data-c="0"] { --c: var(--accent); }
.att[data-c="1"] { --c: #8B6FD6; }      /* purple */
.att[data-c="2"] { --c: var(--warn); }
.att[data-c="3"] { --c: var(--danger); }
.att[data-c="4"] { --c: #E07B39; }      /* orange */
.att[data-c="5"] { --c: var(--ok); }
.att[data-c="6"] { --c: #D45C9A; }      /* pink */
.att[data-c="7"] { --c: #1E9E9A; }      /* teal */
.att[data-c="8"] { --c: #6E7F96; }      /* slate */
/* a lone tile on the last row sits in the middle */
.att:last-child:nth-child(3n+1) { grid-column: 2; }
/* a panel of two tiles: two columns, so the pair sits in the middle */
.attach:has(> .att:nth-child(2):last-child) { grid-template-columns: repeat(2, 1fr); }

/* The Passkeys dialog (ayni-passkey.js, listDialog) */
.ayni-pk-list { list-style: none; margin: 0 0 12px; padding: 0; }
.ayni-pk-list li
{
    display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px;
    padding: 6px 0; border-bottom: 1px solid var(--border);
}
.ayni-pk-list .ayni-pk-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ayni-pk-list .hint { grid-column: 1; font-size: 0.85rem; }
.ayni-pk-list .btn { grid-column: 2; grid-row: 1 / span 2; }
.ayni-pk-add { display: flex; gap: 8px; margin-bottom: 8px; }
.ayni-pk-add .input { flex: 1; min-width: 0; }
/* With more add buttons (listDialog's "extra"): the name on its own line, the buttons below. */
.ayni-pk-add:has([data-extra]) { flex-wrap: wrap; }
.ayni-pk-add:has([data-extra]) .input { flex-basis: 100%; }

/* The "Locked documents" dialog and the recovery code (ayni-vault.js) */
.ayni-vault-row
{
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid var(--border);
}
.ayni-vault-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ayni-vault-code
{
    margin: 8px 0; padding: 10px 12px; border-radius: var(--radius-s, 6px); text-align: center;
    font: 600 1.05rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.04em;
    white-space: pre-wrap; word-break: break-all; user-select: all;
    background: var(--surface-2, rgba(127,127,127,.12));
}

/* ---------- From Nayive's app.css (2026-11-23): Ayni's own rules, moved here ---------- */
/* A row of buttons inside a dialog's body (not its bottom row): Calendar's
   export, the launcher's colour schemes, Write's templates. .extra pins the
   left-hand ones, as in a footer. */
.actions-row          { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.actions-row > .extra { display: flex; gap: var(--space-2); margin-right: auto; }

/* Properties / Info dialog (Drive, Photos): a label / value grid. The dimmed
   label reads like a .field label; the exact byte count goes under its own
   value in small type, the way every file manager writes it. */
.props
{
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin: 0 0 14px;
    font-size: 0.9rem;
}
.props dt { color: var(--text-dim); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.props dd .props-sub { display: block; font-size: 0.8rem; color: var(--text-dim); }

/* In a dialog: a red box that says plainly what went wrong or cannot be
   trusted (.warn-box), and a small dim line under the facts (.dim-note).
   Trips (its route, file and map sheets) and Calculator (its rate check). */
.warn-box { font-size: 0.8rem; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: var(--radius-s); padding: 10px 12px; margin: 0 0 14px; line-height: 1.4; }
.dim-note { font-size: 0.78rem; color: var(--text-dim); margin: 0 0 14px; line-height: 1.4; }
