/* ───────────────────────────── Design tokens ─────────────────────────────
   Warm-paper library system. Generously sized humanist sans, calm palette,
   one cheerful accent. All values use static custom properties so the
   Tweaks panel can override `--primary` and `--paper` at runtime.
   ────────────────────────────────────────────────────────────────────── */

/* Font @import lives in app/assets/tailwind/application.css at the top of
   the file (CSS @import rules must come before all other rules — Tailwind
   warns about misplaced imports). The design bundle's tokens.css keeps the
   @import for the standalone JSX prototype. */

:root{
  /* ── Paper-warm neutrals (default tone) ───────────────────────────── */
  --paper-0: #fbf7ee;       /* page bg, lightest */
  --paper-1: #f6efe0;       /* card surface alt */
  --paper-2: #ece2cd;       /* hairlines, dividers, hover */
  --paper-3: #d9cdb3;       /* stronger dividers */
  --surface: #ffffff;       /* card surface */
  --surface-2: #faf6ee;     /* subtle inset */

  /* ── Ink (text) ───────────────────────────────────────────────────── */
  --ink-1: #1a1815;         /* primary text */
  --ink-2: #4a443b;         /* secondary text */
  --ink-3: #786f60;         /* muted */
  --ink-4: #a89e8a;         /* very muted, captions */

  /* ── Primary action — calm deep blue ──────────────────────────────── */
  --primary:        #1f4e8c;
  --primary-hover:  #173e72;
  --primary-soft:   #e3ecf6;
  --primary-ink:    #0e3060;   /* text on primary-soft */
  --on-primary:     #ffffff;

  /* ── Semantic ────────────────────────────────────────────────────── */
  --overdue:        #b3261e;
  --overdue-soft:   #fbe9e7;
  --overdue-ink:    #7c1812;
  --warning:        #a8650f;
  --warning-soft:   #fbeed9;
  --warning-ink:    #6e4108;
  --success:        #1f6b3a;
  --success-soft:   #e0efe2;
  --success-ink:    #134a26;
  --info-soft:      #e7eef8;

  /* ── Type system — Public Sans throughout ─────────────────────────── */
  --font-sans: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --text-xs:   12px;
  --text-sm:   14px;
  --text-base: 16px;
  --text-md:   18px;
  --text-lg:   20px;
  --text-xl:   24px;
  --text-2xl:  30px;
  --text-3xl:  38px;
  --text-4xl:  48px;
  --text-5xl:  64px;

  /* ── Radii / shadows / spacing ────────────────────────────────────── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-1: 0 1px 0 rgba(26,24,21,.04), 0 1px 2px rgba(26,24,21,.06);
  --shadow-2: 0 1px 0 rgba(26,24,21,.04), 0 4px 12px rgba(26,24,21,.07);
  --shadow-3: 0 2px 0 rgba(26,24,21,.04), 0 12px 32px rgba(26,24,21,.10);

  --hit: 44px;              /* minimum hit target */
}

/* ── Cool / warmer paper variants (toggled via [data-tone]) ─────────── */
[data-tone="cool"]{
  --paper-0:#f7f7f5; --paper-1:#eeede9; --paper-2:#e2e1dc; --paper-3:#c9c8c0;
  --surface-2:#f3f3f0;
}
[data-tone="warmer"]{
  --paper-0:#f8eed8; --paper-1:#f1e3c2; --paper-2:#e3d2ab; --paper-3:#cdb98c;
  --surface-2:#f5ebd2;
}

/* ── Density (compact reduces paddings) ─────────────────────────────── */
[data-density="compact"]{ --hit: 38px; }

