/* ==========================================================================
   EnglishLeo Flashcards
   Scoped to .elfc so the theme can't interfere and several decks can share
   a page. No font-family is declared anywhere — everything inherits from
   your site's own typography.
   ========================================================================== */

.elfc {
  --elfc-ink:       #23201c;
  --elfc-paper:     #faf7f2;
  --elfc-card:      #ffffff;
  --elfc-card-back: #f4efe6;
  --elfc-line:      #ded6c9;
  --elfc-accent:    #b8443a;
  --elfc-green:     #3d7a4e;
  --elfc-focus:     #b8860b;
  --elfc-muted:     #857b6e;

  --elfc-box1:      #f0e2df;
  --elfc-box2:      #e2ebe2;
  --elfc-box3:      #e0e6f0;
  --elfc-box4:      #efe9da;
  --elfc-box5:      #e8e0ef;

  --elfc-radius:    10px;
  --elfc-radius-lg: 14px;
  --elfc-lift:      0 1px 2px rgba(35,32,28,.05), 0 4px 14px rgba(35,32,28,.07);
  --elfc-lift-lg:   0 2px 4px rgba(35,32,28,.05), 0 12px 32px rgba(35,32,28,.10);

  color: var(--elfc-ink);
  background: var(--elfc-paper);
  border: 1px solid var(--elfc-line);
  border-radius: var(--elfc-radius-lg);
  max-width: 760px;
  margin: 2.5rem auto;
  padding: 2.25rem 2rem 2.75rem;
  box-sizing: border-box;
  line-height: 1.55;

  /* No blue flash when tapping cards and buttons on touch devices. */
  -webkit-tap-highlight-color: transparent;
}
.elfc *, .elfc *::before, .elfc *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.elfc p { margin: 0; }
.elfc button { font: inherit; color: inherit; }

/* --- Header -------------------------------------------------------------- */
.elfc-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  padding-bottom: 1.1rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--elfc-line);
}
.elfc-header h2 {
  font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em;
  margin: 0; padding: 0; border: none; background: none; color: var(--elfc-ink);
}
.elfc-total { font-size: .88rem; color: var(--elfc-muted); }

/* --- Tabs ---------------------------------------------------------------- */
.elfc-tabs {
  display: inline-flex; gap: .25rem; margin-bottom: 1.5rem;
  background: rgba(35,32,28,.045); padding: .25rem; border-radius: var(--elfc-radius);
}
.elfc-tab-btn {
  background: transparent; border: none; cursor: pointer;
  padding: .5rem 1.05rem; border-radius: calc(var(--elfc-radius) - 3px);
  font-size: .9rem; font-weight: 500; color: var(--elfc-muted);
  transition: background .15s, color .15s;
}
.elfc-tab-btn.is-active { background: var(--elfc-card); color: var(--elfc-ink); box-shadow: var(--elfc-lift); }
.elfc-tab-btn:hover:not(.is-active) { color: var(--elfc-ink); }
.elfc-tab-btn:focus-visible { outline: 2px solid var(--elfc-focus); outline-offset: 2px; }

/* --- Panels -------------------------------------------------------------- */
.elfc-panel { display: none; }
.elfc-panel.is-active { display: block; }
.elfc-study { text-align: center; }

/* --- Box rail ------------------------------------------------------------ */
.elfc-box-rail {
  display: flex; gap: .6rem; margin-bottom: 1.6rem;
  flex-wrap: wrap; justify-content: center;
}
.elfc-chip {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  border: 1px solid var(--elfc-line); border-radius: var(--elfc-radius);
  background: var(--elfc-card); padding: .6rem 1rem; min-width: 76px;
  cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
  font-size: .78rem; color: var(--elfc-muted);
}
.elfc-chip:hover { transform: translateY(-1px); box-shadow: var(--elfc-lift); }
.elfc-chip.is-active { border-color: var(--elfc-ink); color: var(--elfc-ink); box-shadow: var(--elfc-lift); }
.elfc-chip:focus-visible { outline: 2px solid var(--elfc-focus); outline-offset: 2px; }
.elfc-chip-count { font-size: 1.45rem; font-weight: 600; line-height: 1.15; color: var(--elfc-ink); }
.elfc-chip-b1 { background: var(--elfc-box1); }
.elfc-chip-b2 { background: var(--elfc-box2); }
.elfc-chip-b3 { background: var(--elfc-box3); }
.elfc-chip-b4 { background: var(--elfc-box4); }
.elfc-chip-b5 { background: var(--elfc-box5); }

