/* =====================================================================
   Flashcards — custom styling on top of Pico.css
   Pretty, calm, flashcards.world-ish: soft gradients, big type, 3D flip.
   ===================================================================== */

:root {
  --fc-accent: #6d5efc;      /* soft indigo */
  --fc-accent-2: #8b7dff;
  --fc-ink: #1c1b2e;
  --fc-bg: #f6f5ff;

  /* Six greens for the 6 mastery stages (light -> deep). */
  --stage-1: #c8e6c9;
  --stage-2: #a5d6a4;
  --stage-3: #81c774;
  --stage-4: #66bb6a;
  --stage-5: #4caf50;
  --stage-6: #388e3c;
  --stage-0: #ffffff;        /* new / empty */
}

/* Dark mode support */
:root[data-theme="dark"] {
  --fc-accent: #8b7dff;
  --fc-accent-2: #a598ff;
  --fc-ink: #f0efff;
  --fc-bg: #1a1a2e;
  --stage-0: #2a2a4a;
  --stage-1: #3a4a3e;
  --stage-2: #3f6b2a;
  --stage-3: #4a8a2a;
  --stage-4: #5fb030;
  --stage-5: #6fc02a;
  --stage-6: #7ad81e;
}

:root[data-theme="dark"] .card-face.card-front {
  background: linear-gradient(160deg, #2a2a4a, #332e4d);
  border-color: #3a3a5a;
}

:root[data-theme="dark"] .card-face.card-back {
  /* card-back already has gradient */
}

:root[data-theme="dark"] .deck-card {
  background: #2a2a4a;
  border-color: #3a3a5a;
}

:root[data-theme="dark"] .deck-count { color: #807f9a; }
:root[data-theme="dark"] .deck-subcategory { background: rgba(139, 125, 255, 0.15); color: #8b7dff; }
:root[data-theme="dark"] .deck-progress-bar { background: #3a3a5a; }
:root[data-theme="dark"] .matrix-cell {
  border-color: #3a3a5a;
}

:root[data-theme="dark"] #matrix-wrap {
  background: rgba(26,26,46,.85);
}

:root[data-theme="dark"] .auth-error {
  background: #3a2a2a;
  border-color: #b23;
  color: #ff8080;
}

:root[data-theme="dark"] #forgot-form {
  background: #2a2a4a;
  border-color: #3a3a5a;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #ece9ff 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 20%, #fef0f6 0%, transparent 55%),
    var(--fc-bg);
  min-height: 100vh;
  padding-bottom: 80px;
  box-sizing: border-box;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 80% 110%, #ece9ff 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 80%, #fef0f6 0%, transparent 55%),
    var(--fc-bg);
}

* { box-sizing: border-box; }
.container { max-width: 780px; margin: 0 auto; padding: 3rem 1rem; }

/* Pico.css overrides — our custom button styles */
button {
  border-radius: 10px;
  font-weight: 500;
  transition: transform .15s, box-shadow .15s;
}
button.secondary {
  background: #f0eefe; border-color: #e4e1f5; color: var(--fc-ink);
}
button.secondary.outline {
  background: transparent; border-color: #d4d1e8; color: var(--fc-ink);
}
button.primary {
  background: var(--fc-accent); color: #fff; border-color: var(--fc-accent);
}
button.primary:hover { background: var(--fc-accent-2); border-color: var(--fc-accent-2); }
a.secondary { color: var(--fc-accent); text-decoration: none; }
a.secondary:hover { text-decoration: underline; }

/* -------------------------------------------------------------- deck picker */
.hero { text-align: center; margin-bottom: 2.5rem; }
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  background: linear-gradient(120deg, var(--fc-accent), #e26fae);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: .3rem;
}
.hero p { color: #6b6a80; }

.picker-header { margin-bottom: 1.5rem; }
.top-bar-spacer { height: 60px; }

.deck-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.deck-list li { padding: 0; }

.deck-card {
  background: #fff; border: 1px solid #eceaff; border-radius: 16px;
  box-shadow: 0 8px 24px rgba(109,94,252,.06); transition: transform .15s, box-shadow .15s;
  overflow: hidden; cursor: pointer;
}
.deck-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(109,94,252,.14); border-color: var(--fc-accent-2); }

.deck-card-inner { display: flex; align-items: center; gap: 1rem; padding: 1.15rem 1.4rem; }

.deck-cover {
  width: 64px; height: 64px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--fc-accent), var(--fc-accent-2));
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.8rem;
}
.deck-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.deck-cover .deck-initial { font-size: 2rem; }
.deck-cover .deck-emoji { font-size: 2.5rem; }

