/* ============================================================
   Studying — the subject tracker (/op/study) and the assessment
   form (/forms/assessment). Classes are prefixed st-.
   Colours come from tokens.css only, so a re-theme is a token swap.
   ============================================================ */

/* Elements toggled with the hidden attribute stay hidden whatever else styles them. */
.st-next-panel[hidden], .st-form [hidden], #st-f-wrap[hidden], #st-f-done[hidden],
.st-subject [hidden], .modal-body .st-template [hidden] { display: none !important; }

/* ── page head ──────────────────────────────────────────────────── */

.st-head-actions { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.st-semester { display: flex; align-items: center; gap: var(--space-sm); }
.st-semester-lbl {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: hsl(var(--muted-foreground)); white-space: nowrap;
}
.st-semester .input { width: auto; min-width: 180px; min-height: 44px; }
.st-semester .input:disabled { opacity: 1; background-color: var(--gray-soft); cursor: default; }

/* ── what's next ────────────────────────────────────────────────── */

.st-next-panel .panel-head { margin-bottom: var(--space-md); align-items: center; }
.st-next-note { font-size: 13px; color: hsl(var(--muted-foreground)); }
.st-next { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-md); }
.st-next > .empty { grid-column: 1 / -1; padding: var(--space-lg); }

.st-next-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  text-align: left; cursor: pointer;
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-left: 3px solid var(--gray-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-height: 44px; min-width: 0;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-slow) var(--ease);
}
.st-next-card:hover { border-color: var(--cyan-line); box-shadow: var(--shadow-soft); }
.st-next-card.is-soon { border-left-color: var(--warning); }
.st-next-card.is-overdue { border-left-color: var(--danger); }
.st-next-top { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; }
.st-next-subject {
  font-size: 12.5px; color: hsl(var(--muted-foreground));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.st-next-title { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.st-next-foot { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }

/* ── small labels shared by page and form ───────────────────────── */

.st-kind {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid var(--gray-border); background: var(--gray-soft); color: var(--gray-muted-text);
  white-space: nowrap; flex-shrink: 0;
}
.st-kind-ice        { background: var(--cyan-tint);    color: var(--cyan-ink);    border-color: var(--cyan-line); }
.st-kind-assignment { background: var(--warning-tint); color: var(--warning-ink); border-color: var(--warning-line); }
.st-kind-exam       { background: var(--black);        color: var(--white);       border-color: var(--black); }

.st-due { font-size: 12.5px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.st-due.soon    { color: var(--warning-ink); font-weight: 600; }
.st-due.overdue { color: var(--danger-ink);  font-weight: 600; }
.st-est { font-size: 12.5px; color: hsl(var(--muted-foreground)); font-family: var(--font-mono); white-space: nowrap; }
.st-mark {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700;
  background: var(--success-tint); color: var(--success-ink); border: 1px solid var(--success-line);
  white-space: nowrap;
}

/* ── subject cards ──────────────────────────────────────────────── */

.st-subjects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: var(--space-lg);
  align-items: start;
  transition: opacity var(--dur-fast) var(--ease);
}
.st-subjects.is-loading { opacity: 0.55; pointer-events: none; }
.st-subjects > .panel { grid-column: 1 / -1; margin-bottom: 0; }

.st-subject {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  min-width: 0;
}
.st-subject-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); }
.st-subject-name { min-width: 0; }
.st-subject-name h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
.st-code { display: inline-block; font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.st-subject-actions { flex-shrink: 0; gap: 6px; }

.st-progress-row { display: flex; align-items: center; gap: var(--space-md); margin: var(--space-md) 0 var(--space-sm); }
.st-progress {
  flex: 1; height: 8px; border-radius: var(--radius-full);
  background: var(--gray-soft); border: 1px solid var(--gray-border); overflow: hidden;
}
.st-progress > span {
  display: block; height: 100%; border-radius: var(--radius-full);
  background: var(--accent-gradient);
  transition: width var(--dur-slow) var(--ease);
}
.st-progress-text { font-size: 13px; font-weight: 600; white-space: nowrap; }

.st-group { margin-top: var(--space-md); }
.st-group-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  padding-bottom: 4px; border-bottom: 1px solid var(--gray-border);
}
.st-group-count { font-family: var(--font-mono); letter-spacing: 0; text-transform: none; }

