/* Learner app.
   Built for a phone held one-handed: large tap targets, a single column, and
   nothing that depends on hover. */

:root {
  --ink: #1a1a1a;
  --muted: #6b6459;
  --paper: #f5f3ee;
  --card: #ffffff;
  --line: #ddd8cd;
  --accent: #1b6b3a;
  --warn: #b02a2a;
  --tap: 46px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 17px/1.55 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  /* Clears the notch and the home indicator on iOS. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.view { max-width: 680px; margin: 0 auto; padding: 16px 16px 48px; }

/* ---- chrome ---- */

.banner {
  display: none;
  padding: 10px 16px;
  background: #fdf6e3;
  border-bottom: 1px solid #e6d9a8;
  font-size: 14.5px;
  text-align: center;
}
.banner.visible { display: block; }

.back {
  background: none; border: none; padding: 8px 4px 8px 0;
  font-size: 17px; color: var(--muted); cursor: pointer;
}

h2.section-head {
  font-size: 14px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); margin: 26px 0 10px;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }
.sub { color: var(--muted); margin: 0 0 22px; }

/* ---- cards ---- */

.card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px;
  font: inherit; color: inherit; cursor: pointer;
}
.card strong { display: block; font-size: 17px; margin-bottom: 2px; }
.card.assignment:active { transform: scale(0.995); }
.assignment-due { display: block; margin-top: 4px; }
.completed-homework { margin: 22px 0; border-top: 1px solid var(--line); }
.completed-homework > summary { min-height: var(--tap); padding: 12px 2px; cursor: pointer; font-weight: 600; }
.completed-homework > summary:focus-visible { outline: 3px solid #38804c; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.pill {
  display: inline-block; margin-top: 8px; padding: 3px 10px;
  border-radius: 999px; font-size: 13px; font-weight: 600;
}
.pill.done { background: #eaf3ea; color: var(--accent); }
.pill.pending { background: #fdf6e3; color: #8a6d1f; display: block; text-align: center; margin-bottom: 14px; padding: 9px; }

/* Work that could not be delivered. Deliberately loud: the learner thinks they
   have submitted, and only they can raise it with the teacher. */
.pill.rejected {
  display: block; text-align: left; background: #fdeaea; color: var(--warn);
  padding: 11px 13px; margin-bottom: 14px; border-radius: 10px;
}
.pill.rejected strong { display: block; margin-bottom: 3px; }
.pill.rejected p { margin: 3px 0 0; font-size: 13px; font-weight: 500; }

/* Past-deadline notice inside a worksheet. Distinct from .banner, which is the
   connectivity strip and is hidden until toggled. */
.notice.late {
  background: #fdf0e6; border-left: 3px solid #a8480c; border-radius: 0 9px 9px 0;
  padding: 11px 14px; margin-bottom: 14px;
}
.notice.late strong { display: block; color: #a8480c; margin-bottom: 3px; }
.notice.late p { margin: 0; font-size: 13.5px; }

/* Shown when the tablet could reclaim this app's storage. Informative rather
   than alarming: nothing is wrong yet, and one action prevents it. */
.notice.install {
  background: #eef2f8; border-left: 3px solid #3a6ea8; border-radius: 0 9px 9px 0;
  padding: 11px 14px; margin-bottom: 14px;
}
.notice.install strong { display: block; color: #2a5b8f; margin-bottom: 3px; }
.notice.install p { margin: 3px 0 0; font-size: 13.5px; }
.notice.install p.how { color: var(--muted); font-size: 13px; }

/* ---- forms ---- */

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  flex: 1; padding: 11px; border: 1px solid var(--line); background: transparent;
  border-radius: 10px; font: inherit; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 5px; }
.field-hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%; min-height: var(--tap);
  padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  /* 16px or larger stops iOS zooming the page when the field is focused. */
  font: 16px/1.5 inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--ink); outline-offset: 1px; }

button.primary, button.secondary {
  width: 100%; min-height: var(--tap); padding: 13px;
  border-radius: 10px; font: 17px/1.2 inherit; font-weight: 600; cursor: pointer;
}
button.primary { background: var(--ink); color: #fff; border: 1px solid var(--ink); }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: 0.55; }
button.link {
  display: block; width: 100%; margin-top: 12px; padding: 10px;
  background: none; border: none; color: var(--muted);
  font: inherit; text-decoration: underline; cursor: pointer;
}

.status { margin: 12px 0 0; font-size: 15px; min-height: 1.2em; }
.status.error { color: var(--warn); }

/* ---- worksheet ---- */

.progress {
  margin: 0 0 16px; font-size: 14.5px; color: var(--muted);
  padding: 8px 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; text-align: center;
}

.exercise {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; margin-bottom: 14px;
}
.exercise h2 { font-size: 18px; margin: 0 0 4px; }
.instructions { color: var(--muted); font-size: 15px; margin: 0 0 12px; font-style: italic; }
.general { margin: 0 0 16px; }

ol.items { margin: 0; padding-left: 24px; }
ol.items > li { margin: 0 0 18px; }
ol.items > li:last-child { margin-bottom: 0; }

.question { font-weight: 600; margin: 0 0 8px; }

/* matching */
ol.match-options {
  margin: 0 0 14px; padding: 12px 12px 12px 30px;
  background: var(--paper); border-radius: 10px; list-style: none;
  counter-reset: none;
}
ol.match-options li { margin: 4px 0; }
.letter { display: inline-block; min-width: 22px; }
.match-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.match-row select { width: 82px; flex: none; text-align: center; }
.match-left { flex: 1; }

/* gap fill */
.word-bank {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 12px; margin-bottom: 14px;
  background: var(--paper); border-radius: 10px;
}
.word-bank span {
  padding: 5px 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; font-size: 15px;
}
.gap-input {
  display: inline-block; width: 130px; min-height: 38px;
  margin: 2px 3px; padding: 4px 9px; vertical-align: baseline;
}

/* multiple choice */
.choice {
  display: flex; align-items: center; gap: 11px;
  min-height: var(--tap); padding: 7px 10px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.choice input { width: 21px; height: 21px; flex: none; margin: 0; }
.choice:has(input:checked) { border-color: var(--ink); background: var(--paper); }

/* unscramble */
.scramble-answer {
  min-height: var(--tap); padding: 8px; margin-bottom: 10px;
  border: 1px dashed var(--line); border-radius: 10px; background: var(--paper);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.scramble-hint { color: var(--muted); font-size: 14.5px; padding: 0 4px; }
.scramble-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font: 16px/1.2 inherit; color: inherit; cursor: pointer;
}
.chip.chosen { background: var(--ink); color: #fff; border-color: var(--ink); }

textarea.writing { min-height: 150px; }

.actions { margin-top: 22px; }

/* ---- marks ---- */

.score-box {
  text-align: center; padding: 22px;
  border-radius: 12px; margin-bottom: 18px;
  background: var(--card); border: 2px solid var(--line);
}
.score-box.pass { border-color: #bcd9c4; background: #f2f8f3; }
.score-box.fail { border-color: #e8bcbc; background: #fdf4f4; }
.score-value { display: block; font-size: 32px; font-weight: 700; }
.score-pct { display: block; color: var(--muted); margin-top: 2px; }

.summary { margin: 0 0 8px; }
ul.bullets { margin: 0; padding-left: 22px; }
ul.bullets li { margin: 5px 0; }

.answer-row {
  position: relative;
  background: var(--card); border: 1px solid var(--line);
  border-left-width: 4px; border-radius: 10px;
  padding: 12px 78px 12px 14px; margin-bottom: 9px;
}
.answer-row.correct { border-left-color: var(--accent); }
.answer-row.incorrect { border-left-color: var(--warn); }
.answer-prompt { margin: 0 0 6px; font-weight: 600; }
.answer-line { margin: 2px 0; font-size: 15.5px; }
.answer-feedback { margin: 8px 0 0; font-size: 15px; color: var(--muted); font-style: italic; }
.answer-points {
  position: absolute; top: 12px; right: 14px;
  font-size: 14px; font-weight: 700; color: var(--muted);
}

.wordmark { display: inline-block; color: var(--ink); font-size: 18px; font-weight: 800; text-decoration: none; letter-spacing: -0.5px; margin-top: 12px; }
.view > h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.8px; margin: 18px 0 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.toolbar button { flex: 1 1 180px; }
.toolbar button.link { flex: 0 1 auto; margin: 0; }
.actions > button { margin: 8px 0; }
.notice button, .pill.rejected button { margin-top: 9px; }
.notice[hidden] { display: none; }
.empty-state { padding: 24px 18px; background: var(--card); border: 1px dashed var(--line); border-radius: 12px; }
.teacher-link { display: block; text-align: center; color: var(--muted); margin: 28px 0 8px; }
.banner.error { color: var(--warn); }
button, input, select, textarea { font-family: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #38804c; outline-offset: 3px; }
.answer-prompt { font-size: 17px; }
input.gap-input { width: min(180px, 100%); }
.view > .choice { margin-top: 24px; }

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece7dd;
    --muted: #9c948a;
    --paper: #171614;
    --card: #221f1c;
    --line: #3a352f;
    --accent: #6bbf87;
    --warn: #e08585;
  }
  .banner { background: #2a2415; border-bottom-color: #4a3f22; }
  .pill.done { background: #1e2b21; }
  .pill.pending { background: #2a2415; color: #d8c88a; }
  .notice.late { background: #2a1d12; }
  .notice.late strong { color: #e8a366; }
  .notice.install { background: #19222d; border-left-color: #4a7ab0; }
  .notice.install strong { color: #8fbce8; }
  .pill.rejected { background: #2e1f1f; }
  .score-box.pass { background: #1c2620; border-color: #35513f; }
  .score-box.fail { background: #2a1e1e; border-color: #5a3535; }
  .tab.active { background: var(--ink); color: #171614; }
  button.primary { background: var(--ink); color: #171614; }
  .chip.chosen { background: var(--ink); color: #171614; }
}
