/* Flashcards in the notebooks: the card itself, and the note under it (js/shared/cards.js turns and slides it) */

.fcard {
  transform-origin: 50% 50%;
  backface-visibility: hidden;
}
/* a writing card: the writing box, or the two boxes side by side once it is turned over */
.fcard:not(.wcf):not(.pcard) {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 14px;
  width: 100%;
}
/* a kanji card shows the meaning and readings once turned over: the writing side keeps that much room too */
.fcard.tall {
  min-height: 21.5rem;
}
/* the row of buttons under a card is one fixed height, empty or not, face down or face up. A word or kanji card has no
   row before it turns over, so the note under it keeps that room (the row and the 18px gap): nothing moves when it
   turns (a phrase card has no row on either side) */
.fcard + .acts {
  min-height: 44px;
}
.fcard.wcf:not(.back) + .fhint {
  margin-top: calc(44px + 18px);
}
/* a word card: a real card, the word in the middle */
.fcard.wcf {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  width: min(100%, 24rem);
  /* the same height face down and face up, so nothing around it moves when it turns over */
  min-height: 16.5rem;
  margin: 4px auto 0;
  padding: 30px 22px 34px;
  border: 1px solid var(--rule);
  border-radius: 18px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow:
    0 1px 3px rgba(10, 16, 14, 0.06),
    0 18px 40px -20px rgba(10, 16, 14, 0.4);
  transition:
    transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.2s;
}
.fcard.wcf .kword {
  margin: 0;
}
/* face down, the word is all there is: large, shrinking for a long word (--n, its length) and for a narrow card
   (cqi: the card's width) so it stays on one line */
button.fcard.wcf {
  container-type: inline-size;
}
button.fcard.wcf .kword {
  font-size: clamp(2.4rem, calc(19rem / var(--n, 2)), 5.5rem);
  font-size: min(5.5rem, calc(19rem / var(--n, 2)), calc(90cqi / var(--n, 2)));
  line-height: 1.1;
}
.fcard.wcf .mean {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
}
.fcard.wcf .frd {
  color: var(--ink-2);
}
/* a card for one kana, kanji, hanzi or letter keeps it large once turned over */
.fcard.wcf.one .kword {
  font-size: 3.6rem;
  line-height: 1.1;
}
@media (hover: hover) {
  button.fcard:hover {
    transform: translateY(-2px);
    box-shadow:
      0 2px 6px rgba(10, 16, 14, 0.08),
      0 24px 48px -20px rgba(10, 16, 14, 0.45);
  }
}
button.fcard:active,
button.fcard.pressing {
  transform: scale(0.98);
  transition-duration: 0.08s;
}
.fcard.back {
  cursor: pointer;
}
/* the small "Tap to flip" in the card's corner */
.fcard .fcorner {
  position: absolute;
  right: 14px;
  bottom: 10px;
  font: 600 0.66rem/1 var(--f-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  opacity: 0.8;
}
.fcard.pcard {
  position: relative;
  min-height: 15.5rem;
}
/* the longest phrases with a note need a little more room on the smallest phones, or the card grows when it turns */
@media (max-width: 360px) {
  .fcard.pcard {
    min-height: 17rem;
  }
}

/* on a phone the buttons under a turned card (Stroke order, Open for each character) stay on one row; when there
   are too many for the screen, the row scrolls sideways rather than taking a second line */
@media (max-width: 520px) {
  .fcard.back + .acts {
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: safe center;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .fcard.back + .acts .btn {
    flex: none;
  }
  .fcard.back + .acts .btn {
    padding: 8px 10px;
    font-size: 0.86rem;
  }
}

/* a word written across several boxes: once turned over, your writing is drawn over the faint correct word in one
   box the size of the writing box; on the writing side the same room is kept, unseen, so the card keeps its height */
.ovl {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
}
.ovl .pad .gw {
  color: var(--accent);
  opacity: 0.35;
}
.ovl .mine-over {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ovl .mine-over path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ovcap {
  margin: 0;
  text-align: center;
}
/* a box of several characters (a Chinese word, a sound of two kana such as ぴゅ): each one has a square of its own
   with the dashed cross, the squares parted by a solid line, as on workbook paper */
.sq.wide {
  background: var(--surface);
}
.sq .cells {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}
.sq .cells i {
  flex: 1;
  background:
    linear-gradient(90deg, var(--grid) 50%, transparent 0) center/10px 1px repeat-x,
    linear-gradient(0deg, var(--grid) 50%, transparent 0) center/1px 10px repeat-y;
}
.sq .cells i + i {
  border-left: 1.5px solid var(--grid);
}
/* the right answer as text, one character in the middle of each square */
.sq .gw {
  font-size: calc(60cqi / var(--n, 1));
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
}
.pad .gw {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  pointer-events: none;
}
.pad .gw > span {
  flex: 1;
  text-align: center;
}
.pad.hasso .gw {
  visibility: hidden;
}
.spacer {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
  visibility: hidden;
}

/* the note under the card: what to do, Skip, or "Tap anywhere to continue" */
.fhint {
  text-align: center;
  /* room for two lines on both sides of the card, so the box keeps its height when the note changes */
  min-height: calc(2 * 1.5em);
  line-height: 1.5;
}
.fhint .tlnk {
  margin-left: 6px;
}
.ftap {
  letter-spacing: 0.02em;
  animation: ftapin 0.6s 0.25s ease-out both;
}
@keyframes ftapin {
  from {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ftap {
    animation: none;
  }
  .fcard.wcf {
    transition: none;
  }
}
