/* Styles for the ENGR1000J peer evaluation survey. */

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --border:    #dfe3e8;
  --text:      #1c2024;
  --muted:     #6b7280;
  --accent:    #9b1b30;   /* SJTU red */
  --accent-dk: #7c1526;
  --danger:    #b42318;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ---------- header ---------- */

.app-header {
  margin-bottom: 28px;
  text-align: center;
}

.app-banner {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin: 0 auto 20px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -.01em;
}

/* ---------- progress ---------- */

.progress ol {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}

.progress li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 3px solid var(--border);
  color: var(--muted);
  font-size: .82rem;
  transition: color .15s, border-color .15s;
}

.progress .dot {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  background: var(--border);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
}

.progress li.done { color: var(--text); border-bottom-color: #c8ccd2; }
.progress li.done .dot { background: #9aa1ab; }

.progress li.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.progress li.active .dot { background: var(--accent); }

/* ---------- screens ---------- */

.screen {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.screen[hidden] { display: none; }

.screen h2 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.notes {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: .92rem;
}
.notes li { margin-bottom: 6px; }

.stub-note {
  color: var(--muted);
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: .9rem;
}

/* ---------- form ---------- */

.field { margin-bottom: 18px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: .88rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: .95rem;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 27, 48, .12);
}

.field input.invalid {
  border-color: var(--danger);
  background: #fff8f7;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: .8rem;
  min-height: 0;
}
.error:empty { display: none; }

/* ---------- buttons ---------- */

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost:hover { border-color: #c8ccd2; color: var(--text); }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- misc ---------- */

.debug {
  margin: 14px 0 0;
  padding: 12px;
  background: #1c2024;
  color: #d5f5d5;
  border-radius: 8px;
  font-size: .78rem;
  white-space: pre-wrap;
  overflow-x: auto;
}
.debug:empty { display: none; }

.app-footer {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
}

.app-footer p { margin: 4px 0; }

.copyright {
  font-size: .72rem;
  opacity: .85;
}

/* ---------- team members ---------- */

.lede {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: .92rem;
}
.lede strong { color: var(--text); }

.self-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fafafa;
}

.self-tag {
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.self-name { font-weight: 600; }

/* ---------- item navigation ---------- */

.item-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 22px;
}

.item-pill {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.item-pill:hover:not(:disabled) { border-color: #b9bec6; color: var(--text); }

.item-pill.done {
  background: #eef7ef;
  border-color: #bcdcc1;
  color: #2f6b3a;
}

.item-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.item-pill.locked {
  opacity: .45;
  cursor: not-allowed;
}

.item-text {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: #faf6f7;
  border-radius: 0 8px 8px 0;
  font-size: 1.02rem;
  font-weight: 600;
}

/* ---------- rating table ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.rating-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.rating-table th,
.rating-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
}

.rating-table tr:last-child th,
.rating-table tr:last-child td { border-bottom: none; }

.rating-table th:last-child,
.rating-table td:last-child { border-right: none; }

.rating-table thead th {
  position: sticky;
  top: 0;
  background: #f0f1f3;
  font-size: .8rem;
  line-height: 1.25;
  vertical-align: bottom;
}

/* the scale column stays put while the member columns scroll */
.rating-table .scale-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 150px;
  background: #f7f8f9;
  text-align: left;
  font-weight: 600;
}

.rating-table thead .scale-col { z-index: 3; background: #f0f1f3; }

.rating-table .scale-col .num {
  display: inline-block;
  min-width: 18px;
  margin-right: 8px;
  color: var(--muted);
  font-weight: 700;
}

.rating-table .scale-col .txt { font-weight: 500; }

.rating-table tbody tr:hover td { background: #fafbfc; }
.rating-table tbody tr:hover .scale-col { background: #f1f3f5; }

.rating-table th.self,
.rating-table td.self { background: #faf6f7; }
.rating-table tbody tr:hover td.self { background: #f6eef0; }

.you-tag {
  display: block;
  margin-top: 2px;
  color: var(--accent);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* whole cell is the click target */
.rating-table .cell {
  display: block;
  margin: -8px -10px;
  padding: 8px 10px;
  cursor: pointer;
}

.rating-table input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.rating-table input[type="radio"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- summary ---------- */

.section-title {
  margin: 30px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-title + .hint { margin: 0 0 12px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 20px;
  margin: 0;
}

.detail-pair {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dotted var(--border);
  font-size: .88rem;
}

.detail-pair dt { color: var(--muted); }
.detail-pair dd { margin: 0; font-weight: 600; text-align: right; }

/* score table */

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.score-table th,
.score-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.score-table thead th {
  background: #f0f1f3;
  font-size: .78rem;
  font-weight: 700;
}

.score-table tbody th {
  text-align: left;
  font-weight: 600;
}

.score-table tbody tr:last-child th,
.score-table tbody tr:last-child td { border-bottom: none; }

.score-table tbody tr.self { background: #faf6f7; }

.score-table .score {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.score-table .you-tag { display: inline-block; margin-left: 8px; }

/* response matrix */

.rating-table.matrix td { font-weight: 600; }

.rating-table.matrix .item-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 260px;
  max-width: 320px;
  background: #f7f8f9;
  text-align: left;
  font-weight: 500;
  white-space: normal;
}

.rating-table.matrix thead .item-col { z-index: 3; background: #f0f1f3; }
.rating-table.matrix .item-col .num { color: var(--muted); font-weight: 700; }

.legend {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .76rem;
}

/* confirmation */

.confirm-box {
  margin-top: 26px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
}

.confirm-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}

.confirm-label input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  flex: 0 0 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn-primary:disabled:hover { background: var(--accent); }

.ok-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef7ef;
  border: 1px solid #bcdcc1;
  color: #2f6b3a;
  font-size: .84rem;
  font-weight: 600;
}
.ok-note[hidden] { display: none; }

/* ---------- required markers ---------- */

.req {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- category labels ---------- */

.item-category {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.rating-table.matrix .group th {
  position: sticky;
  left: 0;
  background: #f2f4f6;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.rating-table.matrix tfoot th,
.rating-table.matrix tfoot td {
  background: #f0f1f3;
  border-top: 2px solid #c8ccd2;
  font-weight: 700;
}

.rating-table.matrix tfoot .item-col {
  background: #f0f1f3;
  text-align: left;
}

.rating-table.matrix tfoot tr:first-child th,
.rating-table.matrix tfoot tr:first-child td { border-top: 2px solid #c8ccd2; }

.rating-table.matrix tfoot tr:last-child th,
.rating-table.matrix tfoot tr:last-child td { border-top: 1px solid var(--border); }

/* ---------- reference note ---------- */

.reference {
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.5;
}

/* ---------- closing question ---------- */

.item-pill-note {
  width: auto;
  padding: 0 10px;
  font-size: .74rem;
}

.comment-block textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  line-height: 1.5;
  resize: vertical;
}

.comment-block textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 27, 48, .12);
}

.comment-block .hint { margin-top: 6px; }

.comment-text {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: #fafafa;
  font-size: .9rem;
  white-space: pre-wrap;
}

/* ---------- small screens ---------- */

@media (max-width: 620px) {
  .app { padding: 20px 12px 48px; }
  .app-banner { margin-bottom: 14px; }
  .app-header h1 { font-size: 1.35rem; }
  .screen { padding: 20px 16px; }
  .progress .label { display: none; }
  .progress li { justify-content: center; }
  .actions { flex-direction: column-reverse; }
  .btn { width: 100%; }
}

@media (max-width: 620px) {
  .rating-table .scale-col { min-width: 118px; }
  .rating-table .scale-col .txt { display: block; font-size: .74rem; }
  .rating-table th, .rating-table td { padding: 7px 8px; }
}

@media (max-width: 620px) {
  .detail-grid { grid-template-columns: 1fr; }
  .rating-table.matrix .item-col { min-width: 180px; }
  .score-table th, .score-table td { padding: 8px 7px; font-size: .8rem; }
}
