/* Words page: flashcard drill and the index-card list. Loads after site.css. */

/* part-of-speech colours */
.pos-noun         { --pos: var(--c4); }
.pos-adjective    { --pos: var(--c6); }
.pos-verb         { --pos: var(--c0); }
.pos-adverb       { --pos: var(--c5); }
.pos-interjection { --pos: var(--c2); }

.pos-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--pos, var(--c2));
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.6;
}

.hero-words {
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: 32px;
}

.lede {
  margin: 0;
  max-width: 34em;
  font-size: 20px;
  font-weight: 500;
  color: var(--chalk-dim);
}

.ghost {
  font: inherit;
  font-weight: 700;
  color: var(--chalk);
  background: transparent;
  border: 2px solid rgba(255, 248, 236, 0.35);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms;
}

.ghost:hover { border-color: var(--chalk); background: rgba(255, 248, 236, 0.08); }

/* ---- drill ---- */

.drill { padding: 24px 0 48px; }

.drill-head, .list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.drill-head h2, .list-head h2 { margin: 0; }

.drill-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
  color: var(--chalk-dim);
}

.switch input {
  appearance: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.2);
  position: relative;
  cursor: pointer;
  transition: background-color 180ms;
  margin: 0;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--chalk);
  transition: transform 220ms var(--spring);
}

.switch input:checked { background: var(--c4); }
.switch input:checked::after { transform: translateX(18px); background: var(--ink); }

.deck-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px 0 0;
}

.deck {
  position: relative;
  width: min(100%, 560px);
  height: 340px;
  perspective: 1400px;
}

.deck-card {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: var(--pos, var(--c2));
  color: var(--ink);
}

.ghost-card { box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.18); }
.gc1 { --pos: var(--c5); transform: rotate(3deg) translate(8px, 10px); }
.gc2 { --pos: var(--c0); transform: rotate(-4deg) translate(-8px, 18px); }

.flash {
  border: 0;
  padding: 0;
  font: inherit;
  text-align: center;
  cursor: pointer;
  background: transparent;
  transform-style: preserve-3d;
  transition: transform 560ms var(--spring), opacity 260ms, translate 220ms ease-out, rotate 220ms ease-out;
}
.flash.dragging { transition: transform 560ms var(--spring), opacity 260ms; }

.flash.flipped { transform: rotateY(180deg); }
.flash.deal { animation: deal 520ms var(--spring) backwards; }
.flash.fly-right { transform: translateX(160px) rotate(12deg); opacity: 0; transition: transform 320ms ease-in, opacity 320ms; }
.flash.fly-left  { transform: translateX(-160px) rotate(-12deg); opacity: 0; transition: transform 320ms ease-in, opacity 320ms; }

@keyframes deal {
  from { transform: translateY(-40px) rotate(-6deg) scale(0.9); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.flash .side {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px 40px;
  border-radius: 14px;
  background: var(--pos, var(--c2));
  box-shadow: 6px 8px 0 rgba(0, 0, 0, 0.22);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flash .side.back {
  transform: rotateY(180deg);
  background: color-mix(in srgb, var(--pos, var(--c2)) 55%, white);
}

/* "definition first" swaps which face is forward */
.flash.def-first .side.front { transform: rotateY(180deg); }
.flash.def-first .side.back  { transform: none; }

.flash-word {
  font-family: "Permanent Marker", cursive;
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.flash-pron {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 17px;
}

.hint {
  position: absolute;
  bottom: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.flash-def {
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 600;
  line-height: 1.35;
}

.flash-ex {
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-soft);
  font-style: italic;
}

.verdict {
  display: flex;
  align-items: center;
  gap: 24px;
}

.verdict-btn {
  font: inherit;
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: transform 180ms var(--spring), box-shadow 180ms;
}

.verdict-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); }
.verdict-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.verdict-btn.nope { background: var(--c1); }
.verdict-btn.yep { background: var(--c2); }

.progress {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--chalk-dim);
  min-width: 5ch;
  text-align: center;
}

.drill-tip {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--chalk-dim);
}

