/* ============================================================
   Magic.py Classroom — one simple, colourful, child-friendly stylesheet.
   ============================================================ */

:root {
  --pink:   #ff6b9d;
  --purple: #a06bff;
  --blue:   #4da8ff;
  --green:  #4dd97e;
  --yellow: #ffd84d;
  --orange: #ff9d4d;
  --red:    #ff5d5d;
  --teal:   #36d1c4;
  --ink:    #2b2546;
  --paper:  #fff;
  --bg:     #f4f0ff;
  --shadow: 0 6px 0 rgba(0,0,0,.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Comic Sans MS", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

/* ---- Top bar with the live timers ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  color: #fff; padding: 12px 18px; box-shadow: 0 4px 0 rgba(0,0,0,.1);
}
.topbar .brand { font-size: 1.4rem; font-weight: 800; margin-right: auto; }
.topbar a.back { background: rgba(255,255,255,.25); padding: 8px 14px; border-radius: 999px; font-weight: 700; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  background: rgba(255,255,255,.22); border-radius: 999px;
  padding: 6px 14px; font-weight: 700; display: flex; align-items: center; gap: 6px;
  font-size: .95rem;
}
.chip.warn { background: var(--red); }

/* ---- Generic layout ---- */
.wrap { max-width: 1000px; margin: 0 auto; padding: 22px 18px 60px; }
h1 { font-size: 2rem; margin: .2em 0 .6em; }
h2 { margin-top: 1.4em; }
.muted { opacity: .65; }

/* ---- Big colourful buttons (child menu) ---- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.bigbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 26px 14px; border-radius: 26px; color: #fff;
  font-size: 1.2rem; font-weight: 800; text-align: center;
  box-shadow: var(--shadow); transition: transform .08s ease;
  min-height: 130px; border: none; cursor: pointer;
}
.bigbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.12); }
.bigbtn .ico { font-size: 2.6rem; line-height: 1; }
.c-green{background:var(--green)} .c-blue{background:var(--blue)}
.c-purple{background:var(--purple)} .c-pink{background:var(--pink)}
.c-yellow{background:var(--yellow);color:var(--ink)} .c-orange{background:var(--orange)}
.c-red{background:var(--red)} .c-teal{background:var(--teal)}

/* ---- Forms & buttons ---- */
.card {
  background: var(--paper); border-radius: 22px; padding: 22px;
  box-shadow: var(--shadow); margin-bottom: 20px;
}
label { display: block; font-weight: 700; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 3px solid #e7e0ff; border-radius: 14px;
  font-size: 1rem; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); }
.btn {
  display: inline-block; background: var(--purple); color: #fff; border: none;
  padding: 12px 22px; border-radius: 999px; font-weight: 800; font-size: 1rem;
  cursor: pointer; box-shadow: var(--shadow); font-family: inherit;
}
.btn:active { transform: translateY(3px); }
.btn.green{background:var(--green)} .btn.red{background:var(--red)}
.btn.blue{background:var(--blue)} .btn.small{padding:7px 14px;font-size:.85rem;box-shadow:0 3px 0 rgba(0,0,0,.12)}
.btn.ghost{background:#eee;color:var(--ink)}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 120px; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 2px solid #f0ecff; }
th { color: var(--purple); }
tr:last-child td { border-bottom: none; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 800; color:#fff; }
.badge.ok{background:var(--green)} .badge.no{background:var(--red)} .badge.wait{background:var(--orange)}

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 30% 20%, #ffd6ec, transparent 60%),
              radial-gradient(circle at 80% 70%, #d6e4ff, transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 420px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button { flex: 1; border: none; padding: 12px; border-radius: 14px; font-weight: 800;
  background: #eee; cursor: pointer; font-family: inherit; font-size: 1rem; }
.tabs button.active { background: var(--purple); color: #fff; }
.hide { display: none; }
.error { background: var(--red); color: #fff; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 700; }

/* ---- PIN pad ---- */
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.pinpad button { padding: 18px; font-size: 1.4rem; font-weight: 800; border: none;
  border-radius: 14px; background: #efe9ff; cursor: pointer; }
.pindots { text-align: center; font-size: 2rem; letter-spacing: 8px; min-height: 40px; }

/* ---- Game / canvas frame ---- */
.stage { display: grid; place-items: center; gap: 14px; padding: 14px; width: 100%; }
canvas { background: #fff; border-radius: 18px; box-shadow: var(--shadow); touch-action: none; max-width: 100%; display: block; }
.scorebar { display: flex; gap: 18px; font-weight: 800; font-size: 1.1rem; flex-wrap: wrap; align-items: center; }
.overlay { position: fixed; inset: 0; background: rgba(43,37,70,.85); color: #fff;
  display: none; place-items: center; text-align: center; z-index: 50; }
.overlay.show { display: grid; }
.overlay .box { background: var(--paper); color: var(--ink); padding: 30px; border-radius: 24px; max-width: 320px; }

/* ---- Engine overlays (pause / game-over) ---- */
.goverlay { position: fixed; inset: 0; background: rgba(43,37,70,.82); color: #fff;
  display: none; place-items: center; text-align: center; z-index: 60; padding: 20px; }
.goverlay.show { display: grid; animation: pop .18s ease; }
.gbox { background: var(--paper); color: var(--ink); padding: 28px 30px; border-radius: 26px;
  max-width: 340px; box-shadow: var(--shadow); }
.gbox h2 { margin: .2em 0; }
.gbox #go-score { font-size: 1.3rem; font-weight: 800; margin: 10px 0 18px; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- Mute button ---- */
.mutebtn { position: fixed; bottom: 16px; right: 16px; z-index: 70; width: 52px; height: 52px;
  border-radius: 50%; border: none; background: var(--purple); color: #fff; font-size: 1.4rem;
  cursor: pointer; box-shadow: var(--shadow); }
.mutebtn:active { transform: translateY(3px); }

/* ---- Toast ---- */
.gtoast { position: fixed; left: 50%; top: 80px; transform: translateX(-50%) translateY(-20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800;
  z-index: 65; opacity: 0; transition: all .2s ease; pointer-events: none; }
.gtoast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- In-canvas control buttons row ---- */
#controls { width: 100%; max-width: 520px; text-align: center; }
#controls .row { justify-content: center; }

/* ---- Calm fullscreen ---- */
.calm-stage { position: fixed; inset: 0; overflow: hidden; }
.calm-stage canvas { border-radius: 0; box-shadow: none; width: 100%; height: 100%; }
.calm-controls { position: fixed; top: 16px; left: 16px; z-index: 10; display: flex; gap: 10px; }

@media (max-width: 600px) {
  .topbar .brand { font-size: 1.1rem; width: 100%; }
  h1 { font-size: 1.5rem; }
}

/* ---- Video call ---- */
.vc-overlay { position: fixed; inset: 0; background: #111; z-index: 200; display: none; }
.vc-overlay.show { display: block; }
.vc-stage { position: absolute; inset: 0; }
#vc-remote { width: 100%; height: 100%; object-fit: cover; background: #000; }
#vc-local { position: absolute; right: 14px; top: 14px; width: 28vw; max-width: 180px;
  border-radius: 12px; border: 2px solid #fff; object-fit: cover; background: #222; }
.vc-status { position: absolute; top: 14px; left: 14px; color: #fff; font-weight: 800;
  background: rgba(0,0,0,.4); padding: 6px 12px; border-radius: 999px; }
.vc-bar { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center; }
.vc-ring { position: fixed; inset: 0; background: rgba(43,37,70,.85); z-index: 210;
  display: none; place-items: center; }
.vc-ring.show { display: grid; }
.vc-ringbox { background: #fff; padding: 28px; border-radius: 24px; text-align: center; }

/* ---- iPad-style home screen ---- */
body.ipad { background:
  radial-gradient(circle at 20% 15%, #ffd1f0, transparent 45%),
  radial-gradient(circle at 85% 25%, #cfe4ff, transparent 45%),
  radial-gradient(circle at 50% 90%, #d6fff0, transparent 50%),
  linear-gradient(160deg, #a18bff, #67c7ff); }
.home { max-width: 1000px; margin: 0 auto; padding: 18px 16px 130px; }
.widget { background: rgba(255,255,255,.9); border-radius: 20px; padding: 14px 18px;
  margin-bottom: 16px; box-shadow: 0 6px 18px rgba(0,0,0,.12); backdrop-filter: blur(6px); }
.appgrid { display: grid; gap: 18px 10px;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.app { display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-decoration: none; border: none; background: none; cursor: pointer; }
.app-ico { width: 74px; height: 74px; border-radius: 22px; display: grid; place-items: center;
  font-size: 2.4rem; background: rgba(255,255,255,.92);
  box-shadow: 0 6px 14px rgba(0,0,0,.22); transition: transform .08s ease; }
.app:active .app-ico { transform: scale(.9); }
.app-name { color: #fff; font-weight: 700; font-size: .85rem; text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.dock { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 10px; padding: 12px 16px; border-radius: 26px;
  background: rgba(255,255,255,.35); backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); flex-wrap: wrap; justify-content: center; max-width: 94vw; }
.dock-item { display: flex; flex-direction: column; align-items: center; min-width: 60px;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); text-decoration: none; }
.dock-item b { font-size: 1.2rem; } .dock-item span { font-size: .7rem; }
body.ipad .a11y-contrast, body.ipad.a11y-contrast { background: #000; }

/* ---- Accessibility ---- */
body.a11y-dys { letter-spacing: .04em; word-spacing: .12em; line-height: 1.7;
  font-family: "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif; }
body.a11y-large { font-size: 120%; }
body.a11y-large .bigbtn { min-height: 150px; font-size: 1.4rem; }
body.a11y-contrast { background: #000; color: #fff; }
body.a11y-contrast .card, body.a11y-contrast .wrap .card { background: #111; color: #fff; border: 2px solid #fff; }
body.a11y-contrast .muted { color: #ddd; opacity: 1; }
body.a11y-contrast input, body.a11y-contrast select, body.a11y-contrast textarea { background:#000; color:#fff; }

.a11ybtn { position: fixed; bottom: 16px; left: 16px; z-index: 70; width: 52px; height: 52px;
  border-radius: 50%; border: none; background: var(--ink); color: #fff; font-size: 1.5rem;
  cursor: pointer; box-shadow: var(--shadow); }
.a11ypanel { position: fixed; bottom: 78px; left: 16px; z-index: 71; background: #fff; color: var(--ink);
  border-radius: 16px; box-shadow: var(--shadow); padding: 12px; width: 230px; display: none; }
.a11ypanel.show { display: block; }
.a11y-head { font-weight: 800; margin-bottom: 8px; }
.a11y-opt, .a11y-langs button { display: block; width: 100%; text-align: left; border: none;
  background: #efe9ff; border-radius: 10px; padding: 10px; margin: 5px 0; font-weight: 700;
  cursor: pointer; font-family: inherit; font-size: .95rem; }
.a11y-opt.on { background: var(--green); color: #fff; }
.a11y-langs { display: flex; gap: 6px; margin-top: 8px; }
.a11y-langs button { display: inline; width: auto; flex: 1; text-align: center; background:#eee; }
.a11y-langs button.on { background: var(--purple); color: #fff; }

/* ---- Printable login cards ---- */
.cardsheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.logincard { border: 3px dashed #c9bdf5; border-radius: 16px; padding: 16px; text-align: center;
  background: #fff; break-inside: avoid; }
.lc-school { font-size: .8rem; color: var(--purple); font-weight: 800; }
.lc-avatar { font-size: 2.4rem; }
.lc-name { font-size: 1.2rem; font-weight: 800; margin: 4px 0; }
.lc-pin { font-size: 1.1rem; }
.lc-pin b { letter-spacing: 4px; font-size: 1.4rem; }
.lc-foot { font-size: .7rem; color: #888; margin-top: 6px; }
@media print {
  .topbar, .noprint, .mutebtn { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .cardsheet { grid-template-columns: repeat(3, 1fr); }
  body { background: #fff; }
}
