/* Components of SPEC 3.3. Markup comes from aida_shell/ui/*.html macros; behaviour from static/ui/*.js. */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-4);
  color: var(--ink); text-decoration: none;
  border-radius: var(--r-control); border: 1px solid var(--hairline); background: var(--surface-2);
  font: 500 13px/1 var(--font); cursor: pointer; transition: background var(--m-fast) var(--ease);
}
.btn:hover { background: color-mix(in srgb, var(--surface-2), var(--ink) 6%); }
.btn.primary { background: var(--gold); color: var(--on-gold); border-color: transparent; }
.btn.primary:hover { background: var(--gold-hi); }
.btn.ghost { background: none; }
.btn.danger { background: none; color: var(--fail); border-color: color-mix(in srgb, var(--fail), transparent 55%); }
.btn.danger:hover { background: color-mix(in srgb, var(--fail), transparent 86%); }
.btn.ai { background: color-mix(in srgb, var(--ai), transparent 84%); color: var(--ai); border-color: transparent; }
.btn.ai:hover { background: color-mix(in srgb, var(--ai), transparent 74%); }
.btn.sm { height: 28px; padding: 0 var(--s-3); font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.icon.sm { width: 26px; height: 26px; }
.btn[aria-pressed="true"] { color: var(--gold); background: var(--gold-wash); }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.price { color: var(--ink-2); font: 400 13px/1 var(--font); font-variant-numeric: tabular-nums; }
.btn.primary .price { color: color-mix(in srgb, var(--on-gold), transparent 30%); }

/* Status chip: glyph, two-letter code and label; the meaning is the text colour, never the only signal. */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: var(--r-pill); background: var(--surface-2); font: var(--t-small); color: var(--ink-2);
  border: 0; max-width: 100%; overflow: hidden;
}
.chip.on { background: var(--gold-wash); color: var(--gold); }
.chip .code { font: var(--t-micro); letter-spacing: .04em; }
.chip.ok { color: var(--ok); } .chip.look { color: var(--look); } .chip.fail { color: var(--fail); }
.chip.info { color: var(--info); } .chip.ai { color: var(--ai); } .chip.edited { color: var(--edited); }
.chip.narrator { color: var(--narrator); }

.card { background: var(--surface-1); border-radius: var(--r-card); padding: var(--s-5); min-width: 0; max-width: 100%; }
.card.flat { padding: 0; overflow: hidden; }
.h2 { font: var(--t-title); margin: 0; }
.kv { margin: 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s-5); }
.kv > div { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-2) 0; border-top: 1px solid var(--hairline); font: var(--t-small); }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; text-align: right; }
.kbd { font: var(--t-micro); color: var(--ink-2); border: 1px solid var(--hairline); border-radius: 4px; padding: 0 5px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-control); padding: 2px; align-items: center; }
.seg button { background: none; border: 0; border-radius: 5px; height: 24px; padding: 0 var(--s-3); font: var(--t-small); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--gold-wash); color: var(--gold); }
/* The same control as links, where each choice is a page (Storia's Testo · Scheda · Dialoghi). */
.seg a { display: inline-flex; align-items: center; height: 24px; padding: 0 var(--s-3); border-radius: 5px; font: var(--t-small); color: var(--ink-2); white-space: nowrap; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current="page"] { background: var(--gold-wash); color: var(--gold); }

/* Accordion: <details>, open state remembered by ui/accordion.js. */
details.acc { border-top: 1px solid var(--hairline); }
details.acc > summary {
  list-style: none; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; cursor: pointer;
  font: 500 13px/20px var(--font); white-space: nowrap;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary .n { color: var(--ink-3); font: var(--t-small); font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; }
details.acc > summary > :not(.n) { flex: none; }
details.acc > summary > .sp { flex: 1 1 0; }
details.acc > summary::after {
  content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2);
  transform: rotate(45deg) translateY(-2px); transition: transform var(--m-base) var(--ease);
}
details.acc[open] > summary::after { transform: rotate(-135deg); }
details.acc > .body { padding-bottom: var(--s-5); }

/* Drawer: right side, level 2; only transform animates. 420 px, or 640 px wide. */
.scrim { position: fixed; inset: 0 0 var(--status) var(--rail); background: color-mix(in srgb, var(--bg), transparent 45%); z-index: 6; }
.scrim.clear { background: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: var(--status); width: min(420px, calc(100vw - var(--rail) - 24px)); z-index: 7;
  background: var(--surface-2); border-radius: var(--r-drawer) 0 0 var(--r-drawer); box-shadow: var(--lift-2);
  display: flex; flex-direction: column; animation: drawer-in var(--m-base) var(--ease);
}
.drawer.wide { width: min(640px, calc(100vw - var(--rail) - 24px)); }
.drawer > header { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) 108px var(--s-3) var(--s-5); white-space: nowrap; }
.drawer > header h2 { font: 500 15px/22px var(--font); margin: 0; }
.drawer > .body { padding: 0 var(--s-5) var(--s-5); overflow: auto; min-height: 0; flex: 1 1 auto; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }

