/* Little Edu Games — one stylesheet for the game shelf and the teacher's desk.
   Look: cut paper. Flat colour, fat ink outlines, hard shadows you can press. */

:root {
  color-scheme: light;
  --ink: #1b2559;
  --ink-soft: #4a5488;
  --sky: #eef5ff;
  --paper: #ffffff;
  --cobalt: #2f4bff;
  --tomato: #ff6a57;
  --grape: #9b7bff;
  --sun: #ffc83a;
  --leaf: #3ecf8e;
  --gum: #ff8ec0;
  --line: 3px solid var(--ink);
  --display: "Shantell Sans", "Comic Neue", "Chalkboard SE", "Comic Sans MS", cursive;
  --body: "Lexend", "Segoe UI", system-ui, sans-serif;
  /* a white die-cut edge, so a picture reads on any colour */
  --sticker: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff);
}

/* cover pictures (see covers.js) */
.art, .e, .big { display: block; }
.art svg, .e svg, .big svg, .chip-art > svg { display: block; width: 100%; height: auto; overflow: visible; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--body);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3, .display { font-family: var(--display); font-variation-settings: "BNCE" 40, "INFM" 30; line-height: 1.1; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--cobalt); outline-offset: 3px; border-radius: 6px; }
.on-cobalt :focus-visible { outline-color: var(--sun); }

.wrap { width: min(70rem, 100% - 2rem); margin-inline: auto; }

/* subject colours */
.cat-english { --cat: var(--tomato); }
.cat-spelling { --cat: var(--grape); }
.cat-math { --cat: var(--sun); }
.cat-science { --cat: var(--leaf); }
.cat-fun { --cat: var(--gum); }

/* ---------- brand ---------- */

.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; font: 700 1.3rem/1 var(--display); }
.brand img { width: 2.5rem; height: 2.5rem; }

/* ---------- pressable things ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.9rem; padding: .5rem 1.15rem;
  background: var(--paper); border: var(--line); border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 var(--ink); }
.btn.primary { background: var(--sun); }
.btn.go { background: var(--leaf); }
.btn.danger { background: var(--tomato); }
.btn.small { min-height: 2.4rem; padding: .3rem .85rem; font-size: .95rem; box-shadow: 0 3px 0 var(--ink); }
.btn.quiet { border-color: transparent; box-shadow: none; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn.quiet:hover, .btn.quiet:active { transform: none; box-shadow: none; background: #dfe9ff; }

/* ============================================================
   The game shelf (home page)
   ============================================================ */

