/* FlashDeck — deck list, editor, study mode (3D flip + grade row + ring).
   Theme colors come from site.config.json (--primary violet / --accent amber).
   Elements that can carry [hidden] keep display rules behind :not([hidden])
   per repo convention (P015). */

.fc-tool {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.1rem 1.25rem 1.35rem;
  margin: 1.4rem 0 2rem;
}
.fc-loading { color: var(--text-dim); }
.fc-dim { color: var(--text-dim); font-size: 0.85rem; }
.fc-empty { color: var(--text-dim); }
.fc-dim code { font-size: 0.82em; }

/* ---------- buttons ---------- */

.fc-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  padding: 0.42rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}
.fc-btn:hover { border-color: var(--primary); color: var(--primary); }
.fc-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.fc-btn:active { transform: translateY(1px); }
.fc-btn:disabled { opacity: 0.45; cursor: default; }
.fc-btn:disabled:hover { border-color: var(--border); color: var(--text); }
.fc-btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.fc-btn--primary:hover { color: #fff; filter: brightness(1.1); }
.fc-btn--danger { color: var(--accent); }
.fc-btn--danger:hover { border-color: var(--accent); color: var(--accent); }
.fc-btn--small { font-size: 0.78rem; padding: 0.3rem 0.75rem; }
.fc-btn--big { font-size: 1rem; padding: 0.7rem 1.6rem; }
.fc-filebtn { position: relative; overflow: hidden; display: inline-block; }

/* ---------- notice (storage recovery) ---------- */

.fc-notice:not([hidden]) {
  display: block;
  margin-bottom: 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  font-size: 0.88rem;
}
.fc-notice p { margin: 0 0 0.4rem; }
.fc-notice p:last-of-type { margin-bottom: 0.6rem; }

/* ---------- shared bits ---------- */

.fc-row:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.fc-viewhead { margin-bottom: 1rem; }
.fc-viewhead h2 { margin: 0.3rem 0 0.3rem; }
.fc-viewhead h3 { margin: 1rem 0 0.4rem; font-size: 0.95rem; }
.fc-viewhead p { margin: 0.2rem 0; }

input[type="text"],
textarea,
select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
}
input[type="text"]:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
textarea { resize: vertical; }

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

.fc-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0.8rem 1rem;
  margin-bottom: 0.7rem;
}
.fc-deck-main { min-width: 0; }
.fc-deckname {
  font: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text);
  background: none;
  border: none;
  padding: 0.5rem 0;
  min-height: 44px;
  cursor: pointer;
  text-align: start;
  overflow-wrap: anywhere;
}
.fc-deckname:hover { color: var(--primary); }
.fc-counts { display: block; font-size: 0.82rem; color: var(--text-dim); margin-top: 0.15rem; }
.fc-due.is-hot { color: var(--accent); font-weight: 700; }
.fc-deck-actions { display: flex; gap: 0.45rem; flex: none; }

.fc-newdeck {
  margin-top: 1.2rem;
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
}
.fc-newdeck input[name="name"] { flex: 1; min-width: 12rem; }
.fc-newdeck input[type="file"] { font-size: 0.85rem; max-width: 100%; }

/* ---------- deck manage ---------- */

