/* Memorize · CSS3 puro (sem frameworks) */

:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #f0f0f7;
  --text: #1b1b2b;
  --muted: #62627a;
  --border: #e1e1ec;
  --primary: #5b5bd6;
  --primary-hover: #4a4ac4;
  --primary-soft: #ebebfc;
  --on-primary: #ffffff;
  --discord: #5865f2;
  --hard: #b03a0a;
  --hard-soft: #fff0e8;
  --good: #1c6fd1;
  --good-soft: #e8f1fd;
  --easy: #23733a;
  --easy-soft: #e8f6eb;
  --danger: #c92a2a;
  --shadow: 0 1px 2px rgb(20 20 50 / .06), 0 8px 24px rgb(20 20 50 / .08);
  --shadow-lg: 0 2px 4px rgb(20 20 50 / .06), 0 18px 48px rgb(20 20 50 / .14);
  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12121a;
    --surface: #1c1c27;
    --surface-2: #252533;
    --text: #ececf4;
    --muted: #a0a0b8;
    --border: #2f2f40;
    --primary: #8585f0;
    --primary-hover: #9a9af5;
    --primary-soft: #26264a;
    --on-primary: #12121a;
    --hard: #ff8a4c;
    --hard-soft: #3a2419;
    --good: #6aa8f7;
    --good-soft: #1b2b42;
    --easy: #63c77a;
    --easy-soft: #1a3322;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / .3), 0 18px 48px rgb(0 0 0 / .45);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}
