/* The Arithmancy Mystery: heads-up display, touch controls, the problem sheet. */
:root {
  --ink: #2a1c10; --parch: #f1e2bd; --parch-2: #e3cf9c; --gold: #f0c35a; --gold-2: #b98524;
  --night: #0d0a08; --glass: rgba(16, 12, 9, .62); --line: rgba(240, 195, 90, .35);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--night); color: #f6ead0; overflow: hidden; overscroll-behavior: none; }
body { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 18px; -webkit-user-select: none; user-select: none; touch-action: none; }
[hidden] { display: none !important; }
.app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#wandLayer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.app.casting #wandLayer { pointer-events: auto; cursor: crosshair; }

/* top bar */
.top { position: absolute; left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); top: calc(8px + var(--safe-t)); display: flex; gap: 8px; align-items: center; pointer-events: none; }
.top > * { pointer-events: auto; }
.spacer { flex: 1; pointer-events: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: #f6ead0; font: 700 14px/1 'Cinzel', serif; letter-spacing: .04em; text-decoration: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
button.pill { cursor: pointer; }
.pill.icon { width: 36px; padding: 0; justify-content: center; font-size: 17px; }
.pill.icon[aria-pressed="false"] { opacity: .45; }
.pill b { font-size: 16px; color: var(--gold); min-width: 1ch; text-align: right; }
.pill.coins span { opacity: .7; }
.coin { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b8, #f0c35a 45%, #a8741c); box-shadow: 0 0 8px rgba(240, 195, 90, .7); }
.pill.coins.bump { animation: bump .35s ease-out; }
@keyframes bump { 30% { transform: scale(1.18); } }
.pill.clues span { opacity: .7; }
.copy { white-space: pre-line; }
.pill.place { font-weight: 500; letter-spacing: .1em; text-transform: uppercase; font-size: 12px; opacity: .85; }
.pill.place:empty { display: none; }
.fade { position: absolute; inset: 0; background: #060403; opacity: 0; pointer-events: none; transition: opacity .38s ease; }
.fade.on { opacity: 1; pointer-events: auto; }
.pill.spell { border-color: rgba(190, 215, 255, .7); color: #dce9ff; box-shadow: 0 0 14px rgba(160, 200, 255, .5); }

/* messages */
.say { position: absolute; left: 50%; top: calc(56px + var(--safe-t)); transform: translateX(-50%); max-width: min(560px, 80vw); padding: 8px 18px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); font-size: 19px; text-align: center; opacity: 0; transition: opacity .25s; pointer-events: none; }
.say.show { opacity: 1; }
.app.casting .say { top: calc(104px + var(--safe-t)); }      /* with the wand out, messages sit under "Draw the spell", not on it */
.prompt { position: absolute; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 8px; align-items: center; padding: 8px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font: 700 15px 'Cinzel', serif; }
.prompt kbd { font: 700 13px 'Cinzel', serif; padding: 3px 8px; border-radius: 6px; background: var(--gold); color: var(--ink); }
body.touch .prompt { display: none; }

/* touch controls */
.stick, .pads { display: none; }
body.touch .stick { display: block; position: absolute; left: calc(26px + var(--safe-l)); bottom: calc(26px + var(--safe-b)); width: 132px; height: 132px; border-radius: 50%; background: rgba(255, 240, 200, .08); border: 2px solid rgba(255, 240, 200, .28); }
.stick i { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(255, 240, 200, .35); border: 2px solid rgba(255, 240, 200, .6); }
body.touch .pads { display: grid; position: absolute; right: calc(22px + var(--safe-r)); bottom: calc(22px + var(--safe-b)); grid-template-columns: 76px 92px; grid-template-rows: 64px 92px; gap: 10px; align-items: end; justify-items: end; }
.pad { border-radius: 50%; border: 2px solid rgba(255, 240, 200, .5); background: rgba(20, 14, 10, .55); color: #f6ead0; font: 700 14px 'Cinzel', serif; letter-spacing: .03em; touch-action: none; }
.pad:active, .pad.down { background: rgba(240, 195, 90, .5); color: var(--ink); }
.pad.jump { grid-column: 2; grid-row: 2; width: 92px; height: 92px; font-size: 16px; }
.pad.wand { grid-column: 1; grid-row: 2; width: 72px; height: 72px; }
.pad.use { grid-column: 2; grid-row: 1; width: 92px; height: 56px; border-radius: 28px; border-color: var(--gold); background: rgba(240, 195, 90, .88); color: var(--ink); font-size: 16px; }
.app.casting .stick, .app.casting .pads, .app.solving .stick, .app.solving .pads, .app.solving .prompt { display: none !important; }
/* a tablet held in two hands: the thumbs rest higher up the sides than on a phone, and there is room for bigger controls */
@media (min-width: 1000px) and (min-height: 600px) {
  body.touch .stick { left: calc(46px + var(--safe-l)); bottom: calc(96px + var(--safe-b)); width: 156px; height: 156px; }
  body.touch .stick i { width: 68px; height: 68px; margin: -34px 0 0 -34px; }
  body.touch .pads { right: calc(42px + var(--safe-r)); bottom: calc(92px + var(--safe-b)); grid-template-columns: 88px 110px; grid-template-rows: 74px 110px; gap: 12px; }
  body.touch .pad.jump { width: 110px; height: 110px; font-size: 18px; }
  body.touch .pad.wand { width: 86px; height: 86px; font-size: 15px; }
  body.touch .pad.use { width: 110px; height: 66px; border-radius: 33px; font-size: 18px; }
}

/* wand drawing mode */
.cast { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(64px + var(--safe-t)) 16px calc(22px + var(--safe-b)); pointer-events: none; background: radial-gradient(ellipse at center, transparent 40%, rgba(8, 10, 24, .5)); }
.cast-title { margin: 0; font: 700 22px 'Cinzel', serif; letter-spacing: .08em; text-shadow: 0 2px 12px #000; }
.cast-book { position: absolute; right: calc(16px + var(--safe-r)); top: 50%; transform: translateY(-50%); display: grid; gap: 10px; }
.cast-book .glyph { width: 92px; padding: 8px 6px 6px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); text-align: center; font: 700 13px 'Cinzel', serif; }
.cast-book canvas { display: block; width: 64px; height: 64px; margin: 0 auto 4px; }
.cast-book .glyph.locked { padding: 7px 6px 8px; border-style: dashed; color: rgba(246, 234, 208, .62); }
.cast-book .glyph.locked b { display: block; font-weight: 700; font-size: 11.5px; letter-spacing: 0; }
.cast-book .glyph.locked small { display: block; margin-top: 3px; font: 600 13px/1.15 'Cormorant Garamond', Georgia, serif; letter-spacing: 0; color: rgba(246, 234, 208, .85); }
.cast .pill { pointer-events: auto; }

/* the problem sheet */
.math { position: absolute; inset: 0; display: grid; place-items: center; padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l)); background: rgba(6, 4, 3, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet { position: relative; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(210px, .75fr); gap: 22px; width: min(860px, 100%); max-height: 100%; padding: 22px 24px; border-radius: 14px; color: var(--ink); background: linear-gradient(160deg, var(--parch), var(--parch-2)); box-shadow: 0 18px 60px rgba(0, 0, 0, .6), inset 0 0 60px rgba(140, 95, 30, .28); border: 1px solid #a8843f; }
.sheet .eyebrow { margin: 0 0 6px; font: 700 13px 'Cinzel', serif; letter-spacing: .14em; text-transform: uppercase; color: #8a5a17; }
.question { margin: 0 0 12px; font-size: clamp(19px, 2.6vw, 25px); line-height: 1.32; font-weight: 600; }
/* the drawing that goes with a problem (src/figures.js): under the question, or beside it on a short screen such as a phone held sideways */
.figure { order: 1; margin: -2px 0 10px; color: var(--ink); line-height: 0; text-align: center; }
.figure svg { display: inline-block; width: min(280px, 100%); height: auto; max-height: 32vh; font-family: 'Cinzel', Georgia, serif; }
.sheet-main:has(> .figure:not([hidden])) { display: flex; flex-direction: column; }
.sheet-main:has(> .figure:not([hidden])) > :not(.eyebrow, .question, .figure) { order: 2; }
@media (max-height: 560px) {
  .sheet-main:has(> .figure:not([hidden])) { display: block; }
  .figure { float: right; margin: 0 0 4px 12px; }
  .figure svg { width: clamp(170px, 27vw, 236px); max-height: 46vh; }
  .sheet-main:has(> .figure:not([hidden])) > .question { font-size: 17px; line-height: 1.26; }
}
.hint { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid #b98524; background: rgba(185, 133, 36, .14); font-style: italic; font-size: 19px; }
.hint.note { border-left-color: #1f6b33; background: rgba(31, 107, 51, .1); }
.paper { margin: 0 0 10px; font-size: 19px; font-style: italic; font-weight: 600; color: #6b4a1c; }
.paper span, .loading-tip span { font-style: normal; margin-right: 4px; }
.answer-row { display: flex; align-items: baseline; gap: 10px; min-height: 54px; }
.answer-row .grow { flex: 1; }
.help-btn { align-self: center; height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid #8a5a17; background: #fbf2d8; color: var(--ink); font: 700 14px 'Cinzel', serif; letter-spacing: .05em; white-space: nowrap; cursor: pointer; touch-action: manipulation; animation: helpPulse 1.8s ease-out infinite; }
.help-btn:active { background: var(--gold); }
@keyframes helpPulse { 0% { box-shadow: 0 0 0 0 rgba(185, 133, 36, .55); } 70%, 100% { box-shadow: 0 0 0 11px rgba(185, 133, 36, 0); } }
.answer { min-width: 130px; padding: 4px 14px; border-bottom: 3px solid var(--ink); font: 700 34px 'Cinzel', serif; text-align: center; white-space: pre; }
.answer:empty::before { content: '?'; opacity: .3; }
.unit { font-size: 21px; font-weight: 600; }
.verdict { margin: 8px 0 0; min-height: 26px; font-size: 20px; font-weight: 700; }
.verdict.good { color: #1f6b33; } .verdict.bad { color: #9c2a1c; }
/* a station that needed the steps is solved: one more version is on offer for a Galleon, and there is nothing to type */
.offer { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.offer[hidden] { display: none; }
.offer-btn { display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 24px; border-radius: 999px; border: 1px solid #8a5a17; background: #fbf2d8; color: var(--ink); font: 700 16px 'Cinzel', serif; letter-spacing: .05em; white-space: nowrap; cursor: pointer; touch-action: manipulation; }
.offer-btn.gold { background: linear-gradient(#f4cf6d, #d9a437); }
.offer-btn:active { background: var(--gold); }
.sheet.offering { grid-template-columns: minmax(0, 1fr); width: min(580px, 100%); }
.sheet.offering .keys, .sheet.offering .paper, .sheet.offering .answer-row, .sheet.offering .verdict { display: none; }
.sheet.shake { animation: shake .35s; }
@keyframes shake { 20% { transform: translateX(-7px); } 50% { transform: translateX(6px); } 80% { transform: translateX(-3px); } }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: center; }
.keys button { height: clamp(42px, 9.2vh, 58px); border-radius: 10px; border: 1px solid #8f6a2a; background: #fbf2d8; color: var(--ink); font: 700 23px 'Cinzel', serif; cursor: pointer; touch-action: manipulation; }
.keys button:active { background: var(--gold); }
.keys .wide { grid-column: span 2; background: linear-gradient(#f4cf6d, #d9a437); border-color: #8a5a17; letter-spacing: .08em; font-size: 19px; }
.keys .soft { background: #ead9ad; font-size: 20px; }
.sheet-close { position: absolute; right: -10px; top: -10px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid #8f6a2a; background: #fbf2d8; color: var(--ink); font-size: 16px; cursor: pointer; }
@media (max-height: 430px) {
  .sheet { padding: 12px 16px; gap: 14px; }
  .question { font-size: 18px; margin-bottom: 6px; }
  .hint { font-size: 16px; margin-bottom: 6px; padding: 5px 10px; }
  .paper { font-size: 16px; margin-bottom: 4px; }
  .help-btn { height: 34px; padding: 0 14px; font-size: 13px; }
  .answer { font-size: 26px; } .answer-row { min-height: 40px; } .verdict { font-size: 17px; min-height: 22px; margin-top: 4px; }
  .keys { gap: 6px; } .keys button { height: clamp(34px, 12.5vh, 48px); font-size: 20px; }
}

/* loading and cards */
.loading, .modal { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; }
.loading { background: radial-gradient(ellipse at 50% 40%, #2a1d12, #0d0a08 70%); transition: opacity .6s; }
.loading.gone { opacity: 0; pointer-events: none; }
.loading h1, .modal h2 { margin: 0; font: 900 clamp(26px, 5vw, 44px) 'Cinzel', serif; color: var(--gold); letter-spacing: .04em; }
.eyebrow { margin: 0; font: 700 13px 'Cinzel', serif; letter-spacing: .2em; text-transform: uppercase; opacity: .8; }
.bar { width: min(320px, 60vw); height: 6px; margin-top: 16px; border-radius: 3px; background: rgba(255, 240, 200, .15); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.loading-note { margin: 8px 0 0; opacity: .75; font-style: italic; }
.loading-tip { margin: 6px 0 0; font-size: 19px; color: var(--gold); }
/* Kara and Theo on the opening card; the one who is playing is ringed in gold */
.faces { display: flex; gap: 22px; margin-bottom: 12px; align-items: end; }
.faces figure { margin: 0; display: grid; justify-items: center; gap: 4px; font: 700 13px 'Cinzel', serif; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
.faces img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; object-position: 50% 30%; border: 3px solid rgba(240, 195, 90, .45); }
.faces figure.me { opacity: 1; color: var(--gold); }
.faces figure.me img { width: 124px; height: 124px; border-color: var(--gold); box-shadow: 0 0 22px rgba(240, 195, 90, .55); }
@media (max-height: 430px) { .faces img { width: 60px; height: 60px; } .faces figure.me img { width: 74px; height: 74px; } .faces { margin-bottom: 6px; } }
.modal { background: rgba(6, 4, 3, .6); }
.card { max-width: 440px; padding: 24px 28px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.copy { font-size: 20px; margin: 10px 0 16px; }
.btn { height: 46px; padding: 0 24px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: #f6ead0; font: 700 15px 'Cinzel', serif; letter-spacing: .06em; cursor: pointer; }
.btn.gold { background: linear-gradient(#f4cf6d, #d9a437); color: var(--ink); border-color: #8a5a17; }

.meter { position: absolute; left: calc(10px + var(--safe-l)); top: calc(52px + var(--safe-t)); height: 26px; font: 600 12px/1 ui-monospace, Menlo, monospace; letter-spacing: 0; pointer-events: none; }

/* talking to a student: a framed box along the bottom, portrait on the left, read a page at a time */
.talk { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); width: min(720px, calc(100vw - 24px)); display: flex; gap: 14px; padding: 14px; border-radius: 10px;
  background: linear-gradient(#2b1d12, #17100a); border: 2px solid #c9a045; box-shadow: 0 0 0 4px #17100a, 0 0 0 5px #7a5a22, 0 14px 40px rgba(0, 0, 0, .6); color: #f3e6c8; z-index: 30; }
.talk[hidden] { display: none; }
.talk-face { width: 112px; height: 112px; flex: none; object-fit: cover; border-radius: 6px; border: 2px solid #c9a045; background: #3a2a1a; }
.talk-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.talk-name { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.talk-name b { font: 700 19px 'Cinzel', Georgia, serif; color: #f3d27a; letter-spacing: .03em; }
.talk-name span { font: 600 12px 'Cinzel', Georgia, serif; letter-spacing: .12em; text-transform: uppercase; color: #c9b48a; }
.talk[data-house="gryffindor"] .talk-name span { color: #e58a7a; } .talk[data-house="hufflepuff"] .talk-name span { color: #ecc94b; }
.talk[data-house="ravenclaw"] .talk-name span { color: #8fb4ff; } .talk[data-house="slytherin"] .talk-name span { color: #7fd0a0; }
.talk p { margin: 0; flex: 1; min-height: 3.1em; font: 18px/1.45 Georgia, 'Times New Roman', serif; text-wrap: pretty; }
.talk-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.talk-foot span { font: 12px Georgia, serif; color: #a8946c; }
.talk-foot button { font: 700 14px 'Cinzel', Georgia, serif; letter-spacing: .05em; padding: 8px 20px; border-radius: 6px; border: 1px solid #c9a045; background: #c9a045; color: #20150b; cursor: pointer; }
.talk-foot button:hover { background: #e2bb5c; }
@media (max-width: 520px) { .talk-face { width: 76px; height: 76px; } .talk p { font-size: 16px; } }
.talk-buttons { display: flex; gap: 8px; }
.talk-foot button.quiet { background: transparent; color: #e9d9b4; }
.talk-foot button.quiet:hover { background: rgba(201, 160, 69, .18); }
/* the chess game, opened over this one for a student's challenge */
.chess { position: absolute; inset: 0; z-index: 60; background: #0b0806; display: flex; flex-direction: column; }
.chess[hidden] { display: none; }
.chess-bar { display: flex; justify-content: space-between; align-items: center; padding: calc(8px + var(--safe-t)) 14px 8px; background: linear-gradient(#2b1d12, #17100a); border-bottom: 2px solid #c9a045; color: #f3d27a; font: 700 14px 'Cinzel', Georgia, serif; letter-spacing: .04em; }
.chess-bar button { font: 700 13px 'Cinzel', Georgia, serif; padding: 7px 16px; border-radius: 6px; border: 1px solid #c9a045; background: #c9a045; color: #20150b; cursor: pointer; }
.chess iframe { flex: 1; border: 0; width: 100%; }
