/* Reusable pieces: cards, pills, buttons, inputs, meters, states, toasts.
 * Each maps to a module under app/components/. */

/* --- Card --------------------------------------------------------------- */
/* Soft light instead of a hard border: a 1px line round every panel is what
 * makes an admin screen look like a spreadsheet. The shadow does the same job
 * of separating the card from the shell, without drawing a box. */
.card {
  background: var(--panel);
  border-radius: var(--r-card);
  padding: var(--pad-y) var(--pad-x);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: box-shadow .22s var(--ease-soft), transform .22s var(--ease-soft);
}
.card-tight { padding: clamp(9px, 1.3vh, 16px) clamp(11px, 1.1vw, 20px); }
.card-head {
  flex: 0 0 auto;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}

/* --- Pill --------------------------------------------------------------- */
/* A touch more air and a little more weight: at this size a pill reads as a
 * label rather than a badge unless it is given both. */
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  font-size: var(--t-micro); font-weight: 600;
  letter-spacing: .1px;
  white-space: nowrap; flex: 0 0 auto;
}
.pill-complete  { background: var(--ok-bg);    color: var(--ok); }
.pill-open      { background: var(--open-bg);  color: var(--open); }
.pill-attention { background: var(--bad-bg);   color: var(--bad); }
.pill-error     { background: var(--bad-bg);   color: var(--bad); }
.pill-quiet     { background: var(--quiet-bg); color: var(--quiet); }
.pill-warn      { background: var(--warn-bg);  color: var(--warn); }

/* --- Button ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: clamp(34px, 3.9vh, 42px); padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-btn);
  background: var(--panel); color: var(--ink-2);
  font-size: var(--t-small); font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn[disabled] { opacity: .5; cursor: default; border-color: var(--line); color: var(--muted); }
.btn[disabled]:hover { border-color: var(--line); color: var(--muted); }
/* The one place the brand gradient is the whole surface, matching the app's
 * own primary button. Hover darkens with an overlay rather than swapping the
 * gradient, so the four stops never shift under the pointer. */
