/* BoboEdu: app-shell.css
   Global typography, shared buttons and forms, navigation, account menu and page frame.
   Design tokens are defined in theme.css, loaded before this file. */

.tint-psychology,
body[data-subject='psychology'] {
  --tint: var(--hl-psychology);
}
.tint-sociology,
body[data-subject='sociology'] {
  --tint: var(--hl-sociology);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
}
img {
  max-width: 100%;
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
[tabindex='-1']:focus {
  outline: none;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--ink);
  text-wrap: balance;
}
.noscript {
  margin: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- Buttons: chunky and pressable, because this is a game ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--line-strong);
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    background-color 0.15s;
}
.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--line-strong);
}
.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
  box-shadow: 0 3px 0 var(--ink-edge);
}
.btn.primary:active:not(:disabled) {
  box-shadow: 0 0 0 var(--ink-edge);
  transform: translateY(3px);
}
.btn.big {
  min-height: 54px;
  padding: 12px 22px;
  font-size: 17px;
  border-radius: 14px;
}
.btn.small {
  min-height: 40px;
  padding: 7px 14px;
  font-size: 15px;
  border-radius: 10px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}
@media (hover: hover) {
  .btn:not(:disabled):not(.primary):hover {
    background: var(--accent-soft);
  }
  .btn.primary:not(:disabled):hover {
    background: color-mix(in srgb, var(--ink) 88%, var(--accent));
  }
}
.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* Appearance control: visible in the header and in the sign-in dialog. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  flex: none;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.theme-toggle[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
@media (hover: hover) {
  .theme-toggle:hover {
    border-color: var(--accent);
  }
}
.group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.note {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  max-width: 64ch;
}
.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font: inherit;
}

/* Segmented switches (games, shop tabs, leaderboard period) */
.modes {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 4px;
  gap: 4px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.mode {
  min-height: 42px;
  padding: 8px 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.mode[aria-pressed='true'] {
  background: var(--tint);
  color: var(--on-hl);
  box-shadow: inset 0 -3px 0 rgba(29, 32, 66, 0.14);
}
@media (hover: hover) {
  .mode[aria-pressed='false']:hover {
    color: var(--ink);
    background: var(--bg);
  }
}
.modes.small .mode {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

/* ---------- The frame ---------- */
.app {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 0 var(--gutter) calc(48px + env(safe-area-inset-bottom, 0px));
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px 22px;
  margin: 0 calc(-1 * var(--gutter));
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter) 10px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1.5px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.brand svg {
  width: 38px;
  height: 38px;
  flex: none;
  transform-origin: 50% 90%;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .brand:hover svg {
    animation: nod 0.9s ease-in-out;
  }
}
@keyframes nod {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-12deg);
  }
  60% {
    transform: rotate(9deg);
  }
  85% {
    transform: rotate(-3deg);
  }
}

.mainnav {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
}
.mainnav button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.mainnav svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.mainnav button[aria-current='page'] {
  background: var(--tint);
  color: var(--on-hl);
  box-shadow: inset 0 -3px 0 rgba(29, 32, 66, 0.14);
}
@media (hover: hover) {
  .mainnav button:not([aria-current='page']):hover {
    color: var(--ink);
    background: var(--surface);
  }
}

.me {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-left: auto;
}
.streakchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 4px 12px 4px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.streakchip svg {
  width: 22px;
  height: 22px;
  color: var(--line-strong);
}
.streakchip.lit {
  color: var(--ink);
}
.streakchip.lit svg {
  color: var(--flame);
}
.wallet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.wallet svg {
  width: 26px;
  height: 26px;
  flex: none;
}
.wallet.bump {
  animation: bump 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes bump {
  40% {
    transform: scale(1.18);
  }
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--ink);
  color: var(--surface);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  box-shadow: 0 3px 0 var(--ink-edge);
}
.avatar[aria-expanded='true'] {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink-edge);
}

.accountmenu {
  position: fixed;
  z-index: 35;
  top: calc(70px + env(safe-area-inset-top, 0px));
  right: max(16px, calc((100vw - 1160px) / 2 + 16px));
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  max-height: calc(
    100dvh - 100px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
  );
  overflow-y: auto;
  overscroll-behavior: contain;
}
.accountmenu p {
  margin: 0;
}
.accountmenu .who {
  font-size: 17px;
}
.accountmenu .savestate {
  font-size: 14px;
  color: var(--muted);
}
.accountmenu .field input {
  min-height: 44px;
}

.confirmbar {
  display: flex;
  gap: 10px 16px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--hl);
  color: var(--on-hl);
  font-size: 16px;
}
.confirmbar p {
  margin: 0;
  flex: 1 1 260px;
}
.confirmbar .btn:not(.primary) {
  background: #fff8cc;
  border-color: rgba(29, 32, 66, 0.25);
  color: var(--on-hl);
}

/* Form fields (sign-in, PIN change) */
.field {
  display: grid;
  gap: 6px;
}
.field label {
  font-weight: 700;
  font-size: 15px;
}
.field input {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--muted);
  background: var(--surface);
  font-size: 18px;
}
.field input[type='password'],
.field input[inputmode='numeric'] {
  letter-spacing: 0.3em;
  font-family: var(--font-display);
  font-weight: 700;
}
.field input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field input[aria-invalid='true'] {
  border-color: var(--bad);
}
.autherror {
  margin: 0;
  min-height: 1.5em;
  color: var(--bad);
  font-weight: 700;
  font-size: 15px;
}
.autherror.note {
  color: var(--muted);
  font-weight: 400;
}
.autherror:empty {
  min-height: 0;
}

/* Play area: the subject's name is marked with its highlighter */
.play {
  display: grid;
  gap: 22px;
}
.subhead {
  display: grid;
  gap: 12px;
  padding-top: 8px;
}
.subhead .titles {
  display: grid;
  gap: 4px;
  justify-items: start;
}
.subhead h1 {
  margin: 0 0 0 -0.1em;
  padding: 0 0.1em;
  font-weight: 800;
  font-size: clamp(34px, 5vw, 50px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  --heading-highlight: color-mix(
    in srgb,
    var(--tint) var(--heading-highlight-strength),
    var(--surface)
  );
  background: linear-gradient(
    to top,
    transparent 0.06em,
    var(--heading-highlight) 0.06em 0.44em,
    transparent 0.44em
  );
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.subhead .course {
  margin: 0;
  color: var(--muted);
}
.subhead .modes {
  justify-self: start;
}
.lede {
  color: var(--muted);
  margin: 0;
  max-width: 68ch;
}
