/* ==========================================================================
   That's Write! — "Exercise book" theme
   --------------------------------------------------------------------------
   The one shared stylesheet for the whole site. Every page links this AFTER
   its own inline <style>, so anything defined here wins over the page's own
   copy of the same rule. The idea: paper, ruled lines, masking tape, red-pen
   marks — a real KS2 workbook, not a dashboard.

   Fonts: Caveat (brand), Patrick Hand (headings, labels, buttons, the
   pupil's own writing), Andika (body — designed for beginning readers).

   Conversion status — pages that have been moved over to this theme have
   had their duplicated inline CSS pruned; pages not yet converted still
   carry the old cream/white/orange styles and don't link this file yet.
   ========================================================================== */

:root{
  --paper:#F3ECDC;            /* the desk / page background */
  --paper-raised:#FFFDF7;     /* a sheet of paper / a note */
  --paper-ruled:#FFFDF7;
  --rule:#CFE0F2;             /* faint blue exercise-book lines */
  --margin:#F0A4A4;           /* the red margin line */
  --ink:#3B3A36;              /* pencil graphite */
  --ink-soft:#6E6858;
  --ink-faint:#8A8270;
  --line:#E6DECB;             /* paper edges */
  --pen-blue:#2F5FB3;         /* the pupil's pen */
  --pen-red:#D2452D;          /* the teacher's pen */
  --highlighter:#FFE45C;
  --tape:rgba(255,228,92,0.75);
  --dot:#D9CFB8;              /* dotted-grid background */
  --fantastics:#E8985E;  --fantastics-soft:#FCEADA;
  --grammaristics:#5FA779; --grammaristics-soft:#E3F1E6;
  --boomtastics:#8B7CC9; --boomtastics-soft:#EBE6F8;
  --accent:var(--pen-red);
  --focus:#3D6FE0;
  --error:#C24545;
  --success:#5FA779; --success-soft:#E3F1E6;
  --partial:#D9A441; --partial-soft:#FCF1DB;
  --shadow: 2px 3px 0 rgba(59,58,54,0.10);
  --shadow-lift: 3px 5px 0 rgba(59,58,54,0.14);
  --font-body:'Andika', 'Atkinson Hyperlegible', 'Trebuchet MS', ui-sans-serif, sans-serif;
  --font-hand:'Patrick Hand', 'Bradley Hand', 'Comic Sans MS', cursive;
  --font-brand:'Caveat', 'Bradley Hand', cursive;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#1F1E1A; --paper-raised:#2A2924; --paper-ruled:#2A2924;
    --rule:#3B4658; --margin:#7A3A3A;
    --ink:#EDE7D8; --ink-soft:#B9B2A2; --ink-faint:#8F887A;
    --line:#3A3830; --pen-blue:#8FB0F0; --pen-red:#F07A6A;
    --highlighter:rgba(255,228,92,0.35); --tape:rgba(255,228,92,0.45); --dot:#2C2B26;
    --fantastics:#F0A96C; --fantastics-soft:#3A2E24;
    --grammaristics:#7BC298; --grammaristics-soft:#233229;
    --boomtastics:#A797E0; --boomtastics-soft:#2B2740;
    --focus:#7FA3F5; --error:#E88686;
    --success:#7BC298; --success-soft:#233229; --partial:#E0B85E; --partial-soft:#3A2F1B;
    --shadow: 2px 3px 0 rgba(0,0,0,0.35); --shadow-lift: 3px 5px 0 rgba(0,0,0,0.45);
  }
}
:root[data-theme="dark"]{
  --paper:#1F1E1A; --paper-raised:#2A2924; --paper-ruled:#2A2924;
  --rule:#3B4658; --margin:#7A3A3A;
  --ink:#EDE7D8; --ink-soft:#B9B2A2; --ink-faint:#8F887A;
  --line:#3A3830; --pen-blue:#8FB0F0; --pen-red:#F07A6A;
  --highlighter:rgba(255,228,92,0.35); --tape:rgba(255,228,92,0.45); --dot:#2C2B26;
  --fantastics:#F0A96C; --fantastics-soft:#3A2E24;
  --grammaristics:#7BC298; --grammaristics-soft:#233229;
  --boomtastics:#A797E0; --boomtastics-soft:#2B2740;
  --focus:#7FA3F5; --error:#E88686;
  --success:#7BC298; --success-soft:#233229; --partial:#E0B85E; --partial-soft:#3A2F1B;
  --shadow: 2px 3px 0 rgba(0,0,0,0.35); --shadow-lift: 3px 5px 0 rgba(0,0,0,0.45);
}

