/* Learn and Flashcards study modes: deliberately styled like Quizlet's, with their own colours. */

body.study .topbar { display: none; }

.study-root {
  --q-bg: #f6f7fb;
  --q-card: #ffffff;
  --q-text: #282e3e;
  --q-text-2: #586380;
  --q-muted: #939bb4;
  --q-line: #edeff4;
  --q-line-2: #d9dde8;
  --q-hover: #a8b1ff;
  --q-blue: #4255ff;
  --q-link: #4255ff;
  --q-good: #18ae79;
  --q-good-ink: #0f7a54;
  --q-good-bg: #e7f7ef;
  --q-bad: #ff725b;
  --q-bad-ink: #c5392a;
  --q-bad-bg: #fff1ee;
  --q-learning: #ff983a;
  --q-learning-ink: #b85c00;
  --q-shadow: 0 4px 16px rgba(40, 46, 62, 0.08);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--q-bg);
  color: var(--q-text);
}
@media (prefers-color-scheme: dark) {
  .study-root {
    --q-bg: #0a092d;
    --q-card: #2e3856;
    --q-text: #f6f7fb;
    --q-text-2: #d9dde8;
    --q-muted: #939bb4;
    --q-line: #424b6b;
    --q-line-2: #586380;
    --q-link: #a8b1ff;
    --q-good-ink: #5fe0b0;
    --q-good-bg: rgba(24, 174, 121, 0.16);
    --q-bad-ink: #ff9a88;
    --q-bad-bg: rgba(255, 114, 91, 0.14);
    --q-learning-ink: #ffb066;
    --q-shadow: none;
  }
}

.study-root .icon-btn { color: var(--q-text-2); }
.study-root .icon-btn:hover { background: var(--q-line); }
.study-root button.primary, .study-root .btn.primary { background: var(--q-blue); border-color: var(--q-blue); color: #fff; border-radius: 8px; padding: 10px 20px; font-weight: 600; }
.study-root button.primary:hover, .study-root .btn.primary:hover { background: #423ed8; border-color: #423ed8; filter: none; }
.study-root .finish-actions button:not(.primary), .study-root .finish-actions .btn:not(.primary),
.study-root .fc-end-actions button:not(.primary), .study-root .fc-end-actions .btn:not(.primary),
.study-root .empty-learn .btn:not(.primary) { background: var(--q-card); border: 2px solid var(--q-line); color: var(--q-text); border-radius: 8px; padding: 9px 18px; font-weight: 600; }
.study-root .secondary { color: var(--q-text-2); }
.study-root .muted { color: var(--q-muted); }

.study-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); align-items: center; gap: 12px; height: 64px; padding: 0 20px; flex: none; }
.mode-wrap { position: relative; justify-self: start; }
.mode-switch, .ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--q-line);
  background: var(--q-card);
  color: var(--q-text);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 600;
}
.mode-switch:hover, .ghost-btn:hover { background: var(--q-card); border-color: var(--q-line-2); }
.mode-ico { color: var(--q-blue); }
.mode-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 230px;
  padding: 6px;
  background: var(--q-card);
  border: 1px solid var(--q-line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.mode-menu a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px; color: var(--q-text); text-decoration: none; font-weight: 600; }
