/* Computing Student Homepage -- v1 */

:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --panel-tint: #f1f5f9;
  --ink: #0f172a;
  --ink-mute: #475569;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --warn: #b45309;
  --danger: #b91c1c;
  --pin: #facc15;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--panel-tint);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-mute); }
.small { font-size: 12px; }
.dot { color: var(--ink-mute); margin: 0 .35em; }

.flash {
  background: #bbf7d0;
  color: #064e3b;
  padding: 8px 16px;
  border-bottom: 1px solid #86efac;
}

/* ---------- Public page header ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--bg);
  color: #fff;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { margin: 0; font-size: 22px; font-weight: 600; }
.page-header__meta { margin: 4px 0 0; color: #cbd5e1; font-size: 13px; }

.course-toggle button {
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.15);
  padding: 6px 14px;
  margin-left: 4px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}
.course-toggle button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Grid layout for widgets ---------- */
.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-areas:
    "ann links"
    "dl  links"
    "sch sch";
  gap: 16px;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
    grid-template-areas: "ann" "links" "dl" "sch";
  }
}
.widget--announcements { grid-area: ann; }
.widget--links         { grid-area: links; }
.widget--deadlines     { grid-area: dl; }
.widget--schedule      { grid-area: sch; }

/* ---------- Extra rows under the main grid ---------- */
.games-row, .tp-row {
  display: grid;
  gap: 16px;
  padding: 0 16px 16px;
  max-width: 1200px;
  margin: 0 auto;
}
.games-row { grid-template-columns: repeat(2, 1fr); }
.tp-row    { grid-template-columns: 1fr; }
@media (max-width: 900px) {
  .games-row { grid-template-columns: 1fr; }
}

.widget {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.widget h2 { margin: 0 0 12px; font-size: 16px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-mute); }
.widget h2 small { text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 500; }
.widget .empty { color: var(--ink-mute); font-style: italic; margin: 0; }

