/* Flashcards: a tela do aluno (public/flashcards.js) e a sessão de estudo, que é
   a mesma na guia do material, no assunto e no "Revisar hoje" (montarDeck, em
   common.js). A estética é de cartão de papel: pilha com camadas discretas,
   sombra suave e um filete verde. Uma cor de destaque só (--k1, que o tema
   ametista também troca): cor por matéria viraria legenda sem legenda. */

:root {
  --fc-sombra: rgba(11, 37, 34, .10);
  --fc-sombra-forte: rgba(11, 37, 34, .22);
}
:root[data-tema="escuro"] {
  --fc-sombra: rgba(0, 0, 0, .28);
  --fc-sombra-forte: rgba(0, 0, 0, .5);
}
/* o papel das camadas de trás e o verso puxam do destaque, para seguir o tema */
.fc, .fc-deck {
  --fc-papel: color-mix(in srgb, var(--k1) 9%, var(--surface));
  --fc-verso: color-mix(in srgb, var(--k1) 6%, var(--surface));
}

/* ------------------------------------------------------------ biblioteca */

.fc { gap: 22px; }
.fc-cab { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.fc-hoje, .fc-hoje-ok .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.fc-hoje-ok { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.fc-hoje-ok small { font-size: 12px; color: var(--muted); }

.fc-continuar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  padding: 14px 18px; border: 1px solid var(--line-2); border-left: 3px solid var(--k1); border-radius: 12px; background: var(--surface);
}
.fc-continuar b { display: block; font-size: 14px; }
.fc-continuar small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.fc-continuar-acoes { display: flex; gap: 8px; }
.fc-continuar-acoes .btn { min-height: 40px; }
.fc-erro { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0; }

.fc-biblioteca, .fc-painel { display: flex; flex-direction: column; gap: 18px; }
.fc-abas { display: flex; gap: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.fc-abas [role="tab"] {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 10px 2px 12px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.fc-abas [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--k1); }
.fc-conta { font-size: 11.5px; font-weight: 700; background: var(--wash); color: var(--muted-2); border-radius: 999px; padding: 1px 8px; }

.fc-voltar {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 6px 0;
  border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--k1);
}
.fc-ferramentas { display: flex; flex-direction: column; gap: 12px; }
.fc-busca {
  display: flex; align-items: center; gap: 10px; max-width: 560px; min-height: 46px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
}
.fc-busca:focus-within { border-color: var(--k1); outline: 2px solid var(--k1-t); }
.fc-busca input { flex: 1; min-width: 0; padding: 10px 0; border: 0; background: none; outline: none; font: inherit; font-size: 14px; color: var(--ink); }
.fc-filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.fc-filtros button {
  min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted-2); cursor: pointer;
}
.fc-filtros button[aria-pressed="true"] { background: var(--k1-t); border-color: var(--k1); color: var(--k1); }

.fc-titulo-linha { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 14px; }
.fc-titulo-linha h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.fc-titulo-linha h2:focus { outline: none; }
.fc-titulo-linha small { font-size: 12.5px; color: var(--muted); }
.fc-estado-tela { margin: 0; padding: 30px 0; color: var(--muted); }
.fc-vazio { padding: 44px 24px; }

