/* ============================================================
   worksheet.css — the worksheet viewer + the printable sheet
   ============================================================ */

/* ---------- mini top bar ---------- */
.mini-top { background: #fff; border-bottom: 1px solid var(--line); }
.mini-top .wrap { display: flex; align-items: center; gap: 18px; height: 60px; }
.mini-top .back { color: var(--muted); font-weight: 700; }
.mini-top .back:hover { color: var(--brand-dark); text-decoration: none; }

.ws-stage { padding: 24px 0 70px; }
.ws-head { margin-bottom: 18px; }
.ws-head h1 { margin: 0 0 4px; font-size: 1.9rem; letter-spacing: -0.3px; }
.ws-head .ws-sub { margin: 0; color: var(--muted); font-weight: 600; }

/* ---------- control panel ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 22px 20px; margin-bottom: 26px;
}
.panel-title { margin: 0 0 4px; font-size: 1.25rem; }
.panel-help { margin: 0 0 16px; color: var(--muted); font-size: .95rem; }
.panel-help b { color: var(--ink); }

.ver-list { display: flex; flex-direction: column; gap: 10px; }
.ver {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border: 2px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.ver:hover { border-color: #c9d6f5; }
.ver.active { border-color: var(--brand); background: #f3f7ff; }
.ver-info { display: flex; align-items: center; gap: 13px; }
.ver-emoji { font-size: 26px; line-height: 1; }
.ver-name { font-weight: 800; font-size: 1.05rem; }
.ver-desc { color: var(--muted); font-size: .88rem; }
.ver-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.vbtn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 700; padding: 11px 16px;
  border-radius: 10px; cursor: pointer; font-size: .95rem; white-space: nowrap;
}
.vbtn:hover { border-color: var(--brand); color: var(--brand-dark); }
.vbtn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.vbtn.primary:hover { background: var(--brand-dark); color: #fff; }
.vbtn.wide { width: 100%; justify-content: center; margin-top: 14px; padding: 13px; }
.vbtn.refresh { padding: 11px 18px; }

.panel-opts { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.opt { display: flex; align-items: center; gap: 12px; }
.opt-label { font-weight: 700; }
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: #f3f6fc; width: 42px; height: 42px; font-size: 22px; cursor: pointer; color: var(--brand-dark); font-weight: 700; }
.stepper button:hover { background: #e6edfb; }
.stepper b { min-width: 46px; text-align: center; font-size: 1.1rem; }

.preview-label { color: var(--muted); font-weight: 700; margin-bottom: 12px; text-align: center; }
.preview-label b { color: var(--ink); }

/* ---------- the printable sheet ---------- */
.sheet {
  background: #fff; width: 8.5in; min-height: 11in; margin: 0 auto 26px;
  padding: 0.6in 0.7in; box-shadow: 0 8px 40px rgba(31,51,92,.15);
  color: #1a1a1a; position: relative;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
  font-size: 13px;
  display: flex; flex-direction: column;   /* lets the footer sit at the bottom */
}
#mainSheet .sheet:last-child { margin-bottom: 0; }
.sheet .sheet-head { border-bottom: 2.5px solid #1a1a1a; padding-bottom: 10px; margin-bottom: 8px; }
.sheet .brand-line { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #555; }
.sheet .brand-line .brand { font-weight: 800; letter-spacing: .02em; }
.sheet h1.ws-h { font-size: 21px; margin: 6px 0 2px; }
.sheet .instructions { font-size: 12.5px; color: #333; margin: 2px 0 0; }

.namebar { display: flex; gap: 30px; margin-top: 18px; font-size: 13px; color: #333; align-items: flex-end; }
.namebar .field { flex: 1; display: flex; align-items: flex-end; gap: 8px; }
.namebar .field .ln { flex: 1; border-bottom: 1.5px solid #555; height: 30px; }
.namebar .field.small { flex: 0 0 120px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; padding: 3px 10px; border-radius: 6px; margin-top: 4px;
}
.badge.teacher { background: #fff4e6; color: #b85c00; border: 1px solid #ffd8a8; }
.badge.answers { background: #ffe3e3; color: #c92a2a; border: 1px solid #ffc9c9; }

/* ---------- problem layouts ----------
   Comfortable, consistent spacing — roomy enough to write in, not huge. */
.problems.grid { display: grid; gap: 28px 26px; margin-top: 22px; }
.problems.vertical { display: grid; gap: 34px 18px; margin-top: 24px; }
.problems.list { margin-top: 20px; }

.prob { display: flex; gap: 8px; align-items: flex-start; font-size: 16px; break-inside: avoid; }
.prob .pnum { font-weight: 700; color: #444; min-width: 22px; }
.prob .pbody { flex: 1; }
.prob .expr { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; line-height: 2; }

/* list layout (word problems / ordering) */
.problems.list .prob { margin-bottom: 18px; font-size: 15px; line-height: 1.6; }
.answerline { margin-top: 12px; font-size: 14px; }
.answerline .line { display: inline-block; width: 150px; border-bottom: 1px solid #888; height: 14px; vertical-align: bottom; }
.work { height: 36px; border: 1px dashed #cfd6e4; border-radius: 6px; margin-top: 6px; }

/* blanks & answers */
.blank { display: inline-block; min-width: 46px; border-bottom: 1.6px solid #333; height: 18px; margin: 0 3px; vertical-align: bottom; }
.blank.box { border: 1.6px solid #333; border-radius: 4px; width: 22px; height: 22px; }
.ans { color: #c92a2a; font-weight: 800; }
.ans .frac .fn, .ans .frac .fd { border-color: #c92a2a; }

/* stacked fractions */
.frac { display: inline-flex; flex-direction: column; text-align: center; vertical-align: middle; line-height: 1; margin: 0 1px; }
.frac .fn { padding: 0 3px 1px; border-bottom: 1.5px solid #333; }
.frac .fd { padding: 1px 3px 0; }

/* vertical / column arithmetic */
.problems.vertical .pbody { display: flex; justify-content: center; }
.vstack { font-variant-numeric: tabular-nums; font-size: 18px; text-align: right; width: 104px; }
.vstack .vrow { letter-spacing: 2px; }
.vstack .vop { display: flex; justify-content: space-between; border-bottom: 2px solid #333; padding-bottom: 2px; }
.vstack .vop .opsym { padding-right: 8px; }
.vstack .vans { padding-top: 6px; min-height: 30px; letter-spacing: 2px; }

/* counting dots */
.dots { display: flex; flex-wrap: wrap; gap: 5px; max-width: 150px; margin-bottom: 4px; }
.dot { width: 15px; height: 15px; border-radius: 50%; background: #5b8def; border: 1px solid #33415c; }

/* svg helpers */
.clock, .shape, .fbar, .tenframe, .array, .numline, .tally { display: block; margin-bottom: 4px; }
.glyph { font-size: 19px; letter-spacing: 1px; }

/* multiplication table */
table.multtable { border-collapse: collapse; margin: 16px auto 0; }
table.multtable th, table.multtable td { border: 1px solid #999; width: 30px; height: 30px; text-align: center; font-size: 13px; }
table.multtable th { background: #eef2fb; font-weight: 800; }
table.multtable td.cell { background: #fff; }
table.multtable td.cell .ans { font-size: 12px; }
table.multtable thead th.corner { background: #3b6ef0; color: #fff; }

/* number chart (skip counting grid) */
table.numchart { border-collapse: collapse; margin: 18px auto 0; }
table.numchart td { border: 1.5px solid #33415c; width: 64px; height: 48px; text-align: center;
  font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
table.numchart td.bl { background: #f3f6fc; }
table.numchart td.bl .ans { font-weight: 800; }

/* footer pinned to the bottom of the page (margin-top:auto pushes it down) */
.sheet-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid #ccc;
  font-size: 10px; color: #999; display: flex; justify-content: space-between; }

/* ---------- print ---------- */
@media print {
  @page { size: letter portrait; margin: 0.5in; }
  body { background: #fff; }
  .site-header, .mini-top, .ws-head, .panel, .preview-label, .site-footer, .no-print { display: none !important; }
  .ws-stage { padding: 0; }
  .preview-wrap { margin: 0; }
  /* each sheet fills the printable page so the footer lands at the bottom */
  .sheet {
    width: auto; box-shadow: none; margin: 0; padding: 0;
    min-height: 9.5in;
  }
  /* the teacher copy = worksheet + answer key: start the answer key on a new page */
  #mainSheet .sheet + .sheet { page-break-before: always; }
}

@media screen and (max-width: 900px) {
  .sheet { width: 100%; min-height: auto; padding: 24px 18px; }
}
/* keep worksheets on screen on phones/narrow panels (print keeps full columns) */
@media screen and (max-width: 760px) {
  .problems.grid, .problems.vertical { grid-template-columns: repeat(2, 1fr) !important; }
}
@media screen and (max-width: 460px) {
  .problems.grid, .problems.vertical { grid-template-columns: 1fr !important; }
  .sheet { font-size: 12px; overflow-x: auto; }
}