/* ---------- Announcements ---------- */
.announcement-list { list-style: none; padding: 0; margin: 0; }
.announcement-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.announcement-list li:last-child { border-bottom: 0; }
.announcement-list h3 {
  margin: 0 0 4px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.announcement-list p { margin: 4px 0; }
.announcement-list time { color: var(--ink-mute); font-size: 12px; }
.announcement-list .is-pinned { background: #fffbeb; margin: 0 -16px; padding: 10px 16px; }
.pin { color: var(--warn); font-weight: 700; font-size: 11px; }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.tag--All { background: #e5e7eb; color: #374151; }
.tag--L2  { background: #dcfce7; color: #166534; }
.tag--L3  { background: #ddd6fe; color: #5b21b6; }
.tag--L4  { background: #fed7aa; color: #9a3412; }

/* ---------- Quick links ---------- */
.link-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.link-grid a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel-tint);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
}
.link-grid a:hover { background: var(--accent-soft); border-color: var(--accent); text-decoration: none; }
.link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  flex: 0 0 28px;
}
.link-label { font-weight: 500; }

/* ---------- Deadlines ---------- */
.deadline-list { list-style: none; margin: 0; padding: 0; }
.deadline-list li {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.deadline-list li:last-child { border-bottom: 0; }
.deadline-when { flex: 0 0 100px; }
.deadline-when strong { display: block; }
.deadline-when small { color: var(--ink-mute); }

/* ---------- Timetable (public) ---------- */
.timetable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.timetable th, .timetable td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  min-height: 38px;
}
.timetable thead th { background: var(--panel-tint); }
.timetable .row-h { background: var(--panel-tint); width: 50px; font-weight: 600; }
.cell-label { font-weight: 500; }
.cell-room  { color: var(--ink-mute); font-size: 11px; }

.strip-title { margin: 16px 0 6px; font-size: 13px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .05em; }
.dates-strip {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.dates-strip li {
  background: var(--panel-tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
}
.date-day { font-weight: 600; }
.date-kind { color: var(--warn); margin: 0 4px; }

/* ---------- Custom sections row ---------- */
.sections-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 0 16px 16px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .sections-row { grid-template-columns: 1fr; }
}
.section-card h2 {
  font-size: 16px;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.section-body { white-space: pre-wrap; margin-bottom: 8px; }
.section-items { list-style: disc; margin: 8px 0 0; padding-left: 20px; }
.section-items li { margin: 4px 0; }
.section-items a { color: var(--accent); }
.section-items a:hover { text-decoration: underline; }

.section-card.is-clickable {
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.section-card.is-clickable:hover,
.section-card.is-clickable:focus {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 12px 28px rgba(15,23,42,.10);
  outline: none;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
}
.modal-panel {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(15,23,42,.35);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 24px 28px;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: 0;
  font-size: 28px;
  line-height: 1;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--ink); }
.modal-content h2 { font-size: 22px; margin-top: 0; }
.modal-content .section-body { font-size: 16px; }
.modal-content .section-items { font-size: 16px; }
body.modal-open { overflow: hidden; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 16px;
  color: var(--ink-mute);
  font-size: 12px;
}
.site-footer .inline { display: inline; }
.linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.linklike:hover { text-decoration: underline; }
.linklike.danger { color: var(--danger); }

/* ---------- Login ---------- */
.login-card {
  max-width: 360px;
  margin: 80px auto;
  background: var(--panel);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card label { display: block; margin: 12px 0; }
.login-card input[type=password] { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; }
.login-card button { background: var(--accent); color: #fff; border: 0; padding: 10px 16px; border-radius: 6px; cursor: pointer; }
.error { color: var(--danger); }

/* ---------- Admin chrome ---------- */
.admin-nav {
  background: #1e293b;
  color: #cbd5e1;
  padding: 10px 16px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.admin-nav a { color: #cbd5e1; }
.admin-nav a.brand { font-weight: 700; color: #fff; margin-right: 12px; }
.admin-nav a:hover { color: #fff; text-decoration: none; }

.admin { max-width: 1100px; margin: 16px auto; padding: 0 16px; }
.admin h1 { margin: 6px 0 12px; }
.admin-page-header { display: flex; justify-content: space-between; align-items: center; }

.card-row, .course-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px; padding: 0; list-style: none;
}
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  color: var(--ink);
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h2 { margin: 0 0 6px; font-size: 16px; }
.card .count { color: var(--ink-mute); margin: 0; }

.admin-table {
  width: 100%; border-collapse: collapse;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.admin-table th, .admin-table td {
  padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table thead th { background: var(--panel-tint); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-mute); }
.admin-table tr.is-past td { color: var(--ink-mute); text-decoration: line-through; }
.admin-table .actions { white-space: nowrap; }
.admin-table .actions a, .admin-table .actions form { margin-right: 8px; }
.admin-table .inline { display: inline; }
.icon-bubble {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; background: var(--accent); color: #fff; border-radius: 6px; font-weight: 700;
}

.form { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; max-width: 600px; box-shadow: var(--shadow); }
.form label { display: block; margin-bottom: 12px; }
.form input[type=text], .form input[type=url], .form input[type=number], .form input[type=date], .form input[type=datetime-local], .form select, .form textarea {
  display: block; width: 100%; padding: 8px;
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
.form input.small { width: 100px; display: inline-block; margin-top: 4px; }
.form label.check { display: flex; align-items: center; gap: 8px; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.form-actions button, .btn {
  background: var(--accent); color: #fff; border: 0;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none;
  display: inline-block;
}
.form-actions button:hover, .btn:hover { background: #1d4ed8; text-decoration: none; }

/* Timetable edit grid */
.timetable-edit { width: 100%; border-collapse: collapse; }
.timetable-edit th, .timetable-edit td { border: 1px solid var(--border); padding: 4px; vertical-align: top; }
.timetable-edit input { width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.timetable-edit input.small { margin-top: 3px; font-size: 12px; color: var(--ink-mute); }
.timetable-edit .row-h { background: var(--panel-tint); width: 50px; }

/* ---------- Feature tiles on homepage ---------- */
.feature-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.feature-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--panel); color: var(--ink); text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.feature-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.feature-tile__title { font-weight: 600; }
.feature-tile__desc { color: var(--ink-mute); font-size: 13px; }
.feature-tile--grades { border-top: 3px solid #2563eb; }
.feature-tile--cw     { border-top: 3px solid #16a34a; }
.feature-tile--sudoku { border-top: 3px solid #ca8a04; }
.feature-tile--tp     { border-top: 3px solid #9333ea; }

/* ---------- Sudoku ---------- */
.sudoku-page { padding: 24px; max-width: 600px; margin: 0 auto; }
.sudoku-header h1 { margin-bottom: 4px; }
.sudoku-toolbar { display: flex; gap: 12px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.sudoku-timer { font-family: ui-monospace, monospace; padding: 4px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }
.sudoku-status { color: var(--ink-mute); }
#sudoku-pencil { padding: 4px 10px; border: 1px solid var(--border); background: var(--panel); border-radius: 6px; cursor: pointer; font: inherit; }
#sudoku-pencil.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sudoku-grid {
  display: grid; grid-template-columns: repeat(9, 1fr);
  background: #fff; border: 2px solid var(--ink); border-radius: 6px;
  max-width: 540px;
}
.sudoku-grid .sudoku-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  text-align: center;
  font: 600 20px/1 ui-monospace, monospace;
  background: #fff; color: var(--ink);
  cursor: pointer;
  user-select: none;
  outline: none;
}
.sudoku-grid .sudoku-cell.given { background: var(--panel-tint); color: var(--accent); cursor: default; }
.sudoku-grid .sudoku-cell.wrong { background: #fee2e2; color: var(--danger); }
.sudoku-grid .sudoku-cell.box-right  { border-right: 2px solid var(--ink); }
.sudoku-grid .sudoku-cell.box-bottom { border-bottom: 2px solid var(--ink); }
.sudoku-grid .sudoku-cell.is-selected { box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }
.sudoku-grid .sudoku-cell.is-peer { background: #f1f5f9; }
.sudoku-grid .sudoku-cell.is-highlighted { background: #dbeafe; }
.sudoku-grid .sudoku-cell.is-highlighted.given { background: #c7d8f5; }
.sudoku-grid .sudoku-cell .cell-value {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.sudoku-grid .sudoku-cell .pencil-grid {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 2px; gap: 0;
  font: 500 9px/1 ui-monospace, monospace;
  color: var(--ink-mute);
  pointer-events: none;
}
.sudoku-grid .sudoku-cell.has-value .pencil-grid { display: none; }
.sudoku-grid .sudoku-cell .pencil { display: flex; align-items: center; justify-content: center; }

/* ---------- CompuWordle ---------- */
.cw-page { padding: 24px; max-width: 600px; margin: 0 auto; }
.cw-name-gate, .cw-game { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.cw-stats { display: flex; gap: 18px; margin-bottom: 14px; color: var(--ink-mute); }
.cw-board { display: grid; gap: 6px; justify-content: center; margin-bottom: 14px; }
.cw-row   { display: grid; grid-template-columns: repeat(var(--cw-cols, 5), 44px); gap: 6px; }
.cw-tile  {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--border); border-radius: 4px;
  font: 600 18px/1 ui-monospace, monospace; background: #fff; text-transform: uppercase;
}
.cw-tile.cw-correct { background: #16a34a; color: #fff; border-color: #16a34a; }
.cw-tile.cw-present { background: #ca8a04; color: #fff; border-color: #ca8a04; }
.cw-tile.cw-absent  { background: #94a3b8; color: #fff; border-color: #94a3b8; }
.cw-guess { width: 100%; padding: 8px 12px; font: 600 18px/1 ui-monospace, monospace; text-transform: uppercase; border: 1px solid var(--border); border-radius: 6px; }
.cw-status { min-height: 1.2em; margin-top: 8px; color: var(--ink-mute); }
.cw-share { margin-top: 12px; padding: 12px; background: var(--panel-tint); border-radius: 6px; }
.cw-share pre { font: 14px/1.2 ui-monospace, monospace; margin: 0 0 8px; white-space: pre-wrap; }

/* ---------- GradeView ---------- */
.grades-page { padding: 24px; max-width: 800px; margin: 0 auto; }
.grades-search { display: flex; gap: 8px; margin: 16px 0; }
.grades-search input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.grades-matches ul { list-style: none; padding: 0; }
.grades-matches li { padding: 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; }
.grades-empty { color: var(--ink-mute); padding: 16px; background: var(--panel); border: 1px dashed var(--border); border-radius: 6px; }
.grades-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 16px; }
.grade-card { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--ink-mute); border-radius: var(--radius); padding: 14px 16px; }
.grade-card header { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.grade-card .unit-code { font-family: ui-monospace, monospace; color: var(--accent); }
.grade-card .grade-value { font-weight: 600; font-size: 18px; margin: 4px 0; }
.grade-card .grade-feedback { font-size: 14px; color: var(--ink); }
.grade-card .grade-meta { font-size: 12px; color: var(--ink-mute); margin-top: 6px; }
.grade-distinction { border-left-color: #16a34a; }
.grade-merit       { border-left-color: #2563eb; }
.grade-pass        { border-left-color: #9333ea; }
.grade-refer       { border-left-color: #ca8a04; }
.grade-fail        { border-left-color: #b91c1c; }
.grade-awaiting    { border-left-color: var(--border); opacity: .85; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Admin result row */
.admin-result-row { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.admin-result-row header { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.inline-form { display: grid; gap: 8px; }

/* ---------- Tech Person of the Week ---------- */
.tp-page { padding: 24px; max-width: 800px; margin: 0 auto; }
.tp-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: flow-root; }
.tp-photo { float: left; width: 180px; height: 180px; object-fit: cover; border-radius: 50%; border: 2px solid var(--accent); margin: 0 24px 12px 0; }

/* Full profile page — show image at natural aspect, not cropped to a circle */
.tp-page .tp-card .tp-photo {
  float: none;
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 480px;
  border-radius: 8px;
  margin: 0 0 20px;
}
.tp-name { margin: 0 0 4px; }
.tp-roles { color: var(--accent); font-family: ui-monospace, monospace; font-size: 13px; margin: 0 0 10px; }
.tp-bio { margin-bottom: 12px; }
.tp-achievements { padding-left: 20px; margin: 8px 0; }
.tp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tp-tag { font-size: 12px; padding: 2px 8px; background: var(--panel-tint); border: 1px solid var(--border); border-radius: 4px; color: var(--ink-mute); }
@media (max-width: 540px) { .tp-photo { float: none; display: block; margin: 0 auto 12px; } }

/* ---------- Inline widget tweaks (embedded on homepage) ---------- */
.widget--tp .tp-card--compact { padding: 0; border: 0; background: transparent; }
.widget--tp .tp-card--compact .tp-photo { width: 140px; height: 140px; margin: 0 20px 12px 0; }
.widget--tp .tp-card--compact .tp-name { font-size: 18px; }
.widget--tp .tp-card--compact .tp-bio { font-size: 13px; }

.grades-widget-form { display: grid; gap: 8px; }
.grades-widget-form label span { display: block; font-size: 13px; color: var(--ink-mute); margin-bottom: 4px; }
.grades-widget-form input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.grades-widget-form button { padding: 8px 14px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; cursor: pointer; font: inherit; width: max-content; }

/* Inline Sudoku — slightly smaller cells than the standalone page */
.sudoku-inline .sudoku-grid { max-width: 100%; }
.sudoku-inline .sudoku-toolbar { flex-wrap: wrap; }

/* Inline CompuWordle — tighten the board so it doesn't overflow the widget */
.widget--cw .cw-name-gate, .widget--cw .cw-game { padding: 0; border: 0; background: transparent; margin-top: 0; }
.widget--cw .cw-row { grid-template-columns: repeat(var(--cw-cols, 5), minmax(28px, 40px)); }
.widget--cw .cw-tile { width: 100%; height: 40px; font-size: 16px; }