.deck-info { flex: 1; min-width: 0; }
.deck-title { font-size: 1.15rem; font-weight: 600; margin: 0 0 .2rem; color: var(--fc-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-meta { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.deck-subcategory {
  background: rgba(109, 94, 252, 0.1); color: var(--fc-accent);
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 6px;
}
.deck-count { color: #9a98b5; font-size: .8rem; }
.deck-mastery { font-size: .8rem; font-weight: 600; color: var(--fc-ink); }
.deck-progress-bar {
  width: 100%; height: 6px; background: #e4e1f5; border-radius: 3px; overflow: hidden;
}
.deck-progress-fill {
  height: 100%; background: var(--fc-accent); border-radius: 3px; transition: width .3s;
}
.deck-actions { display: flex; gap: .25rem; flex-shrink: 0; }
.profile-deck-actions { display: flex; gap: .25rem; flex-shrink: 0; }

/* Search row */
.search-row {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
}
.search-row input { flex: 1; max-width: 50%; }
.search-actions { display: flex; gap: .5rem; align-items: center; }

/* -------------------------------------------------------------- deck bar + study layout */
.deck-bar {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem;
}
.deck-bar .secondary.outline { padding: .3rem .7rem; }
.deck-cover-bar {
  width: 40px; height: 40px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--fc-accent), var(--fc-accent-2));
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.2rem;
}
.deck-initial-bar { font-size: 1.2rem; }
.deck-bar #deck-name { font-size: 1.1rem; font-weight: 600; color: var(--fc-ink); }
.deck-bar #mastery-pct { font-weight: 600; color: #6b6a80; }

.study-main {
  display: flex; align-items: flex-start; gap: 1rem;
}
#matrix-wrap-study {
  position: static; transform: none; display: flex; flex-direction: column;
  align-items: center; margin-top: 0;
}
#matrix-wrap-study .matrix-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .18em; color: #9a98b5; }

.card-stage { perspective: 1400px; display: flex; flex: 1; justify-content: center; }

/* Card actions row: position label + Next button. */
.card-actions {
  display: flex; align-items: center; justify-content: center; gap: 1.2rem;
  margin-top: 1.6rem;
}
.card-pos { color: #6b6a80; font-size: .9rem; font-weight: 600; }
.next-btn {
  width: auto; margin: 0; padding: .55rem 1.6rem; font-size: .95rem;
  border-radius: 999px;
}
.card {
  position: relative; width: min(100%, 560px); aspect-ratio: 3 / 2;
  transform-style: preserve-3d; transition: transform .55s cubic-bezier(.4,.2,.2,1);
  cursor: pointer; border-radius: 24px;
}
.card.flipped { transform: rotateY(180deg); }
/* Snap back to front instantly (no flip animation) when advancing decks. */
.card.no-anim { transition: none; }
.card:focus-visible { outline: 3px solid var(--fc-accent-2); outline-offset: 6px; }

.card-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 24px; padding: 2rem; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  box-shadow: 0 24px 60px rgba(28,27,46,.14);
}
.card-front {
  background: linear-gradient(160deg, #ffffff, #f3f1ff);
  border: 1px solid #e9e6ff;
}
.card-back {
  background: linear-gradient(160deg, var(--fc-accent), #7a6bff);
  color: #fff; transform: rotateY(180deg);
  display: flex; flex-direction: column; align-items: center;
  gap: .8rem; padding: 2rem; box-sizing: border-box;
}
.know-label {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  font-size: 0.95rem; color: #fff;
}
.know-label input[type="checkbox"] {
  width: 18px; height: 18px; cursor: pointer;
}
.know-label .check-icon {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
}
.know-label.known input[type="checkbox"] { opacity: 1; }
.face-tag {
  position: absolute; top: 1rem; left: 1.2rem; font-size: .68rem;
  text-transform: uppercase; letter-spacing: .2em; color: #b7b2d8;
}
.word { font-size: clamp(2rem, 7vw, 3.4rem); font-weight: 700; color: var(--fc-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.word-sm { font-size: 1.3rem; font-weight: 600; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.translation { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 700; line-height: 1.1; word-break: break-word; }
.sentence { font-size: 1rem; font-style: italic; opacity: .92; max-width: 40ch; line-height: 1.1; }
.sentence-front {
  font-size: 1rem;
  font-style: italic;
  opacity: .7;
  color: #6b6a80;
  max-width: 40ch;
  line-height: 1.1;
  margin-top: 1rem;
  text-align: center;
}
.hint { position: absolute; bottom: 1rem; color: #b7b2d8; font-size: .75rem; }

.card-overlay-btns {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}
.card-overlay-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.85);
  border: none;
  color: #6b6a80;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  backdrop-filter: blur(2px);
  font-size: 1.1rem;
}
.card-overlay-btn:hover {
  background: rgba(255,255,255,.95);
  transform: scale(1.1);
}
.card-overlay-btn.favorited { color: #ffd43b; }
.know-label {
  display: none;
}

:root[data-theme="dark"] .card-overlay-btns {
  /* keep visible in dark mode */
}

/* -------------------------------------------------------------- the matrix */
#matrix-wrap {
  position: fixed; top: 1rem; right: 1rem; z-index: 40;
  background: rgba(255,255,255,.85); backdrop-filter: blur(6px);
  border: 1px solid #e9e6ff; border-radius: 16px; padding: .7rem;
  box-shadow: 0 12px 30px rgba(28,27,46,.10);
}
.matrix-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .18em; color: #9a98b5; margin-bottom: .4rem; text-align: center; }
.matrix {
  --matrix-n: 10;
  --cell: 16px;
  display: grid;
  grid-template-columns: repeat(var(--matrix-n), var(--cell));
  gap: 2px;
  width: max-content;
  max-width: 180px;
}
.study-deck-image {
  width: 100%; max-width: 180px; border-radius: 12px; margin-top: .8rem;
  object-fit: cover;
}
.matrix-cell {
  width: var(--cell); height: var(--cell);
  border-radius: 3px; background: var(--stage-0);
  border: 1px solid #e4e1f5; transition: background .3s, transform .2s;
}
.matrix-cell.is-blank { background: transparent; border-color: transparent; box-shadow: none; }
.matrix-cell.is-current { outline: 2px solid var(--fc-accent); outline-offset: -2px; }
.matrix-cell.stage-1 { background: var(--stage-1); }
.matrix-cell.stage-2 { background: var(--stage-2); }
.matrix-cell.stage-3 { background: var(--stage-3); }
.matrix-cell.stage-4 { background: var(--stage-4); }
.matrix-cell.stage-5 { background: var(--stage-5); }
.matrix-cell.stage-6 { background: var(--stage-6); }
.matrix-cell.is-flash { animation: cellFlash .45s ease; }
@keyframes cellFlash {
  0%   { transform: scale(1.6); box-shadow: 0 0 0 3px rgba(31,125,18,.5); }
  100% { transform: scale(1); box-shadow: none; }
}

@media (max-width: 768px) {
  .matrix { width: 132px; }
  .study-deck-image { max-width: 132px; }
  .study-main {
    flex-direction: column;
  }
  #matrix-wrap-study { margin-bottom: 1rem; }

  /* Slightly bigger fonts in top bar on mobile */
  .top-title { font-size: 1.25rem; }
  #user-name { font-size: .95rem; }
  .top-bar button { font-size: 1rem; padding: .35rem .7rem; }

  /* Stack auth CTA buttons on narrow screens */
  .auth-cta .grid { flex-direction: column; }
  .auth-cta button { flex: none; width: 100%; }
}

/* -------------------------------------------------------------- auth */
#auth {
  position: fixed;
  inset: 0;
  background: url('../img/bkg/bkg.jpg') center/cover no-repeat fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.auth-frame {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  box-shadow: 0 32px 80px rgba(28, 27, 46, .14);
  border: 1px solid rgba(202, 198, 255, .4);
  padding: 2rem;
  max-width: 90vw;
  width: max-content;
  min-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.hero { text-align: center; margin-bottom: 0; }
.hero h1 {
  font-size: clamp(2rem, 6vw, 2.8rem);
  background: linear-gradient(120deg, var(--fc-accent), #e26fae);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0;
}
.auth-form { width: 100%; margin: 0; text-align: left; }
.auth-form .grid { display: grid; gap: .75rem; }
.auth-form h2 { margin-top: 0; font-size: 1.5rem; }
.auth-form p { font-size: .85rem; color: #6b6a80; }
.auth-form a { color: var(--fc-accent); font-size: .85rem; }
.auth-form a:hover { text-decoration: underline; }
.auth-error { color: #b23; font-size: .85rem; margin-top: .5rem; }
.auth-cta .grid { display: flex; gap: .75rem; flex-wrap: wrap; }
.auth-cta button { flex: 1 1 0; min-width: 0; min-width: 140px; }
#verify-notice { font-size: .85rem; margin-top: 1rem; }
:root[data-theme="dark"] .auth-frame {
  background: rgba(26, 26, 46, .88);
  border-color: #3a3a5a;
}
:root[data-theme="dark"] .hero h1 {
  background: linear-gradient(120deg, #8b7dff, #a598ff);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* -------------------------------------------------------------- top bar */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid #eceaff;
  padding: .4rem 1rem;
}
.top-bar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 780px; margin: 0 auto;
}
.top-left { display: flex; align-items: center; gap: .4rem; }
.top-title {
  font-size: 1.1rem; font-weight: 700; color: var(--fc-ink);
  text-decoration: none;
}
#user-name { color: #6b6a80; font-size: .85rem; }
.top-bar-buttons { display: flex; gap: .4rem; align-items: center; }
.top-bar button { font-size: .85rem; padding: .25rem .6rem; }

:root[data-theme="dark"] .top-bar {
  background: #2a2a4a; border-bottom-color: #3a3a5a;
}

/* -------------------------------------------------------------- card table */
.card-table {
  width: 100%; border-collapse: collapse; margin-top: 1rem;
}
.card-table th { text-align: left; padding: .5rem; border-bottom: 2px solid #e4e1f5; color: #6b6a80; font-size: .8rem; }
.card-table td { padding: .5rem; border-bottom: 1px solid #f0eeff; font-size: .9rem; }
.card-table tr:hover { background: #f8f7ff; }

.sort-menu {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(255,255,255,.85);
  border-radius: 8px;
}
.sort-menu button { font-size: 0.8rem; padding: 0.2rem 0.5rem; }
.search-actions { display: flex; align-items: center; gap: 0.5rem; }

.edit-deck-title {
  font-size: 1.5rem; font-weight: 600; color: var(--fc-ink); margin: 0 0 1rem;
}
.card-editor-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
}
.card-editor-header #cards-deck-name { font-size: 1.2rem; margin: 0; }
.deck-edit-image-row { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.5rem; }

/* -------------------------------------------------------------- footer */
.footer {
  text-align: center; color: #9a98b5; font-size: 0.85rem;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,.93); backdrop-filter: blur(4px);
  border-top: 1px solid #eceaff;
  padding: 0.5rem 1rem; z-index: 100;
  height: auto;
  min-height: 36px;
}
.footer a { color: var(--fc-accent); }
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 780px; margin: 0 auto;
}
.footer-links {
  display: flex; gap: 1rem;
}
@media (data-theme: dark) {
  .footer { background: rgba(17, 17, 28, .93); border-top-color: #2a2a4a; }
}

/* -------------------------------------------------------------- profile page */
#profile-info p { font-size: 0.9rem; margin-bottom: 0.5rem; }
#profile-info strong { color: #6b6a80; }

.card-editor-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.card-editor-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.card-editor-header h3 { margin: 0; font-size: 1.2rem; }

/* -------------------------------------------------------------- modal */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(28, 27, 46, .2);
  border: 1px solid #eceaff;
}
:root[data-theme="dark"] .modal-card {
  background: #2a2a4a;
  border-color: #3a3a5a;
}
.modal-card p {
  margin-bottom: 1.25rem;
  color: var(--fc-ink);
  font-size: .95rem;
}
.modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: center;
}
.modal-actions button {
  min-width: 100px;
}
.deck-edit-name {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 600;
  padding: .3rem .6rem;
  border: 1px solid #e4e1f5;
  border-radius: 8px;
  color: var(--fc-ink);
}
.deck-edit-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}

