/* Lingo Cards — study cards, reveal and actions */

/* Views */
.view { display: none; padding: 28px; max-width: 1100px; width: 100%; margin: 0 auto; flex: 1; min-width: 0; }
.view.active { display: block; }
.view-study.active { display: flex; flex-direction: column; gap: 24px; padding-bottom: 40px; }

/* Study */
.study-filter-panel { display: grid; gap: 10px; }
.study-filter-heading {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--ink-muted);
}
.study-stats { display: flex; gap: 8px; flex-wrap: wrap; }


.deck-browse-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.deck-browse-header h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-browse-back { flex: 0 0 auto; }
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .12s, opacity .12s;
}
.stat-chip:hover { color: var(--ink); }
.stat-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stat-chip:active { transform: translateY(1px); }
.filter-state-mark {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}
.filter-category { display: inline-flex; align-items: baseline; gap: 5px; font-weight: 500; }
.stat-chip b { color: currentColor; font-weight: 700; }

.stat-chip[aria-pressed="true"] { color: var(--ink); }
.stat-chip.new[aria-pressed="true"] { color: var(--new); }
.stat-chip.learn[aria-pressed="true"] { color: var(--warn); }
.stat-chip.review[aria-pressed="true"] { color: var(--good); }

.stat-chip.filter-off {
  opacity: .55;
  color: var(--ink-muted);
}

/* Current word's category in "What we're studying now" is emphasized
   (bolder) than the other two categories. */
.stat-chip.current-state .filter-category > span:first-child {
  font-weight: 800;
  text-shadow: 0 0 .5px currentColor;
}

.card-stage {
  flex: 1;
  min-height: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-sm);
  width: 100%;
  min-width: 0;
}
.card-stage .card-front {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: min(720px, 100%);
  overflow-wrap: anywhere;
}
.card-stage .card-front.context-front {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.38;
  letter-spacing: -0.015em;
}
.card-stage .context-target {
  color: var(--accent);
  font-weight: 800;
  font-style: normal;
}
.card-stage .pronunciation {
  margin-top: 8px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  font-size: 14px;
}
.card-stage .divider {
  width: 60px; height: 1px;
  background: var(--border-strong);
  margin: 28px 0;
}
.card-stage .card-back {
  font-size: 22px;
  font-weight: 500;
  max-width: min(720px, 100%);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.card-stage .card-back.card-translation {
  font-size: 20px;
  font-weight: 650;
}
.card-stage .card-definition {
  margin-top: 10px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.45;
}
.card-stage .card-example {
  margin-top: 18px;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-subtle);
  font-size: 17px;
  max-width: min(640px, 100%);
  overflow-wrap: anywhere;
}
.card-stage .card-meta {
  position: absolute; bottom: 14px; left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 12px; color: var(--ink-subtle);
}
.card-stage .speaker-btn {
  position: absolute; top: 16px; right: 16px;
  /* Bare accent glyph: no circular surface, no outline. iOS Safari paints its
     own button chrome unless `appearance` is reset, which kept the circle
     visible on iPhone even after the background was cleared. */
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  width: 36px; height: 36px;
  padding: 0;
  /* Flexbox instead of the inherited `inline-grid`: old WebKit aligned the grid
     item to the text baseline, pushing the glyph below the centre of the tap
     area on iPhone 7. */
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: var(--accent);
  transition: color 150ms cubic-bezier(0.25, 1, 0.5, 1), transform 120ms cubic-bezier(0.25, 1, 0.5, 1);
}
/* Touch devices latch `:hover` after a tap, so any surface here would stay on
   screen as a filled circle. Only the icon colour reacts. */
.card-stage .speaker-btn:hover,
.card-stage .speaker-btn:focus,
.card-stage .speaker-btn:active {
  background: none;
  border: 0;
  box-shadow: none;
}
.card-stage .speaker-btn:hover { color: var(--accent-hover); }
.card-stage .speaker-btn:active { transform: scale(.94); }
/* Muted and inert while the card front shows the local (non-studied) language. */
.card-stage .speaker-btn:disabled {
  color: var(--ink-faint);
  opacity: .4;
  pointer-events: none;
  transform: none;
}
.card-stage .speaker-btn svg { display: block; width: 18px; height: 18px; }

