/* shared/style.css — one stylesheet for Braille Learn, Learn Math(s) and Learn Music.
   Three looks, chosen in Settings (or matched to the scheme):
     theme-sighted  Standard
     theme-adults   Large, high contrast (black / yellow, bigger type)
     theme-kids     Playful
   Every size comes from tokens; nothing scales "all elements by 105%". */

:root {
  --font-main: 'Outfit', 'Inter', -apple-system, system-ui, sans-serif;
  --font-braille: 'Apple Braille', 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'DejaVu Sans', sans-serif;
  --fs-base: 17px;
  --fs-prompt: clamp(2rem, 6vw, 4.5rem);
  --fs-cells: clamp(3rem, 10vw, 6.5rem);
  --fs-feedback: 1.5rem;
  --bg: linear-gradient(135deg, #0f172a, #1e1b4b, #0f172a);
  --surface: rgba(30, 41, 59, 0.6);
  --ink: #f8fafc;
  --muted: #a5b1c2;
  --accent: #a78bfa;
  --accent-ink: #0f172a;
  --line: rgba(255, 255, 255, 0.18);
  --ok: #4ade80;
  --bad: #f87171;
  --braille-color: #c084fc;
  --radius-btn: 8px;
  --radius-panel: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --header-bg: rgba(15, 23, 42, 0.9);
  --blur: 12px;
  --speed: 0.25s;
}
body.theme-kids {
  --muted: #d4dbe6;
  --line: rgba(255, 255, 255, 0.22);
  --braille-color: #22d3ee;
  --radius-btn: 28px;
  --radius-panel: 28px;
  --font-main: 'Outfit', 'Comic Sans MS', sans-serif;
  --fs-base: 18px;
}
body.theme-adults {
  --ink: #ffffff;
  --muted: #d1d5db;
  --accent-ink: #000000;
  --line: #ffffff;
  --braille-color: #facc15;
  --radius-btn: 4px;
  --radius-panel: 4px;
  --shadow: none;
  --header-bg: #000000;
  --blur: 0px;
  --speed: 0s;
  --fs-base: 20px;
  --fs-prompt: clamp(2.6rem, 7vw, 5.5rem);
  --fs-cells: clamp(3.5rem, 11vw, 7.5rem);
  --fs-feedback: 1.75rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-main);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--bg);
  background-size: 400% 400%;
  animation: bgPan 24s ease infinite;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@keyframes bgPan { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
body.theme-adults { animation: none; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 200; background: var(--ink); color: var(--accent-ink); padding: 8px 14px; border-radius: 6px; font-weight: 700; }
.skip:focus { top: 8px; }

/* ---------------------------------------------------------------- header */
header {
  position: relative; z-index: 50; flex: 0 0 auto;
  padding: 12px 20px;
  background: var(--header-bg);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--line);
}
.head-row { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .app-logo { width: 56px; height: 56px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; justify-content: center; }
.brand h1 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; }
.brand .sub { margin: 0; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.head-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-nav { display: flex; gap: 6px; }
.app-nav a { display: inline-flex; align-items: center; text-decoration: none; }
@media (max-width: 720px) { .head-right { margin-left: 0; width: 100%; } .brand .sub { display: none; } .brand .app-logo { width: 36px; height: 36px; } }

.icon-btn, .pill-btn, .btn {
  min-height: 42px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-btn); cursor: pointer; font: inherit; font-weight: 600;
  padding: 0 14px; transition: background var(--speed), color var(--speed);
  box-shadow: var(--shadow);
}
.icon-btn { width: 42px; padding: 0; font-size: 1.4rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover, .pill-btn:hover, .btn:hover { background: var(--ink); color: var(--accent-ink); border-color: var(--ink); }
.pill-btn.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; }

.hud { display: flex; gap: 10px; font-weight: 800; font-size: 1.05rem; align-items: center; }
.score-box, .timer-box { background: var(--surface); padding: 6px 14px; border-radius: 20px; border: 1px solid var(--line); font-variant-numeric: tabular-nums; transition: transform 0.2s; }
.score-box { color: var(--ink); }
.score-box.bump { transform: scale(1.15); }
.timer-box.urgent { color: var(--bad); border-color: var(--bad); }