.deck-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}

.done-score {
  margin: 0;
  font-family: "Permanent Marker", cursive;
  font-size: clamp(40px, 8vw, 84px);
  color: var(--jot);
  line-height: 1;
  animation: word-in 640ms var(--spring) both;
}

.done-note {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 600;
  color: var(--chalk-dim);
}

.done-acts { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---- list ---- */

.wordlist { padding: 24px 0 8px; }

.list-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#search {
  font: inherit;
  font-weight: 600;
  color: var(--chalk);
  background: rgba(255, 248, 236, 0.1);
  border: 2px solid rgba(255, 248, 236, 0.35);
  border-radius: 999px;
  padding: 8px 18px;
  width: 220px;
  transition: border-color 150ms;
}

#search::placeholder { color: var(--chalk-dim); }
#search:focus { outline: none; border-color: var(--jot); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--chalk);
  background: transparent;
  border: 2px solid rgba(255, 248, 236, 0.35);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: background-color 150ms, color 150ms, border-color 150ms;
}

.chip:hover { border-color: var(--chalk); }
.chip.is-on { background: var(--pos, var(--chalk)); color: var(--ink); border-color: transparent; }

#sort {
  font: inherit;
  font-weight: 700;
  color: var(--chalk);
  background: var(--wall-deep);
  border: 2px solid rgba(255, 248, 236, 0.35);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}

.list-count {
  margin: 0 0 20px;
  font-weight: 600;
  color: var(--chalk-dim);
}

.cards {
  list-style: none;
  margin: 0;
  padding: 8px 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.card {
  position: relative;
  background: var(--chalk);
  color: var(--ink);
  border-radius: 12px;
  padding: 18px 20px 18px;
  border-top: 10px solid var(--pos, var(--c2));
  box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.22);
  transition: transform 260ms var(--spring), box-shadow 260ms;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, rgba(28, 20, 64, 0.07) 27px 28px);
  background-position: 0 14px;
}

.card:hover { transform: translateY(-4px) rotate(-0.6deg); box-shadow: 6px 10px 0 rgba(0, 0, 0, 0.26); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.card-word {
  margin: 0;
  font-family: "Permanent Marker", cursive;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.card-pron {
  margin: 2px 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.card-def {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.45;
}

.card-ex {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ink-soft);
}

@media (max-width: 760px) {
  .deck { height: 300px; }
  .flash .side { padding: 28px 22px; }
  .verdict { gap: 14px; }
  .verdict-btn { padding: 12px 20px; font-size: 16px; }
  #search { width: 100%; }
  .cards { grid-template-columns: 1fr; }
}

/* ---- deck engine additions ---- */

.card-img {
  display: block;
  width: 100%;
  max-width: 200px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 6px;
  margin: 0 0 12px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(28, 20, 64, 0.12);
}

.flash .side img {
  max-width: 220px;
  width: 60%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(28, 20, 64, 0.12);
}

.card-line {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.45;
}

.card-line-label {
  display: inline-block;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(28, 20, 64, 0.08);
  font-size: 12px;
  margin-right: 2px;
}

.card.in-pile::after {
  content: "still missing";
  position: absolute;
  top: -10px;
  right: 14px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--c1);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  transform: rotate(3deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.pile-btn {
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  background: var(--c1);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  transition: transform 180ms var(--spring), box-shadow 180ms;
}

.pile-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3); }

/* ---- spaced repetition ---- */

.srs-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 8px; }

.srs-bit {
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 248, 236, 0.25);
  font-size: 13px;
  font-weight: 600;
  color: var(--chalk-dim);
}

.srs-bit strong { color: var(--chalk); font-weight: 800; }
.srs-due { background: var(--c1); border-color: transparent; color: var(--ink); }
.srs-due strong { color: var(--ink); }
.srs-known strong { color: var(--c2); }

