/* Site stylesheet: design tokens, self-hosted fonts and shared components.
   Fonts are declared in fonts.css: Cormorant SC (headings) and Cactus Classical Serif (body, one weight only). */

:root {
  /* Owner's palette */
  --navy: #3B5183;
  --butter: #F5E283;
  --rust: #833514;
  /* Derived neutrals and states */
  --cream: #FBF7EC;
  --ink: #2B2420;
  --white: #FFFFFF;
  --green: #2F6B4F;
  --navy-tint: #E3E8F3;
  --butter-tint: #FCF6D4;
  --rust-tint: #F6E4DC;
  --green-tint: #E4F1E9;
  --line: #D9D2C3;
  --muted-ink: #6B645D;

  --font-display: "Cormorant SC", Georgia, "Times New Roman", serif;
  --font-body: "Cactus Classical Serif", Georgia, "Times New Roman", serif;
  --radius: 22px;
  --radius-small: 14px;
  --shadow: 0 6px 20px rgba(59, 81, 131, 0.12);
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  font-synthesis: none; /* the body font has one weight: never fake bold or italic */
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, th, .brand, .num {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
h1 { font-size: 2.4rem; color: var(--navy); margin: 0 0 0.6rem; }
h2 { font-size: 1.7rem; color: var(--rust); margin: 1.6rem 0 0.6rem; }
h3 { font-size: 1.3rem; color: var(--navy); margin: 0 0 0.5rem; }
strong, b { font-weight: 400; color: var(--navy); }
a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--rust); }
p { margin: 0.6rem 0; }
ol, ul { padding-left: 1.4rem; }

.page { max-width: 62rem; margin: 0 auto; padding: 1.2rem; }
.page-narrow { max-width: 26rem; margin: 2rem auto; }
.muted { color: var(--muted-ink); font-size: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1.2rem;
  background: var(--navy); color: var(--white);
  border-radius: var(--radius); padding: 0.9rem 1.4rem; margin-bottom: 1.4rem;
}
.topbar .brand { font-size: 1.7rem; color: var(--white); text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.2rem; }
.topbar nav a { color: var(--butter); }
.topbar nav a:hover { color: var(--white); }
.topbar form { margin: 0; }

