/* Website presentation for the supplied G5A 40-minute assessment.
   Preserve the source styles for item geometry, stimulus and answer sizes,
   fraction layout, short-flash presentation, and response animations. */
:root {
  --ink: #123247;
  --muted: #58707d;
  --teal: #0a5b59;
  --line: #d7d9d2;
  --focus: #0e706c;
  --brand-navy: #0a2638;
  --brand-paper: #fffdf8;
  --brand-warm: #f8f5ec;
  --brand-mint: #dcece8;
  --brand-amber: #8a5416;
  --brand-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  color: var(--ink);
  background: var(--brand-warm);
}

body {
  color: var(--ink);
  background: var(--brand-warm);
}

header {
  border-bottom-color: var(--line);
  background: var(--brand-paper);
}

header > div:not(.progress) {
  flex-wrap: wrap;
}

.brand {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 11px;
  align-items: center;
  min-width: 0;
  color: var(--brand-navy);
  font-family: var(--brand-serif);
  letter-spacing: 0.025em;
}

.brand::before {
  display: grid;
  grid-column: 1;
  grid-row: 1 / 3;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--focus);
  border-radius: 50%;
  background: var(--brand-paper);
  box-shadow: inset 0 0 0 4px var(--brand-mint);
  color: var(--teal);
  content: "5·2";
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

#section-timer {
  grid-column: 2;
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

#remaining {
  color: var(--teal);
}

#status-message:empty,
[data-short40-save-status]:empty {
  display: none;
}

.progress {
  background: #efe9dc;
}

.progress > div {
  background: var(--teal);
}

.panel {
  border-color: var(--line);
  border-radius: 4px;
  background: var(--brand-paper);
  box-shadow: 0 10px 30px rgb(10 38 56 / 5%);
}

h1,
h2 {
  color: var(--brand-navy);
  font-family: var(--brand-serif);
}

.tag,
.panel[data-stage="question"] > .tag {
  border-radius: 2px;
  color: var(--teal);
  background: var(--brand-mint);
}

.panel[data-stage="practice"] > .tag {
  color: var(--brand-amber);
  background: #f5e8d1;
}

.notice {
  border-color: var(--teal);
  border-radius: 0 3px 3px 0;
  color: var(--ink);
  background: #edf3ee;
}

.warning {
  border-color: var(--brand-amber);
  background: #f5e8d1;
}

.danger {
  color: #8e352d;
}

.context,
.calculation-line {
  border-color: var(--line);
  border-radius: 4px;
  background: var(--brand-warm);
}

.choice {
  border-color: var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: var(--brand-paper);
}

.choice:focus-visible,
.choice.is-selected {
  border-color: var(--teal);
  background: var(--brand-mint);
}

/* v1.5 separates the worked steps without changing their reading order. */
.solution-steps > li {
  border-color: var(--line);
  border-radius: 4px;
  background: var(--brand-warm);
}

.step-index {
  color: var(--teal);
}

.stimulus.fixation {
  color: var(--ink);
}

kbd,
.choice-key kbd,
.keyboard-action kbd {
  border-color: #a9b3b0;
  border-radius: 3px;
  color: var(--teal);
  background: var(--brand-paper);
}

.choice-key kbd {
  background: var(--brand-mint);
}

button,
.keyboard-action {
  border: 1px solid #91b2a7;
  border-radius: 4px;
  background: #edf4ef;
  color: var(--teal);
}

.keyboard-action {
  max-width: 100%;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 18px;
}

.keyboard-action kbd {
  min-height: 32px;
  padding: 3px 7px;
  border: 1px solid #b8c9bf;
  background: var(--brand-paper);
  font-size: 15px;
  font-weight: 500;
}

.keyboard-action .key-icon {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
}

.keyboard-action kbd small {
  font-size: 9px;
}

button:not(:disabled):hover {
  border-color: var(--teal);
  background: #e1ede5;
}

.secondary {
  border-color: var(--line);
  background: var(--brand-paper);
  color: var(--ink);
}

.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

input,
textarea {
  border-color: #a9b3b0;
  border-radius: 3px;
  color: var(--ink);
  background: #fff;
}

#number-answer {
  border-color: #819a99;
  border-radius: 4px;
  caret-color: var(--teal);
}

input:focus,
#number-answer:focus {
  border-color: var(--focus);
}

button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.keyboard-hint,
.input-submit-hint,
.answer-edit-hint,
.update-step-label,
.practice-next,
.teacher-controls,
.recovery-tools,
#status-message,
footer {
  color: var(--muted);
}

.stimulus {
  color: var(--brand-navy);
}

.practice-dialog {
  border-color: #a9c9bf;
  border-radius: 4px;
  background: #edf3ee;
}

.practice-dialog.retry,
.practice-dialog.bad {
  border-color: #cfb58c;
  background: #faf3e5;
}

.feedback {
  border-color: var(--line);
  border-radius: 3px;
  background: var(--brand-paper);
}

.feedback.bad {
  border-color: #dfd1b8;
  background: var(--brand-paper);
}

.feedback-icon {
  color: var(--teal);
  background: var(--brand-mint);
}

