/* Library — the card grid at `/`. */

html,body{margin:0;min-height:100%}
body{
  background:
    radial-gradient(1000px 560px at 50% -8%, #15243C 0%, transparent 55%),
    radial-gradient(640px 380px at 100% 110%, #0C1A30 0%, transparent 55%),
    var(--bg);
}

.shell{width:min(1180px,100%); margin:0 auto; padding:0 clamp(18px,3vw,32px) 48px}

.bar{
  padding:18px 0 4px; display:flex; gap:20px; flex-wrap:wrap;
  font-size:12.5px; color:var(--faint);
}
.bar b{color:var(--ink); font-weight:600; font-variant-numeric:tabular-nums}

.grid{
  padding:18px 0 0;
  display:grid; gap:16px;
  grid-template-columns:repeat(auto-fill,minmax(320px,1fr));
}

/* ---- card --------------------------------------------------------------- */
.card{
  background:linear-gradient(180deg, #0E1626 0%, #0B1220 100%);
  border:1px solid var(--line);
  border-radius:16px;
  padding:20px 20px 16px;
  display:flex; flex-direction:column;
  position:relative;
  transition:border-color .2s ease, transform .2s ease, box-shadow .25s ease;
  animation:card-in .5s cubic-bezier(.22,1,.36,1) both;
}
.card:nth-child(1){animation-delay:.02s}
.card:nth-child(2){animation-delay:.06s}
.card:nth-child(3){animation-delay:.1s}
.card:nth-child(4){animation-delay:.14s}
.card:nth-child(n+5){animation-delay:.16s}
@keyframes card-in{
  from{opacity:0; transform:translateY(10px)}
  to{opacity:1; transform:none}
}
.card:hover{
  border-color:var(--line-hi);
  transform:translateY(-2px);
  box-shadow:0 18px 40px -24px #000c;
}
.card::before{
  content:""; position:absolute; left:0; top:18px; bottom:18px; width:3px;
  border-radius:0 3px 3px 0; background:var(--faint); opacity:.55;
}
.card.ok::before{background:var(--ok); opacity:.85}
.card.warn::before{background:var(--warn); opacity:.9}
.card.bad::before{background:var(--bad); opacity:.9}

.card h2{
  margin:0; font-family:var(--display); font-weight:600;
  font-size:22px; letter-spacing:-.02em; line-height:1.2;
}
.course{margin:6px 0 0; font-size:12.5px; color:var(--dim); letter-spacing:.02em}

.kv{
  display:flex; gap:14px; flex-wrap:wrap; margin-top:14px;
  font-size:12px; color:var(--faint);
}
.kv span{display:inline-flex; align-items:baseline; gap:4px}
.kv b{color:var(--ink); font-weight:600; font-variant-numeric:tabular-nums; font-size:13px}

.mis{
  margin:14px 0 0; font-size:13px; color:var(--dim); line-height:1.5;
  padding:10px 12px; border-radius:10px; background:var(--sunken); border:1px solid #172338;
}
.mis span{
  color:var(--faint); font-size:11px; letter-spacing:.08em; text-transform:uppercase;
  display:block; margin-bottom:4px;
}

.prims{display:flex; gap:6px; flex-wrap:wrap; margin-top:14px}
.prim{
  font-size:11px; padding:3px 8px; border-radius:6px;
  background:var(--raised); color:var(--dim); border:1px solid var(--line);
}
.prim.f{color:#C9B08A; border-color:#3A3220; background:#16120C}

.issues{margin:14px 0 0; padding-left:17px; font-size:12px; color:var(--warn); line-height:1.55}
.issues li+li{margin-top:3px}

/* ---- verdict -------------------------------------------------------------
   Arrives after the card (see src/ui/library/gate.js). It reserves its own line
   from the first paint so a card does not jump when the answer lands. */
.verdict{
  margin-top:14px; font-size:12px; letter-spacing:.02em;
  display:flex; flex-direction:column; align-items:flex-start; gap:0;
  min-height:17px;
}
.verdict[data-state="pending"]{
  color:var(--faint); flex-direction:row; align-items:center; gap:7px;
}
.verdict[data-state="ok"]{color:var(--ok)}
.verdict[data-state="ok"]::before{content:"✓ "; margin-right:4px}
.verdict[data-state="issues"]{color:var(--warn)}
.verdict[data-state="unknown"]{color:var(--faint)}
.verdict .issues{margin-top:8px}

.spin{
  width:9px; height:9px; border-radius:50%;
  border:1.5px solid var(--line-hi); border-top-color:var(--dim);
  animation:spin .7s linear infinite; flex:none;
}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){ .spin{animation:none} }

/* ---- card actions ------------------------------------------------------- */
.foot{
  margin-top:auto; padding-top:16px;
  display:flex; gap:6px; align-items:center; flex-wrap:wrap;
}
.foot a, .del{
  font:inherit; font-size:13px; font-weight:600;
  padding:8px 13px; border-radius:9px; text-decoration:none; cursor:pointer;
  transition:background .15s, border-color .15s, color .15s, filter .15s;
}
/* Four actions have to fit one row at the narrowest card, or `Delete` wraps to a
   line of its own and every card grows a ragged extra row. The two primary
   actions keep their weight; JSON and Delete give up the padding. */
.raw, .del{padding:8px 9px; font-size:12.5px}
.watch{background:var(--accent); color:#0A0E16; border:1px solid var(--accent)}
.watch:hover{filter:brightness(1.06)}
.raw{color:var(--dim); border:1px solid var(--line); background:transparent}
.raw:hover{color:var(--ink); border-color:var(--line-hi)}
.del{background:transparent; border:1px solid var(--line); color:var(--faint)}
.del:hover{border-color:var(--bad); color:var(--bad)}
.del.arm{border-color:var(--bad); background:var(--bad); color:#fff}
.del:disabled{opacity:.5; cursor:default}

/* MP4. The button IS the progress bar — a render is minutes long, and a
   separate bar somewhere else on the card makes you look in two places to
   answer one question. The fill is a background layer under the label so the
   text stays legible the whole way across. */
.mp4{
  font:inherit; font-size:13px; font-weight:600;
  padding:8px 12px; border-radius:9px; cursor:pointer;
  color:var(--dim); border:1px solid var(--line);
  background:linear-gradient(to right, #1E3454 0 var(--p,0%), transparent var(--p,0%) 100%);
  background-color:transparent;
  transition:color .15s, border-color .15s;
  position:relative; min-width:92px; text-align:center;
}
.mp4:hover{color:var(--ink); border-color:var(--line-hi)}
.mp4.busy{
  color:var(--ink); border-color:var(--line-hi); cursor:default;
  font-variant-numeric:tabular-nums;
}
.mp4.ready{color:var(--ok); border-color:#1E4B3A}
.mp4.ready:hover{color:var(--ok); border-color:var(--ok)}
.mp4.err{color:var(--bad); border-color:var(--bad)}
.mp4 small{font-weight:500; opacity:.6; font-size:11px; margin-left:5px}

.state{
  margin-left:auto; font-size:11px; letter-spacing:.06em;
  text-transform:uppercase; font-weight:600;
}
.state.ok{color:var(--ok)}
.state.warn{color:var(--warn)}
.state.bad{color:var(--bad)}

/* ---- empty + toast ------------------------------------------------------ */
.empty{
  grid-column:1/-1; padding:56px 20px; text-align:center;
  color:var(--faint); font-size:15px;
}
.empty a{color:var(--accent); text-decoration:none; font-weight:600}
.empty a:hover{text-decoration:underline}

.card.going{opacity:.4; pointer-events:none}
.toast{
  position:fixed; left:50%; bottom:26px; transform:translateX(-50%); z-index:9;
  background:var(--panel); border:1px solid var(--line); border-radius:12px;
  padding:12px 16px; font-size:13px; color:var(--dim);
  box-shadow:0 12px 40px #000a;
}
.toast b{color:var(--ink); font-weight:600}
.toast.bad{border-color:var(--bad); color:var(--bad)}

@media (max-width:560px){
  .card h2{font-size:20px}
  .state{width:100%; margin:6px 0 0; order:9}
}