/* Matéria como pilha de cartões: a face na frente, duas folhas tortas atrás. */
.fc-pilhas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 20px; padding: 4px 4px 12px; }
.fc-pilha {
  position: relative; display: block; min-width: 0; padding: 0; border: 0; background: none; text-align: left;
  font: inherit; color: inherit; cursor: pointer; isolation: isolate; transition: transform var(--mov-rapido) var(--mov-ease);
}
.fc-pilha::before, .fc-pilha::after {
  content: ''; position: absolute; inset: 8px 6px -5px; z-index: -1; pointer-events: none;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--fc-papel); transform: rotate(-2deg);
}
.fc-pilha::after { inset: 8px 4px -8px; z-index: -2; background: var(--surface); transform: rotate(2deg); }
.fc-pilha-face {
  position: relative; display: flex; flex-direction: column; gap: 14px; min-height: 176px; padding: 18px; overflow: hidden;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); box-shadow: 0 6px 16px var(--fc-sombra);
}
.fc-pilha-face::before {
  content: ''; position: absolute; left: 18px; right: 18px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--k1); opacity: .8;
}
.fc-pilha-topo { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fc-pilha-topo small { font-size: 12px; color: var(--muted); }
.fc-pilha-icone { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--k1-t); }
.fc-pilha-nome { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fc-pilha-nome b { font-family: var(--font-display); font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.fc-pilha-nome small { font-size: 12.5px; color: var(--muted); }
.fc-pilha-pe {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 11px;
  border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--k1);
}
.fc-pilha-pe > span { display: inline-flex; align-items: center; gap: 5px; }
.fc-pilha-abrir { color: var(--muted); }
.fc-pilha:hover { transform: translateY(-3px); }
.fc-pilha:hover .fc-pilha-face { border-color: var(--k1); }
.fc-pilha:focus-visible { outline: none; }
.fc-pilha:focus-visible .fc-pilha-face { outline: 2px solid var(--k1); outline-offset: 2px; }

/* Assunto: um cartão com o que importa — nome, contexto, quantos, estado e ação. */
.fc-unidade { margin: 24px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fc-titulo-linha + .fc-unidade { margin-top: 2px; }
.fc-assuntos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fc-assunto {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 18px 20px;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); box-shadow: 0 4px 12px var(--fc-sombra);
}
.fc-assunto-topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.fc-assunto-topo > span { display: inline-flex; align-items: center; gap: 6px; }
.fc-salvar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; margin: -8px -10px -8px 0; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.fc-salvar:hover { background: var(--wash); }
.fc-assunto-txt { flex: 1; }
.fc-assunto-txt h3 { margin: 0; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.fc-assunto-txt p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.fc-assunto-pe { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.fc-assunto-pe .btn { min-height: 40px; }
.fc-estado { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.fc-estado.hoje { color: var(--k1); }
.fc-estado.dia { color: var(--muted-2); }
.fc-estado.novo { color: var(--muted); }

/* --------------------------------------------------------------- estudo */

.fc-deck { width: 100%; max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; outline: none; }
.fc-sessao-topo { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 36px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.fc-deck > .bar > i { background: var(--k1); }
.fc-aviso { margin: 8px 0 0; font-size: 12.5px; font-weight: 600; color: var(--warn); }
.fc-aviso:empty { display: none; }

/* O cartão vira de verdade: as duas faces ocupam a mesma célula do grid (a
   altura é a da maior, e a altura da face é fixa — texto longo rola por dentro,
   e o cartão não pula ao virar) e o miolo gira 180° com as costas escondidas. */
.fc-palco { position: relative; margin: 22px 0 6px; padding: 0 4px 12px; perspective: 1400px; isolation: isolate; }
.fc-palco::before, .fc-palco::after {
  content: ''; position: absolute; inset: 16px 14px 4px; z-index: -1; pointer-events: none;
  border: 1px solid var(--line-2); border-radius: 20px; background: var(--fc-papel); transform: rotate(-1.6deg);
}
.fc-palco::after { inset: 18px 12px 0; z-index: -2; background: var(--surface); transform: rotate(1.6deg); }
.fc-cartao { border-radius: 18px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.fc-miolo { display: grid; transform-style: preserve-3d; transition: transform var(--mov-enfase) var(--mov-ease); }
.fc-cartao.virado .fc-miolo { transform: rotateY(180deg); }
.fc-face {
  grid-area: 1 / 1; position: relative; display: flex; flex-direction: column; height: clamp(300px, 52vh, 460px);
  padding: 20px 26px 16px; overflow: hidden; border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface);
  box-shadow: 0 18px 34px -16px var(--fc-sombra-forte); backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.fc-face::before { content: ''; position: absolute; inset: 0 0 auto; height: 5px; background: var(--k1); }
.fc-verso { transform: rotateY(180deg); background: var(--fc-verso); }
.fc-face:focus { outline: none; }
.fc-face:focus-visible { outline: 2px solid var(--k1); outline-offset: 3px; }
.fc-face-topo, .fc-face-pe { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.fc-face-topo { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.fc-face-pe { padding-top: 12px; border-top: 1px solid var(--line); }
.fc-face-pe > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-face-pe > span:last-child { flex: none; }
.fc-marca { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--k1); }
.fc-lado { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
/* margem automática, e não justify-content: center, para o texto longo rolar
   desde a primeira linha em vez de cortar o começo */
.fc-face-corpo {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 16px 4px; overflow-y: auto; overscroll-behavior: contain; text-align: center;
}
.fc-face-corpo > :first-child { margin-top: auto; }
.fc-face-corpo > :last-child { margin-bottom: auto; }
.fc-texto { max-width: 52ch; margin: 0; font-family: var(--font-display); font-size: 23px; line-height: 1.45; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.fc-texto.longo { font-family: var(--font); font-size: 16px; line-height: 1.65; text-align: left; }
/* Dica: o que o autor escreveu para o erro que costuma acontecer. Vem no
   verso, não antes — senão entregaria a resposta. */
.fc-dica {
  max-width: 52ch; margin: 0; padding: 7px 12px; border-left: 2px solid var(--k1); border-radius: 0 6px 6px 0;
  background: var(--k1-t); font-size: 13.5px; line-height: 1.6; color: var(--muted-2); text-align: left;
}

.fc-acoes { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.fc-virar { min-height: 48px; font-size: 14px; }
.fc-pergunta { margin: 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted-2); }
/* As quatro notas: o nome diz o sentido, o número embaixo diz a consequência
   (o intervalo que o FSRS daria) — a cor só reforça. */
.fc-notas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.fc-nota {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 60px; padding: 9px 6px;
  border: 1px solid var(--c); border-radius: 10px; background: var(--bg-c); color: var(--c); font: inherit; cursor: pointer;
}
.fc-nota b { font-size: 14px; font-weight: 700; }
.fc-nota span { font-size: 12px; opacity: .85; font-variant-numeric: tabular-nums; }
.fc-nota:hover { filter: brightness(1.06); transform: translateY(-1px); }
.fc-nota:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.fc-nota.again { --c: var(--err); --bg-c: var(--err-bg); }
.fc-nota.hard { --c: var(--warn); --bg-c: var(--warn-bg); }
.fc-nota.good { --c: var(--ok); --bg-c: var(--ok-bg); }
.fc-nota.easy { --c: var(--k2); --bg-c: var(--k2-t); }

.fc-fim {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 20px; text-align: center;
  border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface);
}
.fc-fim .ring { width: 64px; height: 64px; margin-bottom: 10px; display: grid; place-items: center; border-radius: 999px; background: var(--k1-t); }
.fc-fim h3 { margin: 0; font-size: 19px; }
.fc-fim p { max-width: 48ch; margin: 0; font-size: 13.5px; color: var(--muted); }
.fc-fim .fc-aviso { color: var(--warn); }
.fc-fim-acoes { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }
.fc-fim-acoes .btn { min-height: 44px; }

/* ------------------------------------------------------------ larguras */

@media (max-width: 1100px) { .fc-pilhas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .fc-assuntos { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .fc-cab { align-items: stretch; }
  .fc-cab > .btn, .fc-hoje-ok, .fc-hoje-ok .btn { width: 100%; }
  .fc-hoje-ok { align-items: stretch; text-align: center; }
  .fc-filtros button { min-height: 40px; }
  .fc-continuar-acoes { width: 100%; }
  .fc-continuar-acoes .btn { flex: 1; }
  .fc-palco { margin-top: 16px; }
  /* o que sobra da tela depois do cabeçalho, das notas e da barra de baixo: as
     quatro notas cabem sem rolar mesmo em 360 × 740 */
  .fc-face { height: clamp(240px, calc(100dvh - 430px), 400px); padding: 16px 18px 14px; }
  .fc-texto { font-size: 20px; }
  .fc-notas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fc-nota { min-height: 52px; }
}
@media (max-width: 420px) {
  .fc-pilhas { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .fc-pilha-face { min-height: 150px; }
}
@media (hover: none) { .fc-pilha:hover, .fc-nota:hover { transform: none; } }

/* Movimento reduzido: a face troca sem girar. A face de trás some (visibility),
   e continua inert e aria-hidden como no giro. */
@media (prefers-reduced-motion: reduce) {
  .fc-miolo { transition: none; transform: none !important; }
  .fc-face { backface-visibility: visible; -webkit-backface-visibility: visible; }
  .fc-verso { transform: none; }
  .fc-cartao:not(.virado) .fc-verso, .fc-cartao.virado .fc-frente { visibility: hidden; }
  .fc-pilha { transition: none; }
  .fc-pilha:hover, .fc-nota:hover { transform: none; }
}
