/* Flashcards. Built on the colors and type in /css/site.css, so light and dark mode
   both work. */

.fc {
  padding-top: 40px;
  min-height: calc(100vh - 220px);
}

/* The views are <section>s; skip the home page's spacing between sections. */
.fc-view {
  margin-top: 0;
}

.fc-view h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2.25rem;
  line-height: 1.15;
  margin: 0 0 6px;
}

.fc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.fc-sub,
.fc-muted {
  color: var(--muted);
}

.fc-sub {
  margin: 0;
  max-width: 34em;
}

.fc-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fc-note {
  min-height: 1.2em;
  margin: 16px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.fc-note:empty {
  display: none;
}

.fc-note-warn {
  color: #b3412e;
}

.button-primary:disabled,
.button-secondary:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Deck list */

.fc-decks {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.fc-deck {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fc-deck:hover .fc-deck-name {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fc-deck-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fc-deck-meta {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.fc-empty {
  margin-top: 28px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.fc-empty p {
  margin: 0 0 6px;
}

/* Editor */

.fc-backlink {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.fc-backlink:hover {
  color: var(--text);
}

.fc-title-input {
  flex: 1 1 280px;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--text);
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
}

.fc-title-input:hover,
.fc-title-input:focus {
  border-bottom-color: var(--line);
  outline: none;
}

.fc-count {
  margin: 8px 0 20px;
  font-size: 0.9rem;
}

.fc-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: card;
}

.fc-card-row {
  counter-increment: card;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 16px 0 16px 36px;
  border-top: 1px solid var(--line);
}

.fc-card-row::before {
  content: counter(card);
  position: absolute;
  left: 4px;
  top: 40px;
  font-size: 0.85rem;
  color: var(--muted);
}

.fc-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.fc-side textarea {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.45;
  resize: none;
  overflow: hidden;
}

.fc-side textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.fc-remove {
  width: 32px;
  height: 32px;
  margin-top: 26px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.fc-remove:hover {
  background: var(--line);
  color: var(--text);
}

.fc-edit-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.fc-danger {
  padding: 0;
  border: 0;
  background: none;
  color: #b3412e;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.fc-danger:hover {
  text-decoration: underline;
}

/* Study */

.fc-study-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.fc-study-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
}

.fc-options {
  display: flex;
  gap: 18px;
  font-size: 0.9rem;
  color: var(--muted);
}

.fc-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.fc-options input {
  accent-color: var(--accent);
}

.fc-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.fc-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.fc-progress-text {
  margin: 8px 0 20px;
  font-size: 0.85rem;
}

/* The card flips in 3D: front and back are two faces of one rotating box. */
.fc-card {
  display: block;
  width: 100%;
  height: clamp(220px, 42vh, 340px);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  perspective: 1200px;
}

.fc-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 12px;
}

.fc-card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}

.fc-card.flipped .fc-card-inner {
  transform: rotateY(180deg);
}

.fc-card.no-anim .fc-card-inner {
  transition: none;
}

.fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: auto;
}

.fc-back {
  transform: rotateY(180deg);
}

.fc-face-label {
  position: absolute;
  top: 14px;
  left: 18px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.fc-face-text {
  max-width: 32em;
  font-family: var(--serif);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.35;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.fc-hint {
  margin: 14px 0 0;
  font-size: 0.85rem;
  text-align: center;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8em;
  line-height: 1.5;
  text-align: center;
  opacity: 0.8;
}

.fc-grade {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.fc-grade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.fc-grade-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Green for knowing it, red for not, in both study and quiz. */
.fc-study {
  --ok: #2f9e5b;
  --bad: #d4483b;
}

.fc-miss {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
}

.fc-hit {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
}

.fc-miss:not(:disabled):hover {
  background: color-mix(in srgb, var(--bad) 12%, var(--surface));
  border-color: var(--bad);
}

.fc-hit:not(:disabled):hover {
  background: color-mix(in srgb, var(--ok) 12%, var(--surface));
  border-color: var(--ok);
}

/* Quiz */

.fc-quiz-q {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  padding: 40px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.fc-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.fc-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.fc-choice:not(:disabled):hover {
  border-color: var(--accent);
}

.fc-choice:disabled {
  cursor: default;
}

.fc-choice.correct {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, var(--surface));
}

.fc-choice.wrong {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 16%, var(--surface));
}

.fc-quiz-foot {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.fc-done {
  padding: 48px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}

.fc-done h3 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
}

.fc-done .fc-actions {
  justify-content: center;
  margin-top: 20px;
}

@media (max-width: 600px) {
  .fc-card-row {
    grid-template-columns: 1fr auto;
    padding-left: 28px;
  }

  .fc-card-row .fc-side:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .fc-remove {
    grid-column: 2;
    grid-row: 1;
  }

  .fc-face {
    padding: 36px 20px;
  }

  .fc-choices {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fc-card-inner {
    transition: none;
  }
}
