/* Shared type, icon and spacing scales. */
:root {
  --tc-hand: "Toddler Hand", "Toddler Hand Fallback", ui-rounded, "Avenir Next", system-ui, sans-serif;
  --tc-title: clamp(2.125rem, 1.35rem + 3.6vw, 4.4rem);
  --tc-display: clamp(2.15rem, 1.5rem + 3vw, 4rem);
  --tc-heading: clamp(1.45rem, 1.15rem + 1.3vw, 2.35rem);
  --tc-measure: 62ch;
  --tc-gap: clamp(.875rem, .5rem + 1.4vw, 1.75rem);
  --tc-icon-size: 2rem;
  --tc-target: 44px;
  --tc-ink: #495b6b;
  --tc-rose: #d77d76;
  --tc-blue: #79a8d4;
  --tc-gold: #edc56b;
  --tc-leaf: #83b29b;
  --tc-lilac: #ac95bd;
}
:root:not([data-theme="light"]) { --tc-ink: #e4ddf1; }

/* Caveat, copyright the Caveat project authors. License: fonts/caveat-OFL.txt. */
@font-face {
  font-family: "Toddler Hand";
  src: url("fonts/caveat-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+0304, U+0308, U+2000-206F, U+20AC, U+2191, U+2193;
}
@font-face {
  font-family: "Toddler Hand";
  src: url("fonts/caveat-cyrillic-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* A narrower local fallback keeps the accent on the same line on cold loads. */
@font-face {
  font-family: "Toddler Hand Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT");
  font-weight: 700;
  size-adjust: 78%;
}

.tc-header {
  --nav-surface: #fffdf8;
  --nav-hover: #eef0e8;
  --nav-border: #d2d4c8;
  --nav-text: #283933;
  --nav-muted: #536359;
  --nav-focus: #375f8a;
  display: grid;
  grid-template-columns: var(--tc-target) minmax(0, 1fr) auto;
  align-items: center;
  min-height: 56px;
  column-gap: 12px;
}
:root:not([data-theme="light"]) .tc-header {
  --nav-surface: #2b3046;
  --nav-hover: #3a405a;
  --nav-border: #5b627a;
  --nav-text: #f4eee6;
  --nav-muted: #d0cfe0;
  --nav-focus: #e6c680;
}
.tc-header > .tc-brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  margin: 0;
  color: var(--nav-text);
  font-size: clamp(13px, 3.6vw, 17px);
  font-weight: 750;
  letter-spacing: -.025em;
  white-space: nowrap;
}
.tc-header > .tc-brand img { flex: none; width: 42px; height: 40px; margin: 0; object-fit: cover; }
.tc-header > .tc-action { justify-self: end; min-height: 44px; margin: 0; white-space: nowrap; }
.tc-header > .nav-play { display: inline-flex; align-items: center; font-size: 14px; text-decoration: none; }
.tc-header .tc-menu { position: relative; z-index: 12; width: 44px; margin: 0; }
.tc-header .tc-menu > summary {
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--nav-border);
  border-radius: 15px;
  background: transparent;
  color: var(--nav-text);
}
.tc-header .tc-menu > summary::-webkit-details-marker { display: none; }
.tc-header .tc-menu-backdrop {
  position: fixed;
  z-index: 1;
  inset: 0;
  background: #10132370;
  touch-action: none;
}
.tc-header .tc-menu[open] > summary { position: relative; z-index: 3; background: var(--nav-hover); }
.tc-header .tc-menu[open] > summary .tc-menu-lines { background: transparent; }
.tc-header .tc-menu[data-drawer] > summary { z-index: auto; }
.tc-menu[open] > summary .tc-menu-lines::before { top: 0; transform: rotate(45deg); }
.tc-menu[open] > summary .tc-menu-lines::after { top: 0; transform: rotate(-45deg); }
.tc-menu-lines { display: block; position: relative; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
.tc-menu-lines::before, .tc-menu-lines::after { position: absolute; content: ""; left: 0; width: 100%; height: 2px; border-radius: 2px; background: currentColor; }
.tc-menu-lines::before { top: -6px; }
.tc-menu-lines::after { top: 6px; }
.tc-header .tc-menu-panel {
  position: fixed;
  z-index: 2;
  inset: 0 auto 0 0;
  box-sizing: border-box;
  width: min(360px, calc(100vw - 24px));
  max-width: none;
  max-height: none;
  padding: max(10px, env(safe-area-inset-top)) 18px max(12px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: var(--nav-surface);
  color: var(--nav-text);
  border: 0;
  border-radius: 0;
  box-shadow: 12px 0 44px #0c122b30;
}
.tc-header .tc-menu-panel[data-full-drawer] { width: 100%; }
.tc-header .tc-drawer-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; min-height: 44px; font-weight: 750; }
.tc-header .tc-drawer-heading button {
  display: none;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--nav-hover);
  color: inherit;
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}
.tc-header [data-drawer] .tc-drawer-heading button { display: inline-flex; }
.tc-header .tc-menu:not([data-drawer]) .tc-drawer-heading { padding-left: 58px; }
.tc-header .tc-menu-panel nav { display: block; padding: 0; border: 0; }
.tc-header .tc-menu-panel .tc-group + .tc-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--nav-border); }
.tc-header .tc-menu-panel .tc-group-title {
  margin: 5px 0 3px;
  color: var(--nav-muted);
  font-size: .76rem;
  font-weight: 750;
  letter-spacing: .055em;
}
.tc-header .tc-menu-panel .tc-item {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 4px 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--nav-text);
  font: inherit;
  font-size: .96rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.tc-header .tc-menu-panel .tc-item[hidden] { display: none; }