.st-row {
  display: flex; align-items: flex-start; gap: var(--space-sm);
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
}
.st-row:last-child { border-bottom: 0; }
.st-row-body { flex: 1; min-width: 0; padding-top: 10px; }
.st-row-title { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.st-row.is-done .st-row-title {
  color: hsl(var(--muted-foreground));
  text-decoration: line-through; text-decoration-color: var(--gray-border);
}
.st-row-meta { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; margin-top: 4px; }
.st-row-meta .pill { padding: 2px 8px; font-size: 11.5px; }
.st-row-hold { font-size: 12.5px; color: var(--danger-ink); margin-top: 4px; }
.st-row-detail {
  font-size: 12.5px; color: hsl(var(--muted-foreground)); margin-top: 4px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.st-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 6px; flex-shrink: 0; }

.st-row.st-flash { animation: st-flash 2.4s var(--ease) 1; }
@keyframes st-flash {
  0%, 40% { background: var(--cyan-tint); box-shadow: 0 0 0 2px var(--cyan-line); }
  100%    { background: transparent; box-shadow: 0 0 0 0 transparent; }
}

/* The tick: a 44px tap target around a 22px box. */
.st-tick {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; background: transparent; padding: 0; cursor: pointer;
  border-radius: var(--radius-sm);
}
.st-tick:disabled { cursor: default; }
.st-tick:disabled .st-tick-box { opacity: 0.45; }
.st-tick-box {
  width: 22px; height: 22px; border-radius: 6px;
  border: 1.5px solid var(--gray-muted-text);
  background: var(--white);
  position: relative; display: block; flex-shrink: 0;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.st-tick:not(:disabled):hover .st-tick-box { border-color: var(--cyan); }
.st-tick.done .st-tick-box,
.st-f-tickrow.on .st-tick-box { background: hsl(var(--primary)); border-color: hsl(var(--primary)); }
.st-tick.done .st-tick-box::after,
.st-f-tickrow.on .st-tick-box::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 6px; height: 11px;
  border: solid var(--black); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.st-empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); }
.st-empty-sm { padding: var(--space-lg) var(--space-sm); font-size: 13.5px; }

/* ── modals ─────────────────────────────────────────────────────── */

.st-modal-delete { margin-right: auto; }
.st-template { padding: var(--space-md); border: 1px solid var(--gray-border); border-radius: var(--radius-sm); background: var(--gray-soft); }
.st-template .check-inline { font-weight: 600; min-height: 32px; }
.st-template-date { margin: var(--space-md) 0 0; }

.st-detail { display: grid; grid-template-columns: max-content 1fr; gap: 8px var(--space-md); margin: 0; font-size: 14px; }
.st-detail dt { color: hsl(var(--muted-foreground)); font-weight: 600; font-size: 13px; }
.st-detail dd { margin: 0; }
.st-detail-study { margin-top: var(--space-md); padding-top: var(--space-md); border-top: 1px solid var(--gray-border); font-size: 14px; }
.st-detail-study .lbl { font-size: 13px; font-weight: 600; margin-bottom: 4px; }

/* ── the form ───────────────────────────────────────────────────── */

.st-f-semester { font-weight: 500; text-transform: none; letter-spacing: 0; }

.st-f-tickrow {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-md);
  background: var(--white);
  margin-bottom: var(--space-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.st-f-tickrow:last-child { margin-bottom: 0; }
.st-f-tickrow.is-soon { border-left: 3px solid var(--warning); }
.st-f-tickrow.is-overdue { border-left: 3px solid var(--danger); }
.st-f-tickrow.on { border-color: var(--black); box-shadow: 0 0 0 2px var(--cyan-line); }

.st-f-tickbtn {
  display: flex; align-items: center; gap: var(--space-md);
  width: 100%; min-height: 64px;
  padding: 12px 16px;
  border: 0; background: transparent; border-radius: var(--radius-md);
  text-align: left; cursor: pointer;
}
.st-f-tickbtn .st-tick-box { width: 28px; height: 28px; border-radius: 8px; }
.st-f-tickrow.on .st-f-tickbtn .st-tick-box::after { left: 9px; top: 4px; width: 7px; height: 13px; }
.st-f-tickbody { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.st-f-ticktitle { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.st-f-tickmeta { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.st-f-markwrap { padding: 0 16px 14px 60px; }
.st-f-markwrap .lbl { font-weight: 600; }
.st-f-mark { max-width: 200px; min-height: 44px; }

/* ── narrow screens ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  .st-next { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .st-head-actions { width: 100%; }
  .st-semester { width: 100%; }
  .st-semester .input { flex: 1; min-width: 0; }
  .st-head-actions .btn { flex: 1; min-height: 44px; }
  .st-subject { padding: var(--space-md); }
  .st-subjects { gap: var(--space-md); }
  .st-subject-actions .btn { min-height: 40px; }
  .st-row-side .btn { padding: 8px 10px; }
  .st-f-markwrap { padding-left: 16px; }
  .st-f-mark { max-width: none; }
}