.mode-menu a:hover, .mode-menu a.on { background: var(--q-line); }
.mode-menu hr { border: 0; border-top: 1px solid var(--q-line); margin: 6px 0; }
.study-title { text-align: center; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-actions { justify-self: end; display: flex; gap: 8px; align-items: center; }
.study-actions .close { border: 2px solid var(--q-line); border-radius: 8px; padding: 6px; }

.link-btn { background: none; border: none; padding: 6px 8px; color: var(--q-link, var(--accent)); font-weight: 600; cursor: pointer; }
.link-btn:hover { background: none; text-decoration: underline; }
.link-btn.small { font-size: 13px; }
.link-btn.danger { color: var(--critical); }

/* Learn */

.learn-progress { display: flex; align-items: center; gap: 14px; width: min(100% - 32px, 800px); margin: 10px auto 0; }
.lp-track { position: relative; flex: 1; height: 8px; background: var(--q-line); border-radius: 999px; }
.lp-fill { height: 100%; width: 0; background: var(--q-good); border-radius: 999px; transition: width 0.4s ease; }
.lp-count, .lp-total {
  min-width: 30px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lp-count {
  --p: 0;
  position: absolute;
  top: 50%;
  left: clamp(15px, calc(var(--p) * 1%), calc(100% - 15px));
  transform: translate(-50%, -50%);
  background: var(--q-good);
  color: #fff;
  transition: left 0.4s ease;
}
.lp-total { background: var(--q-line); color: var(--q-text-2); }

.learn-stage { flex: 1; width: min(100% - 32px, 800px); margin: 28px auto 130px; }
.learn-card {
  background: var(--q-card);
  border-radius: 16px;
  box-shadow: var(--q-shadow);
  padding: 24px 32px 28px;
  min-height: 430px;
  display: flex;
  flex-direction: column;
  animation: card-in 0.25s ease;
}
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } }
.lc-top { display: flex; align-items: center; gap: 6px; min-height: 34px; }
.lc-label { color: var(--q-text-2); font-size: 14px; font-weight: 600; }
.lc-prompt { flex: 1; padding: 14px 0 26px; font-size: 22px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.lc-prompt.md { font-size: 19px; }
.lc-prompt.sm { font-size: 16px; }
.lc-sub { font-size: 15px; font-weight: 600; color: var(--q-text-2); margin-bottom: 14px; }
.lc-sub.good { color: var(--q-good-ink); }
.lc-sub.bad { color: var(--q-bad-ink); }
.lc-options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lc-options.single { grid-template-columns: 1fr; }
.lc-option {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 12px 16px;
  text-align: left;
  border: 2px solid var(--q-line);
  border-radius: 8px;
  background: var(--q-card);
  color: var(--q-text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.lc-option:hover:not(:disabled) { border-color: var(--q-hover); background: var(--q-card); }
.lc-option:disabled { opacity: 1; cursor: default; }
.lc-option.center { justify-content: center; font-weight: 600; }
.lc-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.lc-num {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--q-line);
  color: var(--q-text-2);
  font-size: 12px;
  font-weight: 700;
}
.lc-option.correct { border-color: var(--q-good); background: var(--q-good-bg); }
.lc-option.reveal { border: 2px dashed var(--q-good); }
.lc-option.wrong { border-color: var(--q-bad); background: var(--q-bad-bg); }
.lc-option.correct .lc-num, .lc-option.reveal .lc-num { background: var(--q-good); color: #fff; }
.lc-option.wrong .lc-num { background: var(--q-bad); color: #fff; }
.lc-foot { display: flex; justify-content: center; margin-top: 22px; }
.lc-tf { display: grid; grid-template-columns: 1fr 1fr; flex: 1; margin-bottom: 8px; }
.lc-tf > div { padding-right: 22px; }
.lc-tf > div + div { border-left: 2px solid var(--q-line); padding: 0 0 0 22px; }
.lc-reveal-note { margin-top: 14px; padding: 12px 16px; border-radius: 8px; border: 2px dashed var(--q-good); display: grid; gap: 4px; }
.lc-reveal {
  width: 100%;
  min-height: 110px;
  margin-bottom: 14px;
  padding: 16px;
  border: 2px dashed var(--q-line-2);
  border-radius: 8px;
  background: none;
  color: var(--q-text);
  font: inherit;
  font-size: 18px;
  white-space: pre-wrap;
  cursor: pointer;
  justify-content: center;
}
.lc-reveal:hover { border-color: var(--q-hover); background: none; }
.lc-reveal.shown { border-style: solid; border-color: var(--q-line); cursor: default; opacity: 1; }
.study-root input.lc-input {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 14px 16px;
  border: 2px solid var(--q-line);
  border-radius: 8px;
  background: var(--q-bg);
  color: var(--q-text);
}
.study-root input.lc-input:focus { outline: none; border-color: var(--q-blue); }
.study-root input.lc-input.ok { border-color: var(--q-good); }
.study-root input.lc-input:disabled { opacity: 0.7; }
.lc-write-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.lc-ans-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; min-height: 30px; }
.lc-ans {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 2px solid;
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.lc-ans .lc-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; margin-top: 1px; }
.lc-ans.right { border-color: var(--q-good); border-style: dashed; }
.lc-ans.right.solid { border-style: solid; background: var(--q-good-bg); }
.lc-ans.right .lc-mark { background: var(--q-good); }
.lc-ans.wrong { border-color: var(--q-bad); background: var(--q-bad-bg); }
.lc-ans.wrong .lc-mark { background: var(--q-bad); }
.lc-model { padding: 8px 0 0; color: var(--q-text-2); white-space: pre-wrap; }
.lc-retype { margin-top: 4px; }
.empty-learn { align-items: center; justify-content: center; text-align: center; gap: 8px; }

.learn-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  background: var(--q-card);
  border-top: 1px solid var(--q-line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.06);
  animation: slide-up 0.18s ease;
}
@keyframes slide-up { from { transform: translateY(100%); } }
.lf-inner { width: min(100% - 32px, 800px); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; }
.lf-text { color: var(--q-text-2); font-weight: 600; }

.learn-summary h2 { font-size: 26px; margin: 4px 0 20px; }
.learn-summary h3 { font-size: 18px; margin: 0 0 12px; }
.ls-card { background: var(--q-card); border-radius: 16px; box-shadow: var(--q-shadow); padding: 22px 24px; margin-bottom: 30px; }
.ls-head { font-size: 17px; color: var(--q-text-2); margin-bottom: 14px; }
.ls-head strong { color: var(--q-text); }
.q-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--q-line); }
.q-bar .m { background: var(--q-good); transition: width 0.5s; }
.q-bar .l { background: var(--q-learning); transition: width 0.5s; }
.q-legend { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 14px; font-size: 14px; color: var(--q-text-2); }
.q-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; }
.dot.m { background: var(--q-good); }
.dot.l { background: var(--q-learning); }
.dot.n { background: var(--q-line); box-shadow: inset 0 0 0 1px var(--q-line-2); }
.ls-terms { display: grid; gap: 8px; }
.ls-term {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  gap: 18px;
  align-items: center;
  background: var(--q-card);
  border-radius: 12px;
  box-shadow: var(--q-shadow);
  padding: 14px 18px;
}
.ls-term .t { font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.ls-term .d { color: var(--q-text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.status-pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-pill.m { background: var(--q-good-bg); color: var(--q-good-ink); }
.status-pill.l { background: color-mix(in srgb, var(--q-learning) 18%, transparent); color: var(--q-learning-ink); }

.learn-finish { text-align: center; padding: 40px 16px; }
.learn-finish h2 { font-size: 28px; margin: 0 0 8px; }
.trophy { width: 96px; height: 96px; margin: 0 auto 22px; border-radius: 50%; background: var(--q-good); color: #fff; display: grid; place-items: center; animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
.finish-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 22px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.confetti i { position: absolute; top: -16px; width: 9px; height: 15px; border-radius: 2px; animation-name: fall; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes fall { to { top: 110%; transform: rotate(900deg); } }

/* Options dialog (rendered outside the study page, so it uses the app colours) */

.options-modal { max-width: 520px; max-height: calc(100vh - 48px); overflow: auto; padding: 0; }
.opt-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.opt-head h2 { margin: 0; font-size: 20px; }
.opt-section { padding: 12px 22px; border-bottom: 1px solid var(--border); }
.opt-section h3 { font-size: 14px; font-weight: 700; color: var(--text-2); margin: 4px 0; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; cursor: pointer; }
.opt-row.disabled { cursor: default; }
.opt-row.disabled .opt-label { color: var(--muted); }
.opt-label { display: block; font-weight: 600; }
.opt-note { display: block; font-size: 13px; color: var(--text-2); }
.opt-foot { padding: 12px 16px 16px; }

/* Flashcards */

.fc-progress { flex: none; height: 4px; background: var(--q-line); }
.fc-progress > div { height: 100%; width: 0; background: var(--q-blue); transition: width 0.3s; }
.fc-stage { flex: 1; width: min(100% - 32px, 840px); margin: 22px auto 40px; display: flex; flex-direction: column; gap: 16px; }
.fc-counts { display: flex; justify-content: space-between; }
.fc-pill { display: inline-flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; border-radius: 999px; font-size: 14px; font-weight: 700; border: 2px solid; }
.fc-pill.know { padding: 4px 4px 4px 14px; color: var(--q-good-ink); border-color: var(--q-good); }
.fc-pill.learning { color: var(--q-learning-ink); border-color: var(--q-learning); }
.fc-pill b { min-width: 28px; height: 24px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center; color: #fff; }
.fc-pill.know b { background: var(--q-good); }
.fc-pill.learning b { background: var(--q-learning); }
.fc-card { height: clamp(300px, 56vh, 480px); perspective: 2200px; cursor: pointer; outline: none; }
.fc-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1); }
.fc-card.flipped .fc-inner { transform: rotateX(180deg); }
.fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 16px 22px;
  background: var(--q-card);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(40, 46, 62, 0.12);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.fc-face.back { transform: rotateX(180deg); }
.fc-card:focus-visible .fc-face { box-shadow: 0 0 0 3px var(--q-hover); }
.fc-face-top { display: flex; align-items: center; gap: 2px; }
.fc-side { color: var(--q-text-2); font-size: 14px; font-weight: 600; }
.fc-text { flex: 1; display: grid; place-items: center; overflow: auto; padding: 8px 28px 28px; text-align: center; font-size: 30px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.fc-text.md { font-size: 23px; }
.fc-text.sm { font-size: 18px; }
.fc-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.fc-track { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--q-text-2); cursor: pointer; justify-self: start; }
.fc-nav { display: flex; align-items: center; gap: 18px; }
.fc-count { min-width: 64px; text-align: center; font-weight: 700; color: var(--q-text-2); font-variant-numeric: tabular-nums; }
.round-btn {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--q-line);
  background: var(--q-card);
  color: var(--q-text);
  display: grid;
  place-items: center;
}
.round-btn:hover:not(:disabled) { border-color: var(--q-line-2); background: var(--q-card); }
.round-btn.learning { color: var(--q-learning-ink); }
.round-btn.learning:hover { border-color: var(--q-learning); }
.round-btn.know { color: var(--q-good-ink); }
.round-btn.know:hover { border-color: var(--q-good); }
.fc-tools { justify-self: end; display: flex; gap: 4px; }
.fc-tools .toggle.on { color: var(--q-blue); background: color-mix(in srgb, var(--q-blue) 14%, transparent); }
.fc-hint { text-align: center; font-size: 13px; color: var(--q-muted); }
.fc-end { background: var(--q-card); border-radius: 16px; box-shadow: var(--q-shadow); padding: 32px; }
.fc-end h2 { font-size: 26px; margin: 0 0 24px; }
.fc-end-body { display: flex; gap: 40px; align-items: center; flex-wrap: wrap; }
.fc-end-stats { display: flex; gap: 28px; align-items: center; }
.fc-ring-text { font-size: 26px; font-weight: 700; fill: var(--q-text); }
.fc-end-counts { display: grid; gap: 10px; min-width: 200px; }
.fc-end-counts > div { display: flex; justify-content: space-between; gap: 20px; padding: 8px 14px; border-radius: 999px; font-weight: 700; border: 2px solid; }
.fc-end-counts .know { color: var(--q-good-ink); border-color: var(--q-good); }
.fc-end-counts .learning { color: var(--q-learning-ink); border-color: var(--q-learning); }
.fc-end-actions { display: grid; gap: 10px; flex: 1; min-width: 220px; }
.fc-end-actions > * { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .fc-inner, .lp-fill, .lp-count, .learn-card, .learn-footer, .trophy { transition: none; animation: none; }
}


@media (max-width: 640px) {
  .study-head { grid-template-columns: auto minmax(0, 1fr) auto; padding: 0 12px; }
  .study-title { font-size: 14px; }
  .ghost-btn .ghost-label { display: none; }
  .learn-card { padding: 18px 18px 22px; min-height: 360px; }
  .lc-options { grid-template-columns: 1fr; }
  .lc-tf { grid-template-columns: 1fr; }
  .lc-tf > div + div { border-left: 0; border-top: 2px solid var(--q-line); padding: 12px 0 0; }
  .ls-term { grid-template-columns: 1fr; gap: 6px; }
  .fc-controls { grid-template-columns: 1fr; justify-items: center; }
  .fc-track, .fc-tools { justify-self: center; }
  .fc-text { font-size: 22px; padding: 8px 12px 20px; }
}
