/* ============================================================================
   DICCIONARIO LUMBRE — capa transversal (dictionary.css)
   Se carga sólo cuando la función está activa (views/layout.php). Todo con los
   tokens de app.css: sin colores nuevos, sin medidas huérfanas.
   Z-index: por encima de la burbuja de La Mesa (900) y de su hoja (950); el
   popup del diccionario es una capa de lectura, no de escritura.
   ========================================================================== */

/* ── Chip «📖 Definir»: aparece DEBAJO de la selección (La Mesa usa la de arriba) ── */
.dict-bubble {
    position: absolute; z-index: 940; display: flex; gap: 4px;
    padding: 4px 5px; background: var(--ink); border-radius: 10px;
    box-shadow: var(--shadow-md); animation: dict-pop .12s ease-out;
}
.dict-bubble[hidden] { display: none; }
.dict-bubble button {
    border: 0; background: transparent; color: var(--surface); font: inherit; font-size: 13px;
    padding: 4px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.dict-bubble button:hover, .dict-bubble button:focus-visible { background: rgba(255, 255, 255, .18); outline: none; }
@keyframes dict-pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Puerta rápida permanente (encargo 2026-09-28): 📖 en el header de TODAS las páginas ──
   Z-index por debajo del popup de la ficha (960): la ficha manda cuando se abre. */
#dict-launch { font-size: 16px; }
#dict-launch[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.dict-quick {
    position: fixed; z-index: 958; top: 72px; right: 16px; width: min(340px, calc(100vw - 32px));
    display: grid; gap: 8px;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 12px;
    animation: dict-pop .12s ease-out;
}
.dict-quick[hidden] { display: none; }
@media (max-width: 639px) { .dict-quick { top: 60px; left: 8px; right: 8px; width: auto; } }
.dict-quick-form { display: flex; gap: 6px; }
.dict-quick-form input[type="search"] { flex: 1 1 auto; min-width: 0; }
/* La lista de sugerencias reutiliza .dict-suggest-list pero aquí va embutida en el panel, no absoluta. */
.dict-quick .dict-suggest-list {
    position: static; box-shadow: none; border: 0; border-radius: 0; border-top: 1px solid var(--line);
    margin: 0 -12px; padding: 4px 12px 0; max-height: 240px;
}
.dict-quick .dict-link { justify-self: start; font-size: 12px; }

/* ── Popup / bottom sheet ─────────────────────────────────────────────────── */
.dict-wrap { position: fixed; inset: 0; z-index: 960; display: flex; align-items: flex-end; justify-content: center; }
.dict-wrap[hidden] { display: none; }
.dict-scrim { position: absolute; inset: 0; background: rgba(20, 14, 6, .45); border: 0; padding: 0; }
.dict-card {
    position: relative; width: min(560px, 100%); max-height: min(78vh, 620px);
    display: flex; flex-direction: column;
    background: var(--surface); color: var(--ink);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .25);
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
    .dict-wrap { align-items: center; }
    .dict-card { border-radius: var(--radius-lg); box-shadow: var(--shadow-md), 0 20px 60px rgba(0, 0, 0, .28); }
}

