/* Language Ledger — adapted from the original prototype's palette and type. */

:root {
  --bg: #EEF1E7;
  --bg-alt: #E4E9DA;
  --paper: #F8F9F3;
  --ink: #202B22;
  --ink-soft: #55645A;
  --line: #C7D0BE;
  --accent: #2F5D57;
  --accent-dark: #234742;
  --accent-soft: #DCE7DF;
  --bronze: #A0703F;
  --silver: #8E9CA3;
  --gold: #BE922B;
  --platinum: #5C7680;
  --danger: #A2453A;
  --danger-soft: #F1DEDA;
  --ok: #3D6B4A;
  --ok-soft: #DDEBDF;
  --warn: #8A6D1F;
  --warn-soft: #F6EDD3;
  --radius: 10px;

  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; color: var(--ink); }
.mono { font-family: var(--mono); }
a { color: var(--accent); }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }

/* ---------- Masthead ---------- */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 22px;
  flex-wrap: wrap; gap: 10px;
}
.masthead .title-block h1 { font-size: 28px; letter-spacing: -0.01em; }
.masthead .title-block .eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 4px; display: block;
}
.masthead .who { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); text-align: right; }
.masthead .who form { display: inline; }
.masthead .who button {
  background: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; margin-left: 8px;
  font-size: 12px; color: var(--ink-soft);
}
.masthead .who button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Nav ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; }
.tab-btn {
  background: none; border: 1px solid var(--line); border-radius: 20px; padding: 7px 16px;
  font-size: 13px; color: var(--ink-soft); font-weight: 500; text-decoration: none; display: inline-block;
}
.tab-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* ---------- Panels ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.panel-head h2 { font-size: 19px; }
.subtle { color: var(--ink-soft); font-size: 13px; }
.section-gap { margin-top: 26px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 7px 13px;
  font-size: 13px; color: var(--ink); text-decoration: none; display: inline-block; line-height: 1.4;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-danger { background: none; color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

input[type=text], input[type=password], select {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fff; color: var(--ink);
}
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
label.field input, label.field select { width: 100%; }

.inline-form { display: inline; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form input[type=text] { flex: 1; min-width: 140px; }

/* ---------- Banners ---------- */
.banner { border-radius: 8px; padding: 11px 15px; margin-bottom: 18px; font-size: 13.5px; border: 1px solid; }
.banner-warn { background: var(--warn-soft); border-color: #E0CE9A; color: var(--warn); }
.banner-error { background: var(--danger-soft); border-color: #E3BDB6; color: var(--danger); }
.banner-ok { background: var(--ok-soft); border-color: #B9D3BE; color: var(--ok); }
.banner a { color: inherit; font-weight: 600; }

/* ---------- Catalogue ---------- */
/* 320px keeps sentence-length items (Paragraph Complexity, Syntax) legible in
   the edit field rather than clipping them after three words. */
.strand-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.strand-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.strand-card.is-archived { opacity: .6; }
.strand-card > .sc-head {
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-alt);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.strand-card > .sc-head h3 { font-size: 15px; }
.sc-head .sc-actions { display: flex; gap: 2px; align-items: center; }

.tier-block { padding: 10px 14px; border-bottom: 1px dashed var(--line); }
.tier-block:last-of-type { border-bottom: none; }
.tier-label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px; margin-bottom: 7px; font-weight: 600;
}
.tier-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-bronze { background: var(--bronze); }
.dot-silver { background: var(--silver); }
.dot-gold { background: var(--gold); }
.dot-platinum { background: var(--platinum); }

.item-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13.5px; }
.item-row.is-archived { opacity: .55; text-decoration: line-through; }
.item-row .item-label { flex: 1; word-break: break-word; }
.item-row .item-actions { display: flex; gap: 2px; align-items: center; }
.item-row select { font-size: 11px; padding: 3px 2px; max-width: 74px; }

.icon-btn { background: none; border: none; color: var(--ink-soft); font-size: 14px; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.empty-note { font-size: 12px; color: var(--ink-soft); font-style: italic; padding: 4px 0; }

.add-item-form { display: flex; gap: 6px; margin-top: 8px; }
.add-item-form input[type=text] { flex: 1; min-width: 0; font-size: 13px; padding: 5px 8px; }

/* ---------- Roster ---------- */
.class-block { margin-bottom: 24px; }
.class-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding-bottom: 7px; border-bottom: 1px solid var(--line); margin-bottom: 10px; flex-wrap: wrap;
}
.class-head h3 { font-size: 16px; }
.class-head .count { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); }

.roster-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; margin-bottom: 6px;
  flex-wrap: wrap;
}
.roster-row.is-archived { opacity: .55; }
.roster-row .student-name { flex: 1; min-width: 120px; }
.roster-row .row-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

.code-chip {
  font-family: var(--mono); font-size: 13px; letter-spacing: .18em; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-dark); border-radius: 5px; padding: 3px 9px;
}

/* ---------- Tracking ---------- */
.track-selectors { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 20px; flex-wrap: wrap; }
.track-selectors label.field { margin-bottom: 0; min-width: 190px; }

.track-category { margin-bottom: 28px; }
.track-category > h3 { font-size: 17px; margin-bottom: 4px; }
.track-category .cat-status { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); margin-bottom: 12px; }

