/* Clawypedia: estilos de la app.
   Lenguaje de diccionario: lema en negrita, metadatos en cursiva, sangría francesa y «V.» para
   las remisiones (etiquetas). Una sola familia (Alegreya, autoalojada), mobile-first, claro/oscuro.
   Sin JS: todo lo visual vive aquí (la CSP no admite estilos en línea). */

/* ---- Fuente (Alegreya, SIL OFL 1.1: ver alegreya-OFL.txt). Subconjunto latin, variable en peso.
   La versión va en el nombre del archivo: /static se sirve con caché inmutable de un año. ---- */
@font-face {
  font-family: "Alegreya";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("alegreya-v41-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Alegreya";
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url("alegreya-v41-latin-wght-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;
  /* Papel gris frío, tinta negro azulada y rúbrica carmín (la tinta roja de las rúbricas). */
  --bg: #f6f7f4;        /* papel */
  --surface: #ffffff;   /* superficie (barra del visor, campos) */
  --text: #1b2030;      /* tinta */
  --muted: #5b6173;     /* tinta secundaria: 5.7:1 sobre papel */
  --rule: #d8dae1;      /* filete (solo decorativo) */
  --rubric: #a61d3c;    /* rúbrica: 6.8:1 sobre papel */
  --marker: #f6e39a;    /* rotulador de la búsqueda (tinta encima: 12.6:1) */

  --serif: "Alegreya", ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  /* Escala modular ≈1.25 sobre el cuerpo de 1.0625rem (17 px). */
  --step--1: .875rem;
  --step-0: 1.0625rem;
  --step-1: 1.328rem;
  --step-2: 1.66rem;
  --step-3: 2.075rem;
  --step-4: 2.594rem;
  --step-5: 3.242rem;
  --hang: 1.25rem;      /* sangría francesa */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151e;
    --surface: #171c27;
    --text: #e2e5ed;
    --muted: #9aa1b3;   /* 7.1:1 sobre papel */
    --rule: #283043;
    --rubric: #ff8098;  /* 7.7:1 sobre papel */
    --marker: #5c4c14;  /* tinta encima: 6.7:1 */
  }
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--step-0)/1.6 var(--serif);
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  overflow-wrap: break-word;
}
a {
  color: var(--text);
  text-decoration-line: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  transition: color .15s ease, text-decoration-color .15s ease;
}
a:hover { color: var(--rubric); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--rubric); outline-offset: 2px; border-radius: 2px; }
abbr[title] { text-decoration: none; }
.wrap { width: 100%; max-width: 44rem; margin: 0 auto; padding: 0 1rem; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- Cabecera y pie ---- */
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.25rem; }
.brand { padding: .4rem 0; font-weight: 800; font-size: var(--step-1); line-height: 1.2; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--rubric); }
.session { margin-left: auto; }
.session a { display: inline-block; padding: .5rem 0; }
.logout { margin: 0; }
.site-footer { margin-top: 3.5rem; padding: 0 0 2.5rem; color: var(--muted); font-style: italic; }