/* --- Session progress ---------------------------------------------------- */
.elfc-session-bar {
  max-width: 520px; margin: 0 auto .9rem; height: 5px;
  background: rgba(35,32,28,.09); border-radius: 999px; overflow: hidden;
}
.elfc-session-fill { height: 100%; background: var(--elfc-ink); border-radius: 999px; transition: width .35s; }

.elfc-meta {
  font-size: .95rem; color: var(--elfc-muted); margin-bottom: 1.4rem;
}

/* --- Flip card ----------------------------------------------------------- */
.elfc-card {
  perspective: 1400px; width: 100%; max-width: 520px; min-height: 300px;
  margin: 0 auto 1.4rem; cursor: pointer; background: none; border: none;
  padding: 0; display: block; -webkit-tap-highlight-color: transparent;
}
.elfc-card:focus-visible { outline: 2px solid var(--elfc-focus); outline-offset: 6px; border-radius: var(--elfc-radius-lg); }
.elfc-card-inner {
  width: 100%; min-height: 300px; position: relative;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.32,.72,.35,1);
}
.elfc-card.is-flipped .elfc-card-inner { transform: rotateY(180deg); }

.elfc-face {
  position: absolute; inset: 0;
  border: 1px solid var(--elfc-line); border-radius: var(--elfc-radius-lg);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2.75rem 2.25rem; text-align: center;
  box-shadow: var(--elfc-lift-lg);
}
.elfc-face-front { background: var(--elfc-card); }
.elfc-face-back  { background: var(--elfc-card-back); transform: rotateY(180deg); }

.elfc-def {
  font-size: 1.2rem; line-height: 1.6; max-width: 28ch; color: var(--elfc-ink);
}
.elfc-word {
  font-size: 2.1rem; font-weight: 600; line-height: 1.2; letter-spacing: -.015em;
}
.elfc-pos {
  font-size: .95rem; font-style: italic; color: var(--elfc-muted); margin-top: .45rem;
}

/* --- Listen button (back of card only) ----------------------------------- */
.elfc-audio {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  margin-top: 1.5rem; padding: .55rem 1.15rem;
  border: 1px solid var(--elfc-line); border-radius: 999px;
  background: var(--elfc-card); cursor: pointer;
  font-size: .88rem; color: var(--elfc-ink);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.elfc-audio:hover { transform: translateY(-1px); box-shadow: var(--elfc-lift); border-color: var(--elfc-muted); }
.elfc-audio:focus-visible { outline: 2px solid var(--elfc-focus); outline-offset: 2px; }
.elfc-audio svg { width: 16px; height: 16px; flex: none; fill: currentColor; }
.elfc-audio.is-playing { background: var(--elfc-ink); color: var(--elfc-card); border-color: var(--elfc-ink); }
.elfc-audio.is-error { border-color: var(--elfc-accent); color: var(--elfc-accent); }

@keyframes elfc-pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }
.elfc-audio.is-playing { animation: elfc-pulse 1s ease-in-out infinite; }

/* --- Answer buttons ------------------------------------------------------
   The row keeps its space when hidden, so revealing the answer never
   shifts the page.
   ------------------------------------------------------------------------- */
.elfc-answers {
  display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap;
  min-height: 46px; transition: opacity .2s;
}
.elfc-answers.is-hidden { visibility: hidden; opacity: 0; pointer-events: none; }