.btn-primary {
  border: 0; color: #fff;
  background-image: var(--brand-sweep);
  background-color: var(--accent);
}
.btn-primary:hover {
  color: #fff;
  background-image: linear-gradient(rgba(0, 0, 0, .12), rgba(0, 0, 0, .12)), var(--brand-sweep);
}
.btn-dark { border: 0; background: var(--dark); color: #fff; }
.btn-dark:hover { background: var(--dark-2); color: #fff; }
.btn-danger { border: 0; background: var(--bad); color: #fff; }
.btn-danger:hover { background: #a8262f; color: #fff; }
.btn-ok { border: 0; background: var(--ok); color: #fff; }
.btn-ok:hover { background: #146c3c; color: #fff; }
.btn-quiet { background: var(--sub-2); border-color: transparent; }
.btn-quiet:hover { background: #ece7f3; border-color: transparent; color: var(--ink-2); }
.btn-wide { width: 100%; height: clamp(38px, 4.4vh, 48px); font-size: var(--t-body); border-radius: var(--r-nav); }

.btn-sq {
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-sq:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-sq[disabled] { opacity: .4; cursor: default; border-color: var(--line); color: var(--faint); }
.btn-sq[disabled]:hover { border-color: var(--line); color: var(--faint); }

.spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Field / input ------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: var(--t-micro); color: var(--muted); line-height: 1.5; }
.field .err { font-size: var(--t-micro); color: var(--bad); line-height: 1.5; }

.input {
  width: 100%; height: clamp(36px, 3.9vh, 42px);
  border: 1px solid var(--line); border-radius: var(--r-btn);
  padding: 0 12px; font-size: var(--t-small);
  background: var(--panel); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 47, 248, .12); }
.input[aria-invalid="true"] { border-color: var(--bad); }

.pw { position: relative; display: flex; }
.pw .input { padding-right: 46px; }
.pw > button {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.pw > button:hover { color: var(--ink-2); background: var(--sub-2); }

/* --- Segmented control -------------------------------------------------- */
.seg {
  display: flex; align-items: center; gap: 4px;
  background: var(--sub-2); border-radius: var(--r-btn); padding: 3px;
  flex: 0 0 auto;
}
.seg > button {
  border: 0; border-radius: var(--r-sm); padding: 7px 11px;
  background: transparent; color: var(--muted);
  font-size: var(--t-small); font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.seg > button:hover { color: var(--ink-2); }
.seg > button[aria-pressed="true"] {
  background: var(--panel); color: var(--ink);
  box-shadow: 0 1px 3px rgba(35, 34, 40, .12);
}
.seg-dark > button[aria-pressed="true"] { background: var(--dark); color: #fff; box-shadow: none; }
.seg-plain { background: var(--panel); padding: 4px; border-radius: var(--r-tile); }

/* Two segmented controls side by side. They scroll together rather than
 * wrapping into a staircase of pill-shaped blocks. */
.chiprow {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: nowrap; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.chiprow::-webkit-scrollbar { display: none; }

/* --- Radio-style picker (export format, document list) ------------------ */
.pick {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px; border: 0; border-radius: var(--r-nav);
  background: var(--sub); cursor: pointer; text-align: left; width: 100%;
  transition: background .16s var(--ease), box-shadow .16s var(--ease);
}
.pick:hover { background: var(--sub-2); }
.pick[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-ring); }
.pick .pl { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pick .pl .t { font-size: var(--t-body); font-weight: 500; }
.pick .pl .s { font-size: var(--t-micro); color: var(--muted); }
.pick .dot { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px #ddd8e6; }
.pick[aria-pressed="true"] .dot { background: var(--accent); box-shadow: inset 0 0 0 3px #fff; }

/* --- Thumbnail ---------------------------------------------------------- */
.thumb {
  display: block; flex: 0 0 auto;
  width: clamp(38px, 3.8vh, 44px); height: clamp(38px, 3.8vh, 44px);
  border-radius: var(--r-ctl); object-fit: cover; background: var(--sub-2);
}
.thumb-empty { background: var(--sub-2); box-shadow: inset 0 0 0 1px #ebe7f1; }
/* Stands in for a photo whose preview never reached the archive. */
.iris { background: radial-gradient(circle at 50% 50%, #17161b 0 20%, #6d3fb0 22% 52%, #d9c8f2 54% 100%); }

/* The archive link is a round trip to another host. The row keeps its shape
   and shimmers until the image lands, rather than popping in over a hole. */
.thumb-live { position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px #ebe7f1; }
.thumb-live::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, var(--sub-2) 30%, #eae4f3 48%, var(--sub-2) 66%);
  background-size: 260% 100%;
  animation: shimmer 1.5s linear infinite;
}
.thumb-live.is-ready::before { display: none; }
.thumb-live .thumb-img {
  position: relative; display: block; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; transition: opacity .3s var(--ease);
}
.thumb-live.is-ready .thumb-img { opacity: 1; }

/* --- Meter / bars ------------------------------------------------------- */
.meter { display: block; height: 6px; border-radius: 999px; background: var(--accent-wash); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s var(--ease); }
.meter.tall { height: 7px; }
.meter .m-bad { background: var(--bad); }
.meter .m-warn { background: var(--warn); }
.meter .m-ok { background: var(--ok); }

.track { display: flex; align-items: center; height: clamp(20px, 2.6vh, 30px); background: var(--sub-3); border-radius: 8px; overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 8px; background: var(--accent); transition: width .4s var(--ease); }
.track .t-soft { background: #c9a8f7; }
.track .t-dark { background: var(--dark); }
.track .t-bad  { background: var(--bad); }
.track .t-ok   { background: var(--ok); }

.minirow { display: flex; flex-direction: column; gap: 4px; }
.minirow .lbl { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: var(--t-small); }
.minirow .lbl .a { color: var(--ink-2); min-width: 0; }
.minirow .lbl .b { color: var(--ink-4); white-space: nowrap; }

/* --- Key/value ---------------------------------------------------------- */
.kv { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kv .k { font-size: var(--t-micro); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kv .v { font-size: var(--t-body); color: var(--ink); overflow-wrap: anywhere; }

.rowkv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rowkv .k { font-size: var(--t-small); color: var(--muted); white-space: nowrap; }
.rowkv .v { font-size: var(--t-small); color: var(--ink); text-align: right; overflow-wrap: anywhere; }

/* --- Disclosure --------------------------------------------------------- */
details.disc {
  flex: 0 0 auto; background: var(--panel); border-radius: var(--r-card);
  padding: clamp(9px, 1.3vh, 16px) clamp(11px, 1.1vw, 20px);
}
details.disc.bare { background: transparent; padding: 9px 0 0; border-top: 1px solid var(--line-3); border-radius: 0; }
details.disc > summary {
  font-size: var(--t-body); font-weight: 500; color: var(--ink-2);
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  min-height: 28px;
}
details.disc > summary::-webkit-details-marker { display: none; }
details.disc > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .18s var(--ease);
}
details.disc[open] > summary::after { transform: rotate(-135deg); }
details.disc .disc-body { display: flex; flex-direction: column; gap: 5px; padding-top: 10px; }

.pre {
  margin: 8px 0 0; background: var(--sub); border-radius: 10px; padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--t-micro); color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5;
}

/* --- Empty / error / loading states ------------------------------------- */
.state {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px 16px; min-height: 140px;
}
.state svg { color: var(--faint); }
.state .t { font-size: var(--t-body); color: var(--ink-2); font-weight: 500; }
.state .b { font-size: var(--t-small); color: var(--muted); max-width: 44ch; line-height: 1.55; }
.state-bad svg { color: var(--bad); }

.banner {
  flex: 0 0 auto; display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--r-row);
  padding: clamp(9px, 1.1vh, 13px) clamp(11px, 1.1vw, 18px);
  font-size: var(--t-small); line-height: 1.5;
}
.banner svg { flex: 0 0 auto; margin-top: 1px; }
.banner-bad  { background: var(--bad-soft); color: var(--bad-ink); }
.banner-bad svg { color: var(--bad); }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-warn svg { color: var(--warn); }
.banner-ok   { background: var(--ok-bg); color: #0f6236; }
.banner-ok svg { color: var(--ok); }
.banner-quiet { background: var(--sub); color: var(--ink-4); }
.banner-quiet svg { color: var(--muted); }

.sk {
  background: linear-gradient(90deg, #f1eef5 25%, #f8f6fb 37%, #f1eef5 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 10px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --- Toasts ------------------------------------------------------------- */
.toasts {
  position: fixed; z-index: 120;
  right: clamp(10px, 2vw, 26px); bottom: clamp(10px, 2vh, 26px);
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(92vw, 400px); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--dark); color: #fff;
  border-radius: var(--r-row); padding: 12px 14px;
  font-size: var(--t-small); line-height: 1.45;
  box-shadow: var(--shadow-pop);
  animation: toastin .22s var(--ease);
}
.toast svg { flex: 0 0 auto; margin-top: 1px; color: #d9bcff; }
.toast.ok svg  { color: #7ee2a8; }
.toast.bad svg { color: #ff8f97; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* --- Confirm dialog ----------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 160;
  background: rgba(20, 19, 23, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadein .16s var(--ease);
}
@keyframes fadein { from { opacity: 0; } }
.dialog {
  width: 100%; max-width: 400px;
  background: var(--panel); border-radius: var(--r-shell);
  box-shadow: var(--shadow-shell);
  padding: clamp(18px, 2.6vh, 26px);
  display: flex; flex-direction: column; gap: 12px;
}
.dialog h2 { margin: 0; font-size: var(--t-lg); font-weight: 600; }
.dialog p { margin: 0; font-size: var(--t-small); color: var(--ink-4); line-height: 1.55; }
.dialog .acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* --- How-it-works film (Settings) ---------------------------------------- */
/* The film the app plays, a drop zone to replace it, and the upload's real
   progress in place of the zone while it runs. */
.film-now {
  display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  gap: 14px; align-items: center;
}
@media (max-width: 520px) { .film-now { grid-template-columns: minmax(0, 1fr); } }
.film-preview {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-tile); overflow: hidden;
  /* The app's own placeholder: black, lit from two corners in the brand's ends. */
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(11, 139, 255, .34), transparent 55%),
    radial-gradient(120% 120% at 100% 100%, rgba(233, 53, 233, .28), transparent 55%),
    #0b0b10;
  box-shadow: var(--shadow-card);
}
.film-preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.film-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.film-kicker {
  font-size: var(--t-micro); font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-ink);
}
.film-name { font-size: var(--t-mid); font-weight: 600; color: var(--ink); line-height: 1.3; overflow-wrap: anywhere; }
.film-sub { font-size: var(--t-small); color: var(--muted); }

.film-drop {
  position: relative; display: flex; align-items: center; gap: 13px;
  padding: 14px 16px; border-radius: var(--r-row);
  border: 1.5px dashed var(--accent-ring); background: var(--accent-soft);
  cursor: pointer;
  transition: border-color .18s var(--ease), background-color .18s var(--ease),
    transform .18s var(--ease), box-shadow .18s var(--ease);
}
.film-drop:hover { border-color: var(--accent); background: var(--accent-wash); }
.film-drop:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 77, 246, .2); }
.film-drop.over {
  border-style: solid; border-color: var(--accent); background: var(--accent-wash);
  transform: scale(1.01); box-shadow: var(--shadow-card-hover);
}
.film-drop:has(.film-file:disabled) { opacity: .5; cursor: default; }
/* Hidden from sight, not from the keyboard or a screen reader. */
.film-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.film-drop-ic {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background-image: var(--brand-sweep);
  box-shadow: 0 8px 18px -10px rgba(139, 77, 246, .9);
}
.film-drop-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.film-drop-t { font-size: var(--t-body); font-weight: 600; color: var(--ink); }
.film-drop-or { font-weight: 400; color: var(--ink-4); }
.film-drop-t u { color: var(--accent-ink); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.film-drop-s { font-size: var(--t-micro); color: var(--muted); }

.film-progress {
  display: flex; flex-direction: column; gap: 8px;
  padding: 13px 15px; border-radius: var(--r-row); background: var(--sub-2);
}
.film-progress-row { display: flex; align-items: center; gap: 10px; min-height: 24px; }
.film-progress-name { flex: 1 1 auto; min-width: 0; font-size: var(--t-small); font-weight: 600; color: var(--ink); }
.film-pct { font-size: var(--t-mid); font-weight: 700; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.film-detail { flex: 1 1 auto; font-size: var(--t-micro); color: var(--muted); font-variant-numeric: tabular-nums; }
.film-bar { position: relative; height: 8px; border-radius: 999px; background: var(--line-4); overflow: hidden; }
.film-bar-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit;
  background-image: var(--brand-sweep); transition: width .25s linear;
}
.film-bar.checking .film-bar-fill { width: 100%; }
.film-bar.checking::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: translateX(-100%); animation: film-sheen 1.1s var(--ease) infinite;
}
@keyframes film-sheen { to { transform: translateX(100%); } }

.film-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.film-foot .disc { flex: 1 1 14rem; min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  .film-drop, .film-bar-fill { transition: none; }
  .film-drop.over { transform: none; }
  .film-bar.checking::after { animation: none; }
}