.fc-decktitle {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.fc-deckbar { margin: 0.6rem 0; }
.fc-nps { font-size: 0.82rem; color: var(--text-dim); display: inline-flex; align-items: center; gap: 0.4rem; }
.fc-nps select { font-size: 0.82rem; padding: 0.3rem 0.5rem; min-height: 32px; }
.fc-impresult { font-size: 0.85rem; color: var(--text-dim); min-height: 1.2em; margin: 0.3rem 0 0; }

.fc-addcard {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  background: var(--bg);
}
.fc-addcard h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.fc-addgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.fc-addcard textarea { width: 100%; }
.fc-addcard .fc-dim { margin: 0.4rem 0; }
.fc-addcard .fc-btn { margin-top: 0.4rem; }

.fc-scroll { overflow-x: auto; }
.fc-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.fc-table th, .fc-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: start;
  vertical-align: top;
}
.fc-table th { background: var(--surface-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.fc-cellface { max-width: 22rem; overflow-wrap: anywhere; white-space: pre-line; }
.fc-status { white-space: nowrap; color: var(--text-dim); font-size: 0.8rem; }
.fc-rowbtns { white-space: nowrap; }
.fc-rowbtns .fc-btn { margin: 0.1rem 0.15rem 0.1rem 0; }
.fc-editrow textarea { width: 100%; box-sizing: border-box; }

/* ---------- study ---------- */

.fc-studyhead {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.fc-studytitle { flex: 1; min-width: 0; }
.fc-studytitle strong { display: block; overflow-wrap: anywhere; }
.fc-studytitle .fc-dim { font-size: 0.8rem; }

.fc-ring { width: 3.1rem; height: 3.1rem; flex: none; }
.fc-ring circle { fill: none; stroke-width: 3.4; }
.fc-ring-bg { stroke: var(--border); }
.fc-ring-fg {
  stroke: var(--primary);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.35s ease;
}
.fc-ring-txt {
  fill: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 700;
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
}

.fc-stage { text-align: center; }
.fc-cardtag { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); margin: 0 0 0.5rem; }

/* 3D flip: faces are absolutely stacked inside a fixed-height wrap; the
   back face starts rotated 180° and the whole card rotates on flip. */
.fc-flipwrap {
  position: relative;
  min-height: 15rem;
  perspective: 1200px;
  margin: 0 auto 0.7rem;
  max-width: 34rem;
}
.fc-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1.05);
  cursor: pointer;
}
.fc-card.is-flipped { transform: rotateY(180deg); }
/* Flip faces are scoped under .fc-card so no other markup can pick up the
   absolute, inset-0 overlay styling (P-bug: a bare .fc-face elsewhere in the
   DOM once painted a page-level click blocker). */
.fc-card .fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1.4rem 1.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow-y: auto;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 30px -18px color-mix(in srgb, var(--primary) 60%, transparent);
}
.fc-card .fc-face--front { border-top: 4px solid var(--primary); }
.fc-card .fc-face--back {
  transform: rotateY(180deg);
  border-top: 4px solid var(--accent);
}
.fc-side {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.fc-text { font-size: 1.25rem; line-height: 1.45; }
.fc-text code { font-size: 0.95em; }

.fc-hint { font-size: 0.78rem; color: var(--text-dim); margin: 0.4rem 0 0.9rem; }
.fc-hint kbd { font-size: 0.72rem; }

.fc-graderow {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.fc-grade {
  min-width: 6.2rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: #fff;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.fc-grade:hover { color: #fff; filter: brightness(1.1); }
.fc-grade .fc-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.72rem;
  font-weight: 700;
}
.fc-grade--again { background: #b91c1c; border-color: #b91c1c; }
.fc-grade--hard { background: #b45309; border-color: #b45309; }
.fc-grade--good { background: #15803d; border-color: #15803d; }
.fc-grade--easy { background: #0369a1; border-color: #0369a1; }
.fc-gradenote { max-width: 34rem; margin: 0 auto; }

/* ---------- summary ---------- */

.fc-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 1.2rem 1.3rem;
  max-width: 34rem;
  margin: 0 auto;
  text-align: center;
}
.fc-summary h3 { margin: 0 0 0.9rem; }
.fc-sumgrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.fc-sum { display: flex; flex-direction: column; gap: 0.15rem; }
.fc-sum-n { font-size: 1.25rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.fc-sum-l { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.fc-gradesum { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fc-g {
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.fc-g--again { color: #b91c1c; border-color: #b91c1c; }
.fc-g--hard { color: #b45309; border-color: #b45309; }
.fc-g--good { color: #15803d; border-color: #15803d; }
.fc-g--easy { color: #0369a1; border-color: #0369a1; }
.fc-summary .fc-row { justify-content: center; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .fc-tool { padding: 0.9rem 0.7rem 1.1rem; }
  .fc-deck { padding: 0.7rem 0.8rem; }
  .fc-deck-actions { width: 100%; }
  .fc-deck-actions .fc-btn { flex: 1; }
  .fc-addgrid { grid-template-columns: 1fr; }
  .fc-flipwrap { min-height: 12.5rem; }
  .fc-text { font-size: 1.1rem; }
  .fc-card .fc-face { padding: 1rem 1rem; }
  .fc-graderow { display: grid; grid-template-columns: 1fr 1fr; }
  .fc-grade { min-width: 0; width: 100%; }
  .fc-sumgrid { grid-template-columns: repeat(2, 1fr); }
  .fc-studyhead { flex-wrap: wrap; }
}

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