.run-label {
  margin: 0 0 -8px;
  padding: 3px 14px;
  border-radius: 999px;
  background: var(--jot);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  transform: rotate(-2deg);
}

.pile-btn.new-btn { background: var(--c4); }

/* the example often gives the word away, so hold it back until the flip */
.flash.def-first:not(.flipped) .flash-ex { visibility: hidden; }

.card.is-due::after, .card.is-known::after {
  position: absolute;
  top: -10px;
  right: 14px;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  transform: rotate(3deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.card.is-due::after { content: "due"; background: var(--jot); }
.card.is-known::after { content: "known"; background: var(--c2); }

/* ---- multiple choice ---- */

.choices { display: none; width: min(100%, 560px); gap: 10px; margin-top: 10px; }
.deck-wrap.is-mc .choices { display: grid; }
.deck-wrap.is-mc .verdict .verdict-btn { display: none; }
.deck-wrap.is-mc .hint { display: none; }

.choice {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
  color: var(--ink);
  background: var(--chalk);
  border: 0;
  border-left: 8px solid var(--c5);
  border-radius: 4px 12px 12px 4px;
  padding: 13px 16px;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.25);
  transition: transform 180ms var(--spring), background-color 200ms;
  -webkit-tap-highlight-color: transparent;
}

.choice:nth-child(2) { border-left-color: var(--c0); }
.choice:nth-child(3) { border-left-color: var(--c4); }
.choice:nth-child(4) { border-left-color: var(--c6); }
.choice:active { transform: scale(0.98); }
.choice:disabled { cursor: default; opacity: 0.55; }
.choice.is-right { background: var(--c2); opacity: 1; transform: rotate(-0.6deg) scale(1.02); }
.choice.is-wrong { background: var(--c1); opacity: 1; animation: shake 360ms; }

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@media (max-width: 760px) {
  .drill-head, .list-head { gap: 12px; margin-bottom: 18px; }
  .drill-tools { gap: 10px 14px; }
  .deck-wrap { gap: 22px; padding-top: 12px; }
  .verdict { width: 100%; justify-content: space-between; }
  .verdict-btn { flex: 1 1 0; padding: 14px 8px; }
  .progress { flex: 0 0 auto; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; max-width: 100vw; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; padding: 8px 14px; }
  #search, #sort { font-size: 16px; }
}

/* ---- quotes page: the front of the card is a sentence, not a word ---- */

.th-money   { --pos: var(--c4); }
.th-living  { --pos: var(--c6); }
.th-mind    { --pos: var(--c0); }
.th-history { --pos: var(--c5); }
.th-words   { --pos: var(--c2); }
.th-science { --pos: var(--c3); }

.quotes-page .deck { height: 440px; }
.quotes-page .flash .side { overflow-y: auto; justify-content: center; }
.quotes-page .flash-word {
  font-family: inherit;
  font-size: clamp(16px, 2.4vw, 20px);
  font-weight: 600;
  font-style: italic;
  line-height: 1.45;
  overflow-wrap: normal;
  max-width: 44em;
}
.quotes-page .flash-def { font-family: "Permanent Marker", cursive; font-weight: 400; font-size: clamp(24px, 4.5vw, 36px); line-height: 1.1; }
.quotes-page .flash-ex { font-style: normal; font-weight: 600; }
.quotes-page .card-word { font-family: inherit; font-size: 18px; font-weight: 800; line-height: 1.25; }
.quotes-page .card-pron { font-weight: 600; }
.quotes-page .card-def { font-style: italic; font-size: 17px; line-height: 1.5; }
.quotes-page .card-ex { font-style: normal; }
.quotes-page .choice { font-size: 15px; }

@media (max-width: 760px) {
  .quotes-page .deck { height: 400px; }
  .quotes-page .flash-word { font-size: 15px; }
  .quotes-page .flash .side { padding: 28px 18px 30px; }
}