/* --- Buttons ------------------------------------------------------------- */
.elfc-btn {
  display: inline-block; border: 1px solid var(--elfc-line);
  border-radius: 999px; padding: .65rem 1.4rem;
  font-size: .92rem; font-weight: 500; cursor: pointer;
  background: var(--elfc-card); color: var(--elfc-ink);
  transition: transform .15s, box-shadow .15s, filter .15s;
  text-decoration: none; line-height: 1.2;
}
.elfc-btn:hover { transform: translateY(-1px); box-shadow: var(--elfc-lift); }
.elfc-btn:active { transform: translateY(0); }
.elfc-btn:focus-visible { outline: 2px solid var(--elfc-focus); outline-offset: 2px; }
.elfc-btn-wrong { background: var(--elfc-accent); border-color: var(--elfc-accent); color: #fff; }
.elfc-btn-wrong:hover { color: #fff; filter: brightness(1.06); }
.elfc-btn-right { background: var(--elfc-green); border-color: var(--elfc-green); color: #fff; }
.elfc-btn-right:hover { color: #fff; filter: brightness(1.06); }
.elfc-btn-outline { background: transparent; }

/* --- Empty state --------------------------------------------------------- */
.elfc-empty {
  border: 1px dashed var(--elfc-line); border-radius: var(--elfc-radius-lg);
  padding: 2.75rem 1.75rem; text-align: center;
  color: var(--elfc-muted); font-size: .98rem; line-height: 1.8;
  background: var(--elfc-card);
}
.elfc-empty strong { color: var(--elfc-ink); }
.elfc-empty .elfc-btn { margin-top: .5rem; }

.elfc-done { padding: 3rem 1.75rem; border-style: solid; }
.elfc-done-mark {
  display: block; width: 52px; height: 52px; margin: 0 auto 1.1rem;
  border-radius: 50%; background: var(--elfc-green); color: #fff;
  font-size: 1.6rem; line-height: 52px; text-align: center;
}
.elfc-done-title { font-size: 1.25rem; font-weight: 600; color: var(--elfc-ink); }
.elfc-done-sub   { font-size: .95rem; color: var(--elfc-muted); margin-top: .4rem; margin-bottom: 1.6rem; }

/* --- Word list ----------------------------------------------------------- */
.elfc-list-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.1rem; flex-wrap: wrap; gap: .6rem;
}
.elfc-list-head h3 {
  font-size: 1.1rem; font-weight: 600;
  margin: 0; padding: 0; border: none; background: none; color: var(--elfc-ink);
}
.elfc-search {
  width: 100%; font: inherit; font-size: .95rem;
  border: 1px solid var(--elfc-line); border-radius: var(--elfc-radius);
  background: var(--elfc-card); color: var(--elfc-ink);
  padding: .65rem .9rem; margin-bottom: 1rem;
}
.elfc-search:focus-visible { outline: 2px solid var(--elfc-focus); outline-offset: 1px; }
.elfc-filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.elfc-filter {
  border: 1px solid var(--elfc-line); border-radius: 999px;
  padding: .35rem .9rem; font-size: .85rem; cursor: pointer;
  background: var(--elfc-card); color: var(--elfc-muted); transition: all .15s;
}
.elfc-filter:hover { color: var(--elfc-ink); }
.elfc-filter.is-on { background: var(--elfc-ink); border-color: var(--elfc-ink); color: var(--elfc-paper); }
.elfc-filter:focus-visible { outline: 2px solid var(--elfc-focus); outline-offset: 2px; }

.elfc-rows { display: flex; flex-direction: column; gap: .5rem; }
.elfc-row {
  display: grid; grid-template-columns: minmax(100px,.75fr) 1fr auto;
  align-items: center; gap: .9rem;
  border: 1px solid var(--elfc-line); border-radius: var(--elfc-radius);
  padding: .8rem 1.1rem; background: var(--elfc-card);
}
.elfc-row-word { font-size: 1rem; font-weight: 600; }
.elfc-row-word em { font-size: .82rem; font-weight: 400; color: var(--elfc-muted); }
.elfc-row-def {
  font-size: .9rem; color: var(--elfc-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.elfc-badge {
  font-size: .76rem; padding: .25rem .65rem; border-radius: 999px;
  border: 1px solid var(--elfc-line); white-space: nowrap; color: var(--elfc-ink);
}

/* --- Progress ------------------------------------------------------------ */
.elfc-prog-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: .75rem; margin-bottom: 2rem; }
.elfc-prog-box {
  border: 1px solid var(--elfc-line); border-radius: var(--elfc-radius);
  padding: 1.35rem .75rem; text-align: center;
}
.elfc-prog-box.elfc-chip-b1 { background: var(--elfc-box1); }
.elfc-prog-box.elfc-chip-b2 { background: var(--elfc-box2); }
.elfc-prog-box.elfc-chip-b3 { background: var(--elfc-box3); }
.elfc-prog-box.elfc-chip-b4 { background: var(--elfc-box4); }
.elfc-prog-box.elfc-chip-b5 { background: var(--elfc-box5); }
.elfc-prog-num { font-size: 2rem; font-weight: 600; line-height: 1; }
.elfc-prog-label { font-size: .82rem; color: var(--elfc-muted); margin-top: .4rem; }

.elfc-bar-wrap {
  height: 10px; background: rgba(35,32,28,.09);
  border-radius: 999px; overflow: hidden; margin-bottom: .5rem;
}
.elfc-bar { height: 100%; background: var(--elfc-green); border-radius: 999px; transition: width .5s; }
.elfc-bar-stat { font-size: .88rem; color: var(--elfc-muted); text-align: right; }
.elfc-bar-head { font-size: .95rem; font-weight: 600; margin-bottom: .5rem; }
.elfc-prog-note { font-size: .92rem; color: var(--elfc-muted); margin-top: 1.25rem; }
.elfc-prog-done {
  font-size: .95rem; color: var(--elfc-ink); margin-top: 1.25rem;
  background: var(--elfc-box2); border: 1px solid var(--elfc-line);
  border-radius: var(--elfc-radius); padding: .9rem 1.1rem; line-height: 1.6;
}

/* --- Toast --------------------------------------------------------------- */
.elfc-toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: #23201c; color: #faf7f2;
  padding: .75rem 1.35rem; border-radius: 999px; font-size: .92rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.22);
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; white-space: nowrap; z-index: 99999;
}
.elfc-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.elfc-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
}

/* --- Mobile --------------------------------------------------------------
   Statistics stay legible: the meta line, chip counts and totals are all
   sized up rather than down.
   ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .elfc {
    margin: 1.25rem auto; padding: 1.5rem 1.15rem 2rem;
    border-radius: var(--elfc-radius);
  }
  .elfc-header { margin-bottom: 1.2rem; padding-bottom: .9rem; }
  .elfc-header h2 { font-size: 1.2rem; }

  .elfc-total { font-size: .95rem; }
  .elfc-meta  { font-size: 1rem; margin-bottom: 1.2rem; }

  .elfc-tabs { display: flex; width: 100%; }
  .elfc-tab-btn { flex: 1; padding: .6rem .35rem; font-size: .92rem; }

  .elfc-box-rail { gap: .5rem; }
  .elfc-chip { flex: 1; min-width: 0; padding: .65rem .4rem; font-size: .82rem; }
  .elfc-chip-count { font-size: 1.5rem; }

  .elfc-card, .elfc-card-inner { min-height: 265px; }
  .elfc-face { padding: 2.25rem 1.35rem; }
  .elfc-def  { font-size: 1.12rem; max-width: none; }
  .elfc-word { font-size: 1.85rem; }

  .elfc-btn { padding: .7rem 1.2rem; font-size: .95rem; }
  .elfc-answers { gap: .6rem; min-height: 50px; }

  .elfc-row { grid-template-columns: 1fr auto; row-gap: .35rem; }
  .elfc-row-def { grid-column: 1 / -1; white-space: normal; font-size: .88rem; }

  .elfc-done-title { font-size: 1.15rem; }
  .elfc-prog-note, .elfc-prog-done { font-size: .95rem; }
  .elfc-prog-num   { font-size: 1.75rem; }
  .elfc-prog-label { font-size: .8rem; }
  .elfc-bar-stat   { font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .elfc-card-inner, .elfc-btn, .elfc-bar, .elfc-session-fill,
  .elfc-audio, .elfc-chip, .elfc-answers { transition: none; }
  .elfc-audio.is-playing { animation: none; }
}
