/* ====================================================================
 * Mimi Word System — single source of truth
 * ====================================================================
 *
 * This file defines the canonical styling for Mimi's word-segmentation
 * UI: the underlined word chips and the hover/click definition popup.
 *
 * IT IS THE ONE SYSTEM.
 *
 * Loaded by:
 *   1. browser-extension/styles/styles.css     (via @import)
 *      → renders on YouTube, Netflix, Disney+, Prime, learnmimi.com,
 *        and any other page where the extension overlay activates.
 *   2. app/web/index.html                      (via <link rel="stylesheet">)
 *      → makes the same classes available to the Flutter web app, so the
 *        marketing-site demo (DemoSubtitleWidget rendered through
 *        HtmlElementView) renders bit-identical to the live extension.
 *
 * Whoever changes this file changes EVERY surface at once. That is
 * deliberate — anything that "looks like a Mimi word" in any surface
 * MUST come from here, not from a parallel re-implementation.
 *
 * If you find yourself styling a word chip or definition popup in a
 * different file, stop and add it here instead.
 *
 * Last sync: 2026-04-15
 * ==================================================================== */


/* ====================================================================
 *  CSS CUSTOM PROPERTIES — Design tokens
 *  Override these per-host if you ever need to (e.g. light-mode), but
 *  by default they are the brand colours used everywhere.
 * ==================================================================== */
:root {
  /* Brand */
  --mimi-bg-deep:        #0B1929;
  --mimi-bg-surface:     #15202E;
  --mimi-bg-elevated:    #1C2938;
  --mimi-primary:        #5B7CFF;
  --mimi-secondary:      #4DD4FF;
  --mimi-text-primary:   #F5F7FF;
  --mimi-text-secondary: rgba(245, 247, 255, 0.9);

  /* SRS state colours — base */
  --mimi-srs-new:        #FF5722;
  --mimi-srs-learning:   #FDD835;
  --mimi-srs-known:      #4CAF50;

  /* SRS state colours — lighter "tint" used on hover */
  --mimi-srs-new-tint:      #FF8A65;
  --mimi-srs-learning-tint: #FFE97A;
  --mimi-srs-known-tint:    #81C784;
}


/* ====================================================================
 *  WORD CHIPS
 *  An inline, hoverable, color-coded word from a parsed subtitle.
 *  Status class is one of: .new / .unknown (treated identical to new),
 *  .learning, .known.
 * ==================================================================== */
.mimi-word {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 2px 0;
  margin: 0;
  border-radius: 4px;
  display: inline-block;
  position: relative;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
}

/* When the host is the YouTube subtitle box, override font sizing */
.mimi-subtitle-box .mimi-word {
  color: #ffffff;
  font-size: 24px;
  font-weight: 600;
}

/* Optional spacing mode (extension setting) */
body.mimi-word-spacing .mimi-word {
  padding: 4px 6px;
  margin: 0 2px;
}

/* Animated underline that grows on hover */
.mimi-word::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 90%;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  transition: transform 0.2s ease;
  pointer-events: none;
}

/* SRS-specific underlines */
.mimi-word.unknown::after,
.mimi-word.new::after      { background: var(--mimi-srs-new); }
.mimi-word.learning::after { background: var(--mimi-srs-learning); }
.mimi-word.known::after    { background: var(--mimi-srs-known); }

/* Hover lift */
.mimi-word:hover {
  transform: translateY(-1px) !important;
  padding: 2px 4px;
  z-index: 10;
}
body.mimi-word-spacing .mimi-word:hover { padding: 4px 6px; }
.mimi-word:hover::after { transform: translateX(-50%) scaleX(1); }

/* Active press */
.mimi-word:active {
  transform: translateY(0) scale(0.95) !important;
  background: rgba(91, 124, 255, 0.4) !important;
}

/* SRS state styling (background + text shift on hover) */
.mimi-word.unknown,
.mimi-word.new {
  border-bottom: 2px solid rgba(255, 87, 34, 0.6) !important;
  background: transparent !important;
}
.mimi-word.unknown:hover,
.mimi-word.new:hover {
  background: rgba(255, 87, 34, 0.35) !important;
  border-bottom: 2px solid var(--mimi-srs-new) !important;
  color: var(--mimi-srs-new-tint) !important;
}

.mimi-word.learning {
  border-bottom: 2px solid rgba(253, 216, 53, 0.6) !important;
  background: transparent !important;
}
.mimi-word.learning:hover {
  background: rgba(253, 216, 53, 0.30) !important;
  border-bottom: 2px solid var(--mimi-srs-learning) !important;
  color: var(--mimi-srs-learning-tint) !important;
}

.mimi-word.known {
  border-bottom: 2px solid rgba(76, 175, 80, 0.6) !important;
  background: transparent !important;
}
.mimi-word.known:hover {
  background: rgba(76, 175, 80, 0.30) !important;
  border-bottom: 2px solid var(--mimi-srs-known) !important;
  color: var(--mimi-srs-known-tint) !important;
}


/* ====================================================================
 *  DEFINITION POPUP
 *  The card that appears on hover/click of a word chip.
 *  Structure expected by the JS:
 *    .mimi-definition-popup
 *      .mimi-popup-word         the headword
 *      .mimi-popup-reading      pronunciation / IPA / kana
 *      .mimi-popup-frequency    type or commonality badge
 *      .mimi-popup-meaning      translated meaning
 *      .mimi-popup-jisho-link   fallback / add-to-deck CTA
 * ==================================================================== */
.mimi-definition-popup {
  background: linear-gradient(135deg,
                              rgba(11, 25, 41, 0.98) 0%,
                              rgba(21, 32, 46, 0.98) 100%);
  border: 1px solid rgba(77, 212, 255, 0.3);
  border-radius: 12px;
  padding: 14px 16px;
  max-width: 320px;
  min-width: 200px;
  z-index: 999999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(77, 212, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: mimi-popup-fade-in 0.15s ease-out;
}

@keyframes mimi-popup-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mimi-popup-word {
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.mimi-popup-reading {
  color: var(--mimi-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.mimi-popup-frequency {
  display: inline-block;
  background: rgba(77, 212, 255, 0.15);
  color: var(--mimi-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mimi-popup-meaning {
  color: var(--mimi-text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}
.mimi-popup-no-definition {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-style: italic;
  margin-bottom: 8px;
}
.mimi-popup-jisho-link {
  display: inline-block;
  color: var(--mimi-secondary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 12px;
  background: rgba(77, 212, 255, 0.1);
  border: 1px solid rgba(77, 212, 255, 0.3);
  border-radius: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
}
.mimi-popup-jisho-link:hover {
  background: rgba(77, 212, 255, 0.2);
  border-color: rgba(77, 212, 255, 0.5);
  transform: translateY(-1px);
}
