/* Modular dictionary "Look Up" card (greb dictionary-node design).
   Used by greb-course.dict-system for any document that declares :dictionaries.
   Neo-brutalist: thick black border, hard offset shadow, mono labels.
   ──────────────────────────────────────────────────────────────────────── */
.greb-dict-card {
  position: fixed;
  z-index: 100000;
  width: 320px;
  max-width: min(92vw, 340px);
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fffdf8;
  color: #1d2b2c;
  border: 3px solid #000;
  border-radius: 10px;
  box-shadow: -4px 4px 0 #000, 0 14px 36px rgba(0, 0, 0, 0.28);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  animation: gd-fade 0.12s ease-out;
}
/* opacity-only: the card carries an inline `transform: scale(zoom)` so it tracks
   the document zoom (see dict-system/apply-card-scale!) — a transform in the
   entrance keyframe would override that and pop the card to full size for 0.12s. */
@keyframes gd-fade { from { opacity: 0; } to { opacity: 1; } }
.greb-dict-card .gd-head {
  display: flex;
  align-items: center;
  gap: 6px 8px;
  flex-wrap: wrap;
  position: relative;
  padding: 9px 12px;
  padding-right: 44px;            /* reserve room for the absolute close button */
  background: #f3e2b8;
  border-bottom: 2px solid rgba(0, 0, 0, 0.18);
}
.greb-dict-card .gd-word {
  font-family: "EB Garamond", serif;
  font-weight: 700;
  font-size: 1.35em;
  line-height: 1.1;
  color: #6b1414;
  /* the word gets its OWN line so the POS badge can never overlap/clip it */
  flex: 1 1 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.greb-dict-card .gd-pos {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  background: #b08d2e;
  color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
/* header action buttons (pin / close) — match the neo-brutalist gd-btn look */
.greb-dict-card .gd-pin,
.greb-dict-card .gd-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  flex: 0 0 auto;
  border: 2px solid #000;
  border-radius: 6px;
  background: #fff;
  color: #1d2b2c;
  box-shadow: -2px 2px 0 #000;
  cursor: pointer;
}
.greb-dict-card .gd-pin:active,
.greb-dict-card .gd-close:active { transform: translate(-2px, 2px); box-shadow: none; }
.greb-dict-card .gd-close {
  background: #6b1414; color: #fff;
  position: absolute; top: 8px; right: 10px;   /* pinned top-right, never collides with the word */
}
@media (max-width: 840px) {
  /* bigger tap targets on touch */
  .greb-dict-card .gd-pin,
  .greb-dict-card .gd-close { width: 38px; height: 38px; }
}

/* loading spinner (replaces the "buscando…" text) */
.greb-dict-card .gd-spin {
  width: 15px; height: 15px;
  border: 2px solid rgba(107, 20, 20, 0.25);
  border-top-color: #6b1414;
  border-radius: 50%;
  animation: gd-spin-rot 0.7s linear infinite;
}
@keyframes gd-spin-rot { to { transform: rotate(360deg); } }

/* skeleton shimmer (replaces the "consultando el léxico…" text) */
.greb-dict-card .gd-skel { display: flex; flex-direction: column; gap: 9px; padding: 2px 0; }
.greb-dict-card .gd-skel-line {
  height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, #e7ddc4 25%, #f3ecd9 37%, #e7ddc4 63%);
  background-size: 400% 100%;
  animation: gd-shimmer 1.3s ease-in-out infinite;
}
.greb-dict-card .gd-skel-short { width: 55%; }
@keyframes gd-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.greb-dict-card .gd-body { padding: 10px 12px; overflow-y: auto; }
.greb-dict-card .gd-sec { margin-bottom: 9px; }
.greb-dict-card .gd-sec:last-child { margin-bottom: 0; }
.greb-dict-card .gd-lbl {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #9a7b2e;
  margin-bottom: 2px;
}
.greb-dict-card .gd-val {
  font-family: "EB Garamond", serif;
  font-size: 1.02rem;
  line-height: 1.4;
  color: #1d2b2c;
}
.greb-dict-card .gd-pron { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.greb-dict-card .gd-respell {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: #6b1414;
}
.greb-dict-card .gd-ipa { color: #5a6a6b; font-size: 0.95rem; }
.greb-dict-card .gd-audio {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  flex-wrap: wrap;
}
.greb-dict-card .gd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border: 2px solid #000;
  background: #fff;
  color: #1d2b2c;
  border-radius: 6px;
  box-shadow: -2px 2px 0 #000;
  cursor: pointer;
  padding: 0;
}
.greb-dict-card .gd-btn:active { transform: translate(-2px, 2px); box-shadow: none; }
.greb-dict-card .gd-say { background: #f5df4d; }
.greb-dict-card .gd-rec.gd-on { background: #e23b3b; color: #fff; animation: gd-pulse 1s infinite; }
@keyframes gd-pulse { 50% { opacity: 0.55; } }
.greb-dict-card .gd-rechint {
  font-size: 0.6rem;
  color: #8a7a64;
  margin-left: 2px;
}
.greb-dict-card .gd-miss { color: #8a7a64; font-style: italic; font-family: "EB Garamond", serif; }
.greb-dict-card .gd-foot {
  padding: 6px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  color: #8a7a64;
  background: rgba(0, 0, 0, 0.02);
}

/* "En el libro" — special-word link that flips the reader to a book page
   (greb-course.dict-special; declared per course via :meta :special-pages). */
.greb-dict-card .gd-goto {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 2px solid #000;
  border-radius: 8px;
  background: #f5df4d;
  box-shadow: -2px 2px 0 #000;
  cursor: pointer;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  text-align: left;
}
.greb-dict-card .gd-goto:active { transform: translate(-2px, 2px); box-shadow: none; }
.greb-dict-card .gd-goto-thumb {
  width: 34px;
  height: 42px;
  object-fit: cover;
  object-position: top;
  border: 1.5px solid #000;
  border-radius: 3px;
  background: #fff;
  flex: 0 0 auto;
}
.greb-dict-card .gd-goto-lbl {
  flex: 1 1 auto;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  color: #1d2b2c;
}
.greb-dict-card .gd-goto-arrow { font-weight: 800; flex: 0 0 auto; }

/* prev/next word navigation — desktop uses the . and , keys, so the bar is
   hidden here and only shown on mobile (see the media query below). */
.greb-dict-card .gd-nav-bar { display: none; }

/* ── Mobile: ~30% smaller card + thumb-friendly prev/next word bar ───────── */
@media (max-width: 840px) {
  .greb-dict-card { width: 230px; max-width: 78vw; max-height: 62vh; }
  .greb-dict-card .gd-head { padding: 6px 40px 6px 9px; gap: 6px; }
  .greb-dict-card .gd-word { font-size: 1.02em; }
  .greb-dict-card .gd-pos { font-size: 0.5rem; padding: 1px 5px; }
  /* keep tap targets usable but in proportion to the smaller card */
  .greb-dict-card .gd-pin,
  .greb-dict-card .gd-close { width: 30px; height: 30px; }
  .greb-dict-card .gd-body { padding: 7px 9px; }
  .greb-dict-card .gd-sec { margin-bottom: 6px; }
  .greb-dict-card .gd-lbl { font-size: 0.5rem; }
  .greb-dict-card .gd-val { font-size: 0.72rem; line-height: 1.32; }
  .greb-dict-card .gd-ipa { font-size: 0.72rem; }
  .greb-dict-card .gd-respell { font-size: 0.62rem; }
  .greb-dict-card .gd-btn { width: 26px; height: 24px; }

  /* subtle prev/next — small arrows only (no labels), one at each edge */
  .greb-dict-card .gd-nav-bar {
    display: flex;
    justify-content: space-between;
    gap: 7px;
    padding: 4px 8px;
    background: transparent;
    border-top: 1px solid rgba(0, 0, 0, 0.10);
  }
  .greb-dict-card .gd-nav {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.55);
    color: #6b1414;
    box-shadow: none;
    font: 600 1.1rem "EB Garamond", serif;
    line-height: 1;
    opacity: 0.65;
    cursor: pointer;
  }
  .greb-dict-card .gd-nav:active { opacity: 1; transform: translateY(1px); }
  /* arrow only — drop the "Anterior"/"Siguiente" labels (aria-label keeps a11y) */
  .greb-dict-card .gd-nav span { display: none; }
  .greb-dict-card .gd-nav svg { width: 16px; height: 16px; }
}

/* ── Editable definitions (admin curation) ──────────────────────────────── */
.greb-dict-card .gd-edit{
  display:inline-flex; align-items:center; justify-content:center;
  width:26px; height:26px; flex:0 0 auto; padding:0;
  border:2px solid #000; border-radius:6px; background:#fff; color:#1d2b2c;
  box-shadow:-2px 2px 0 #000; cursor:pointer; font-size:14px;
}
.greb-dict-card .gd-edit:active{ transform:translate(-2px,2px); box-shadow:none; }
.greb-dict-card.gd-editing .gd-edit{ background:#b08d2e; color:#fff; }
/* the editable fields get a clear "input" look while editing */
.greb-dict-card.gd-editing .gd-sec[data-field] .gd-val{
  outline:none; background:#fffbe9; border:1px dashed #b08d2e; border-radius:5px;
  padding:4px 7px; min-height:1.4em; cursor:text;
}
.greb-dict-card.gd-editing .gd-sec[data-field] .gd-val:focus{ border-style:solid; background:#fff; }
.greb-dict-card .gd-editbar{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
  padding:9px 12px; margin-top:6px; border-top:2px solid rgba(0,0,0,.18);
  background:#f3e2b8; position:sticky; bottom:0;
}
.greb-dict-card .gd-edithint{ flex:1; font-size:11px; color:#6b5320; font-style:italic; }
.greb-dict-card .gd-save, .greb-dict-card .gd-cancel{
  border:2px solid #000; border-radius:6px; box-shadow:-2px 2px 0 #000;
  padding:5px 11px; cursor:pointer; font:inherit; font-size:13px; font-weight:700;
}
.greb-dict-card .gd-save{ background:#2f7a3a; color:#fff; }
.greb-dict-card .gd-cancel{ background:#fff; color:#1d2b2c; }
.greb-dict-card .gd-save:active, .greb-dict-card .gd-cancel:active{ transform:translate(-2px,2px); box-shadow:none; }