.feedback-title {
  color: var(--teal);
}

.practice-dialog.retry .feedback-title,
.practice-dialog.bad .feedback-title,
.practice-dialog.retry .feedback-icon,
.practice-dialog.bad .feedback-icon {
  color: var(--brand-amber);
}

.practice-dialog.retry .feedback-icon,
.practice-dialog.bad .feedback-icon {
  display: none;
}

.answer-receipt {
  border-radius: 2px;
  color: var(--teal);
  background: var(--brand-mint);
}

.answer-receipt::before {
  background: var(--teal);
}

#qa-banner {
  border-bottom: 1px solid #c78d7e;
  color: #8e352d;
  background: #f3ded8;
}

#warning-banner,
#storage-warning {
  border-color: #cfb58c;
  border-radius: 3px;
  color: #704110;
  background: #f5e8d1;
}

#storage-warning {
  width: calc(100% - 48px);
}

.flow {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.flow > div {
  border-color: var(--line);
  border-radius: 3px;
  background: var(--brand-warm);
}

.flow b,
.saved,
summary {
  color: var(--teal);
}

.short40-profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 24px;
}

.short40-profile-grid input {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.short40-consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 18px 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.short40-consent input {
  flex: 0 0 auto;
  margin-top: 4px;
  accent-color: var(--teal);
}

[data-web-control] button,
button[data-web-control] {
  cursor: pointer;
}

[data-web-control] button:disabled,
button[data-web-control]:disabled {
  cursor: wait;
}

input[readonly] {
  background: var(--brand-warm);
}

.teacher-controls,
.admin-panel,
.panel[data-stage="question"] > .actions,
.panel[data-stage="practice"] > .actions,
th,
td {
  border-color: var(--line);
}

.admin-panel,
#download-status,
#status-message {
  overflow-wrap: anywhere;
}

#teacher-results {
  overflow-x: auto;
}

#teacher-results table {
  min-width: 480px;
}

#end-confirm,
#new-confirm {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border-color: var(--brand-amber);
  border-radius: 4px;
  background: var(--brand-paper);
  box-shadow: 0 0 0 100vmax rgb(10 38 56 / 40%), 0 20px 60px rgb(10 38 56 / 14%);
}

@media (max-width: 700px) {
  .brand {
    grid-template-columns: 34px minmax(0, 1fr);
    column-gap: 8px;
  }

  .brand::before {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  header > div:not(.progress) {
    row-gap: 8px;
  }

  .flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .short40-profile-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #storage-warning {
    width: calc(100% - 24px);
  }

  /* Keep the brief receipt clear of long section labels without moving items. */
  .answer-receipt {
    top: auto;
    right: 17px;
    bottom: 3px;
  }

  #end-confirm,
  #new-confirm {
    width: calc(100vw - 24px);
    padding: 20px;
  }
}

@media (max-width: 430px) {
  #remaining {
    margin-left: 42px;
    white-space: normal;
  }
}

@media (forced-colors: active) {
  .panel,
  .notice,
  .flow > div,
  button,
  .keyboard-action {
    border: 1px solid CanvasText;
  }

  .progress > div {
    background: Highlight;
  }
}

/* Inline mathematical fractions preserve the item text while avoiding slash notation. */
.inline-fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  vertical-align: middle;
  line-height: 1.05;
  font-size: .85em;
  margin: .08em .2em;
  white-space: nowrap;
}
.inline-fraction > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .12em .15em; }
.inline-fraction > span:last-child { padding: .15em .12em 0; }
.operation-examples { padding: 12px 16px; background: var(--brand-paper); border: 1px solid var(--line); }
.panel[data-stage="registration"] button { cursor: pointer; }

@media (max-height: 680px) and (min-width: 701px) {
  header > div:not(.progress) { padding-top: 5px; padding-bottom: 5px; }
  #status-message { min-height: 0; margin-top: 3px; }
  #status-message:empty { display: none; }
  main { margin-top: 7px; }
  .panel { padding-top: 14px; padding-bottom: 14px; }
  .keyboard-hint { margin-top: 8px; margin-bottom: 8px; }
  .panel[data-module="semantic"] .prompt { font-size: 21px; line-height: 1.5; margin: 12px 0; }
  .panel[data-module="semantic"] .choice { min-height: 52px; padding: 7px 14px; font-size: 20px; }
  .panel[data-module="semantic"] .options { gap: 7px; margin: 10px 0; }
  .panel[data-module="geometry"] .visual svg { max-height: 175px; }
  .panel[data-module="meta"] { padding-top: 14px; padding-bottom: 14px; }
  .panel[data-module="meta"] .solution-steps { margin: 8px 0; gap: 4px; }
  .panel[data-module="meta"] .solution-steps > li { padding-top: 5px; padding-bottom: 5px; }
  .panel[data-module="meta"] .step-content { font-size: 19px; line-height: 1.45; }
  .panel[data-module="meta"] .meta-question { margin-top: 8px; margin-bottom: 8px; }
  .panel[data-module="meta"] .options { gap: 8px; }
}