/* ── Resets / base ──────────────────────────────────────────────────── */
*,*::before,*::after{ box-sizing:border-box; }
body{
  margin:0;
  font-family: var(--font-sans);
  color: var(--ink-1);
  font-size: var(--text-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01","cv11";
}

/* ── Screen frame — every artboard uses this as its root ─────────────── */
.screen{
  width:1366px; height:768px;
  background: var(--paper-0);
  color: var(--ink-1);
  display:flex; overflow:hidden;
  font-family: var(--font-sans);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  gap:8px; padding:0 18px; height:44px;
  font-family:inherit; font-size:15px; font-weight:600;
  border-radius: var(--r-md); border:1px solid transparent;
  cursor:pointer; user-select:none; white-space:nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-sm{ height:36px; padding:0 12px; font-size:14px; }
.btn-lg{ height:52px; padding:0 22px; font-size:17px; }

.btn-primary{ background: var(--primary); color: var(--on-primary); }
.btn-primary:hover{ background: var(--primary-hover); }

.btn-secondary{ background: var(--surface); color: var(--ink-1); border-color: var(--paper-3); }
.btn-secondary:hover{ background: var(--paper-1); }

.btn-ghost{ background: transparent; color: var(--ink-2); }
.btn-ghost:hover{ background: var(--paper-2); color: var(--ink-1); }

.btn-danger{ background: var(--surface); color: var(--overdue-ink); border-color: var(--overdue-soft); }
.btn-danger:hover{ background: var(--overdue-soft); }

.btn:focus-visible{ outline: 3px solid var(--primary); outline-offset: 2px; }

/* ── Inputs ─────────────────────────────────────────────────────────── */
.field{ display:flex; flex-direction:column; gap:6px; }
.field-label{ font-size:14px; font-weight:600; color:var(--ink-2); }
.field-hint{ font-size:13px; color:var(--ink-3); }
.input{
  height:44px; padding:0 14px;
  background: var(--surface); color: var(--ink-1);
  border:1px solid var(--paper-3); border-radius: var(--r-md);
  font-family:inherit; font-size:15px; width:100%;
}
.input::placeholder{ color: var(--ink-4); }
.input:focus{ outline:none; border-color: var(--primary); box-shadow:0 0 0 3px var(--primary-soft); }

/* Scan-input — distinctive bookish framed variant */
.scan{
  position:relative;
  background: var(--surface);
  border:2px dashed var(--paper-3);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  display:flex; align-items:center; gap:18px;
}
.scan-icon{
  width:56px; height:56px; flex:0 0 56px;
  border-radius: var(--r-md);
  background: var(--primary-soft);
  color: var(--primary);
  display:grid; place-items:center;
}
.scan-input{
  flex:1 1 auto;
  background:transparent; border:none; outline:none;
  font-family: var(--font-mono);
  font-size: 22px; font-weight:500;
  color: var(--ink-1); letter-spacing: .02em;
  width:100%;
}
.scan-input::placeholder{ color: var(--ink-4); }
/* A11y — `outline: none` above strips the default focus ring; restore
   it for keyboard users via a soft glow that fits inside the scan
   container rather than straddling the caption above. Box-shadow not
   outline so it composes with the parent's primary border without
   bleeding into adjacent text. */
.scan-input:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
  border-radius: 4px;
}
.scan-status{
  display:inline-flex; align-items:center; gap:6px;
  font-size:13px; color: var(--ink-3);
  padding:6px 10px; background: var(--paper-1);
  border-radius: 999px;
}
.scan-pulse{
  width:8px; height:8px; border-radius:50%;
  background: var(--success);
  box-shadow: 0 0 0 0 var(--success);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(31,107,58,.5); }
  100%{ box-shadow:0 0 0 12px rgba(31,107,58,0); }
}

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge{
  display:inline-flex; align-items:center; gap:6px;
  padding:3px 10px; border-radius:999px;
  font-size:12px; font-weight:600;
  font-feature-settings:"tnum";
}
.badge-overdue{ background: var(--overdue-soft); color: var(--overdue-ink); }
.badge-warning{ background: var(--warning-soft); color: var(--warning-ink); }
.badge-success{ background: var(--success-soft); color: var(--success-ink); }
.badge-info{    background: var(--info-soft);    color: var(--primary-ink); }
.badge-neutral{ background: var(--paper-2);      color: var(--ink-2); }