/* Flash messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { background: var(--butter-tint); border: 1px solid var(--butter); border-radius: var(--radius-small); padding: 0.7rem 1rem; margin-bottom: 0.5rem; }
.messages li.error { background: var(--rust-tint); border-color: var(--rust); }
.messages li.success { background: var(--green-tint); border-color: var(--green); }

/* Cards and layout */
.card { background: var(--white); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; }
.grid .card { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.text-block { white-space: pre-line; }

/* Buttons */
.btn {
  display: inline-block; min-height: 2.6rem; padding: 0.6rem 1.5rem;
  font: inherit; font-size: 1rem; line-height: 1.4; text-align: center; text-decoration: none; cursor: pointer;
  border: 2px solid transparent; border-radius: 999px;
}
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: #2F4269; color: var(--white); }
.btn-accent { background: var(--butter); color: var(--navy); }
.btn-accent:hover { background: #EBD767; color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-ghost:hover { background: var(--navy-tint); color: var(--navy); }
.btn-danger { background: var(--rust); color: var(--white); }
.btn-danger:hover { background: #6B2B10; color: var(--white); }
.btn-small { min-height: 2rem; padding: 0.2rem 1rem; font-size: 0.9rem; }
.topbar .btn-ghost { color: var(--white); border-color: var(--butter); }
.topbar .btn-ghost:hover { background: var(--butter); color: var(--navy); }
.btn-block { display: block; width: 100%; }
.btn:focus-visible, a:focus-visible, .field:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.topbar a:focus-visible, .topbar .btn:focus-visible { outline-color: var(--butter); }

/* Badges and tabs */
.badge { display: inline-block; padding: 0.15rem 0.9rem; border-radius: 999px; font-size: 0.85rem; }
.badge-butter { background: var(--butter); color: var(--navy); }
.badge-navy { background: var(--navy-tint); color: var(--navy); }
.badge-rust { background: var(--rust-tint); color: var(--rust); }
.badge-green { background: var(--green-tint); color: var(--green); }
.tabs { display: inline-flex; background: var(--white); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.tabs a, .tabs span { padding: 0.5rem 1.3rem; border-radius: 999px; color: var(--navy); text-decoration: none; }
.tabs .on { background: var(--navy); color: var(--white); }

/* Forms */
label { display: block; font-size: 0.9rem; color: var(--muted-ink); margin-bottom: 0.25rem; }
.field, .card input[type="text"], .card input[type="password"], .card input[type="number"], .card input[type="datetime-local"],
.card select, .card textarea {
  width: 100%; min-height: 2.8rem; padding: 0.6rem 0.9rem;
  font: inherit; color: var(--ink); background: var(--white);
  border: 2px solid var(--line); border-radius: var(--radius-small);
}
.field:focus, .card input:focus, .card select:focus, .card textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 4px var(--navy-tint); outline: none; }
.form-row { margin-bottom: 1rem; }
.errorlist { list-style: none; padding: 0; margin: 0.3rem 0; color: var(--rust); font-size: 0.9rem; }
.helptext { color: var(--muted-ink); font-size: 0.85rem; }

/* Answer states */
.answer { font-size: 1.1rem; }
.answer-ok { border-color: var(--green) !important; background: var(--green-tint) !important; }
.answer-bad { border-color: var(--rust) !important; background: var(--rust-tint) !important; }
.task-ok { border-left: 6px solid var(--green); }
.task-bad { border-left: 6px solid var(--rust); }
.task-neutral { border-left: 6px solid var(--line); }
.label-ok { color: var(--green); }
.label-bad { color: var(--rust); }
.solution { background: var(--butter-tint); border-radius: var(--radius-small); padding: 0.9rem 1.1rem; margin-top: 0.8rem; white-space: pre-line; }

/* Progress bar and numbers */
.bar { height: 0.9rem; border-radius: 999px; background: var(--butter-tint); border: 1px solid #EADF9E; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--navy); border-radius: 999px; }
.num { font-size: 1.35rem; color: var(--navy); line-height: 1.1; margin: 0.3rem 0 0.6rem; }

/* Tables */
.table-scroll { overflow-x: auto; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.5rem; }
.table-scroll table { border-collapse: collapse; min-width: 100%; }
.table-scroll th, .table-scroll td { padding: 0.6rem 0.9rem; text-align: left; vertical-align: top; border-bottom: 1px solid #EFE8D8; }
.table-scroll th { color: var(--navy); font-size: 1.1rem; }

@media (max-width: 640px) {
  html { font-size: 17px; }
  .page { padding: 0.8rem; }
  .topbar { padding: 0.8rem 1rem; }
  h1 { font-size: 2rem; }
  .card { padding: 1.1rem; }
  .btn { width: 100%; }
  .topbar .btn, .row .btn-small { width: auto; }
}

/* Builder page (tutor): pick tasks from the whole bank */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.9rem; }
.builder-layout { display: grid; grid-template-columns: 1fr 20rem; gap: 1.2rem; align-items: start; }
.builder-side { position: sticky; top: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-bottom: 1rem; }
.filters > div { flex: 1; min-width: 10rem; }
.pick { cursor: pointer; border: 2px solid transparent; box-shadow: var(--shadow); }
.pick:hover { border-color: var(--navy-tint); }
.pick.on { border-color: var(--navy); background: var(--navy-tint); }
.pick[hidden] { display: none; }
.picked-list { padding-left: 1.4rem; margin: 0.6rem 0; }
.picked-list li { margin-bottom: 0.4rem; }
.picked-list button { font: inherit; font-size: 0.85rem; padding: 0 0.5rem; margin-left: 0.3rem; cursor: pointer; background: var(--white); border: 1px solid var(--line); border-radius: 8px; color: var(--navy); }
@media (max-width: 900px) {
  .builder-layout { grid-template-columns: 1fr; }
  .builder-side { position: static; }
}

/* Mastery levels (progress by line): 1-2 rust, 3 butter, 4 navy, 5-6 green */
.level-1, .level-2 { background: var(--rust-tint); color: var(--rust); }
.level-3 { background: var(--butter); color: var(--navy); }
.level-4 { background: var(--navy-tint); color: var(--navy); }
.level-5, .level-6 { background: var(--green-tint); color: var(--green); }
.bar-level-1 > i, .bar-level-2 > i { background: var(--rust); }
.bar-level-3 > i { background: #CDB43A; }
.bar-level-4 > i { background: var(--navy); }
.bar-level-5 > i, .bar-level-6 > i { background: var(--green); }

/* Checkboxes (lesson marks): big enough to tap, in the site color */
input[type="checkbox"] { width: 1.5rem; height: 1.5rem; accent-color: var(--navy); cursor: pointer; }

/* Rating: the student's own row */
.table-scroll tr.row-me td { background: var(--butter-tint); color: var(--navy); }

/* Shop: reward cards */
.reward-photo { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radius-small); margin-bottom: 0.8rem; background: var(--butter-tint); }
.reward-photo-empty { display: flex; align-items: center; justify-content: center; color: var(--muted-ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Picture of a task (a reaction scheme). Wide schemes scroll sideways inside the card on a phone and open full size on tap. */
.task-image-wrap { overflow-x: auto; max-width: 560px; margin: 0.75rem 0; }
.task-image { display: block; width: 100%; min-width: 480px; max-width: none; height: auto; }