.track-tier {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 12px 14px; margin-bottom: 9px;
}
.track-tier.is-passed { background: var(--ok-soft); border-color: #B9D3BE; }
.track-tier.is-current { border-color: var(--accent); border-width: 2px; padding: 11px 13px; }
.track-tier.is-locked { opacity: .5; }

.tt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.tt-head .tier-label { margin-bottom: 0; }
.tt-count { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.tt-head .spacer { flex: 1; }
.tt-passed { font-family: var(--mono); font-size: 11.5px; color: var(--ok); font-weight: 600; }

/* The fill is scaled rather than resized: animating transform stays on the
   compositor, where animating width would force a layout pass on every frame.
   --fill is a unitless 0-100 set inline by the template. The rounding lives on
   the container so scaleX cannot distort it. */
.bar { height: 7px; border-radius: 4px; background: var(--bg-alt); overflow: hidden; margin-bottom: 10px; }
.bar > span {
  display: block; height: 100%; width: 100%; background: var(--accent);
  transform-origin: left center; transform: scaleX(calc(var(--fill, 0) / 100));
  transition: transform .2s ease;
}
.track-tier.is-passed .bar > span { background: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  .bar > span { transition: none; }
}

.check-row { display: flex; align-items: center; gap: 10px; padding: 4px 2px; font-size: 13.5px; }
.check-row label { flex: 1; cursor: pointer; }
.checkbox { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; flex: none; }

.promote-actions { margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.promote-hint { font-size: 12px; color: var(--ink-soft); font-style: italic; }

/* ---------- Stamps (student passport) ---------- */
.strand-passport { margin-bottom: 30px; }
.strand-passport h3 { font-size: 17px; margin-bottom: 10px; }
.badge-row { display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }

.stamp {
  width: 74px; height: 74px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2.5px solid var(--line); transform: rotate(-4deg);
  font-family: var(--mono); text-align: center; flex: none;
}
.stamp .t-name { font-size: 8.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.stamp .t-frac { font-size: 10px; margin-top: 2px; }
.stamp .t-date { font-size: 7.5px; margin-top: 1px; opacity: .8; }
.stamp.locked { border-color: var(--line); color: var(--ink-soft); opacity: .45; }
.stamp.partial { border-style: dashed; }
.stamp.bronze.complete, .stamp.bronze.partial { border-color: var(--bronze); color: var(--bronze); }
.stamp.silver.complete, .stamp.silver.partial { border-color: var(--silver); color: var(--silver); }
.stamp.gold.complete, .stamp.gold.partial { border-color: var(--gold); color: var(--gold); }
.stamp.platinum.complete, .stamp.platinum.partial { border-color: var(--platinum); color: var(--platinum); }
.stamp.complete { background: color-mix(in srgb, currentColor 12%, transparent); box-shadow: 0 0 0 3px rgba(0,0,0,.04) inset; }

.unlocked-list { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 15px; }
.unlocked-tier-h {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  margin: 14px 0 5px; color: var(--ink-soft);
}
.unlocked-tier-h:first-child { margin-top: 0; }
.unlocked-item { font-size: 13.5px; padding: 2px 0; }
.unlocked-item.goal { color: var(--ink-soft); }
.goal-note { font-size: 12.5px; color: var(--ink-soft); font-style: italic; margin: 4px 0 0; }

/* ---------- Student sign-in ---------- */
.code-entry { max-width: 340px; margin: 60px auto; text-align: center; }
.code-entry h2 { font-size: 22px; margin-bottom: 6px; }
.code-entry p { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 22px; }
.code-entry input {
  width: 100%; text-align: center; font-family: var(--mono);
  letter-spacing: .35em; font-size: 22px; text-transform: uppercase; padding: 12px 10px; margin-bottom: 14px;
}
.code-entry button { width: 100%; padding: 11px 0; font-size: 14px; }

.student-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 24px; flex-wrap: wrap; gap: 10px; }
.student-header h2 { font-size: 24px; }

/* ---------- Sign in ---------- */
.login-panel { max-width: 360px; margin: 60px auto; }

/* ---------- Codes sheet ---------- */
.code-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.code-card {
  border: 1px dashed var(--ink-soft); border-radius: 8px; padding: 14px; background: #fff; text-align: center;
}
.code-card .cc-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.code-card .cc-class { font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .1em; }
.code-card .cc-code { font-family: var(--mono); font-size: 24px; letter-spacing: .22em; font-weight: 600; margin: 9px 0 6px; color: var(--accent-dark); }
.code-card .cc-url { font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft); word-break: break-all; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .app { max-width: none; padding: 0; }
  .code-sheet { grid-template-columns: repeat(3, 1fr); }
  .code-card { break-inside: avoid; }
}

/* ---------- Misc ---------- */
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { visibility: visible; }
.htmx-indicator { visibility: hidden; }
.stat-row { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.stat b { display: block; font-size: 21px; color: var(--ink); font-weight: 600; }
.export-list { display: flex; flex-direction: column; gap: 14px; }
.export-item { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; background: #fff; }
.export-item h3 { font-size: 15px; margin-bottom: 3px; }
.export-item p { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }

@media (max-width: 560px) {
  .masthead { flex-direction: column; align-items: flex-start; }
  .masthead .who { text-align: left; }
  .track-selectors label.field { min-width: 100%; }
}

/* ---------- Inline editing ----------
   Names are editable in place: the input is borderless until focused, so a dense
   list of items still reads as text rather than as a wall of form fields. */
.inline-edit {
  border: 1px solid transparent; background: transparent; padding: 3px 5px;
  border-radius: 5px; width: 100%; font-size: inherit; color: inherit; font-family: inherit;
}
.inline-edit:hover { border-color: var(--line); background: #fff; }
.inline-edit:focus { border-color: var(--accent); background: #fff; }
.sc-head .inline-edit { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.inline-edit-lg { font-family: var(--serif); font-weight: 600; font-size: 16px; }
.item-label .inline-edit { font-size: 13.5px; }
