/* ============================================================
   GOOD SITE – Accessible styles meeting WCAG 2.2 AA
   Each comment references the fix number in overlay.js
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Fix #5 – Clear, sans-serif font; generous size and line-height */
body {
  font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #1a1a1a;       /* Fix #1 – ~18.5:1 contrast on white */
  background: #ffffff;
}

/* ---- Skip link – Fix #9 ---- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: #1a56db;
  color: #ffffff;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 6px 0;
  z-index: 20000;
  transition: top 0.15s;
}

/* Becomes visible on keyboard focus – Fix #4 */
.skip-link:focus {
  top: 0;
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

/* ---- Navbar – Fix #8 uses <nav> landmark ---- */
.navbar {
  background: #1e3a5f;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
}

.site-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;       /* Fix #1 – white on dark blue, >7:1 */
  margin-right: auto;
  text-decoration: none;
}

.navbar a {
  color: #bfdbfe;       /* Fix #1 – ~4.7:1 on dark blue */
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;   /* Fix #10 – tall enough for 44px touch target with navbar height */
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.navbar a:hover {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
}

/* Fix #4 – Visible focus ring on all interactive elements */
.navbar a:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

.navbar .logo {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  margin-right: 8px;
  /* Fix #3 – alt text set in HTML */
}

/* ---- Login page ---- */
.login-wrapper {
  max-width: 420px;
  margin: 48px auto;
  padding: 0 20px;
}

.login-hero {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  margin-bottom: 28px;
  /* Fix #3 – descriptive alt text in HTML */
}

/* Fix #5 – Clear heading hierarchy */
.login-wrapper h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #111827;       /* Fix #1 */
  margin-bottom: 6px;
}

.login-wrapper .tagline {
  font-size: 0.95rem;
  color: #374151;       /* Fix #1 – ~9:1 on white */
  margin-bottom: 28px;
}

/* Fix #2 – Visible <label> elements above each input */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #111827;       /* Fix #1 */
  margin-bottom: 5px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;   /* Fix #10 – comfortable target height */
  border: 2px solid #9ca3af;
  border-radius: 6px;
  font-size: 16px;      /* Fix #5 – readable size */
  font-family: 'Trebuchet MS', Arial, sans-serif;
  color: #111827;       /* Fix #1 */
  background: #fff;
  transition: border-color 0.15s;
}

.form-group input:hover  { border-color: #6b7280; }
.form-group input:focus  { border-color: #1a56db; outline: 3px solid #93c5fd; outline-offset: 0; }

.password-row {
  position: relative;
}

.password-row input { padding-right: 80px; }

/* Fix #10 – show/hide password toggle with adequate target */
.show-pwd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #1a56db;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
}

/* Fix #1 high-contrast submit button */
.login-btn {
  width: 100%;
  padding: 13px;
  background: #1a56db;
  color: #ffffff;       /* Fix #1 – white on blue ~4.6:1 */
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Trebuchet MS', Arial, sans-serif;
  cursor: pointer;
  margin-top: 6px;
  min-height: 48px;     /* Fix #10 */
}

.login-btn:hover { background: #1e429f; }

/* Fix #10 – adequate target for forgot link */
.forgot-link {
  display: inline-block;
  margin-top: 14px;
  color: #1a56db;       /* Fix #1 */
  font-size: 14px;
  text-decoration: underline;
  padding: 4px 0;
}

/* ---- Dashboard layout – Fix #6: single main column with aside ---- */
.dash-wrapper {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  padding: 24px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ---- Announcement bar – Fix #6: static, not auto-scrolling ---- */
.announce-bar {
  background: #eff6ff;
  border-left: 4px solid #1a56db;
  padding: 10px 16px;
  margin: 0 20px;
  font-size: 14px;
  color: #1e3a5f;       /* Fix #1 */
  border-radius: 0 6px 6px 0;
}

/* ---- Section headings – Fix #8: real <h> elements ---- */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e5e7eb;
}

/* ---- Course cards ---- */
.course-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}

.course-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fafafa;
}

.course-card img {
  width: 100%;
  height: 70px;
  object-fit: cover;
  display: block;
  /* Fix #3 – alt text in HTML */
}

.course-card-body {
  padding: 12px;
}

.course-card-body h3 {
  font-size: 14px;
  font-weight: 700;
  color: #111827;       /* Fix #1 */
  margin-bottom: 6px;
}

