/* Mojin Learning — hover dictionary popup styles.
   Themed to match the Supercell-chunky surface used by .learn-* and
   .dict-* components: thick navy border, offset shadow, blue accent
   on hover, yellow JLPT chips, Lilita-One on the kanji glyph.

   This file is served statically (public/), independent of Vite —
   so colors are inlined rather than referencing CSS variables. */

.jp-tok {
  cursor: help;
  border-bottom: 1px dotted rgba(59, 130, 246, 0.32);
  transition: background 80ms ease-in, border-bottom-color 80ms ease-in;
}
.jp-tok:hover {
  background: rgba(59, 130, 246, 0.08);
  border-bottom-color: rgba(59, 130, 246, 0.7);
}

/* Click mode: cursor signals tokens are click-to-open. The dotted underline
   stays as a "this is interactive" affordance. */
body[data-lookup-mode="click"] .jp-tok {
  cursor: pointer;
}

/* Shift mode: the popup only fires while the modifier is held, so a hover
   alone doesn't deserve the heavy hover-highlight (it'd lie). Keep the
   underline + background subtle. */
body[data-lookup-mode="shift"] .jp-tok:hover {
  background: rgba(59, 130, 246, 0.04);
}

.jp-popup-close {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  appearance: none;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: rgba(30, 41, 59, 0.55);
  border-radius: 6px;
  z-index: 1;
}
.jp-popup-close:hover {
  background: rgba(30, 41, 59, 0.08);
  color: #1e293b;
}

.jp-popup-content {
  /* Reserve space so the heading doesn't slide under the X button. */
  padding-right: 0.8rem;
}

.jp-popup {
  position: absolute;
  z-index: 9999;
  max-width: 380px;
  min-width: 240px;
  padding: 0.85rem 1rem 0.8rem;
  background: #ffffff;
  border: 3px solid #1e293b;
  border-radius: 14px;
  /* Offset shadow — Supercell chunky look, no blur. */
  box-shadow: 0 4px 0 0 #1e293b, 0 6px 18px rgba(0, 0, 0, 0.18);
  font-family: "Nunito", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  color: #1e293b;
  display: none;
  pointer-events: auto;
}

.jp-popup-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

/* Inline play button on the lemma head — mirrors the React
   WordAudioButton component so popup + page audio feels like the
   same control. State-driven via data-state attribute. */
.jp-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  background: white;
  border: 2px solid #3b82f6;
  border-radius: 7px;
  color: #3b82f6;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  box-shadow: 0 2px 0 0 #3b82f6;
  transition: transform 100ms, background 120ms, color 120ms;
}
.jp-audio-btn:hover:not(:disabled) {
  background: #3b82f6;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 0 0 #1e3a8a;
}
.jp-audio-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 0 #1e3a8a;
}
.jp-audio-btn[data-state="playing"] {
  background: #3b82f6;
  color: white;
}
.jp-audio-btn[data-state="missing"]:disabled {
  border-color: #cbd5e1;
  color: #94a3b8;
  box-shadow: 0 2px 0 0 #cbd5e1;
  cursor: not-allowed;
  opacity: 0.55;
}
.jp-audio-spin {
  animation: jp-audio-spin 800ms linear infinite;
}
@keyframes jp-audio-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@media (prefers-color-scheme: dark) {
  .jp-audio-btn {
    background: #0f172a;
    border-color: #fbbf24;
    color: #fbbf24;
    box-shadow: 0 2px 0 0 #fbbf24;
  }
  .jp-audio-btn:hover:not(:disabled) {
    background: #fbbf24;
    color: #0f172a;
    box-shadow: 0 3px 0 0 #f59e0b;
  }
  .jp-audio-btn[data-state="playing"] {
    background: #fbbf24;
    color: #0f172a;
  }
  .jp-audio-btn[data-state="missing"]:disabled {
    border-color: #334155;
    color: #475569;
    box-shadow: 0 2px 0 0 #334155;
  }
}
.jp-written {
  font-size: 1.55rem;
  font-weight: 800;
  font-family: "Lilita One", "Hiragino Mincho ProN", Georgia, serif;
  color: #1e293b;
  line-height: 1.1;
}
.jp-reading {
  font-size: 0.95rem;
  color: #64748b;
  font-weight: 600;
}