/* ---------------------------------------------------------------- layout */
.panes { flex: 1 1 auto; min-height: 0; display: flex; padding: 16px; max-width: 1200px; margin: 0 auto; width: 100%; }
.pane {
  flex: 1 1 0; min-width: 0; min-height: 0;
  background: var(--surface);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line); border-radius: var(--radius-panel);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.home-screen { flex: 1 1 auto; min-height: 0; overflow: hidden; padding: clamp(10px, 2vh, 18px); display: flex; flex-direction: column; }
.activity-grid {
  display: grid;
  gap: clamp(8px, 2vh, 14px);
  max-width: 1200px; margin: 0 auto;
  width: 100%; height: 100%;
}
@media (orientation: landscape) { .activity-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); } }
@media (orientation: portrait) { .activity-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); } }

.activity-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: clamp(12px, 3vmin, 24px) clamp(10px, 2vmin, 20px); cursor: pointer; text-align: center; color: var(--ink); font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: clamp(6px, 1.5vmin, 12px); 
  min-height: 0; height: 100%;
  transition: border-color var(--speed), transform var(--speed);
}
.activity-card:hover { border-color: var(--ink); transform: translateY(-2px); }
.activity-card.unsuitable { opacity: 0.55; }
.activity-card .activity-icon { font-size: clamp(2.5rem, 10vmin, 7rem); line-height: 1; margin: 0 auto clamp(8px, 2.5vmin, 20px); }
.activity-card h3 { font-size: clamp(1rem, 3.5vmin, 2rem); font-weight: 800; margin: 0; color: var(--accent); }
.activity-card p { font-size: clamp(0.75rem, 2.2vmin, 1.2rem); color: var(--muted); margin: 0; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.activity-card .suits { font-size: clamp(0.6rem, 1.5vmin, 1rem); color: var(--muted); margin-top: auto; padding-top: 4px; }
.activity-card.unsuitable .suits { color: var(--bad); }

.pane-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 20px; display: flex; flex-direction: column; align-items: center; }
.pane-body:focus-visible { outline-offset: -3px; }
.game-ui { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; flex: 1 1 auto; width: 100%; min-height: 0; gap: 10px; }
.prompt { font-size: var(--fs-prompt); font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; text-wrap: balance; max-width: 18ch; }
.prompt.long { font-size: clamp(1.4rem, 4vw, 2.4rem); max-width: 30ch; font-weight: 700; }
.braille-input { font-family: var(--font-braille); font-size: var(--fs-cells); color: var(--braille-color); line-height: 1.1; min-height: 1.1em; word-break: break-all; }
.braille-input .ok { color: var(--ok); }
.braille-input .bad { color: var(--bad); }
.feedback { font-size: var(--fs-feedback); font-weight: 700; color: var(--bad); min-height: 1.6em; max-width: 30ch; }
.feedback.correct { color: var(--ok); }
.feedback.reveal { color: var(--ink); }
.reveal-cells { font-family: var(--font-braille); color: var(--braille-color); font-size: 1.3em; }
.progress { color: var(--muted); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.replay { font-size: 1.1rem; margin-bottom: 6px; }

.cell-diagram { display: inline-grid; grid-template-columns: repeat(2, 30px); grid-auto-rows: 30px; gap: 10px; margin: 6px 0; }
.cell-diagram .dot { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--braille-color); background: transparent; }
.cell-diagram .dot.on { background: var(--braille-color); }
.cell-diagram .dot.missing { border-style: dashed; border-color: var(--muted); }

.passage-display { font-size: clamp(1.4rem, 4vw, 2.4rem); font-weight: 600; max-width: 30ch; line-height: 1.4; }
.transcription-input { font-size: clamp(2rem, 6vw, 3.6rem); max-width: 100%; word-break: break-all; }

.invader-zone { flex: 1 1 auto; width: 100%; min-height: 240px; position: relative; border-bottom: 3px dashed var(--line); border-radius: 12px; overflow: hidden; }
.invader {
  position: absolute; top: 0; font-size: clamp(1.4rem, 4vw, 2.2rem); font-weight: 800; color: var(--ink);
  padding: 4px 12px; background: var(--surface); border-radius: 8px; border: 2px solid var(--ink); will-change: transform; white-space: nowrap;
}
.invader.hit { animation: hit 0.3s forwards; }
@keyframes hit { to { opacity: 0; transform: scale(1.6); } }