/* Tray: chips with role groups, a drop target. */
.tray { display: flex; flex-wrap: wrap; gap: var(--s-5); min-width: 0; padding: var(--s-3); border-radius: var(--r-card); }
.tray.over { box-shadow: inset 0 0 0 1px var(--gold); background: var(--gold-wash); }
.tray .group { min-width: 0; max-width: 100%; }
.tray .group > .gl { margin-bottom: var(--s-3); font: var(--t-micro); color: var(--ink-3); }
.tray .refs { display: flex; flex-wrap: wrap; gap: var(--s-3); }

/* Compare strip: ciak thumbnails, up to three selected for the synced players. */
.strip { display: flex; gap: var(--s-3); overflow-x: auto; max-width: 100%; padding-bottom: var(--s-2); }
.strip > * { flex: none; width: 140px; border-radius: var(--r-control); background: var(--surface-2); cursor: pointer; }
.strip > [aria-selected="true"] { box-shadow: inset 0 0 0 1px var(--gold); }

/* Timeline strip: clip ranges on a time ruler. The ruler is shared with the studio dopesheet. */
.timeline { position: relative; min-width: 0; }
.ruler { position: relative; height: 28px; border-bottom: 1px solid var(--hairline); }
.ruler span { position: absolute; top: 6px; margin-left: 6px; white-space: nowrap; font: var(--t-micro); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ruler span::before { content: ""; position: absolute; left: -6px; top: 16px; height: 6px; border-left: 1px solid var(--hairline); }
.clips { position: relative; height: 44px; margin-top: var(--s-2); }
.clips > [data-range] { position: absolute; top: 0; bottom: 0; background: var(--gold-wash); border-radius: var(--r-control); box-shadow: inset 0 0 0 1px var(--gold); overflow: hidden; }
.clips > .slug { background: none; box-shadow: inset 0 0 0 1px var(--hairline); }

/* Soft-limit inline: warning line with its reason field, never a modal. */
.soft { display: flex; gap: var(--s-2); align-items: flex-start; margin: var(--s-3) 0 0; color: var(--look); }
.soft svg { margin-top: 2px; }
.soft input { flex: 1; min-width: 0; background: var(--surface-1); color: var(--ink); border: 1px solid var(--hairline); border-radius: var(--r-control); height: 28px; padding: 0 var(--s-3); font: var(--t-small); }

/* Dialog: level 3, one primary action. */
dialog.dlg {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--hairline); border-radius: var(--r-drawer);
  box-shadow: var(--lift-3); padding: var(--s-5); width: min(480px, calc(100vw - var(--rail) - 32px));
}
dialog.dlg::backdrop { background: color-mix(in srgb, var(--bg), transparent 45%); }
dialog.dlg form { display: grid; gap: var(--s-3); }
dialog.dlg menu { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-3); padding: 0; margin: var(--s-3) 0 0; }
dialog.dlg .actions { display: flex; justify-content: flex-end; gap: var(--s-3); margin-top: var(--s-5); }

/* Live news pill (6.1 item 10): "something changed here, click to show it". Compact, gold, never full width. */
.aida-pill {
  display: inline-flex; align-items: center; gap: var(--s-2); width: auto; justify-self: start; height: 22px;
  padding: 0 var(--s-3); border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--gold), transparent 60%); background: var(--gold-wash); color: var(--gold);
  font: var(--t-small); font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: color var(--m-fast) var(--ease), border-color var(--m-fast) var(--ease);
}
.aida-pill::before { content: "\21BB" / ""; }
.aida-pill:hover { color: var(--gold-hi); border-color: var(--gold-hi); }
.aida-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.aida-fresh { animation: aida-fresh 1.2s var(--ease); }
@keyframes aida-fresh { from { background: var(--gold-wash); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .aida-fresh { animation: none; } }

/* Toast: a notice at the foot of the window; announce() appends it to the body, or into an open dialog. */
.toast {
  position: fixed; bottom: calc(var(--status) + var(--s-4)); left: 50%; transform: translateX(-50%); z-index: 20;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-control); box-shadow: var(--lift-2); background: var(--ink); color: var(--bg);
}
.toast.error { background: var(--fail); }