/* ---- Base ------------------------------------------------------------- */
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background-color:var(--paper);
  background-image:radial-gradient(var(--dot) 0.8px, transparent 0.8px);
  background-size:18px 18px;
  color:var(--ink);
  font-family:var(--font-body);
  -webkit-font-smoothing:antialiased;
  line-height:1.5;
}
h1,h2,h3,.display{
  font-family:var(--font-hand);
  font-weight:400;
  margin:0;
  letter-spacing:0.01em;
}
button{font-family:inherit;}
a{color:var(--pen-blue);}

/* The stripe at the very top of every page: kept as the three family
   colours, but drawn as three short strips of washi tape rather than a
   continuous gradient bar. */
.rainbow-rule{
  height:7px; width:100%; border-radius:0;
  background:
    linear-gradient(90deg, var(--fantastics) 0 32%, transparent 32% 34%,
      var(--grammaristics) 34% 66%, transparent 66% 68%, var(--boomtastics) 68% 100%);
  opacity:0.85;
}

/* ---- Brand ------------------------------------------------------------ */
.brand, .brand h1, header .brand, h1.brand{
  font-family:var(--font-brand);
  font-weight:600;
  color:var(--pen-blue);
  letter-spacing:0;
}
.brand h1{font-size:44px; line-height:1;}
header .brand{font-size:30px; line-height:1;}
.brand-tagline{
  font-family:var(--font-hand);
  font-size:17px; font-weight:400; color:var(--ink-soft); margin-top:2px;
}
.teacher-link, button.link{
  font-family:var(--font-hand); font-size:17px; font-weight:400;
  color:var(--ink); text-decoration:none;
  border-bottom:2px solid var(--ink); padding-bottom:1px;
  background:none; border-top:0; border-left:0; border-right:0; cursor:pointer;
}
.teacher-link:hover, button.link:hover{color:var(--pen-blue); border-color:var(--pen-blue);}

/* A red pen line under a page header, the way a title gets underlined. */
.red-rule{height:2px; background:var(--pen-red); opacity:0.8; margin:14px 0 22px;}

/* ---- Headings with a highlighter swipe -------------------------------- */
h2.page-title, .family-head h2, .card h2{
  font-family:var(--font-hand);
  font-size:30px; line-height:1.15;
}
.highlight, .family-head h2{
  display:inline;
  text-decoration:underline;
  text-decoration-color:var(--highlighter);
  text-decoration-thickness:10px;
  text-underline-offset:-4px;
  text-decoration-skip-ink:none;
}
.card h3, .sheet-body h3, .feedback-label, label{
  font-family:var(--font-hand);
  font-size:18px; font-weight:400; letter-spacing:0;
  text-transform:none; color:var(--pen-red);
}

/* ---- Paper sheets (cards) --------------------------------------------- */
.card, .sheet, .modal-box{
  background:var(--paper-raised);
  border:1px solid var(--line);
  border-radius:3px;
  box-shadow:var(--shadow);
}
.card{padding:26px 24px 22px;}

/* A strip of masking tape across the top edge of a sheet. Any element with
   .taped gets one; the library's icon cards get one automatically. */
.taped, .icon-card, .roster-btn, .skill-display{position:relative;}
.taped::before, .icon-card::before, .skill-display::before{
  content:""; position:absolute; top:-11px; left:50%;
  width:84px; height:22px; margin-left:-42px;
  background:var(--tape); transform:rotate(-3deg);
  box-shadow:0 1px 2px rgba(0,0,0,0.08);
  pointer-events:none;
}

