/* Shared stylesheet for the vocab apps (japanese.agrill.at, chinese.agrill.at).
   Each page keeps only a tiny page-specific <style> block (the --cjk-font
   root variable and its .jp/.zh class) inline; everything else lives here
   so a design tweak updates every language page at once. */

/* !important needed: theme.css forces .text-zinc-300 to --text-on-dominant
   with !important, which happens to equal --color-secondary — without this,
   selected-state text is invisible (same color as its own background). */
#displayToggle button[aria-pressed="true"] { color: var(--text-on-secondary) !important; background: var(--color-secondary); }
/* Word-set branch switch — deliberately styled apart from the other
   toolbar toggles since it swaps the entire active vocabulary, not
   just a filter. Unused (no matching elements) on single-branch pages. */
.branch-btn { border-radius: 9999px; padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--text-on-dominant); }
.branch-btn[aria-pressed="true"] { color: var(--text-on-accent) !important; background: var(--color-blue-accent); }

/* Study modal */
.study-mode-btn { border-radius: 9999px; padding: 5px 14px; font-size: 12px; font-weight: 600; color: var(--text-on-dominant); }
.study-mode-btn[aria-pressed="true"] { color: var(--text-on-accent) !important; background: var(--color-blue-accent); }
.study-action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 9999px;
  background: transparent; border: 2px solid currentColor; color: inherit;
  transition: transform .1s, background .15s;
}
.study-action-btn svg { width: 24px; height: 24px; }
.study-action-btn:hover { transform: scale(1.06); }
.study-action-btn:active { transform: scale(0.94); }
.study-action-btn.active { background: currentColor; }
.study-action-btn.active svg { color: var(--color-dominant); }
.quiz-choice-btn {
  border-radius: 10px; border: 2px solid #bcc4d0; padding: 14px 10px;
  font-size: 20px; color: var(--text-on-dominant); background: var(--color-dominant);
  transition: border-color .15s, background .15s;
}
.quiz-choice-btn:hover:not(:disabled) { border-color: var(--color-blue-accent); }
.quiz-choice-btn:disabled { cursor: default; }
.quiz-choice-btn.quiz-choice-text { font-size: 14px; text-align: left; padding: 12px 14px; }
.quiz-choice-btn.quiz-correct { border-color: #3f9d63 !important; background: rgba(63,157,99,.15); }
.quiz-choice-btn.quiz-wrong { border-color: #c0524a !important; background: rgba(192,82,74,.15); }
#graphBar .topic-pill[aria-pressed="true"] { color: var(--text-on-secondary) !important; background: var(--color-secondary); border-color: var(--color-secondary); }

/* Per-word quiz-correct badge shown in dictionary views (list/tiles/opposites) */
.quiz-correct-badge {
  display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0;
  border-radius: 9999px; padding: 1px 6px; font-size: 10px; font-weight: 600;
  background: rgba(154,122,184,.18); color: #9a7ab8;
}

/* Quiz completion screen */
@keyframes quizPop { 0% { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes quizBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.quiz-result-emoji { font-size: 56px; line-height: 1; animation: quizPop .5s ease-out; }
.quiz-tier-gold .quiz-result-emoji { animation: quizPop .5s ease-out, quizBounce 1s ease-in-out .5s infinite; }

/* Sticky top toolbar */
#topBar { position: sticky; top: 0; z-index: 30; background: var(--color-dominant); border-bottom: 1px solid #bcc4d0; }
#topBar select, #topBar input { min-width: 0; }
.toolbar-btn { border-radius: 9999px; border: 1px solid #bcc4d0; padding: 6px 14px; font-size: 13px; color: var(--text-on-dominant); white-space: nowrap; transition: border-color .15s; }
.toolbar-btn:hover { border-color: var(--color-accent); }
.toolbar-select { border-radius: 8px; border: 1px solid #bcc4d0; padding: 6px 10px; font-size: 13px; color: var(--text-on-dominant); background: var(--color-dominant); }
.dropdown-wrap { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px;
  background: var(--color-dominant); border: 1px solid #bcc4d0; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.dropdown-menu.hidden { display: none; }
.dropdown-menu label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-on-dominant); cursor: pointer; }
.dropdown-menu label.stack { flex-direction: column; align-items: stretch; gap: 4px; }
.dropdown-menu .field-check { accent-color: var(--color-blue-accent); width: 15px; height: 15px; flex-shrink: 0; }
@media (max-width: 640px) {
  .dropdown-menu { left: 0; right: 0; min-width: 0; }
}
#wordlist .word-card[data-open="true"] .examples { display: block; }
#wordlist .word-card .examples { display: none; }
#tileGrid .tile-card[data-open="true"] .examples-tile { display: block; }
#tileGrid .tile-card .examples-tile { display: none; }
#tileGrid { align-items: start; }
/* Tiles view breaks out of the centered column to use the full window width */
#main.tiles-active { max-width: 100%; }
.speak-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 9999px; flex-shrink: 0;
  color: var(--color-blue-accent); background: rgba(107,130,168,.12);
  transition: background .15s, transform .1s;
}
.speak-btn:hover { background: rgba(107,130,168,.25); }
.speak-btn:active { transform: scale(0.92); }
.speak-btn.speaking { background: var(--color-blue-accent); color: var(--text-on-accent); }
.speak-btn[disabled] { opacity: .3; cursor: not-allowed; }
.speak-btn svg { width: 14px; height: 14px; }
.link-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 9999px; flex-shrink: 0;
  color: #7a9a6b; background: rgba(122,154,107,.14);
  transition: background .15s, transform .1s;
}
.link-btn:hover { background: rgba(122,154,107,.28); }
.link-btn:active { transform: scale(0.92); }
.link-btn svg { width: 13px; height: 13px; }
.mark-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 9999px; flex-shrink: 0;
  color: #c9a227; background: rgba(201,162,39,.14);
  transition: background .15s, transform .1s;
}
.mark-btn:hover { background: rgba(201,162,39,.28); }
.mark-btn:active { transform: scale(0.92); }
.mark-btn svg { width: 14px; height: 14px; fill: none; }
.mark-btn.marked svg { fill: currentColor; }
.learn-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 9999px; flex-shrink: 0;
  color: #3f9d63; background: rgba(63,157,99,.14);
  transition: background .15s, transform .1s;
}
.learn-btn:hover { background: rgba(63,157,99,.28); }
.learn-btn:active { transform: scale(0.92); }
.learn-btn svg { width: 14px; height: 14px; }
.learn-btn:not(.learned) svg { opacity: .35; }
.word-card.marked, .tile-card.marked { box-shadow: inset 3px 0 0 0 #c9a227; }
.word-card.learned, .tile-card.learned { box-shadow: inset 3px 0 0 0 #3f9d63; }
.word-card.marked.learned, .tile-card.marked.learned { box-shadow: inset 3px 0 0 0 #3f9d63, inset 6px 0 0 0 #c9a227; }
/* Mastery bar: graphical breakdown of the current filtered list */
#masteryBar { height: 10px; border-radius: 9999px; overflow: hidden; display: flex; background: #d4d9e4; }
#masteryBar > div { height: 100%; }

/* Graph view */
#graphWrap { display: none; }
#graphWrap.active { display: block; }
#graphSvg { width: 100%; height: 560px; display: block; border-radius: 12px; background: #e2e6ed; touch-action: none; }
.field-check { accent-color: var(--color-blue-accent); width: 15px; height: 15px; }

/* Fullscreen ("Bigger view") mode — the canvas fills the entire browser
   window edge-to-edge; every control becomes a floating box laid on top
   of it instead of a flex sibling that would shrink the canvas. */
#graphWrap.fullscreen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--color-dominant);
  margin: 0; padding: 0; max-width: none;
  display: block;
  overflow: hidden;
}
#graphWrap.fullscreen #graphRow { display: contents; }
#graphWrap.fullscreen #graphSvgWrap {
  position: absolute; inset: 0;
  border: none; border-radius: 0;
}
#graphWrap.fullscreen #graphSvg { width: 100%; height: 100%; border-radius: 0; }

#graphWrap.fullscreen #graphViewControls {
  position: absolute; top: 14px; right: 14px; z-index: 130;
  justify-content: flex-end;
}
#graphWrap.fullscreen #graphViewControls #fullscreenToggle,
#graphWrap.fullscreen #graphViewControls #hudToggle { background: var(--color-dominant); }
#graphWrap:not(.fullscreen) #hudToggle { display: none; } /* only meaningful in fullscreen */
#graphWrap.fullscreen.hud-hidden #graphBar,
#graphWrap.fullscreen.hud-hidden #graphFieldPanel,
#graphWrap.fullscreen.hud-hidden #graphLegend,
#graphWrap.fullscreen.hud-hidden #graphInfo { display: none; }
#graphWrap.fullscreen #graphBar {
  position: absolute; top: 14px; left: 14px; z-index: 120;
  max-width: min(70vw, 640px); max-height: 42vh; overflow: auto;
  padding: 12px 14px;
  background: var(--color-dominant); border: 1px solid #bcc4d0; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
#graphWrap.fullscreen #graphFieldPanel {
  position: absolute; top: 14px; right: 14px; z-index: 120;
  margin-top: 44px; width: 190px; max-height: calc(100vh - 72px); overflow: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
#graphWrap.fullscreen #graphLegend {
  position: absolute; bottom: 14px; left: 14px; z-index: 120;
  padding: 8px 14px; max-width: min(90vw, 520px);
  background: var(--color-dominant); border: 1px solid #bcc4d0; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
#graphWrap.fullscreen #graphInfo {
  position: absolute; bottom: 14px; right: 14px; z-index: 120;
  width: 320px; max-width: calc(100vw - 28px); max-height: 40vh; overflow: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
@media (max-width: 700px) {
  #graphWrap.fullscreen #graphBar { max-width: calc(100vw - 28px); max-height: 26vh; }
  #graphWrap.fullscreen #graphFieldPanel {
    top: auto; bottom: 14px; right: 14px; left: 14px;
    margin-top: 0; width: auto; max-height: 30vh;
  }
  #graphWrap.fullscreen #graphInfo { display: none; } /* keep the small screen readable; details still show inline in list view */
}
.graph-node { cursor: pointer; }
.graph-node circle { transition: opacity .15s, stroke-width .15s; }
.graph-node circle.speaking { stroke: #c47a3a !important; stroke-width: 3 !important; }
.graph-node text { pointer-events: none; font-family: var(--font, inherit); }
.graph-edge { transition: opacity .15s; }
.graph-dim { opacity: .12; }
.legend-dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:5px; vertical-align:middle; }
.legend-line { display:inline-block; width:16px; height:0; border-top-width:2px; margin-right:5px; vertical-align:middle; }