/* Fix #7 – status uses colour + icon + text */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.status-badge.on-track  { background: #dcfce7; color: #14532d; }
.status-badge.needs-att { background: #fef9c3; color: #713f12; }
.status-badge.behind    { background: #fee2e2; color: #7f1d1d; }

.progress-outer {
  background: #e5e7eb;
  border-radius: 4px;
  height: 8px;
  margin: 6px 0 4px;
}

.progress-inner {
  height: 8px;
  border-radius: 4px;
  background: #1a56db;
}

.progress-label {
  font-size: 12px;
  color: #374151;       /* Fix #1 */
}

/* ---- Activity feed ---- */
.activity-list {
  list-style: none;
  margin-bottom: 24px;
}

.activity-list li {
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
  color: #374151;       /* Fix #1 */
  line-height: 1.5;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.activity-list li .time {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  padding-top: 2px;
  min-width: 90px;
}

/* ---- Timetable ---- */
.timetable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 24px;
}

/* Fix #8 – proper th elements with scope attribute in HTML */
.timetable caption {
  text-align: left;
  font-weight: 700;
  font-size: 1.1rem;
  color: #111827;
  padding-bottom: 8px;
}

.timetable th {
  background: #1e3a5f;
  color: #ffffff;       /* Fix #1 */
  padding: 8px 10px;
  text-align: center;
  font-weight: 700;
}

.timetable td {
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  text-align: center;
  color: #111827;       /* Fix #1 */
  vertical-align: top;
}

.timetable tr:nth-child(even) td { background: #f9fafb; }

/* ---- Sidebar widgets – Fix #8: uses <aside> ---- */
.sidebar-widget {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.sidebar-widget h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;       /* Fix #1 */
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e5e7eb;
}

/* Fix #10 – sidebar links have adequate padding */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;     /* Fix #10 – ~38px tall, meets 24px min */
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: #1a56db;       /* Fix #1 */
  min-height: 44px;
}

.sidebar-link:hover { background: #eff6ff; }

/* Fix #7 – deadline badges with colour + icon + text */
.deadline-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  color: #374151;       /* Fix #1 */
}

.deadline-item:last-child { border-bottom: none; }

.urgency {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 56px;
  text-align: center;
}

.urgency.urgent   { background: #fee2e2; color: #7f1d1d; }
.urgency.upcoming { background: #fef9c3; color: #713f12; }
.urgency.ok       { background: #dcfce7; color: #14532d; }

/* Grade list */
.grade-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  color: #374151;
}

.grade-item:last-child { border-bottom: none; }

.grade-val {
  font-weight: 700;
  font-size: 14px;
  color: #111827;
}

/* Fix #5 – wellbeing buttons are large and labelled */
.wellbeing-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.wb-btn {
  flex: 1;
  padding: 10px 4px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 60px;     /* Fix #10 */
}

.wb-btn span.wb-label {
  font-size: 10px;
  color: #374151;       /* Fix #1 */
  font-family: 'Trebuchet MS', Arial, sans-serif;
}

.wb-btn:hover { border-color: #1a56db; background: #eff6ff; }
.wb-btn:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }

/* ---- Footer ---- */
footer {
  font-size: 14px;      /* Fix #5 – readable size */
  color: #374151;       /* Fix #1 */
  text-align: center;
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  margin-top: 16px;
}

footer a {
  color: #1a56db;
  text-decoration: underline;
}

/* ============================================================
   AUDIT PANEL – accessible styles (same pattern as bad site)
   ============================================================ */

.audit-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #166534;
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-family: 'Trebuchet MS', Arial, sans-serif;
  font-weight: 700;
  cursor: pointer;
  z-index: 9990;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
}

.audit-btn:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }

.audit-panel {
  position: fixed;
  top: 0;
  right: -440px;
  width: 420px;
  height: 100vh;
  background: #fff;
  border-left: 4px solid #166534;
  z-index: 10000;
  overflow-y: auto;
  transition: right 0.3s ease;
  box-shadow: -6px 0 20px rgba(0,0,0,0.25);
  font-family: 'Trebuchet MS', Arial, sans-serif;
  font-size: 13px;
  color: #1a1a1a;
  line-height: 1.5;
}

.audit-panel.open { right: 0; }

.audit-header {
  background: #166534;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: sticky;
  top: 0;
}

.audit-header h2 {
  font-size: 15px;
  font-weight: 700;
}

.audit-header p {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 2px;
}

.close-btn {
  background: none;
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 8px;
}

.close-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.panel-body { padding: 12px; }

.clear-btn {
  display: block;
  width: 100%;
  padding: 8px;
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Trebuchet MS', Arial, sans-serif;
  cursor: pointer;
  margin-bottom: 12px;
}

.audit-item {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.audit-item:hover  { background: #f0fdf4; }
.audit-item.active { background: #f0fdf4; border-color: #166534; }

.audit-item-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
}

.badge {
  background: #166534;
  color: #fff;
  border-radius: 50%;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.item-title  { font-weight: 700; font-size: 13px; color: #111; margin-bottom: 3px; }
.item-desc   { font-size: 12px; color: #374151; margin-bottom: 5px; }
.item-meta   { display: flex; gap: 6px; flex-wrap: wrap; }

.wcag-tag {
  font-size: 10px;
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.cat-tag {
  font-size: 10px;
  background: #f3f4f6;
  color: #374151;
  padding: 1px 6px;
  border-radius: 3px;
}

/* Highlight applied to fixed elements when a fix is clicked */
.a11y-highlight {
  outline: 3px solid #166534 !important;
  outline-offset: 3px !important;
  animation: pulse-fix 1.2s ease-in-out infinite;
}

@keyframes pulse-fix {
  0%, 100% { outline-color: #166534; box-shadow: 0 0 0 0 rgba(22,101,52,0.4); }
  50%       { outline-color: #4ade80; box-shadow: 0 0 0 6px rgba(22,101,52,0); }
}