/* Exercise-book lines: faint blue rules with a red margin down the left. */
.ruled{
  background-color:var(--paper-ruled);
  background-image:repeating-linear-gradient(0deg, transparent 0 27px, var(--rule) 27px 28px);
}

/* ---- Icon cards (skills library, "skills to show") -------------------- */
.icon-card, .skill-display{
  background:var(--paper-raised);
  border:1px solid var(--line);
  border-radius:3px;
  box-shadow:var(--shadow);
  padding:22px 10px 14px;
  gap:8px;
  transition:transform .15s ease, box-shadow .15s ease;
}
.icon-card:nth-child(6n+1){transform:rotate(-1.5deg);}
.icon-card:nth-child(6n+2){transform:rotate(1deg);}
.icon-card:nth-child(6n+3){transform:rotate(-0.6deg);}
.icon-card:nth-child(6n+4){transform:rotate(1.4deg);}
.icon-card:nth-child(6n+5){transform:rotate(-1deg);}
.icon-card:nth-child(6n+6){transform:rotate(0.8deg);}
.icon-card:hover{transform:rotate(0deg) translateY(-3px); box-shadow:var(--shadow-lift);}
.fam-fantastics .icon-card:hover, .fam-grammaristics .icon-card:hover, .fam-boomtastics .icon-card:hover{border-color:var(--line);}
.icon-card img, .skill-display img{width:70px; height:70px; border-radius:50%;}
.icon-card .icon-name, .skill-display{
  font-family:var(--font-hand); font-size:20px; font-weight:400; line-height:1.15;
}
.skill-display{background:var(--paper-raised); border-color:var(--line);}
.skill-display:nth-child(odd){transform:rotate(-1deg);}
.skill-display:nth-child(even){transform:rotate(1deg);}
.draft-dot{background:var(--pen-red);}

/* ---- Inputs ----------------------------------------------------------- */
input, select, textarea{
  font-family:var(--font-body);
  font-size:17px;
  border:2px solid var(--ink);
  border-radius:3px;
  background:var(--paper-raised);
  color:var(--ink);
  padding:10px 14px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline:3px solid var(--focus); outline-offset:2px; border-color:var(--ink);
}
input::placeholder, textarea::placeholder{color:#B8B0A0;}
input#classCode, input#pinInput{
  font-family:var(--font-hand); font-size:30px; letter-spacing:0.2em; font-weight:400;
  padding:8px 16px;
}
select#langSelect{
  font-family:var(--font-hand); font-size:18px; padding:6px 12px; border-radius:3px;
  border:2px solid var(--ink); background:var(--paper-raised);
}