/* Gentle floating cue for the active tools — only when the button is
   enabled (the glyph animates, so hit area and press feedback stay put). */
@keyframes card-tool-float {
  0%, 100% { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); }
  50% { -webkit-transform: translate3d(0, -3px, 0); transform: translate3d(0, -3px, 0); }
}
.card-stage .speaker-btn:not(:disabled) svg,
.card-stage .info-link:not(:disabled) svg {
  -webkit-animation: card-tool-float 3.4s ease-in-out infinite;
  animation: card-tool-float 3.4s ease-in-out infinite;
  will-change: transform;
}
/* Phase-shift the two buttons so they never bob in sync. */
.card-stage .info-link:not(:disabled) svg {
  -webkit-animation-delay: -1.7s;
  animation-delay: -1.7s;
}
.card-stage .speaker-btn:not(:disabled):hover svg,
.card-stage .info-link:not(:disabled):hover svg {
  -webkit-animation-duration: 1.9s;
  animation-duration: 1.9s;
}

.card-stage .edit-link {
  position: absolute; top: 16px; left: 16px;
  background: transparent; border: none; color: var(--ink-faint); font-size: 12px;
}

/* Pencil icon: same icon-button metrics as the undo chevron next to it. */
.card-stage .card-stage-tools .edit-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.card-stage .card-stage-tools .edit-link {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 6px;
}

.card-stage .card-stage-tools .edit-link svg {
  width: 15px;
  height: 15px;
}
.card-stage .edit-link:hover { color: var(--accent); }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--ink-subtle); }
.empty-state .emoji { font-size: 40px; }
.empty-state h2 { font-family: var(--font-serif); margin: 0; color: var(--ink); font-weight: 500; }
.empty-state p { margin: 0; max-width: 420px; }
.empty-state-actions { display: flex; gap: 8px; margin-top: 8px; }
.empty-state-padded { padding: 40px; }
.browse-empty { padding: 40px; text-align: center; color: var(--ink-muted); }
.boot-error { padding: 40px; font-family: system-ui, sans-serif; }

/* Reveal + grade */
.reveal-bar { display: flex; justify-content: center; }
.reveal-btn {
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 10px;
  transition: opacity .12s, transform .08s;
}
.reveal-btn:hover { opacity: .9; }
.reveal-btn:active { transform: translateY(1px); }
.reveal-btn kbd {
  background: rgba(255,255,255,.14);
  padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 11px;
}

.card-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; min-width: 0; }
.grade-btn {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: background .12s, border-color .12s, transform .06s;
}
.grade-btn:hover { transform: translateY(-1px); }
.grade-btn .grade-label { font-weight: 600; font-size: 15px; }
.grade-btn .grade-interval { font-size: 12px; color: var(--ink-muted); font-family: var(--font-mono); }
.grade-btn kbd {
  margin-top: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint);
}
.grade-btn.again { background: var(--bad-soft); border-color: transparent; }
.grade-btn.again .grade-label { color: var(--bad); }
.grade-btn.hard { background: var(--warn-soft); border-color: transparent; }
.grade-btn.hard .grade-label { color: var(--warn); }
.grade-btn.good { background: var(--good-soft); border-color: transparent; }
.grade-btn.good .grade-label { color: var(--good); }
.grade-btn.easy { background: var(--new-soft); border-color: transparent; }
.grade-btn.easy .grade-label { color: var(--new); }

/* Buttons */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--bg-elev); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 22%, transparent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--ink-muted); }
.btn.ghost:hover { color: var(--ink); background: var(--bg-elev); }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.danger:hover { background: #973f35; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

.icon-btn {
  background: transparent; border: 1px solid transparent;
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
}
.icon-btn:hover { background: var(--bg-elev); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; min-width: 0; }
.search, .filter {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  outline: none;
}
.search { min-width: 240px; flex: 1; max-width: 360px; min-width: 0; }
.search:focus, .filter:focus { border-color: var(--accent); }

.decks-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
  min-width: 0;
}
.deck-tool {
  display: inline-flex; align-items: center; gap: 6px;
}
.deck-tool svg { width: 16px; height: 16px; flex: none; }


