/* competition.css — student and reviewer surfaces.
 *
 * Every colour comes from tokens.css. Nothing here invents a value: the brand
 * palette is cream / teal / navy / coral with separate safety amber and red,
 * and an eyeballed near-miss is worse than an obvious mismatch because nobody
 * notices it until the whole product looks slightly wrong.
 *
 * Direction-agnostic throughout: `inline-start`, `inline-size`, `margin-inline`
 * rather than left/right/width/margin-left. Roughly half this cohort will use
 * the Arabic interface, and an RTL layout patched with `[dir="rtl"]` overrides
 * is a layout that breaks on the next screen somebody adds.
 */

/* ============================ layout ============================ */

.cmp-h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink, #10243d);
  margin: 0;
}

.cmp-help {
  color: var(--ink-3, #5b6b7c);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0.35rem 0 0;
}

.cmp-back {
  background: none;
  border: 0;
  color: var(--accent-700, #0f6d65);
  font: inherit;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-block-end: 0.5rem;
}
.cmp-back:hover { text-decoration: underline; }

/* ============================ progress ============================ */

.cmp-progress {
  background: var(--surface, #fffdf8);
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.2rem;
  margin-block-end: 1.25rem;
}

.cmp-points {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.cmp-points-value {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-700, #0f6d65);
  font-variant-numeric: tabular-nums;
}
.cmp-points-unit {
  color: var(--ink-3, #5b6b7c);
  font-size: 0.95rem;
}

.cmp-bar {
  block-size: 10px;
  border-radius: 999px;
  background: var(--border-2, #e4ddcd);
  overflow: hidden;
  margin-block: 0.75rem 0.4rem;
}
.cmp-bar-fill {
  display: block;
  block-size: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg,
              var(--accent-700, #0f6d65), var(--coral, #d86f5c));
  /* Animates on gain, not on load: a bar that replays its whole fill every
     time the tab opens turns an achievement into a loading spinner. */
  transition: inline-size 600ms cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
  .cmp-bar-fill { transition: none; }
}

.cmp-bar-caption {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-3, #5b6b7c);
}

.cmp-milestones {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}
.cmp-milestone {
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.25;
  opacity: 0.45;
  filter: grayscale(1);
}
.cmp-milestone.is-earned {
  opacity: 1;
  filter: none;
}
.cmp-milestone-icon { display: block; font-size: 1.4rem; }
.cmp-milestone-name { display: block; font-weight: 600; color: var(--ink, #10243d); }
.cmp-milestone-note { display: block; color: var(--ink-3, #5b6b7c); font-size: 0.66rem; }

/* ============================ case list ============================ */

.cmp-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-end: 0.75rem;
}

.cmp-cases {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.cmp-case-btn,
.cmp-qrow > button {
  inline-size: 100%;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  text-align: start;
  background: var(--surface, #fffdf8);
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 12px;
  padding: 0.7rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.cmp-case-btn:hover,
.cmp-qrow > button:hover { border-color: var(--accent-700, #0f6d65); }
.cmp-case-btn:focus-visible,
.cmp-qrow > button:focus-visible {
  outline: 2px solid var(--accent-700, #0f6d65);
  outline-offset: 2px;
}

/* A case waiting on the student gets an amber edge and the note in full. It is
   the only thing on this screen they can actually act on. */
.cmp-case.is-urgent .cmp-case-btn {
  border-inline-start: 4px solid var(--amber, #c9821f);
  background: var(--amber-bg, #fdf6e7);
}

.cmp-case-thumb,
.cmp-qrow img {
  inline-size: 64px;
  block-size: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--border-2, #e4ddcd);
}
.cmp-case-thumb.is-empty { display: block; }

.cmp-case-body { flex: 1 1 auto; min-inline-size: 0; }
.cmp-case-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.cmp-case-ref {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink, #10243d);
}
.cmp-case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block-start: 0.25rem;
  font-size: 0.82rem;
  color: var(--ink-3, #5b6b7c);
}
.cmp-case-note {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink, #10243d);
}

/* ============================ status tags ============================ */

.cmp-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  /* Never colour alone: the tag always carries its own word, so a
     red/green-blind reader and a black-and-white printout both still work. */
  border: 1px solid currentColor;
}
.cmp-status-needs_attention { color: var(--amber, #c9821f); }
.cmp-status-in_progress     { color: var(--ink-3, #5b6b7c); }
.cmp-status-in_review       { color: var(--accent-700, #0f6d65); }
.cmp-status-complete        { color: var(--green, #2f7d5d); }
.cmp-status-not_accepted    { color: var(--red, #b23c2e); }
.cmp-status-withdrawn       { color: var(--ink-3, #5b6b7c); }

.cmp-chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--border-2, #e4ddcd);
  color: var(--ink, #10243d);
}
.cmp-chip-points { background: var(--accent-700, #0f6d65); color: #fff; }
.cmp-chip-warn { background: var(--amber-bg, #fdf6e7); color: var(--amber, #c9821f); }

/* ============================ buttons and fields ============================ */

.cmp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-block-size: 44px;          /* thumb-sized: this is a phone product */
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--accent-700, #0f6d65);
  background: transparent;
  color: var(--accent-700, #0f6d65);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.cmp-btn:hover { background: rgba(15, 109, 101, 0.08); }
.cmp-btn:focus-visible { outline: 2px solid var(--ink, #10243d); outline-offset: 2px; }
.cmp-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.cmp-btn-primary {
  background: var(--accent-700, #0f6d65);
  color: #fff;
}
.cmp-btn-primary:hover { background: #0c5b54; }

.cmp-btn-quiet {
  border-color: var(--border-2, #e4ddcd);
  color: var(--ink, #10243d);
}

.cmp-send {
  inline-size: 100%;
  margin-block-start: 1.25rem;
}

.cmp-field {
  display: grid;
  gap: 0.3rem;
  margin-block-end: 0.75rem;
}
.cmp-field > span { font-size: 0.85rem; font-weight: 600; color: var(--ink, #10243d); }
.cmp-field input,
.cmp-field select,
.cmp-field textarea,
.cmp-input {
  inline-size: 100%;
  min-block-size: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 10px;
  font: inherit;
  background: var(--surface, #fffdf8);
  color: var(--ink, #10243d);
}
.cmp-field textarea, textarea.cmp-input { min-block-size: 88px; resize: vertical; }

.cmp-check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-size: 0.85rem;
  line-height: 1.45;
  margin-block-end: 0.75rem;
}
.cmp-check input { margin-block-start: 0.2rem; flex: 0 0 auto; }

.cmp-field-error {
  color: var(--red, #b23c2e);
  font-size: 0.85rem;
  margin: 0 0 0.6rem;
}

/* ============================ photos ============================ */

.cmp-counter {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-3, #5b6b7c);
  margin: 0.75rem 0 0.4rem;
}
.cmp-counter.is-good { color: var(--green, #2f7d5d); }

.cmp-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 0.75rem;
}
.cmp-thumb { position: relative; }
.cmp-thumb img {
  inline-size: 76px;
  block-size: 76px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}
.cmp-thumb button {
  position: absolute;
  inset-block-start: -6px;
  inset-inline-end: -6px;
  inline-size: 26px;
  block-size: 26px;
  border-radius: 50%;
  border: 0;
  background: var(--ink, #10243d);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  font-size: 1rem;
}

.cmp-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
  margin-block: 0.75rem;
}
.cmp-photos img {
  inline-size: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}
.cmp-photos-review {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.cmp-draft-status {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-3);
}
.cmp-draft-status.is-error { color: var(--red); }
.cmp-draft-discard { margin-inline-start: 0.5rem; }

/* A photograph the server listed but the browser could not load: the
   reader is told, in the slot the picture would have filled. */
.cmp-photo-missing {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0.5rem;
  border: 1px dashed var(--border-2);
  border-radius: 10px;
  color: var(--ink-3);
  font-size: 0.8rem;
  text-align: center;
}

/* ============================ questions ============================ */

.cmp-step { margin-block-end: 2rem; }

.cmp-qprogress { margin-block-end: 1.25rem; }
.cmp-qprogress .cmp-counter { margin: 0.35rem 0 0; font-size: 0.85rem; }

.cmp-question { margin-block-end: 1rem; }
.cmp-required {
  font-size: 0.78rem;
  color: var(--ink-3, #5b6b7c);
  margin: 0.4rem 0 0.8rem;
}

.cmp-answer { display: grid; gap: 0.5rem; }

.cmp-option,
.cmp-choice {
  min-block-size: 52px;
  padding: 0.7rem 1rem;
  text-align: start;
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 12px;
  background: var(--surface, #fffdf8);
  color: var(--ink, #10243d);
  font: inherit;
  cursor: pointer;
}
.cmp-option:hover,
.cmp-choice:hover { border-color: var(--accent-700, #0f6d65); }
.cmp-option.is-on {
  border-color: var(--accent-700, #0f6d65);
  background: rgba(15, 109, 101, 0.1);
  font-weight: 600;
}
.cmp-option:focus-visible,
.cmp-choice:focus-visible { outline: 2px solid var(--accent-700, #0f6d65); outline-offset: 2px; }

.cmp-choice-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.cmp-choice-row > * { flex: 1 1 140px; }

.cmp-done {
  color: var(--green, #2f7d5d);
  font-weight: 600;
}

/* ============================ detail ============================ */

.cmp-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-end: 0.75rem;
}

.cmp-callout {
  border-inline-start: 4px solid var(--amber, #c9821f);
  background: var(--amber-bg, #fdf6e7);
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin-block-end: 1rem;
}
.cmp-callout p { margin: 0.35rem 0 0; line-height: 1.5; }
.cmp-callout-warn {
  border-inline-start-color: var(--red, #b23c2e);
  background: rgba(178, 60, 46, 0.07);
}

.cmp-answers dl { margin: 0.5rem 0 0; }
.cmp-answers dt {
  font-size: 0.8rem;
  color: var(--ink-3, #5b6b7c);
  margin-block-start: 0.6rem;
}
.cmp-answers dd {
  margin: 0.1rem 0 0;
  font-weight: 500;
  color: var(--ink, #10243d);
}

.cmp-timeline ol {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  border-inline-start: 2px solid var(--border-2, #e4ddcd);
}
.cmp-timeline li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 0.35rem;
  padding-inline-start: 0.85rem;
  font-size: 0.88rem;
}
.cmp-timeline time { color: var(--ink-3, #5b6b7c); font-variant-numeric: tabular-nums; }

.cmp-actionbar,
.cmp-decisions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-block-start: 1.25rem;
}
.cmp-actionbar > *, .cmp-decisions > * { flex: 1 1 140px; }

.cmp-attachments ul { list-style: none; padding: 0; margin: 0.5rem 0 0.75rem; }
.cmp-attachments li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
}
.cmp-attach-form { margin-block-start: 0.5rem; }

/* ============================ reviewer ============================ */

.cmp-health {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-block-end: 0.75rem;
}
.cmp-alarms { list-style: none; padding: 0; margin: 0.4rem 0 0; flex: 1 1 100%; }
.cmp-alarm {
  background: var(--amber-bg, #fdf6e7);
  border-inline-start: 4px solid var(--amber, #c9821f);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-block-end: 0.35rem;
}

.cmp-buckets {
  display: flex;
  gap: 0.4rem;
  margin-block-end: 0.75rem;
  overflow-x: auto;
}
.cmp-bucket {
  min-block-size: 44px;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-2, #e4ddcd);
  background: transparent;
  color: var(--ink, #10243d);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.cmp-bucket.is-on {
  background: var(--ink, #10243d);
  border-color: var(--ink, #10243d);
  color: #fff;
}
.cmp-bucket-count { font-variant-numeric: tabular-nums; opacity: 0.85; }

.cmp-search { margin-block-end: 0.75rem; }
.cmp-search input {
  inline-size: 100%;
  min-block-size: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 10px;
  font: inherit;
}

.cmp-queue { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.cmp-qrow > button > span { flex: 1 1 auto; min-inline-size: 0; }
.cmp-qrow-student {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-3, #5b6b7c);
}

.cmp-guess {
  background: var(--border-2, #e4ddcd);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  margin-block: 0.75rem;
}

.cmp-decision-form {
  margin-block-start: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 12px;
  background: var(--surface, #fffdf8);
}
.cmp-why { margin-block-end: 0.75rem; font-size: 0.86rem; }
.cmp-why ul { margin: 0.4rem 0 0; padding-inline-start: 1.2rem; }

/* ============================ states ============================ */

.cmp-loading { display: grid; gap: 0.6rem; }
.cmp-skeleton {
  block-size: 72px;
  border-radius: 12px;
  background: linear-gradient(90deg,
              var(--border-2, #e4ddcd) 25%,
              rgba(255, 255, 255, 0.6) 37%,
              var(--border-2, #e4ddcd) 63%);
  background-size: 400% 100%;
  animation: cmp-shimmer 1.4s ease infinite;
}
@keyframes cmp-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .cmp-skeleton { animation: none; }
}

.cmp-empty,
.cmp-error {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-3, #5b6b7c);
  border: 1px dashed var(--border-2, #e4ddcd);
  border-radius: 12px;
}
.cmp-error { color: var(--red, #b23c2e); border-color: currentColor; }
.cmp-error p { margin: 0 0 0.75rem; }

/* ==================== forced password rotation ==================== */

/* A full-screen blocker, not a dismissible modal. The server refuses every
   route until the printed password is replaced, so a student who dismissed
   this would face an app where nothing works and no explanation for why. */
.cmp-rotate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(16, 36, 61, 0.72);
  overflow-y: auto;
}
.cmp-rotate-card {
  inline-size: min(440px, 100%);
  background: var(--surface, #fffdf8);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 18px 48px rgba(16, 36, 61, 0.28);
}
.cmp-rotate-card .cmp-help { margin-block: 0.5rem 1.25rem; }
.cmp-rotate-card .cmp-btn { inline-size: 100%; }

/* ============================ admin ============================ */

.cmp-admin { margin-block-start: 0.5rem; }

.cmp-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-block-end: 1rem;
}
.cmp-tile {
  background: var(--surface, #fffdf8);
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 12px;
  padding: 0.85rem;
  display: grid;
  gap: 0.15rem;
}
.cmp-tile-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink, #10243d);
  font-variant-numeric: tabular-nums;
}
.cmp-tile-label {
  font-size: 0.78rem;
  color: var(--ink-3, #5b6b7c);
}

/* The policy editor. Two columns on a desk, one on a phone — an organiser
   retuning point values is at a desk, but the overview gets read on a phone. */
.cmp-policy-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 0.9rem;
  margin-block-end: 1rem;
}

.cmp-milestone-rows { display: grid; gap: 0.75rem; margin-block-end: 0.75rem; }
.cmp-milestone-row {
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 12px;
  padding: 0.85rem;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0 0.75rem;
  align-items: end;
}
.cmp-milestone-row legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-3, #5b6b7c);
  padding-inline: 0.35rem;
}
.cmp-ms-remove { min-block-size: 40px; }

/* Wide tables scroll inside their own box; the page itself never scrolls
   sideways, which on a phone is the difference between usable and not. */
.cmp-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 12px;
}
.cmp-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.cmp-table th,
.cmp-table td {
  padding: 0.5rem 0.7rem;
  text-align: start;
  border-block-end: 1px solid var(--border-2, #e4ddcd);
  white-space: nowrap;
}
.cmp-table th {
  background: var(--border-2, #e4ddcd);
  font-weight: 600;
  color: var(--ink, #10243d);
  position: sticky;
  inset-block-start: 0;
}
.cmp-table tbody tr:last-child td { border-block-end: 0; }

/* ── Quarantined attachments (admin) ─────────────────────────────────────── */
/* Colours come from tokens.css. The amber family is reserved for safety
   meaning elsewhere in this app, and a file nobody has scanned is exactly
   that, so the notice borrows it rather than inventing a shade. */

.cmp-note {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-2, #e4ddcd);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-block-end: 1rem;
}
.cmp-note-warn {
  background: var(--coral-soft, #fff0ec);
  border-color: var(--coral-border, #f1bbb1);
  color: var(--ink, #10243d);
}

.cmp-muted { color: var(--ink-3, #66727c); font-size: 0.87rem; }

.cmp-file {
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-block-end: 0.75rem;
  background: #fff;
}
.cmp-file-name {
  font-size: 1rem;
  margin: 0 0 0.25rem;
  /* A student's filename: it must never widen the card or escape the box. */
  overflow-wrap: anywhere;
}
.cmp-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 0.75rem;
}
.cmp-file-actions .cmp-btn { min-block-size: 44px; }

.cmp-btn-danger {
  border-color: var(--coral-border, #f1bbb1);
  color: var(--coral, #d86f5c);
}
.cmp-btn-danger:hover { background: var(--coral-soft, #fff0ec); }

/* ── Owner consent (student, new case) ───────────────────────────────────── */
/* Deliberately quiet rather than alarming: this is a question about somebody
   else's animal, not a warning, and a student who feels pressured will tick it
   without asking. */

.cmp-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-block-start: 1.25rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-2, #e4ddcd);
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.5;
  cursor: pointer;
  /* The whole row is the target, not just the 13px native box. */
  min-block-size: 44px;
}
.cmp-consent input {
  inline-size: 20px;
  block-size: 20px;
  margin-block-start: 0.15rem;
  flex: none;
}
.cmp-consent-note {
  margin-block-start: 0.4rem;
  font-size: 0.83rem;
  color: var(--ink-3, #66727c);
}

/* A badge whose milestone was withdrawn. Earned, kept, and quietly marked —
   the muting says "this is history", not "this is lesser". */
.cmp-milestone.is-retired .cmp-milestone-note { font-style: italic; }
.cmp-milestone.is-retired .cmp-milestone-icon { opacity: 0.75; }
