/*
 * BTEC Submit design layer. Loaded after site.css on every page; the rules are written down in DESIGN.md.
 * Global floors (focus, motion, touch, long content) live here instead of being repeated per component.
 */
/* Cairo for the whole site, served from /fonts (the CSP allows only this site's fonts). One variable file per
 * script covers every weight from 200 to 1000; the browser downloads only the subsets a page actually uses. */
@font-face {
  font-family: Cairo;
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("/fonts/cairo-arabic-4d90a59cb1819bdd41f970549ab90a16.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F,
    U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: Cairo;
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("/fonts/cairo-latin-ext-2ef88f3a969dc5395f2dca66e6259630.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Cairo;
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("/fonts/cairo-latin-3c9597566d23234e05dc818314188491.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --focus-ring: #2f8f6b;
  --ease-out-strong: cubic-bezier(.23, 1, .32, 1);
  --press-duration: 160ms;
  --tap-target: 44px;
}

/* Form controls use the system font unless told otherwise. */
button, input, select, textarea, optgroup { font-family: inherit; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Skip link ------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -60px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus-visible { top: 12px; }

/* ---- Visible keyboard focus everywhere ----------------------------------------------------- */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: 2px;
}
main[tabindex="-1"]:focus { outline: none; }
:target { scroll-margin-top: 84px; }

/* ---- Touch and press feedback -------------------------------------------------------------- */
a, button, label, summary, [role="button"], input[type="file"] { touch-action: manipulation; }
button, .button, [role="button"] { -webkit-user-select: none; user-select: none; }

button,
.button {
  transition-property: transform, background-color, border-color, color, box-shadow, opacity;
  transition-duration: var(--press-duration), .15s, .15s, .15s, .15s, .15s;
  transition-timing-function: var(--ease-out-strong), ease, ease, ease, ease, ease;
}
button:active:not(:disabled),
.button:active:not([aria-disabled="true"]) { transform: scale(.97); }

/* Inputs at 16px on touch screens so iOS does not zoom the page on focus. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }
}

/* ---- Numbers and long content --------------------------------------------------------------- */
.stat-card strong, .count-pill, .tab-count, .notification-count, .version-number,
.deadline-chip b, .grade-table td, .student-progress, time { font-variant-numeric: tabular-nums; }

h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

h1, h2, h3, .teacher-name, .version-info a, .notification-text, .grade-table td,
.assignment-description, .student-card-title, .user-chip span:last-child {
  overflow-wrap: anywhere;
}
.student-card-title, .version-info, .card-title-row > h3 { min-width: 0; }

/* Short status labels never break onto two lines. */
.status-badge, .mini-status, .count-pill, .assignment-kind-badge, .file-chips span { white-space: nowrap !important; }

/* Dates stay left-to-right inside Arabic text. */
.ltr-value { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.time-value { direction: rtl; unicode-bidi: isolate; display: inline-block; white-space: nowrap; }

/* ---- Fixes found while testing ------------------------------------------------------------- */
/* Visually hidden file-type checkboxes inherited width:100% and pushed the teacher page sideways. */
.type-option { position: relative; }
.type-option input { inset: 0; width: 1px !important; height: 1px !important; margin: 0; }

/* Login: keep the headline clear of the decorative card on narrow screens. */
@media (max-width: 800px) { .story-copy { max-width: 55%; } }
@media (max-width: 560px) {
  .story-copy { max-width: 58%; }
  .story-copy h1 { font-size: 22px; }
  .story-art small { display: none; }
}

/* ---- Top bar on small screens ----------------------------------------------------------- */
.brand span { white-space: nowrap; }
.topbar-link { white-space: nowrap; }
.notification-bell svg { width: 16px; height: 16px; }
.logout-button { min-height: 36px; padding-inline: 12px; }
@media (max-width: 560px) {
  .topbar { gap: 8px; padding-inline: 12px; }
  .topbar-right { gap: 6px; }
  .user-chip span:last-child { display: none; }
  .brand span { font-size: 15px; }
  .topbar-link { min-height: 36px; padding: 6px 9px; }
}
@media (max-width: 380px) {
  .brand span { display: none; }
}

/* ---- Grade report on phones: each row becomes a small card ------------------------------- */
@media (max-width: 640px) {
  .grade-report-head { align-items: flex-start; gap: 12px; }
  .grade-report-head .button { white-space: nowrap; }
  .grade-table thead { display: none; }
  .grade-table, .grade-table tbody, .grade-table tr, .grade-table td { display: block; width: 100%; }
  .grade-table tr { padding: 12px 0; border-bottom: 1px solid #eef1f5; }
  .grade-table tr:last-child { border-bottom: 0; }
  .grade-table td { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; }
  .grade-table td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12px; font-weight: 600; }
  .grade-table td > * { text-align: end; }
}

/* ---- Hover only where a pointer can hover ------------------------------------------------- */
@media (hover: hover) and (pointer: fine) {
  .notification-list button:hover { border-color: #cfd6e4; background: #f3f5fa; }
  .topbar-link:hover { background: #e6eaf3; }
}

/* ---- Reduced motion: keep colour and opacity changes, drop movement ---------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  button:active:not(:disabled), .button:active { transform: none; }
  .live-update-pulse { animation: none !important; }
}

/* ---- Print ------------------------------------------------------------------------------- */
@media print { .skip-link { display: none; } }

.stat-card .grade-split { display: flex; flex-wrap: wrap; gap: 4px 10px; font-family: Cairo,Tahoma,sans-serif; }

/* ---- Teacher feedback: a clear card the student cannot miss ------------------------------- */
.submission-history .feedback-note,
.feedback-note {
  margin: 10px 0 2px;
  padding: 14px 16px;
  border: 1px solid #d9def7;
  border-inline-start: 4px solid #4b5fd6;
  border-radius: 12px;
  background: #f4f6ff;
  color: var(--ink);
  font-size: 14px;
}
.feedback-note-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 6px; }
.feedback-note-icon { width: 18px; height: 18px; flex: none; color: #4b5fd6; }
.feedback-note-head strong { color: #2f3f9e; font-size: 13px; font-weight: 700; }
.feedback-note-head small { margin-inline-start: auto; color: var(--muted); font-size: 11px; }
.submission-history .feedback-note p.feedback-note-text,
.feedback-note p.feedback-note-text {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
}
.feedback-note .student-feedback-images { margin-top: 10px; }
.feedback-note .student-feedback-images img { width: 120px; max-height: 110px; }

/* Revision requested: amber, the same colour as the "new version requested" callout. */
.submission-history .feedback-note.feedback-note-revision,
.feedback-note.feedback-note-revision { border-color: #f0d3a3; border-inline-start-color: #d97716; background: #fff7ea; }
.feedback-note-revision .feedback-note-icon { color: #c96711; }
.feedback-note-revision .feedback-note-head strong { color: #8a4300; }

/* Teacher's own copy of the comment, same structure in a quieter tone. */
.teacher-version .saved-feedback {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #dfe3f0;
  border-inline-start: 4px solid #7b86c9;
  border-radius: 12px;
  background: #f7f8fd;
}
.teacher-version .saved-feedback span { color: #4a56a6; font-size: 12px; font-weight: 700; }
.teacher-version .saved-feedback p { color: var(--ink); font-size: 13.5px; line-height: 1.8; }
.teacher-version .saved-feedback.feedback-note-revision { border-inline-start-color: #d97716; background: #fffaf1; }

.upload-error { margin: 10px 0 0; }

/* ---- Attachment preview before saving -------------------------------------------------------
 * Documents are full-width rows so long names never run into each other; images and videos stay
 * as thumbnails. Names mixing Arabic and Latin text are isolated (dir="auto") and cut with "…". */
.feedback-image-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.feedback-image-preview figure.preview-file,
.feedback-image-preview figure.preview-media { position: relative; width: auto; min-width: 0; margin: 0; }
.feedback-image-preview figure.preview-file {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.preview-file-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--blue-pale);
  color: #3d4fb8;
  font: 800 10px Cairo,Tahoma,sans-serif;
}
.feedback-image-preview figcaption { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 1px; }
.preview-file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.preview-file-size { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.feedback-image-preview figure.preview-file .pasted-image-remove { flex: none; margin: 0; }
.feedback-image-preview figure.preview-media img,
.feedback-image-preview figure.preview-media video { width: 100%; max-width: 100%; height: 110px; object-fit: cover; }
.feedback-image-preview figure.preview-media figcaption { margin-top: 4px; }
.feedback-image-preview figure.preview-media .pasted-image-remove { margin-top: 6px; }

/* Busy submit button while attachments upload. */
.button.is-busy { cursor: progress; opacity: .85; }
.button.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: button-spin .8s linear infinite;
}
@keyframes button-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .button.is-busy::before { animation: none; border-inline-end-color: currentColor; opacity: .5; } }

/* ---- Teacher notifications: bell + dropdown, in the style of Facebook's notifications ------ */
.notif { position: relative; }
.notif-bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #eef0f5;
  color: var(--ink);
  cursor: pointer;
}
.notif-bell svg { width: 20px; height: 20px; }
.notif-bell[aria-expanded="true"] { background: #e3e8ff; color: #3d4fb8; }
.notif-badge {
  position: absolute;
  top: -3px;
  inset-inline-start: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 10px;
  background: #e41e3f;
  color: #fff;
  font: 800 11px/15px Cairo,Tahoma,sans-serif;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.notif-bell.has-new { animation: notif-ring .6s var(--ease-out-strong); }
@keyframes notif-ring {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-14deg); }
  45% { transform: rotate(10deg); }
  70% { transform: rotate(-5deg); }
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 60;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(24, 40, 68, .16), 0 2px 6px rgba(24, 40, 68, .08);
  overflow: hidden;
  opacity: 0;
  transform: scale(.97) translateY(-4px);
  transform-origin: top left;
  transition: opacity 150ms ease-out, transform 150ms var(--ease-out-strong);
}
.notif-panel.is-open { opacity: 1; transform: none; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 6px; }
.notif-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.notif-read-all { border: 0; background: none; color: #3d5afe; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.notif-tabs { display: flex; gap: 6px; padding: 4px 16px 8px; }
.notif-tabs button {
  border: 0;
  border-radius: 18px;
  padding: 6px 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.notif-tabs button[aria-selected="true"] { background: #e7ebff; color: #3d4fb8; }
.notif-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; overscroll-behavior: contain; }
.notif-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
}
.notif-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
.notif-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-text { font-size: 13.5px; line-height: 1.6; color: #3c4658; overflow-wrap: anywhere; }
.notif-text strong { color: var(--ink); font-weight: 700; }
.notif-time { font-size: 12px; color: var(--muted); }
.notif-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: transparent; }
.notif-item.is-unread .notif-text { color: var(--ink); }
.notif-item.is-unread .notif-time { color: #3d5afe; font-weight: 700; }
.notif-item.is-unread .notif-dot { background: #3d5afe; }
.notif-empty { margin: 0; padding: 22px 16px 26px; color: var(--muted); font-size: 13px; text-align: center; }
@media (hover: hover) and (pointer: fine) {
  .notif-bell:hover { background: #e4e7ef; }
  .notif-item:hover { background: #f2f4f8; }
  .notif-read-all:hover, .notif-tabs button:hover { background: #f2f4f8; }
}
.notif-item:active { background: #e9ecf3; }

/* The student card opened from a notification is briefly highlighted. */
.review-student-card.notification-target { outline: 3px solid #8fa0ff; outline-offset: 2px; transition: outline-color .6s ease; }

@media (max-width: 560px) {
  .notif-bell { width: 36px; height: 36px; }
  .notif-panel {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top, 0px));
    inset-inline: 8px;
    width: auto;
    max-height: calc(100dvh - 80px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .notif-panel { transform: none; transition: opacity 120ms ease; }
  .notif-bell.has-new { animation: none; }
}

/* ---- Error pages (templates/error.html) ----------------------------------------------------- */
.error-wrap { display: grid; place-items: center; min-height: calc(100dvh - 140px); padding: 24px 16px; }
.error-card {
  width: min(520px, 100%);
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}
.error-code { display: block; color: #c7cfdd; font: 800 56px/1 Cairo,Tahoma,sans-serif; letter-spacing: -2px; }
.error-card h1 { margin: 10px 0 8px; font-size: 22px; }
.error-card p { margin: 0 auto 20px; max-width: 42ch; color: var(--muted); font-size: 14px; line-height: 1.9; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---- Submission receipt (student-receipt.html, receipt-verify.html) ------------------------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.receipt-link { justify-self: start; width: fit-content; color: #3d4fb8; font-size: 12px; font-weight: 600; text-decoration: none; }
.receipt-link::before { content: "▤ "; }
@media (hover: hover) and (pointer: fine) { .receipt-link:hover { text-decoration: underline; } }
.receipt-wrap { width: min(100% - 32px, 640px); margin: 24px auto 40px; }
.receipt-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.receipt-card { padding: 24px 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.receipt-head { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px dashed #d5dbe6; }
.receipt-head .brand-logo { width: 48px; height: 48px; border-radius: 12px; }
.receipt-head h1 { margin: 0; font-size: 21px; }
.receipt-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.receipt-code-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; margin: 18px 0 10px; }
.receipt-code-row span { color: var(--muted); font-size: 13px; }
.receipt-code { font: 800 21px/1.3 Cairo,Tahoma,sans-serif; letter-spacing: .5px; color: var(--ink); }
.receipt-status { display: inline-block; margin: 0 0 14px; padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.receipt-status.is-on-time { background: var(--green-pale); color: #237055; }
.receipt-status.is-late { background: var(--red-pale); color: #9c3c46; }
.receipt-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.receipt-details div { min-width: 0; }
.receipt-details dt { color: var(--muted); font-size: 12px; }
.receipt-details dd { margin: 2px 0 0; color: var(--ink); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.receipt-details .receipt-file { unicode-bidi: plaintext; }
.receipt-foot { margin-top: 18px; padding-top: 14px; border-top: 1px dashed #d5dbe6; color: var(--muted); font-size: 12px; line-height: 1.8; }
.receipt-printed { margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.receipt-verify-form { margin-bottom: 16px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.receipt-verify-form h1 { margin: 0 0 4px; font-size: 20px; }
.receipt-verify-form p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.receipt-search { display: flex; gap: 8px; }
.receipt-search input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid #dfe3ec; border-radius: 10px; font: 600 15px Cairo,Tahoma,sans-serif; text-transform: uppercase; }
@media (max-width: 560px) {
  .receipt-card { padding: 18px 16px; }
  .receipt-details { grid-template-columns: 1fr; }
  .receipt-search { flex-direction: column; }
}
@media print {
  .receipt-page { background: #fff; }
  .receipt-wrap { width: 100%; margin: 0; }
  .receipt-card { border: 1px solid #999; box-shadow: none; }
}

/* Portal notices (grades, feedback, reminders) show the site's logo instead of a person's initial. */
.notif-avatar.is-system { background: #fff; border: 1px solid var(--line, #e3e7ef); overflow: hidden; padding: 0; }
.notif-avatar.is-system img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
/* The browser-notifications switch at the foot of the student's dropdown. */
.notif-foot { border-top: 1px solid var(--line, #e3e7ef); padding: 8px 12px; }
.notif-foot[hidden] { display: none; }
.notif-device-toggle { width: 100%; border: 0; border-radius: 8px; padding: 8px 10px; background: #e7ebff; color: #3d4fb8; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.notif-device-toggle.is-on { background: #f2f4f8; color: var(--muted, #5b6475); font-weight: 600; }
.notif-device-toggle:disabled { opacity: .6; cursor: progress; }
@media (hover: hover) { .notif-device-toggle:hover { filter: brightness(.97); } }
