/* Navigation drawer and contextual glossary, independent of the game layout. */
body:has(dialog[open]) {
  overflow: hidden;
}
dialog {
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  padding: 0;
  box-shadow: 0 12px 80px #102b3740;
}
dialog::backdrop {
  background: #10232d8a;
}
.main-nav {
  display: block;
  margin: 0;
}
.main-nav .button {
  min-width: 0;
  flex: none;
}
.header-inner .main-nav {
  flex: none;
}
#quick-menu-toggle {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
  padding: 10px 18px;
}
.quick-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(390px, 92vw);
  max-width: 92vw;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0 16px 16px 0;
  border: 0;
  overflow: auto;
}
.drawer-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--teal);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
}
.drawer-header h2 {
  font-size: 1.35rem;
}
.drawer-header .button {
  width: 46px;
  padding: 0;
  background: transparent;
  border-color: #ffffff70;
  color: white;
  font-size: 1.5rem;
}
.drawer-content {
  padding: 8px 20px 28px;
}
.drawer-section {
  font-size: 1rem;
  padding: 18px 0 10px;
}
.drawer-links {
  display: grid;
  gap: 5px;
}
.drawer-link {
  display: block;
  text-align: left;
  justify-content: flex-start;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  font-weight: 500;
  min-height: 46px;
}
.drawer-link:hover {
  background: var(--teal-soft);
}
.drawer-chapter {
  border-top: 1px solid var(--line);
  padding: 4px 0;
}
.drawer-chapter > summary,
.drawer-exercises > summary {
  min-height: 46px;
  padding: 12px 4px;
  cursor: pointer;
  font-weight: 600;
}
.drawer-chapter > .drawer-links {
  padding-left: 14px;
}
.drawer-exercises {
  font-size: 0.9rem;
}
.drawer-exercises > .drawer-links {
  border-left: 2px solid var(--line);
  padding-left: 8px;
}
.definition-link {
  display: inline;
  border: 0;
  border-bottom: 1px dotted var(--teal);
  border-radius: 0;
  background: transparent;
  color: var(--teal);
  font: inherit;
  line-height: inherit;
  font-weight: inherit;
  padding: 0;
  min-height: 0;
  cursor: pointer;
  text-align: inherit;
}
.definition-link:hover {
  background: var(--teal-soft);
  border-bottom-style: solid;
}
.definition-link:focus-visible {
  outline-offset: 2px;
}
.word-with-definition {
  display: inline-flex;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
}
.word-with-definition > .button:first-child {
  flex: 1;
  min-width: 0;
}
.definition-info {
  flex: none;
  display: grid;
  place-items: center;
  align-self: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--teal);
  font-weight: 700;
  cursor: pointer;
  font-style: italic;
}
.definition-info:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
}
.matching-words .word-with-definition {
  width: 100%;
}
.matching-words .definition-info {
  font-size: 0.85rem;
  width: 36px;
  height: 44px;
  border-radius: 9px;
}
.choice-grid .word-with-definition {
  width: 100%;
}
.definition-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(720px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: 90dvh;
  border-radius: 18px;
  overflow: auto;
}
.definition-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
}
.definition-header h2 {
  font-size: 1.5rem;
}
.definition-header > .button {
  flex: none;
  width: 44px;
  padding: 0;
  font-size: 1.5rem;
}
.definition-body {
  padding: 10px 24px 24px;
}
.definition-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  background: white;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}
.definition-body > .illustration {
  margin-top: 18px;
}
.definition-body .definition-link {
  font-weight: inherit;
}
@media (max-width: 560px) {
  .header-inner {
    gap: 12px;
  }
  .header-inner h1 {
    font-size: 1rem;
  }
  #quick-menu-toggle {
    font-size: 0.85rem;
    padding: 10px 12px;
  }
  .main-nav {
    display: block;
  }
  .definition-header {
    padding: 14px 16px;
  }
  .definition-body {
    padding: 8px 16px 20px;
  }
  .definition-footer {
    padding: 14px 16px;
  }
  .definition-header h2 {
    font-size: 1.25rem;
  }
  .matching-words .word-with-definition {
    flex-wrap: wrap;
  }
  .matching-words .definition-info {
    height: 44px;
    width: 44px;
    border-radius: 50%;
    min-height: 44px;
  }
  .matching-words .word-with-definition > .button:first-child {
    flex-basis: 100%;
  }
  .word-pool .word-with-definition {
    max-width: 100%;
  }
}

/* Short drawer movement; touch devices retain the Menu button. */
.quick-drawer[open] {
  animation: drawer-enter 200ms ease-out;
}
.quick-drawer[open]::backdrop {
  animation: drawer-backdrop-enter 200ms ease-out;
}
.drawer-link {
  transition:
    background-color 140ms ease,
    color 140ms ease;
}
@keyframes drawer-enter {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes drawer-backdrop-enter {
  from {
    background: transparent;
  }
  to {
    background: #10232d8a;
  }
}
@media (prefers-reduced-motion: reduce) {
  .quick-drawer[open],
  .quick-drawer[open]::backdrop {
    animation: none;
  }
  .drawer-link {
    transition: none;
  }
}

