/* --- study: one card at a time ------------------------------------------ */

kbd.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--chip);
  color: var(--chip-ink);
  font: 500 11px/1 var(--font-body);
}

.study {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 0 32px;
}

/* The title and the way out, and under them the track. On a phone the bar is
   one row that stays put (below). */
.study-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px 16px;
}

.study-bar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

.study-bar .study-close {
  grid-column: 2;
  grid-row: 1;
}

.study-bar .track {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--line-soft);
}

.study-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Under the track as it was when they shared a block. */
  margin-top: -12px;
}

.study-bar .track > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.study-progress .counts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--muted);
  font-size: 13px;
}

.study-progress .counts span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.study-progress .counts .c-new .dot { color: var(--dash); }
.study-progress .counts .c-learning .dot { color: var(--learning); }
.study-progress .counts .c-due .dot { color: var(--accent); }

/* The card holds its room whether the answer is shown or not: showing it
   moves nothing above it. */
.study-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: 340px;
  padding: 28px 32px 28px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.study-card .study-source {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.study-card .study-front {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.study-card .study-divider {
  width: 100%;
  max-width: 420px;
  border: 0;
  border-top: 1px dashed var(--dash);
}

.study-card .study-back {
  color: var(--ink-soft);
  font-size: 24px;
  overflow-wrap: anywhere;
}

.study-card .study-back.hidden,
.study-card .study-divider.hidden {
  visibility: hidden;
}

/* The controls under the card: the button that shows the answer, then the
   four that grade it. */
.study-dock {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.study-dock .study-reveal {
  align-self: center;
}

.grade-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

button.grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 8px 10px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-btn);
}

button.grade:hover:not(:disabled) {
  border-color: var(--accent);
}

button.grade .grade-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

button.grade .grade-when {
  min-height: 1.3em;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

button.grade.again .grade-name {
  color: var(--danger);
}

button.grade.good {
  border-color: var(--accent);
}

.study-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.study-keys span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* The end of a session. */
.study-result {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 28px 24px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.study-result h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
}

.study-result .result-grades {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.study-result .result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

@media (max-width: 760px) {
  .study-card {
    min-height: 300px;
    padding: 20px 16px;
  }

  .study-card .study-front {
    font-size: 32px;
  }

  .study-card .study-back {
    font-size: 20px;
  }

  .grade-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button.grade {
    min-height: 56px;
  }

  /* The page is as tall as the screen at least, so the controls rest at its
     foot even when the card is short, and need no room under them. */
  .content.study-page {
    min-height: calc(100vh - 57px);
    min-height: calc(100dvh - 57px);
    padding-bottom: 0;
  }

  .study-page .study {
    flex: 1 1 auto;
    padding-bottom: 0;
  }

  /* Only the track and the way out stay in view as the card scrolls, under
     the top bar: not the title (the top bar has it), nor the counts. */
  .study-bar {
    position: sticky;
    top: 56px;
    z-index: 10;
    display: flex;
    gap: 12px;
    margin-inline: -16px;
    padding: 6px 16px;
    background: var(--bg);
  }

  .study-bar h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .study-bar .track {
    flex: 1 1 auto;
  }

  .study-bar .study-close {
    margin-left: auto;
  }

  .study-progress {
    margin-top: 0;
  }

  /* Always in view, whichever way the card scrolls; its own ground, so the
     card goes under it, and clear of the phone's home bar. */
  .study-dock {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-top: auto;
    margin-inline: -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: var(--border-w) solid var(--line);
    background: var(--bg);
  }

  .study-dock .study-reveal {
    align-self: stretch;
    min-height: 56px;
  }

  /* No keyboard under the thumb: the hint goes. */
  .study-keys {
    display: none;
  }
}

/* A link that is the page's main action, drawn as the main button is. */
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: var(--border-w) solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

a.button:hover {
  background: var(--accent-hover);
}