.tc-header .tc-menu-panel .tc-item:hover { background: var(--nav-hover); }
.tc-header .tc-game-links { display: grid; grid-template-columns: minmax(0,1fr); }
.tc-header .tc-game-links [aria-current="true"] { background: var(--nav-hover); font-weight: 750; }
.tc-header .tc-game-links .tc-icon { --tc-icon-size: 1.65rem; }
.tc-header .tc-adult-links { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 8px; }
@media (max-width: 340px) { .tc-header .tc-menu-panel { width: 100%; } }
@media (orientation: landscape) and (max-height: 490px) {
  .tc-header .tc-menu-panel { width: 100%; padding-right: max(18px, env(safe-area-inset-right)); }
  .tc-header .tc-menu-panel nav { display: grid; grid-template-columns: 1fr 1.65fr 1fr; gap: 12px; }
  .tc-header .tc-menu-panel .tc-group + .tc-group { margin: 0; padding: 0 0 0 10px; border: 0; border-left: 1px solid var(--nav-border); }
  .tc-header .tc-adult-links { grid-template-columns: minmax(0,1fr); }
}
.tc-header :is(a, button, summary, select):focus-visible { outline: 2px solid var(--nav-focus); outline-offset: 2px; }
/* One rounded-stroke icon set, sized by its surface. */
.tc-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--tc-icon-size);
  height: var(--tc-icon-size);
  border-radius: .36em;
  font-size: var(--tc-icon-size);
  color: var(--tc-icon-ink);
  background: var(--tc-icon-paper);
}
.tc-icon::before {
  content: "";
  width: 64%;
  aspect-ratio: 1;
  background: currentColor;
  -webkit-mask: var(--tc-icon-drawing) center / contain no-repeat;
  mask: var(--tc-icon-drawing) center / contain no-repeat;
}
.tc-icon--colours {
  --tc-icon-paper: #f3e4cd;
  --tc-icon-ink: #795335;
  --tc-icon-drawing: url("icons/colours.svg");
}
.tc-icon--shapes {
  --tc-icon-paper: #dcebe2;
  --tc-icon-ink: #41665a;
  --tc-icon-drawing: url("icons/shapes.svg");
}
.tc-icon--letters {
  --tc-icon-paper: #eee1f2;
  --tc-icon-ink: #654b77;
  --tc-icon-drawing: url("icons/letters.svg");
}
.tc-icon--bubbles {
  --tc-icon-paper: #deebf6;
  --tc-icon-ink: #3f6384;
  --tc-icon-drawing: url("icons/bubbles.svg");
}
.tc-icon--tap {
  --tc-icon-paper: #f3e4cd;
  --tc-icon-ink: #795335;
  --tc-icon-drawing: url("icons/tap.svg");
}
.tc-icon--replay {
  --tc-icon-paper: #dcebe2;
  --tc-icon-ink: #41665a;
  --tc-icon-drawing: url("icons/replay.svg");
}
.tc-icon--spark {
  --tc-icon-paper: #eee1f2;
  --tc-icon-ink: #654b77;
  --tc-icon-drawing: url("icons/spark.svg");
}

.hero:not(.topic) h1 em, .welcome h1, .journal-intro h1, .login-layout h1, .speech {
  font-family: var(--tc-hand);
  font-weight: 700;
  font-style: normal;
  font-synthesis: none;
  letter-spacing: 0;
}
.hero:not(.topic) h1 em { display: block; font-size: 1.13em; line-height: .96; }
:is(.hero, .journal-intro, .journal-article, .login-layout, .welcome) h1 { text-wrap: balance; }
.journal-intro h1, .login-layout h1 { font-size: var(--tc-display); line-height: 1.06; }
.welcome .game-tile-icon.tc-icon { --tc-icon-size: 2.375rem; }
@media (max-width: 420px) {
  .tc-header { column-gap: 8px; }
  .tc-header > .tc-brand img { width: 35px; height: 36px; }
  .tc-header > .tc-action.nav-play { padding-inline: 11px; }
}

.bar.tc-header { margin-top: 12px; padding-block: 0; }
@media (max-width: 600px) {
  .bar.tc-header, .shell { padding-inline: 20px; }
  .shell { padding-top: 12px; }
  main:has(> .feedback-header.tc-header) { margin-top: 12px; padding-inline: 20px; }
  .app:has(> .tc-header) { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
}

.tc-appearance-button {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  min-height: 44px;
  padding: .55rem .9rem;
  border: 1px solid var(--line, currentColor);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.tc-appearance-button svg { width: 1.25rem; height: 1.25rem; flex: none; }
.tc-appearance-button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