.dict-head { display: flex; align-items: flex-start; gap: 10px; }
.dict-headword { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.dict-headword h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.dict-pos { font-size: 12px; color: var(--muted); font-style: italic; }
.dict-lang {
    font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 2px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.dict-badge {
    font-size: 11px; padding: 2px 7px; border-radius: 999px;
    background: var(--warn-soft); color: var(--warn); white-space: nowrap;
}
.dict-badge.tech { background: var(--ok-soft); color: var(--ok); }
.dict-head-actions { margin-left: auto; display: flex; gap: 2px; flex-shrink: 0; }
.dict-ico {
    border: 0; background: transparent; color: var(--muted); border-radius: 8px;
    width: 32px; height: 32px; font-size: 15px; line-height: 1; cursor: pointer;
}
.dict-ico:hover, .dict-ico:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.dict-ico.is-on { color: var(--warm); }

.dict-note { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.dict-note em { font-style: normal; color: var(--ink); font-weight: 600; }

/* Solapas */
.dict-tabs { display: flex; gap: 4px; margin: 10px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.dict-tabs button {
    border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px;
    padding: 7px 10px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.dict-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.dict-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 2px 4px; -webkit-overflow-scrolling: touch; }
.dict-body h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dict-body p { margin: 0 0 10px; }
.dict-empty { color: var(--muted); font-size: 13.5px; }

/* Acepciones */
.dict-sense { display: grid; gap: 3px; margin-bottom: 12px; }
.dict-sense-n { color: var(--accent); font-weight: 700; font-size: 12px; }
.dict-def { font-size: 15px; line-height: 1.5; }
.dict-simple { font-size: 13.5px; color: var(--muted); }
.dict-example { font-size: 13.5px; font-style: italic; color: var(--ink); border-left: 2px solid var(--line); padding-left: 8px; margin: 2px 0 0; }
.dict-domain { font-size: 11.5px; color: var(--muted); }

/* Listas de palabras (traducciones, relaciones, resultados) */
.dict-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.dict-chips li { margin: 0; }
.dict-chip {
    display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line);
    background: var(--bg); color: var(--ink); border-radius: 999px; padding: 4px 11px;
    font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none;
}
.dict-chip:hover, .dict-chip:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.dict-chip .n { font-size: 11px; color: var(--muted); }
.dict-chip-kind { font-size: 11px; color: var(--muted); }

/* En Lumbre: dónde sale la palabra */
.dict-occ { display: grid; gap: 6px; }
.dict-occ a { display: block; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 8px 10px; font-size: 13.5px; }
.dict-occ a:hover, .dict-occ a:focus-visible { border-color: var(--accent); outline: none; }
.dict-occ small { display: block; color: var(--muted); font-size: 11.5px; }

/* Pie: estados de «Mi vocabulario» (§17) */
.dict-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.dict-foot .spacer { margin-left: auto; }
.dict-status {
    border: 1px solid var(--line); background: transparent; color: var(--muted);
    font: inherit; font-size: 12px; border-radius: 999px; padding: 3px 10px; cursor: pointer;
}
.dict-status[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dict-link { font-size: 12.5px; color: var(--accent); text-decoration: underline; }
.dict-lic { font-size: 11px; color: var(--muted); }

/* ── Página /diccionario ──────────────────────────────────────────────────── */
.dict-block-title { font-size: 1.2rem; margin: 24px 0 10px; }
.dict-intro { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 18px 20px; }
.dict-intro h2 { margin: 0 0 6px; font-size: 1.15rem; }
.dict-intro p { margin: 0 0 12px; }
.dict-page .dict-search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 18px; }
.dict-page .dict-search input[type="search"] { flex: 1 1 220px; min-width: 180px; }
.dict-suggest { position: relative; }
.dict-suggest-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin: 2px 0 0; padding: 4px;
    list-style: none; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-md); box-shadow: var(--shadow-md); max-height: 280px; overflow-y: auto;
}
.dict-suggest-list[hidden] { display: none; }
.dict-suggest-list li { margin: 0; }
.dict-suggest-list button {
    display: flex; gap: 8px; align-items: baseline; width: 100%; text-align: left;
    border: 0; background: transparent; color: inherit; font: inherit; font-size: 14px; padding: 7px 9px; border-radius: 7px; cursor: pointer;
}
.dict-suggest-list button:hover, .dict-suggest-list button:focus-visible { background: var(--accent-soft); outline: none; }

/* La ficha, en la página, es el mismo componente que el popup — sin duplicar estilos */
.dict-page .dict-card { width: 100%; max-height: none; box-shadow: var(--shadow-sm); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.dict-page .dict-body { overflow: visible; }

.dict-cols { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .dict-cols { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }

.dict-vp { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; padding: 0; list-style: none; }
.dict-vp .n { font-size: 11px; color: var(--muted); }

/* Tabla de «Mi vocabulario» */
.dict-table-wrap { overflow-x: auto; }
.dict-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dict-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dict-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dict-table tr:hover td { background: var(--bg); }

/* Repaso (§19) */
.dict-review { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; background: var(--bg); }
.dict-review h3 { margin: 0 0 8px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.dict-review-opts { display: grid; gap: 8px; margin: 10px 0; }
.dict-review-opts button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-md); padding: 9px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.dict-review-opts button:hover, .dict-review-opts button:focus-visible { border-color: var(--accent); outline: none; }
.dict-review-opts button.ok { border-color: var(--ok); background: var(--ok-soft); }
.dict-review-opts button.bad { border-color: var(--danger); background: var(--danger-soft); }

/* ── Panel de administración ──────────────────────────────────────────────── */
.dict-meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.dict-meter span { display: block; height: 100%; background: var(--ok); }
.dict-meter.warn span { background: var(--warn); }
.dict-meter.bad span { background: var(--danger); }
.dict-kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 0 0 18px; }
.dict-kpi { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; background: var(--surface); }
.dict-kpi b { display: block; font-size: 20px; }
.dict-kpi span { font-size: 12px; color: var(--muted); }
.dict-admin-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dict-admin-actions form { display: inline; }
/* Interruptor general del subsistema: es lo primero que ve quien administra y lo que responde a §52. */
.dict-switch { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 20px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.dict-switch span { flex: 1 1 220px; }

@media (prefers-reduced-motion: reduce) {
    .dict-bubble, .dict-card, .dict-quick { animation: none; }
}