[hidden] { display: none !important; }
a { color: var(--primary); }
code, kbd { font-family: var(--mono); font-size: .9em; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -.02em; }
.h2 { font-size: 1.4rem; }
.h3 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, calc((100vw - 1040px) / 2));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--primary); }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); flex: none; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }
.view { animation: fade-in .25s ease both; }
.view-center { min-height: 50vh; display: grid; place-content: center; justify-items: center; gap: 8px; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.center { justify-content: center; }
.crumbs { margin-bottom: 12px; }
.crumbs a { text-decoration: none; font-weight: 600; }
.section-title { font-size: 1.15rem; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-title { font-size: 1rem; font-weight: 700; margin: 0 0 12px; }
details.panel > summary { cursor: pointer; margin: 0; list-style-position: inside; }
details.panel[open] > summary { margin-bottom: 12px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field > span { font-size: .9rem; font-weight: 600; }
input, textarea {
  width: 100%; font: inherit; color: inherit;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-inline { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 0 12px; align-items: end; }
.form-inline .panel-title { grid-column: 1 / -1; }
.form-inline .btn { margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.checkbox { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.checkbox input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-ghost { color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: .9rem; }
.btn-lg { padding: 13px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-discord { background: var(--discord); border-color: var(--discord); color: #fff; box-shadow: 0 6px 18px rgb(88 101 242 / .35); }
.btn-discord:hover { background: #4752c4; border-color: #4752c4; }
.btn kbd { font-size: .75rem; opacity: .8; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; }

.badge { font-size: .8rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 1px 9px; }
.pill { font-size: .85rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.pill-review { background: var(--good-soft); color: var(--good); }
.pill-new { background: var(--easy-soft); color: var(--easy); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-top: 16px; }
.alert-error { background: var(--hard-soft); color: var(--hard); }

/* ---------- Login ---------- */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; padding: 32px 0 24px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 52ch; margin: 0 0 24px; }
.hero-demo { display: grid; place-items: center; perspective: 1000px; }
.demo-card { width: min(320px, 80vw); aspect-ratio: 3 / 2; }
.demo-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: demo-flip 6s ease-in-out infinite; }
.demo-face {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center;
  font-size: 1.25rem; font-weight: 700; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.demo-back { transform: rotateY(180deg); background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
@keyframes demo-flip { 0%, 35% { transform: rotateY(0); } 50%, 85% { transform: rotateY(180deg); } 100% { transform: rotateY(360deg); } }
.features { list-style: none; padding: 0; margin: 24px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.features li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; }
.features span { color: var(--muted); font-size: .95rem; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat dt { font-size: .85rem; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.deck {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.deck:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.deck h3 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.deck p { margin: 0; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.deck-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: .85rem; }
.deck-meta span { background: var(--surface-2); border-radius: 99px; padding: 2px 9px; }
.deck-meta .due { background: var(--good-soft); color: var(--good); font-weight: 700; }
.deck-meta .new { background: var(--easy-soft); color: var(--easy); font-weight: 700; }
.deck .actions { margin-top: auto; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius); grid-column: 1 / -1; }

/* ---------- Card list ---------- */
.card-list { display: grid; gap: 10px; }
.card-row {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px;
}
.card-row .side { white-space: pre-wrap; overflow-wrap: anywhere; }
.card-row .side small { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.card-row .info { grid-column: 1 / 3; font-size: .82rem; color: var(--muted); }
.card-row .row-actions { display: flex; gap: 4px; grid-row: 1; grid-column: 3; }

/* ---------- Estudo / cartão que vira ---------- */
.study-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.study-counts { display: flex; gap: 6px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 22px; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .4s ease; }
#study-area { max-width: 640px; margin: 0 auto; }

.flashcard {
  perspective: 1400px;
  cursor: pointer;
  outline: none;
  border-radius: var(--radius);
  transition: opacity .22s ease, transform .22s ease;
  -webkit-tap-highlight-color: transparent;
}
.flashcard:focus-visible .face { outline: 3px solid var(--primary); outline-offset: 3px; }
.flashcard-inner {
  display: grid;                       /* as duas faces se sobrepõem na mesma célula */
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.3, .7, .25, 1);
}
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
@media (hover: hover) {
  .flashcard:hover:not(.is-flipped) .flashcard-inner { transform: rotateY(6deg); }
}
.face {
  grid-area: 1 / 1;
  position: relative;
  min-height: clamp(240px, 42vh, 380px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 44px 28px 36px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face-back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--surface), var(--primary-soft)); }
.face-label { position: absolute; top: 14px; left: 18px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card-tag { position: absolute; top: 12px; right: 14px; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.card-tag.is-new { background: var(--easy-soft); color: var(--easy); }
.card-tag.is-review { background: var(--good-soft); color: var(--good); }
.face-text { font-size: clamp(1.25rem, 3.2vw, 1.8rem); font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow: auto; }
.face-hint { position: absolute; bottom: 12px; font-size: .82rem; color: var(--muted); }
.face-mini { font-size: .9rem; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid var(--border); padding-top: 10px; max-width: 90%; }

/* troca de cartão */
.flashcard.is-leaving { opacity: 0; transform: translateX(-28px) rotate(-1.5deg); }
.flashcard.is-entering { opacity: 0; transform: translateX(28px); transition: none; }
.flashcard.no-anim .flashcard-inner { transition: none; }

.study-actions { margin-top: 20px; }
.rating { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.btn-rate {
  display: grid; justify-items: center; gap: 2px;
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 12px 8px; border-radius: var(--radius-sm); border: 2px solid transparent;
  transition: transform .1s, filter .15s, box-shadow .15s;
}
.btn-rate small { font-weight: 600; font-size: .8rem; opacity: .85; }
.btn-rate kbd { font-size: .7rem; opacity: .6; }
.btn-rate:hover { filter: brightness(1.05); box-shadow: var(--shadow); }
.btn-rate:active { transform: scale(.97); }
.btn-rate[disabled] { opacity: .5; cursor: wait; }
.rate-hard { background: var(--hard-soft); color: var(--hard); border-color: color-mix(in srgb, var(--hard) 35%, transparent); }
.rate-good { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.rate-easy { background: var(--easy-soft); color: var(--easy); border-color: color-mix(in srgb, var(--easy) 35%, transparent); }

.done { max-width: 520px; margin: 24px auto; text-align: center; padding: 32px 20px; }
.done-icon { width: 64px; height: 64px; margin: 0 auto 12px; display: grid; place-items: center; font-size: 2rem; border-radius: 50%; background: var(--easy-soft); color: var(--easy); animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Dialog / toasts / spinner ---------- */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgb(10 10 30 / .45); backdrop-filter: blur(2px); }
.dialog-foot { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 8px; margin-top: 8px; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-weight: 600; animation: rise .25s ease both; }
.toast.is-error { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .toast.is-error { color: #12121a; } }
.toast.is-hiding { opacity: 0; transform: translateY(6px); transition: .25s; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--surface-2); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Rodapé ---------- */
.footer { border-top: 1px solid var(--border); padding: 18px 16px; text-align: center; font-size: .9rem; }
.footer p { margin: 2px 0; }
.footer code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-weight: 700; }

/* ---------- Responsivo ---------- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 8px; }
  .features { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-inline { grid-template-columns: 1fr; }
  .form-inline .btn { justify-self: start; }
}
@media (max-width: 560px) {
  .two-col { grid-template-columns: 1fr; }
  .card-row { grid-template-columns: 1fr auto; }
  .card-row .side + .side { grid-column: 1; }
  .card-row .info { grid-column: 1 / -1; }
  .card-row .row-actions { grid-row: 1 / 3; grid-column: 2; flex-direction: column; }
  .user-name { display: none; }
  .face { padding: 40px 18px 34px; }
  .btn-rate { padding: 10px 4px; }
  .btn-rate kbd, .btn kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