#printNotationContainer { flex: 0 0 auto; width: 100%; max-width: 640px; margin-bottom: 12px; }
#staffHolder { width: 100%; display: flex; justify-content: center; }
#printNotationContainer svg { max-width: 100%; max-height: 160px; width: auto; height: auto; background: #fff; border-radius: 8px; }

/* ---------------------------------------------------------------- dialogs */
dialog {
  max-width: 680px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: var(--radius-panel);
  padding: 0; color: var(--ink); background: var(--surface); font-size: var(--fs-base);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}
body.theme-adults dialog { background: #000; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.help-head h2 { margin: 0; font-size: 1.25rem; font-weight: 800; }
.help-body { padding: 8px 22px 22px; max-height: 72vh; overflow: auto; line-height: 1.55; }
.help-body h3 { margin: 22px 0 8px; font-size: 1rem; color: var(--ink); font-weight: 700; }
.help-body p, .help-body li { max-width: 68ch; }
.help-body ul { padding-left: 22px; }
.settings-body label { display: block; margin: 10px 0 4px; font-weight: 600; }
.settings-body label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.settings-body select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 8px; font: inherit; }
.settings-body select option { background: #fff; color: #000; }
.settings-body .btn { margin-top: 8px; }
.settings-body .hint { color: var(--muted); font-size: 0.9rem; margin: 2px 0 0; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding: 14px 22px 22px; }
#gameOverDialog { text-align: center; max-width: 440px; }
#gameOverDialog h2 { font-size: 2.4rem; margin: 26px 0 8px; }
#gameOverDialog p { font-size: 1.3rem; color: var(--muted); margin: 0 0 8px; }
#gameOverDialog strong { color: var(--ink); font-size: 1.6rem; }
#gameOverDialog .dialog-actions { justify-content: center; }

table.keys { border-collapse: collapse; margin: 12px 0; }
table.keys th { text-align: right; padding: 4px 12px 4px 0; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; }
table.keys td { padding: 6px 12px; text-align: center; border: 1px solid var(--line); font-weight: 600; min-width: 40px; }
table.keys td.gap { border: 0; width: 20px; }

/* editor */
.editor-rows { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 46vh; padding: 0 22px; }
.editor-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 8px; align-items: center; }
.editor-row input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, 0.06); color: var(--ink); font: inherit; min-width: 0; }
.editor-row input.editor-braille { font-family: var(--font-braille); font-size: 1.25rem; }
.editor-row input.invalid { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.editor-del-btn { background: transparent; color: var(--bad); border: 1px solid var(--bad); border-radius: 6px; width: 38px; height: 38px; cursor: pointer; font-size: 1.1rem; }
.editor-del-btn:hover { background: var(--bad); color: #fff; }
.editor-errors { color: var(--bad); font-weight: 600; padding: 6px 22px; }
@media (max-width: 600px) { .editor-row { grid-template-columns: 1fr 1fr; } .editor-row input:nth-child(3) { grid-column: 1; } }

/* status bar */
#statusBar { flex: 0 0 auto; display: flex; align-items: center; opacity: 0.7; font-size: min(1em, 2.8vh); margin: min(4px, 0.6vh) 0 min(10px, 1.4vh); background: transparent; border: none; padding: 0 20px; color: inherit; }
#levelNameDisplay { font-weight: 700; text-align: left; padding-right: 10px; flex: 0 0 auto; min-width: 0; }
#statusText { flex: 1 1 auto; text-align: center; white-space: nowrap; }

/* Settings button inside header */
.settings-btn {
  border: none; background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--accent); width: 64px; height: 64px; min-width: 64px; min-height: 64px;
  border-radius: 50%; display: grid; place-items: center; padding: 0;
  flex: 0 0 auto; transition: background var(--speed), color var(--speed); cursor: pointer;
}
.settings-btn svg { width: 72%; height: 72%; }
.settings-btn:hover { background: color-mix(in srgb, var(--ink) 16%, transparent); color: var(--ink); }
