/* Trainer chrome. Scoped to this page's three blocks.
   The page itself does not scroll; a block scrolls only when its own content does. */

.trainer > .block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
  overflow: hidden;
  text-align: left;
}

.trainer-list .path {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  margin: 0;
  overflow: auto;
  font-size: 0.95rem;
}

.trainer-list .path span {
  white-space: nowrap;
}

.trainer-list .path .now {
  color: #7f1d1d;
  font-weight: 700;
}

.trainer-list .path .lock {
  color: #b0a8a4;
}

.trainer .forget {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 0.6rem;
  padding: 0;
  border: 0;
  background: none;
  color: #8a8580;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
}

.trainer .forget:hover {
  color: #7f1d1d;
  text-decoration-color: crimson;
}

.trainer-field {
  overflow: hidden;
  gap: 0.25rem;
}

.trainer-field .field-head {
  flex: 0 0 auto;
  overflow: visible;
}

.field-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.8rem;
}

.field-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.trainer .info-btn {
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: 1px solid rgba(220, 20, 60, 0.45);
  border-radius: 50%;
  background: #fff;
  color: var(--accent-dark);
  font-family: var(--italicfont);
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.trainer .info-btn[aria-expanded="true"] {
  background: var(--accent-dark);
  color: #fff;
}

.trainer .info-pop {
  position: fixed;
  z-index: 6;
  width: max-content;
  max-width: min(18rem, calc(100vw - 1rem));
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.45;
  text-align: left;
  opacity: 0;
  transition: opacity 0.7s ease;
}

.trainer .info-pop.is-in {
  opacity: 1;
}

.trainer .info-pop .sentence,
.trainer .info-pop .crumb,
.trainer .info-pop .note,
.trainer .info-pop .moves {
  margin: 0;
}

.trainer .info-pop .sentence + .crumb,
.trainer .info-pop .sentence + .moves,
.trainer .info-pop .sentence + .note,
.trainer .info-pop .crumb + .moves,
.trainer .info-pop .crumb + .note,
.trainer .info-pop .moves + .note {
  margin-top: 0.4rem;
}

@media (prefers-reduced-motion: reduce) {
  .trainer .info-pop {
    transition: none;
  }
}

.trainer .modes {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  margin: 0;
  padding: 0.12rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.trainer .modes button {
  padding: 0.12rem 0.6rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.3;
  cursor: pointer;
}

.trainer .modes button.is-on {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(220, 20, 60, 0.35);
}

.trainer .mode-tip {
  position: fixed;
  z-index: 5;
  width: max-content;
  max-width: 16rem;
  margin: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: left;
  pointer-events: none;
}

.trainer .script {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.trainer .script-line {
  margin: 0.15rem 0;
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  letter-spacing: 0.04em;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.trainer .script-line.done {
  color: #7f1d1d;
}

.trainer .script-line.rest {
  color: rgba(0, 0, 0, 0.38);
}

.trainer .script-line .done {
  color: #7f1d1d;
}

.trainer .script-line .now {
  border-bottom: 2px solid crimson;
}

.trainer .script-line .rest {
  color: rgba(0, 0, 0, 0.45);
}

.trainer-field h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.15;
  color: #7f1d1d;
}

.trainer .kicker {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: #8a3b3b;
}

.trainer .sentence,
.trainer .crumb,
.trainer .note,
.trainer .progress,
.trainer .drill-text {
  margin: 0.15rem 0;
}

.trainer .crumb {
  color: #7f1d1d;
}

.trainer .moves {
  margin: 0.2rem 0;
  padding-left: 1.2rem;
}

.trainer .moves li::marker {
  content: counter(list-item) ". ";
  color: #7f1d1d;
}

.trainer-board {
  align-items: stretch;
  justify-content: center;
  overflow: auto;
}

.trainer .board {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin: 0;
  user-select: none;
}

.trainer .board-row {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  gap: 0.28rem;
}

.trainer .board-row-space {
  flex: 0.7 1 0;
  padding-left: 18%;
  padding-right: 18%;
}

.trainer .key {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  height: auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 0.28rem;
  background: #fff;
  color: inherit;
  font-family: var(--boldfont);
  font-weight: 700;
  font-size: clamp(1.15rem, 3.8vh, 1.75rem);
  line-height: 1;
  cursor: pointer;
}

.trainer .key.is-space {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.trainer .key.is-rest {
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.trainer .key.is-bump::after {
  content: "";
  position: absolute;
  bottom: 0.22rem;
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 50%;
  background: #111;
}

.trainer .key.is-next {
  color: #1c1408;
  border-color: transparent;
  animation: trainer-next 1.8s ease-in-out infinite;
}

.trainer .key.is-reject {
  background: #d42020;
  color: #fff;
  border-color: transparent;
  animation: none;
}

.trainer .key.is-trail {
  border-color: transparent;
  animation: trainer-ok 700ms ease forwards;
}

@keyframes trainer-next {
  0%, 100% { background-color: #f0c84a; }
  50% { background-color: #ffe7a3; }
}

@keyframes trainer-ok {
  0%, 45% { background-color: #2f9e44; color: #fff; }
  100% { background-color: #fff; color: #1c1408; }
}

@media (prefers-reduced-motion: reduce) {
  .trainer .key.is-next,
  .trainer .key.is-trail {
    animation: none;
  }

  .trainer .key.is-next {
    background: #f0c84a;
  }

  .trainer .key.is-trail {
    background: #2f9e44;
    color: #fff;
  }
}