/* ---- Buttons: rubber stamps ------------------------------------------- */
button.primary, .btn-primary, button.secondary, .btn-secondary, .skill-more-btn{
  font-family:var(--font-hand);
  font-size:22px; font-weight:400; letter-spacing:0.04em; line-height:1.1;
  border:3px solid var(--pen-red); color:var(--pen-red);
  background:rgba(255,255,255,0.7);
  border-radius:6px;
  padding:8px 22px;
  cursor:pointer;
  transform:rotate(-2deg);
  transition:transform .12s ease, background .12s ease, color .12s ease;
  width:auto; margin-top:0;
  opacity:1;
}
button.primary:hover, .btn-primary:hover{transform:rotate(0deg); background:var(--pen-red); color:#fff; opacity:1;}
button.secondary, .btn-secondary{border-color:var(--pen-blue); color:var(--pen-blue); transform:rotate(1.5deg);}
button.secondary:hover, .btn-secondary:hover{transform:rotate(0deg); background:var(--pen-blue); color:#fff;}
.skill-more-btn{font-size:15px; padding:2px 12px; border-width:2px; border-color:var(--pen-blue); color:var(--pen-blue); transform:none; border-radius:4px; margin-top:4px;}
.skill-more-btn:hover{background:var(--pen-blue); color:#fff;}
button:disabled, button.primary:disabled, .btn-primary:disabled{opacity:0.5; cursor:default; transform:none;}
button.primary:focus-visible, button.secondary:focus-visible, .btn-primary:focus-visible{outline:3px solid var(--focus); outline-offset:3px;}
.submit-card .primary{border-color:var(--success); color:var(--success); background:rgba(255,255,255,0.7);}
.submit-card .primary:hover{background:var(--success); color:#fff;}
button.submit-big{font-size:28px; padding:10px 40px;}
.back-step, a.back{
  font-family:var(--font-hand); font-size:17px; color:var(--ink-soft);
  text-decoration:none; border-bottom:1.5px solid var(--ink-soft);
  background:none; border-top:0; border-left:0; border-right:0; padding:0; cursor:pointer;
}
.back-step:hover, a.back:hover{color:var(--pen-blue); border-color:var(--pen-blue); text-decoration:none;}

/* ---- Chips: little highlighter tags ----------------------------------- */
.done-chip, .chip{
  font-family:var(--font-hand); font-size:17px; font-weight:400;
  background:#FFF6BF; border:1.5px dashed #B9A24A; border-radius:3px;
  color:var(--ink); padding:3px 12px 3px 6px;
}
:root[data-theme="dark"] .done-chip, :root[data-theme="dark"] .chip{background:#3A3520;}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .done-chip, :root:not([data-theme="light"]) .chip{background:#3A3520;}
}

/* ---- Roster / avatar buttons (join page) ------------------------------ */
.roster-btn, .avatar-option{
  background:var(--paper-raised); border:1px solid var(--line); border-radius:3px;
  box-shadow:var(--shadow); font-family:var(--font-hand); font-size:18px; font-weight:400;
}
.roster-btn:hover, .avatar-option:hover{transform:translateY(-2px); border-color:var(--line); box-shadow:var(--shadow-lift);}
.roster-btn:nth-child(3n+1){transform:rotate(-1deg);} .roster-btn:nth-child(3n+2){transform:rotate(0.8deg);} .roster-btn:nth-child(3n+3){transform:rotate(-0.5deg);}
.roster-btn:hover{transform:rotate(0deg) translateY(-2px);}
.avatar-option.selected{border:2px solid var(--pen-red); background:var(--paper-raised); box-shadow:var(--shadow-lift);}

/* ---- Messages --------------------------------------------------------- */
.error{
  font-family:var(--font-hand); font-size:17px; border-radius:3px;
  background:transparent; color:var(--pen-red);
  border:2px dashed var(--pen-red); padding:8px 12px;
}
.submitted-note{
  font-family:var(--font-hand); font-size:18px; font-weight:400; border-radius:3px;
  background:transparent; color:var(--success); border:2px dashed var(--success);
}

/* ---- Modals: a sheet of paper with tape at the top -------------------- */
.overlay, .modal-overlay{background:rgba(59,58,54,0.45);}
.sheet, .modal-box{border-radius:3px; box-shadow:var(--shadow-lift), 0 24px 60px rgba(0,0,0,0.3); overflow:visible;}
.sheet::before, .modal-box::before{
  content:""; position:absolute; top:-12px; left:50%; width:120px; height:26px; margin-left:-60px;
  background:var(--tape); transform:rotate(-2deg); pointer-events:none; z-index:1;
}
.close-btn, .modal-close{
  font-family:var(--font-hand); background:none; color:var(--ink-soft); border-radius:0;
}
.close-btn:hover, .modal-close:hover{background:none; color:var(--pen-red);}
.sheet-head{border-bottom:2px solid var(--pen-red);}
.sheet-head h2{font-size:30px;}
.examples li, .examples-list li, .translated-block, .lang-error, .next-step-item, .feedback-box{
  border-radius:3px;
}
.examples li, .examples-list li{
  background:var(--paper-raised); border:0; border-left:3px solid var(--highlighter);
  font-family:var(--font-hand); font-style:normal; font-size:18px;
}
.translated-block{background:transparent; border:1.5px dashed var(--line);}

/* Reduced motion: no tilts that change on hover. */
@media (prefers-reduced-motion:reduce){
  .icon-card, .roster-btn, .skill-display, button.primary, button.secondary, .btn-primary{transition:none;}
}

/* ---- Where the pupil writes: real exercise-book paper ------------------ */
textarea#practiceInput, textarea#writingBox{
  font-family:var(--font-hand);
  font-size:21px; line-height:28px; color:var(--pen-blue);
  border:2px solid var(--ink); border-radius:3px;
  background-color:var(--paper-ruled);
  background-image:linear-gradient(to bottom, transparent 27px, var(--rule) 28px);
  background-size:100% 28px;
  background-attachment:local;
  padding:5px 16px 5px 16px;
}
textarea#writingBox{width:100%; flex:1; resize:vertical; padding-left:52px; min-height:240px;}
textarea#practiceInput{min-height:96px;}
.paper-wrap::before{background:var(--margin); opacity:1; left:38px; top:2px; bottom:2px; width:2px;}

/* ---- Teacher console: shared bits ------------------------------------ */
header a.brand{
  font-family:var(--font-brand); font-size:30px; line-height:1; font-weight:600;
  color:var(--pen-blue); text-decoration:none;
}
#whoami{ font-family:var(--font-hand); font-size:18px; color:var(--ink-soft); }
.link, button.link, a.link{
  font-family:var(--font-hand); font-size:17px; font-weight:400;
  color:var(--ink); text-decoration:none; background:none; cursor:pointer; padding:0 0 1px;
  border:0; border-bottom:2px solid var(--ink); border-radius:0;
}
.link:hover, button.link:hover, a.link:hover{ color:var(--pen-blue); border-color:var(--pen-blue); }
.top-row h2{ font-family:var(--font-hand); font-size:34px; line-height:1.15; }
.empty{
  background:var(--paper-raised); border:1px solid var(--line); border-radius:3px;
  box-shadow:var(--shadow); text-align:center; color:var(--ink-soft);
  font-family:var(--font-hand); font-size:20px;
}
.modal{
  background:var(--paper-raised); border:1px solid var(--line); border-radius:3px;
  box-shadow:var(--shadow-lift), 0 24px 60px rgba(0,0,0,0.3); position:relative; overflow:visible;
}
.modal::before{
  content:""; position:absolute; top:-12px; left:50%; width:120px; height:26px; margin-left:-60px;
  background:var(--tape); transform:rotate(-2deg); pointer-events:none;
}
.modal-backdrop{ background:rgba(59,58,54,0.45); }
.modal h3{ font-family:var(--font-hand); font-size:28px; color:var(--ink); }
.modal label{ font-family:var(--font-hand); font-size:18px; color:var(--pen-red); }
.modal input, .modal select, .modal textarea{ width:100%; }
.modal-actions{ align-items:center; }
.modal-actions button{ margin:0; }
button.secondary.small, button.primary.small{ font-size:17px; padding:4px 14px; border-width:2px; }
button.danger{
  font-family:var(--font-hand); font-size:17px; padding:4px 14px; border:2px solid var(--pen-red); color:var(--pen-red);
  background:transparent; border-radius:5px; cursor:pointer; transform:rotate(-1deg);
}
button.danger:hover{ background:var(--pen-red); color:#fff; transform:none; }
table{ border-collapse:collapse; }
th{ font-family:var(--font-hand); font-size:17px; font-weight:400; color:var(--pen-red); text-transform:none; letter-spacing:0; }
td{ border-bottom:1px solid var(--rule); }
.badge, .pill{ font-family:var(--font-hand); font-size:15px; border-radius:4px; }

/* ---- Pop-ups must scroll their own content -------------------------- */
/* The tape strip on a pop-up sits just outside its top edge, so the box
   itself can't clip (overflow:visible above). Scrolling therefore lives on
   the CONTENT inside the box, and the page behind is frozen while any
   pop-up is open — otherwise a wheel over a long feedback pop-up scrolled
   the page underneath instead. */
.sheet, .modal-box{ display:flex; flex-direction:column; max-height:82vh; }
.sheet-body, #skillModalBody, #feedbackModalBody, .modal-box > form{
  overflow-y:auto; min-height:0; flex:1 1 auto; overscroll-behavior:contain;
}
.sheet-body, #skillModalBody, #feedbackModalBody{ padding-bottom:4px; }
body:has(.overlay.open), body:has(.modal-overlay.open), body:has(.modal-backdrop.open){ overflow:hidden; }