/* ----- Word info modal ----- */
.word-info-panel { width: min(600px, 94vw); }
.word-info-head-actions { display: inline-flex; align-items: center; gap: 6px; }
.word-info-word { margin-top: 2px; font-size: 13px; color: var(--ink-muted); }
.word-info-body { overflow-y: auto; }
/* ----- Word info typography: structured, comfortable reading ----- */
.word-info-content { overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.62; }
.word-info-content p.word-info-para { margin: 0 0 9px; }
.word-info-content .word-info-quote { font-style: italic; color: var(--accent); }
.word-info-content strong { font-weight: 700; }
.word-info-content h3.word-info-subject {
  margin: 14px 0 4px;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 15.5px;
  color: var(--ink);
}
.word-info-content .word-info-list,
.word-info-content .word-info-nested {
  list-style: none;
  margin: 2px 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Numbered items carry their own badge so numbering survives the nested
   lists that sit between "steps". */
.word-info-content ol.word-info-list > li,
.word-info-content ul.word-info-list > li,
.word-info-content ul.word-info-nested > li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.word-info-content .word-info-num {
  flex: 0 0 auto;
  width: 21px; height: 21px;
  margin-top: 1px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px; font-weight: 700; line-height: 21px;
  text-align: center;
}
.word-info-content .word-info-dot {
  flex: 0 0 auto;
  width: 6px; height: 6px;
  margin-top: .55em;
  border-radius: 50%;
  background: var(--accent);
  opacity: .75;
}
.word-info-content .word-info-li { min-width: 0; }
.word-info-content ul.word-info-nested {
  margin: 4px 0 2px;
  padding-left: 14px;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink-muted);
}
.word-info-content ol.word-info-list > li:last-child,
.word-info-content ul.word-info-list > li:last-child { margin-bottom: 0; }
.word-info-content.word-info-empty { color: var(--ink-muted); }
.word-info-content.word-info-error { color: var(--bad); }

/* Mobile: bottom sheet should be tall enough to read as a real window,
   not just a header strip (iPhone Safari / --app-vh safe). */

@media (max-width: 640px) {
  .word-info-panel {
    min-height: calc(var(--app-vh, 1vh) * 55);
  }
  .word-info-body {
    flex: 1 1 auto;
    min-height: 0;
  }
}

/* Sheet grabber: drag up to expand, drag down to close (touch only). */
.sheet-grabber { display: none; }
@media (max-width: 640px) {
  .sheet-grabber {
    display: flex;
    justify-content: center;
    padding: 9px 0 3px;
    flex: 0 0 auto;
    touch-action: none;
  }
  .sheet-grabber span {
    width: 42px;
    height: 4px;
    border-radius: 2px;
    background: var(--ink-faint);
    opacity: .55;
  }
  .modal-panel .modal-head { touch-action: none; }
  .modal-panel .sheet-grabber { touch-action: none; }
  /* The finger must be able to drag the sheet all the way down,
     so the panel's own min-height has to give way while dragging. */
  .modal-panel.sheet-dragging { transition: none; min-height: 0; }
}

/* When active, the info button uses the same accent color as the speaker
   button; when disabled, it mirrors the speaker button's inactive look. */
.card-stage .info-link:not(:disabled) { color: var(--accent); }
.card-stage .info-link:not(:disabled):hover { color: var(--accent-hover); }
.card-stage .info-link:disabled {
  color: var(--ink-faint);
  opacity: .4;
  pointer-events: none;
  transform: none;
}

/* Finger-sized hit zones for the small toolbar buttons on touch screens. */
@media (pointer: coarse) {
  .card-stage .card-stage-tools .undo-link,
  .card-stage .card-stage-tools .info-link {
    position: relative;
  }
  .card-stage .card-stage-tools .undo-link::after,
  .card-stage .card-stage-tools .info-link::after {
    content: "";
    position: absolute;
    inset: -9px;
  }
}