.hero { position: relative; overflow: hidden; background: var(--cobalt); color: #fff; border-bottom: var(--line); }
.hero-top { padding-block: 1.1rem; }
.hero-body { position: relative; padding-block: clamp(1.5rem, 6vw, 4rem) clamp(2.75rem, 8vw, 5.5rem); }
.hero h1 { font-size: clamp(2.6rem, 9vw, 5.75rem); font-weight: 800; max-width: 11ch; letter-spacing: -.01em; }
.hero h1 span { display: inline-block; }
.hero h1 span:nth-child(odd) { transform: rotate(-2.5deg); }
.hero h1 span:nth-child(even) { transform: rotate(2deg) translateY(.06em); }
.hero p { margin-top: 1.25rem; font-size: clamp(1.1rem, 2.6vw, 1.4rem); font-weight: 500; }

.bits { position: absolute; inset: 0; pointer-events: none; }
.bits svg { position: absolute; overflow: visible; }
.bit-1 { width: clamp(7rem, 20vw, 13rem); right: 6%; top: 4%; transform: rotate(12deg); }
.bit-2 { width: clamp(5rem, 13vw, 8.5rem); right: 27%; bottom: 9%; transform: rotate(-14deg); }
.bit-3 { width: clamp(4.5rem, 11vw, 7.5rem); right: 3%; bottom: 14%; transform: rotate(8deg); }
.bit-4 { width: clamp(3rem, 7vw, 5rem); right: 38%; top: 12%; transform: rotate(-20deg); }

@media (max-width: 46rem) {
  .bit-2, .bit-4 { display: none; }
  .bit-1 { right: -1.5rem; top: -.5rem; opacity: .95; }
  .bit-3 { right: 1rem; bottom: 1rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero h1 span { animation: drop-in .55s cubic-bezier(.3, 1.6, .5, 1) backwards; }
  .hero h1 span:nth-child(2) { animation-delay: .08s; }
  .hero h1 span:nth-child(3) { animation-delay: .16s; }
  .hero h1 span:nth-child(4) { animation-delay: .24s; }
  .hero h1 span:nth-child(5) { animation-delay: .32s; }
  .card { animation: pop-in .4s cubic-bezier(.3, 1.5, .5, 1) backwards; animation-delay: calc(.35s + var(--i, 0) * .05s); }
  .is-filtering .card { animation: none; }
}
@keyframes drop-in { from { opacity: 0; translate: 0 -1.2em; } }
@keyframes pop-in { from { opacity: 0; scale: .85; } }

/* subject tabs */
.tabs { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: -1.6rem; position: relative; }
.tab {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 3.2rem; padding: .4rem 1.1rem;
  background: var(--paper); border: var(--line); border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  font: 700 1.1rem/1 var(--display); cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.tab:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tab[aria-pressed="true"] { background: var(--cat, var(--ink)); transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tab[aria-pressed="true"]:not([class*="cat-"]) { color: #fff; }
.tab .e { width: 1.7rem; margin-left: -.2rem; }

/* the shelf */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: 1.5rem 1.25rem; padding-block: 2rem 3.5rem; }
@media (max-width: 34rem) { .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem .8rem; } }

.card {
  display: flex; flex-direction: column;
  background: var(--paper); border: var(--line); border-radius: 1.5rem;
  box-shadow: 0 7px 0 var(--ink);
  text-decoration: none; overflow: hidden;
  transition: transform .1s, box-shadow .1s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 0 var(--ink); }
.card:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.cover {
  position: relative;
  display: grid; place-items: center; aspect-ratio: 4 / 3;
  background-color: var(--cat);
  background-image: radial-gradient(rgba(255, 255, 255, .45) 18%, transparent 19%);
  background-size: 1.6rem 1.6rem;
  border-bottom: var(--line);
}
.cover .art { width: 54%; filter: var(--sticker); }
.ribbon {
  position: absolute; top: .7rem; left: .7rem; transform: rotate(-8deg);
  padding: .1rem .75rem; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink); font: 800 1rem/1.3 var(--display);
}
.card:nth-child(3n + 1) .cover { background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .32) 0 .6rem, transparent .6rem 1.5rem); background-size: auto; }
.card:nth-child(3n + 2) .cover .art { transform: rotate(-7deg); }
.card:nth-child(3n) .cover .art { transform: rotate(6deg); }
.card-text { display: flex; flex-direction: column; gap: .5rem; padding: .85rem 1rem 1rem; flex: 1; }
.card-title { font: 700 1.25rem/1.2 var(--display); overflow-wrap: anywhere; }
.card-sub { margin-top: -.3rem; color: var(--ink-soft); font-size: .95rem; line-height: 1.3; overflow-wrap: anywhere; }
.tag { align-self: flex-start; margin-top: auto; padding: .1rem .65rem; border: 2px solid var(--ink); border-radius: 999px; background: var(--cat); font-size: .85rem; font-weight: 600; }
@media (max-width: 34rem) {
  .card-title { font-size: 1.05rem; } .card-sub { font-size: .85rem; } .card-text { padding: .65rem .75rem .8rem; }
  .ribbon { top: .45rem; left: .45rem; font-size: .85rem; padding-inline: .55rem; }
}

.empty { padding-block: 3rem 5rem; text-align: center; }
.empty .big { width: 7rem; margin-inline: auto; filter: var(--sticker); }
.empty h2 { margin-top: 1rem; font-size: 1.9rem; }
.empty p { margin-top: .5rem; color: var(--ink-soft); }