.jp-pitch {
  margin: 0.4rem 0 0.6rem;
  padding: 0.35rem 0.6rem;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  display: inline-block;
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
.jp-pitch-bars {
  letter-spacing: 2px;
  color: #3b82f6;
  font-weight: 700;
}
.jp-pitch-morae {
  font-size: 0.85rem;
  color: #1e293b;
  letter-spacing: 2px;
}
.jp-pitch-type {
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 0.15rem;
  font-family: "Nunito", sans-serif;
  letter-spacing: 0;
  font-weight: 700;
  text-transform: uppercase;
}

.jp-senses {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0.6rem;
}
.jp-senses li {
  margin-bottom: 0.32rem;
  line-height: 1.45;
}
.jp-pos {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: "Nunito", sans-serif;
}

/* Per-kanji breakdown row.
   Grid layout: [glyph] [readings] [meanings].
   Now wider to accommodate the new on/kun reading column added 2026-04-26. */
.jp-kanji-list {
  border-top: 2px solid #e2e8f0;
  padding-top: 0.6rem;
  margin-top: 0.5rem;
  display: grid;
  gap: 0.35rem;
}
.jp-kanji-row {
  display: grid;
  grid-template-columns: 2.4rem auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 0.05rem 0.55rem;
  align-items: baseline;
  font-size: 0.84rem;
}
.jp-kanji-ch {
  grid-row: 1 / 3;
  align-self: center;
}
.jp-kanji-meta {
  grid-row: 1;
}
.jp-kanji-meaning {
  grid-row: 1;
  grid-column: 3;
}
.jp-kanji-readings {
  grid-row: 2;
  grid-column: 2 / 4;
}
.jp-kanji-ch {
  font-size: 1.5rem;
  font-family: "Lilita One", "Hiragino Mincho ProN", Georgia, serif;
  font-weight: 800;
  text-align: center;
  color: #1e293b;
  line-height: 1;
}
.jp-kanji-meta {
  font-size: 0.7rem;
  color: #3b82f6;
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
/* On/kun readings column — sits between glyph and meaning, displays
   the actual phonetic reading so a learner can sound out the kanji. */
.jp-kanji-readings {
  font-size: 0.78rem;
  color: #1e293b;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.jp-kanji-reading-on {
  color: #1e3a8a;
  font-weight: 600;
}
.jp-kanji-reading-kun {
  color: #475569;
}
.jp-kanji-reading-sep {
  color: #cbd5e1;
  margin: 0 0.3rem;
}
.jp-kanji-meaning {
  color: #64748b;
  font-size: 0.82rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jp-empty {
  color: #64748b;
  font-style: italic;
  font-size: 0.9rem;
}

.jp-empty-soft {
  font-size: 0.78rem;
  margin-bottom: 0.55rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px dashed #cbd5e1;
  color: #64748b;
  font-style: italic;
}
.jp-empty-soft b {
  font-style: normal;
  color: #1e293b;
  font-weight: 700;
}

/* Navigational links — lemma headlines and per-kanji rows.
   Subtle by default; blue on hover (matches the rest of the site). */
.jp-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 80ms ease-in, color 80ms ease-in;
}
.jp-link:hover,
.jp-link:focus-visible {
  color: #3b82f6;
  outline: none;
}
.jp-written.jp-link:hover,
.jp-written.jp-link:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.jp-link-row {
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
  margin: -0.1rem -0.45rem;
}
.jp-link-row:hover,
.jp-link-row:focus-visible {
  background: rgba(59, 130, 246, 0.08);
  color: inherit;
}
.jp-link-row:hover .jp-kanji-ch,
.jp-link-row:focus-visible .jp-kanji-ch {
  color: #3b82f6;
}

/* Homonym / alternate-lemma blocks rendered below the primary entry. */
.jp-alt-lemmas {
  border-top: 1px dashed #cbd5e1;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}
.jp-popup-head-alt {
  margin-bottom: 0.25rem;
  opacity: 0.88;
}
.jp-popup-head-alt .jp-written {
  font-size: 1.2rem;
}

/* Level-gated kanji toggle. */
.jp-kanji-toggle {
  appearance: none;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  font-family: "Nunito", sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.4rem 0.6rem;
  margin-top: 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 80ms ease-in, border-color 80ms ease-in, color 80ms ease-in;
}
.jp-kanji-toggle:hover {
  background: #f1f5f9;
  border-color: #3b82f6;
  color: #1e293b;
}

@media (prefers-color-scheme: dark) {
  .jp-popup {
    background: #0f172a;
    border-color: #f1f5f9;
    color: #f1f5f9;
    box-shadow: 0 4px 0 0 #f1f5f9, 0 6px 18px rgba(0, 0, 0, 0.5);
  }
  .jp-written, .jp-kanji-ch {
    color: #fbbf24;
  }
  .jp-reading {
    color: #cbd5e1;
  }
  .jp-pos {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
  }
  .jp-pitch {
    background: #1e293b;
    border-color: #334155;
  }
  .jp-pitch-bars {
    color: #fbbf24;
  }
  .jp-pitch-type, .jp-kanji-meaning, .jp-empty, .jp-empty-soft {
    color: #cbd5e1;
  }
  .jp-empty-soft b {
    color: #f1f5f9;
  }
  .jp-kanji-meta {
    color: #fbbf24;
  }
  .jp-kanji-readings {
    color: #f1f5f9;
  }
  .jp-kanji-reading-on {
    color: #93c5fd;
  }
  .jp-kanji-reading-kun {
    color: #cbd5e1;
  }
  .jp-kanji-reading-sep {
    color: #475569;
  }
  .jp-kanji-list, .jp-alt-lemmas, .jp-empty-soft {
    border-color: #334155;
  }
  .jp-kanji-toggle {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
  }
  .jp-kanji-toggle:hover {
    background: #334155;
    border-color: #fbbf24;
    color: #f1f5f9;
  }
  .jp-link:hover,
  .jp-link:focus-visible {
    color: #fbbf24;
  }
  .jp-link-row:hover,
  .jp-link-row:focus-visible {
    background: rgba(251, 191, 36, 0.12);
    color: inherit;
  }
  .jp-link-row:hover .jp-kanji-ch,
  .jp-link-row:focus-visible .jp-kanji-ch {
    color: #fbbf24;
  }
}