.badge-dot{ width:6px; height:6px; border-radius:50%; background: currentColor; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card{
  background: var(--surface);
  border:1px solid var(--paper-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-header{
  padding: 18px 22px; border-bottom:1px solid var(--paper-2);
  display:flex; align-items:center; justify-content:space-between;
}
.card-title{ font-size: 17px; font-weight:600; margin:0; }
.card-body{ padding: 18px 22px; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.tbl{ width:100%; border-collapse:collapse; font-size:14px; }
.tbl th{
  text-align:left; padding: 10px 14px;
  font-size:12px; font-weight:600; letter-spacing:.04em;
  text-transform:uppercase; color: var(--ink-3);
  border-bottom:1px solid var(--paper-2);
  background: var(--surface-2);
}
.tbl td{
  padding: 12px 14px; border-bottom:1px solid var(--paper-2);
  color: var(--ink-1); vertical-align: middle;
}
.tbl tr:last-child td{ border-bottom:none; }
.tbl tr:hover td{ background: var(--surface-2); }

/* ── Sidebar (app shell pieces — used on most screens) ─────────────── */
.sidebar{
  width:240px; flex:0 0 240px;
  background: var(--paper-1);
  border-right:1px solid var(--paper-2);
  display:flex; flex-direction:column;
  padding: 22px 14px;
  gap: 6px;
}
.sidebar-brand{
  display:flex; align-items:center; gap:10px;
  padding: 4px 8px 18px;
  border-bottom:1px solid var(--paper-2);
  margin-bottom: 10px;
}
.brand-mark{
  width:34px; height:34px; border-radius:8px;
  background: var(--primary); color: var(--on-primary);
  display:grid; place-items:center;
  font-weight:800; font-size:18px;
  letter-spacing:-.02em;
}
.brand-name{ font-weight:700; font-size:15px; line-height:1.1; }
.brand-school{ font-size:12px; color: var(--ink-3); }

.nav-item{
  display:flex; align-items:center; gap:12px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--ink-2); font-size:14px; font-weight:500;
  text-decoration:none; cursor:pointer;
}
.nav-item:hover{ background: var(--paper-2); color: var(--ink-1); }
.nav-item:focus-visible{ outline: 3px solid var(--primary); outline-offset: -3px; }
.nav-item.active{ background: var(--surface); color: var(--primary); font-weight:600; box-shadow: var(--shadow-1); }
.nav-item .nav-icon{ color: var(--ink-3); }
.nav-item.active .nav-icon{ color: var(--primary); }
.nav-count{
  margin-left:auto; font-size:12px; font-weight:600;
  background: var(--overdue); color:#fff;
  padding:1px 7px; border-radius:999px;
  font-variant-numeric:tabular-nums;
}

/* ── Main column ────────────────────────────────────────────────────── */
.main{ flex:1 1 auto; display:flex; flex-direction:column; overflow:hidden; }
.topbar{
  height:64px; flex:0 0 64px;
  padding: 0 28px;
  display:flex; align-items:center; justify-content:space-between;
  background: var(--paper-0);
  border-bottom:1px solid var(--paper-2);
}
.topbar h1{ font-size: 20px; font-weight:700; margin:0; letter-spacing:-.01em; }
.topbar-meta{ font-size:13px; color: var(--ink-3); }
.content{ flex:1 1 auto; padding: 22px 28px; overflow:auto; }

/* ── Stat tiles ─────────────────────────────────────────────────────── */
.stat{
  background: var(--surface);
  border:1px solid var(--paper-2);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display:flex; flex-direction:column; gap:6px;
  min-width:0;
}
.stat-label{ font-size:13px; color: var(--ink-3); font-weight:500; }
.stat-value{ font-size: 36px; font-weight:700; letter-spacing:-.02em; line-height:1; font-variant-numeric:tabular-nums; }
.stat-sub{ font-size:13px; color: var(--ink-3); margin-top:2px; }

/* ── Class card (lend flow) ─────────────────────────────────────────── */
.class-card{
  position:relative; aspect-ratio: 1.4 / 1;
  background: var(--surface);
  border:1px solid var(--paper-2);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display:flex; flex-direction:column; justify-content:space-between;
  cursor:pointer; transition: border-color .12s, transform .08s;
  text-align:left;
}
.class-card:hover{ border-color: var(--primary); }
.class-card.selected{ border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.class-card-year{ font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color: var(--ink-3); }
.class-card-name{ font-size: 22px; font-weight:700; letter-spacing:-.01em; }
.class-card-count{ font-size:13px; color: var(--ink-3); }
.class-card-swatch{
  position:absolute; top:14px; right:14px;
  width:32px; height:32px; border-radius: 8px;
  display:grid; place-items:center;
  font-size:14px; font-weight:700; color: var(--ink-1);
}

/* ── Child row ─────────────────────────────────────────────────────── */
.child-row{
  display:flex; align-items:center; gap:14px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  cursor:pointer;
}
.child-row:hover{ background: var(--surface-2); }
.child-row.selected{ background: var(--primary-soft); }
.avatar{
  width:40px; height:40px; flex:0 0 40px;
  border-radius:50%; display:grid; place-items:center;
  font-weight:700; font-size:14px; color: var(--ink-1);
  letter-spacing: -.01em;
}
.child-row-name{ font-size:15px; font-weight:500; }
.child-row-meta{ font-size:13px; color: var(--ink-3); margin-left:auto; }

/* ── Book cover (tinted tile) ───────────────────────────────────────── */
.cover{
  flex:0 0 auto;
  border-radius: 4px 8px 8px 4px;
  border-left: 3px solid rgba(0,0,0,.18);
  background: var(--surface);
  padding: 8px 9px 10px 11px;
  display:flex; flex-direction:column; justify-content:space-between;
  color: var(--ink-1);
  overflow:hidden;
  position:relative;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), inset 1px 0 0 rgba(255,255,255,.5);
}
.cover-title{ font-size:11px; font-weight:700; line-height:1.15; text-wrap:balance; letter-spacing:-.01em; }
.cover-author{ font-size:9px; opacity:.75; font-weight:500; }

/* ── Breadcrumb step indicator (lend flow) ──────────────────────────── */
.steps{ display:flex; align-items:center; gap:10px; }
.step{
  display:flex; align-items:center; gap:8px;
  padding: 6px 12px 6px 8px; border-radius:999px;
  font-size:13px; font-weight:500; color: var(--ink-3);
}
.step.active{ background: var(--surface); color: var(--ink-1); box-shadow: var(--shadow-1); }
.step.done{ color: var(--ink-2); }
.step-num{
  width:22px; height:22px; border-radius:50%;
  display:grid; place-items:center;
  font-size:12px; font-weight:700;
  background: var(--paper-2); color: var(--ink-2);
}
.step.active .step-num{ background: var(--primary); color: var(--on-primary); }
.step.done   .step-num{ background: var(--success); color: #fff; }
.step-arrow{ color: var(--ink-4); }

/* ── Misc ───────────────────────────────────────────────────────────── */
.divider{ height:1px; background: var(--paper-2); border:none; margin:0; }
.kbd{
  display:inline-block;
  font-family: var(--font-mono); font-size:11px;
  padding: 2px 6px;
  background: var(--surface); border:1px solid var(--paper-3); border-bottom-width:2px;
  border-radius: 5px; color: var(--ink-2);
}
.section-eyebrow{
  font-size:12px; font-weight:600; letter-spacing:.08em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ── Print stylesheet — for end-of-term certificates ───────────────── */
@media print{
  @page{ size: A4 landscape; margin: 12mm; }
  body{ background:#fff; }
}