/* ---- Formularios ---- */
input[type="search"], input[type="password"] {
  font: inherit;
  min-height: 2.75rem;
  padding: .5rem .7rem;
  border: 1px solid var(--muted);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  appearance: none;
}
input::placeholder { color: var(--muted); opacity: 1; font-style: italic; }
input[type="search"]:focus-visible, input[type="password"]:focus-visible { outline-offset: 1px; border-color: var(--text); }
button {
  font: inherit;
  font-weight: 700;
  min-height: 2.75rem;
  padding: .5rem 1.1rem;
  border: 1px solid var(--text);
  border-radius: 3px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
button:hover { background: color-mix(in srgb, var(--text) 82%, var(--bg)); }
button.linklike {
  min-height: 0;
  padding: .5rem 0;
  border: 0;
  background: none;
  color: var(--text);
  font-weight: 400;
  text-decoration: underline 1px var(--muted);
  text-underline-offset: .18em;
  transition: color .15s ease;
}
button.linklike:hover { background: none; color: var(--rubric); text-decoration-color: currentColor; }

/* ---- Lema (portada, login, 404, error) ---- */
.hero { padding: 1rem 0 0; }
.lemma { margin: 0; font-weight: 800; font-size: clamp(2.4rem, 12vw, var(--step-5)); line-height: 1.05; letter-spacing: -.005em; }
.syl { margin: 0 .03em; color: var(--muted); font-weight: 400; }
.lemma-sm { font-size: var(--step-3); line-height: 1.15; }
/* Acepción: sangría francesa (la segunda línea entra bajo el texto, no bajo la «f.»). */
.def { margin: .5rem 0 0; padding-left: var(--hang); text-indent: calc(-1 * var(--hang)); font-size: 1.1875rem; line-height: 1.5; max-width: 38rem; }
.gram { margin-right: .1em; font-style: italic; color: var(--rubric); }
.note { margin: 1rem 0 0; }
.lemma-sm + .def { padding-left: 0; text-indent: 0; font-style: italic; }

/* ---- Buscador ---- */
.search { display: flex; gap: .5rem; margin: 1.5rem 0 0; }
.search input { flex: 1 1 auto; min-width: 0; }

/* ---- Etiquetas como remisiones: «V. a, b, c» ---- */
.xref { margin-right: .2em; font-style: italic; color: var(--rubric); }
.tags, .tagbar-list { display: inline; margin: 0; padding: 0; list-style: none; }
/* Cada etiqueta es una caja con su coma dentro: la línea solo se corta entre etiquetas (y dentro de
   una etiqueta solo si no cabe sola en la línea). */
.tags li, .tagbar-list li { display: inline-block; max-width: 100%; text-indent: 0; }
.tags li:not(:last-child)::after, .tagbar-list li:not(:last-child)::after { content: ","; color: var(--muted); }
.tag { display: inline-block; padding: .25rem 0; text-indent: 0; text-decoration-color: var(--muted); }
/* Si la lista salta de línea, sigue bajo las etiquetas y no bajo la «V.» (sangría francesa). */
.xrefs, .tagbar { padding-left: 1.1em; text-indent: -1.1em; }
.tag:hover { text-decoration-color: currentColor; }
.tagbar { margin: 1rem 0 0; line-height: 1.5; }
/* El recuento queda fuera del subrayado (inline-block) y en tinta secundaria. */
.tag-count { display: inline-block; margin-left: .05em; color: var(--muted); font-size: var(--step--1); }
/* En la barra todo son enlaces y el subrayado cruzaría el espacio antes del recuento: solo al pasar. */
.tag-btn { text-decoration-line: none; }
.tag-btn:hover { text-decoration-line: underline; }
.tag.on { color: var(--rubric); font-weight: 700; }
.tag.on .tag-count { color: inherit; font-weight: 400; }
.tag-clear { display: table; text-indent: 0; padding: .25rem 0; font-style: italic; }

/* ---- Lista de entradas: artículos de diccionario con sangría francesa ---- */
.results { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.count { margin: 0 0 1.5rem; color: var(--muted); font-style: italic; }
.entries { margin: 0; padding: 0; list-style: none; }
.entry { margin: 0 0 2.4rem; padding-left: var(--hang); max-width: 40rem; }
.entry-title {
  margin: 0 0 0 calc(-1 * var(--hang));
  padding-left: var(--hang);
  text-indent: calc(-1 * var(--hang));
  font-weight: 800;
  font-size: clamp(1.45rem, 5.6vw, var(--step-2));
  line-height: 1.18;
  letter-spacing: -.01em;
}
.entry-title a { color: var(--text); text-decoration: none; }
.entry-title a:hover, .entry-title a:focus-visible { color: var(--rubric); text-decoration: underline 1px; text-underline-offset: .15em; }
.entry-meta { margin: .35rem 0 .3rem; color: var(--muted); font-style: italic; }
.badge-private { color: var(--rubric); }
/* El lema manda: la acepción va en tinta secundaria para que el título destaque por contraste. */
.entry-desc, .entry-excerpt { margin: 0; color: var(--muted); hyphens: auto; }
.entry-excerpt { color: var(--muted); }
.entry .xrefs { margin-top: .15rem; line-height: 1.5; }
mark {
  padding: 0 .12em;
  border-radius: 1px;
  background: var(--marker);
  color: var(--text);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.empty { color: var(--muted); font-style: italic; }

/* ---- Iniciar sesión ---- */
.narrow { max-width: 30rem; }
.login { display: flex; flex-direction: column; gap: .4rem; margin: 1.75rem 0 2rem; }
.login label { font-weight: 700; }
.login-row { display: flex; gap: .5rem; }
.login-row input { flex: 1 1 auto; min-width: 0; }
.form-error { margin: 0 0 .5rem; color: var(--rubric); font-style: italic; font-weight: 600; }

/* ---- Visor ---- */
body.page-viewer { height: 100vh; height: 100dvh; overflow: hidden; }
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 .75rem;
  padding: .15rem .75rem .2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  line-height: 1.35;
}
.v-back { padding: .2rem .3rem .2rem 0; color: var(--text); font-size: 1.3rem; line-height: 1; text-decoration: none; white-space: nowrap; }
.v-back-text { display: none; font-size: var(--step-0); font-weight: 700; vertical-align: .1em; }
.v-title { flex: 1 1 0; min-width: 0; margin: 0; font-weight: 700; font-size: var(--step-0); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-full { padding: .4rem 0; font-size: .9375rem; white-space: nowrap; }
.v-meta {
  flex: 1 0 100%;
  display: flex;
  align-items: baseline;
  gap: 0 1rem;
  padding-bottom: .1rem;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--muted);
  font-style: italic;
  font-size: .9375rem;
  scrollbar-width: none;
}
.v-meta::-webkit-scrollbar { display: none; }
.v-meta > * { flex: none; }
.v-meta :focus-visible { outline-offset: -2px; }
.v-meta .xrefs { padding-left: 0; text-indent: 0; font-style: normal; }
.v-meta .tag { padding: 0; }
/* La fuente va antes de las tags y es lo único que encoge (con elipsis): siempre queda a la vista. */
.v-meta > .v-source-wrap { flex: 0 1 auto; min-width: 11rem; overflow: hidden; text-overflow: ellipsis; max-width: 20rem; }
.v-label { color: var(--muted); }
.v-source { color: var(--muted); }
a.v-source:hover { color: var(--rubric); }
/* Fondo del tema (no blanco): es lo que se ve mientras carga la entrada; con #fff, flash en oscuro. */
.viewer-frame { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: var(--bg); }

@media (min-width: 40rem) {
  .v-back-text { display: inline; }
  .viewer-bar { flex-wrap: nowrap; gap: 1rem; padding: .15rem 1rem; }
  .v-title { flex: 1 1 auto; }
  .v-meta { flex: 0 1 auto; max-width: 55%; order: 2; padding-bottom: 0; }
  .v-full { order: 3; }
}

/* ---- Pantallas anchas ---- */
@media (min-width: 48rem) {
  .hero { padding-top: 2.5rem; }
  .lemma { font-size: 4rem; }
  .lemma-sm { font-size: var(--step-4); }
  .def { font-size: var(--step-1); }
  .search { margin-top: 2rem; }
  .results { margin-top: 1.75rem; padding-top: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