/* ============================================================
   The teacher's desk
   ============================================================ */

.desk-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-block: 1rem; }
.desk-top nav { display: flex; gap: .25rem; flex-wrap: wrap; }

.panel { background: var(--paper); border: var(--line); border-radius: 1.75rem; box-shadow: 0 7px 0 var(--ink); padding: clamp(1.25rem, 4vw, 2.25rem); }

/* key gate */
.gate { max-width: 31rem; margin: clamp(1rem, 6vh, 4rem) auto; }
.gate h1 { font-size: clamp(1.9rem, 6vw, 2.5rem); }
.gate p { margin-top: .6rem; color: var(--ink-soft); }
.gate form { margin-top: 1.4rem; display: grid; gap: .9rem; }
.gate label { font-weight: 600; }
.field { display: flex; gap: .5rem; }
.field input { flex: 1; min-width: 0; min-height: 3.1rem; padding: .5rem .9rem; border: var(--line); border-radius: 1rem; background: var(--sky); font-size: 1.1rem; }
.note { min-height: 1.5em; font-weight: 600; }
.note.bad { color: #b3261e; }

/* drop zone */
.desk { padding-bottom: 4rem; }
.desk h1 { font-size: clamp(2rem, 6vw, 2.9rem); margin-top: .75rem; }
.desk .lede { margin-top: .4rem; color: var(--ink-soft); max-width: 46ch; }
.drop {
  margin-top: 1.4rem; padding: clamp(1.75rem, 6vw, 3.25rem) 1.25rem;
  display: grid; justify-items: center; gap: .65rem; text-align: center;
  background: var(--paper); border: 4px dashed var(--ink); border-radius: 2rem;
  transition: background .12s, transform .12s;
}
.drop svg { width: 5.5rem; height: 5.5rem; overflow: visible; }
.drop .display { font-size: clamp(1.6rem, 5vw, 2.2rem); font-weight: 700; }
.drop .or { color: var(--ink-soft); }
.drop small { color: var(--ink-soft); font-size: .92rem; }
.dragging .drop { background: var(--sun); transform: scale(1.01); border-style: solid; }
@media (prefers-reduced-motion: no-preference) {
  .dragging .drop svg { animation: hop .5s ease-in-out infinite alternate; }
}
@keyframes hop { to { translate: 0 -.6rem; } }

/* games waiting to be published + the library */
.stack { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
#staged { margin-top: 1.25rem; }
.slip { background: var(--paper); border: var(--line); border-radius: 1.4rem; box-shadow: 0 5px 0 var(--ink); padding: 1rem 1.1rem; display: grid; gap: .85rem; }
.slip-head { display: flex; gap: .85rem; align-items: center; }
.slip-head .grow { flex: 1; min-width: 0; display: grid; gap: .3rem; }
.chip-art { flex: none; display: grid; place-items: center; width: 4rem; height: 4rem; padding: .45rem; border: var(--line); border-radius: 1rem; background: var(--cat, #dfe9ff); }
.chip-art svg { filter: var(--sticker); }
.chip-art .art { width: 100%; }
button.chip-art { cursor: pointer; }
button.chip-art:hover { transform: rotate(-4deg); }
.name-input { width: 100%; min-height: 2.9rem; padding: .4rem .8rem; border: var(--line); border-radius: .9rem; background: var(--sky); font: 700 1.15rem/1.2 var(--display); }
.small-input { width: 100%; min-height: 2.4rem; padding: .3rem .8rem; border: 2px solid var(--ink); border-radius: .8rem; background: var(--paper); font-size: .95rem; }
.small-input::placeholder { color: var(--ink-soft); }
.file-name { color: var(--ink-soft); font-size: .88rem; overflow-wrap: anywhere; }
.row { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.row.end { justify-content: flex-end; }
.row .spacer { flex: 1; }
.ask { font-weight: 600; margin-right: .2rem; }

.pick { position: relative; }
.pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pick .e { width: 1.5rem; }
.pick > span { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.6rem; padding: .3rem .85rem; border: var(--line); border-radius: 999px; background: var(--paper); font-weight: 600; }
.pick input:checked + span { background: var(--cat); box-shadow: inset 0 3px 0 rgba(27, 37, 89, .22); }
.pick input:focus-visible + span { outline: 4px solid var(--cobalt); outline-offset: 3px; }

.cover-tray { display: flex; flex-wrap: wrap; gap: .4rem; padding: .6rem; border: var(--line); border-radius: 1rem; background: #dfe9ff; }
.cover-tray button { width: 3.4rem; height: 3.4rem; padding: .35rem; border: 2px solid transparent; border-radius: .8rem; background: none; cursor: pointer; }
.cover-tray button:hover { background: var(--paper); border-color: var(--ink); }
.cover-tray .art { filter: var(--sticker); }

.done-mark { font: 700 1.2rem/1.2 var(--display); }
.link-box { flex: 1 1 15rem; min-width: 0; min-height: 2.9rem; padding: .45rem .85rem; border: var(--line); border-radius: .9rem; background: var(--sky); font-weight: 500; overflow-wrap: anywhere; user-select: all; }
.slip.done { background: #e9fbf2; }

.library-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-top: 3rem; margin-bottom: 1rem; }
.library-head h2 { font-size: 1.8rem; }
.library-head span { color: var(--ink-soft); }
.library-head .spacer { flex: 1; }
.game-sub { font-weight: 500; }
.game-title { font: 700 1.2rem/1.2 var(--display); overflow-wrap: anywhere; }
.meta { color: var(--ink-soft); font-size: .92rem; overflow-wrap: anywhere; }
.warn { font-weight: 600; flex: 1 1 14rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; translate: -50% 0; z-index: 10;
  max-width: calc(100% - 2rem); padding: .7rem 1.2rem;
  background: var(--ink); color: #fff; border-radius: 999px; font-weight: 600; text-align: center;
}
.toast.bad { background: #b3261e; }

/* ============================================================
   Printable game cards (the /cards page)
   ============================================================ */

.cards-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding-block: 1rem; }
.cards-bar .spacer { flex: 1; }
.cards-intro { max-width: 52ch; color: var(--ink-soft); margin-bottom: 1.5rem; }
.sheet { display: grid; grid-template-columns: repeat(auto-fill, 90mm); gap: 10mm 6mm; justify-content: center; padding-bottom: 3rem; }
.pcard-wrap { display: grid; gap: 3mm; justify-items: center; break-inside: avoid; }
.pcard-tools { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.pcard {
  width: 90mm; height: 128mm; display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1.2mm solid var(--ink); border-radius: 7mm;
  break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.pcard-cover {
  flex: none; height: 38mm; display: grid; place-items: center;
  background-color: var(--cat);
  background-image: radial-gradient(rgba(255, 255, 255, .45) 18%, transparent 19%); background-size: 6mm 6mm;
  border-bottom: 1.2mm solid var(--ink);
}
.pcard-cover .art { width: 27mm; filter: var(--sticker); transform: rotate(-5deg); }
.pcard-body { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4mm 5mm 4mm; min-height: 0; }
.pcard h2 { font-size: 6.2mm; line-height: 1.1; overflow-wrap: anywhere; }
.pcard .sub { margin-top: 1mm; font-size: 3.4mm; color: var(--ink-soft); line-height: 1.25; }
.pcard .qr { margin-top: auto; width: 40mm; height: 40mm; }
.pcard .qr svg { display: block; width: 100%; height: 100%; }
.pcard .how { margin-top: 2mm; font: 700 3.9mm/1.2 var(--display); }
.pcard .link { margin-top: 1mm; font-size: 2.7mm; line-height: 1.25; color: var(--ink-soft); overflow-wrap: anywhere; }

@page { size: A4; margin: 12mm; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .wrap { width: auto; margin: 0; }
  .sheet { grid-template-columns: repeat(2, 90mm); gap: 8mm 6mm; padding: 0; }
  .pcard-wrap { gap: 0; }
}
