/* OposDocs design system — "Subrayado".
 *
 * People preparing an oposición read with a highlighter in hand, so the
 * highlighter is the only accent: a fluorescent yellow on ink and paper. It
 * marks what matters — the active filter, the search hit, the link under the
 * pointer, the focused field — and nothing else is coloured, except the
 * provenance tags (Oficial / Editorial / Comunidad), which carry meaning.
 *
 * The rest is the vocabulary of a well-set reference work rather than of an
 * app: hairline rules instead of cards and shadows, square corners, § marks
 * on sections, monospace labels for metadata, dense rows that scan quickly.
 *
 * Typography is system stacks on purpose: no web-font request means nothing
 * third-party loads before consent, and no font swap shifts the layout of the
 * pages whose ranking pays for the site.
 *
 * Everything here is layout and colour only. No rule may hide content that a
 * crawler must see (constraint 1) — if something needs to collapse, it uses
 * <details>, whose content is in the HTML either way. Line clamps on long BOE
 * titles are visual only; the full text is still in the markup.
 */

:root {
  color-scheme: light dark;

  /* Paper and surfaces */
  --paper: #f6f6f2;
  --surface: #ffffff;
  --sunken: #eeeee8;

  /* Ink */
  --ink: #121212;
  --ink-2: #3b3b38;
  --muted: #66665f;

  /* Rules */
  --line: rgba(18, 18, 18, 0.12);
  --line-strong: rgba(18, 18, 18, 0.3);

  /* The highlighter */
  --hl: #ffea3d;
  --hl-soft: #fff6b0;
  --on-hl: #121212;

  /* Provenance */
  --official: #b3261e;
  --editorial: #2848b0;
  --user: #17734a;

  /* Semantic */
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --success: #17734a;

  --radius: 3px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, "Cascadia Mono", Consolas,
    "Liberation Mono", monospace;

  --measure: 70ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141413;
    --surface: #1b1b19;
    --sunken: #242421;
    --ink: #f0efe8;
    --ink-2: #cbcac2;
    --muted: #9c9b92;
    --line: rgba(240, 239, 232, 0.13);
    --line-strong: rgba(240, 239, 232, 0.3);
    --hl-soft: #4a4520;
    --official: #ff8f85;
    --editorial: #9db2ff;
    --user: #74d6a5;
    --danger: #ff8f85;
    --danger-soft: #3a1d1b;
    --success: #74d6a5;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

.container { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
main.container { padding-bottom: 3.5rem; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  background: var(--hl);
  color: var(--on-hl);
  font-weight: 600;
}
.skip-link:focus { top: 0.5rem; }

/* --- Typography ----------------------------------------------------------- */

h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.02em; color: var(--ink); }
h1 { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.4rem); font-weight: 800; margin: 1.5rem 0 0.9rem; max-width: 30ch; }
h2 { font-size: 1.2rem; font-weight: 750; margin: 2.75rem 0 0.9rem; }
h3 { font-size: 1rem; font-weight: 650; margin: 0 0 0.25rem; letter-spacing: -0.01em; }

/* Section mark: § before every page-level h2. Decoration only, so it lives in
   CSS and never pollutes the heading text crawlers and the .md views read. */
main > h2::before,
main section > h2:first-child::before,
.section-head h2::before {
  content: "§";
  margin-right: 0.45em;
  color: var(--muted);
  font-weight: 500;
}

p { margin: 0.7rem 0; }

a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
/* The signature: hovering a link draws a highlighter stroke under it. */
a:hover {
  text-decoration-color: transparent;
  background: linear-gradient(transparent 58%, var(--hl) 58%);
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  a:hover { background: linear-gradient(transparent 58%, rgba(255, 234, 61, 0.38) 58%); }
}

.muted { color: var(--muted); font-size: 0.875rem; }

mark { background: var(--hl); color: var(--on-hl); padding: 0 0.12em; }

code, kbd, samp { font-family: var(--font-mono); font-size: 0.88em; }

hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

::selection { background: var(--hl); color: var(--on-hl); }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 5px var(--hl); }

/* Metadata labels: small monospace caps. */
.label, .meta, dl.facts dt, th, .facet-group > strong, .stats {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta { margin: 0.2rem 0 0; font-size: 0.76rem; letter-spacing: 0; text-transform: none; }

/* --- Header --------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem 1.5rem;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { background: none; }
.brand svg { flex: none; }

.main-nav { display: flex; gap: 0.1rem; }
.main-nav a {
  padding: 0.35rem 0.6rem;
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}
.main-nav a:hover { color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--ink); background: linear-gradient(transparent 58%, var(--hl) 58%); }
.nav-sep { width: 1px; background: var(--line-strong); margin: 0.35rem 0.4rem; }

.header-search { display: flex; margin-left: auto; }
.header-search input[type="search"] {
  width: 260px;
  max-width: none;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface);
  font-size: 0.9rem;
}
.header-search button { border-radius: 0 var(--radius) var(--radius) 0; padding: 0.45rem 0.85rem; }

/* Secondary nav strip (account area). */
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.1rem;
  margin: 1.25rem 0 0;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

/* --- Ad slots ------------------------------------------------------------- */

/* Fixed height reserved before any ad exists: zero layout shift, always. */
.ad-slot { height: 90px; max-width: 1120px; margin: 0.75rem auto; background: transparent; }

/* --- Buttons -------------------------------------------------------------- */

.btn,
button[type="submit"],
.header-search button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.35;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover,
button[type="submit"]:hover,
.header-search button:hover {
  background: var(--hl);
  color: var(--on-hl);
  border-color: var(--on-hl);
}
.btn:active, button[type="submit"]:active { transform: translateY(1px); }

.btn-lg { padding: 0.8rem 1.4rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }

/* Secondary: the quieter of two adjacent actions (e.g. "Guardar borrador"). */
button[value="draft"],
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

/* --- Breadcrumbs and page heads -------------------------------------------- */

.crumbs {
  margin: 1.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.crumbs a { color: var(--ink-2); }
.crumbs .sep { margin: 0 0.35rem; color: var(--line-strong); }

/* Answer-first paragraph: the factual summary an assistant quotes. Marked in
   the margin with the highlighter, the way a student marks the key line. */
.answer-first {
  max-width: var(--measure);
  margin: 0.75rem 0 1.5rem;
  padding-left: 1rem;
  border-left: 4px solid var(--hl);
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.notice {
  border: 1px solid var(--ink);
  background: var(--hl-soft);
  padding: 0.75rem 1rem;
  font-size: 0.93rem;
  margin: 1.25rem 0;
}

/* --- Sections -------------------------------------------------------------- */

main section { margin: 2.75rem 0 0; }
main section > h2:first-child { margin-top: 0; }
main section > h2:first-child,
main > h2,
.section-head {
  padding-top: 0.6rem;
  border-top: 2px solid var(--ink);
}
main section ul, main section ol { padding-left: 1.25rem; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 2.75rem 0 0.75rem;
}
.section-head h2 { margin: 0; }
.section-head a { font-size: 0.88rem; }

.more { margin: 0.9rem 0 0; font-size: 0.92rem; font-weight: 600; }

/* --- Provenance tags and grupo badges --------------------------------------- */

.tag {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--muted);
}
.tag-official { color: var(--official); }
.tag-editorial { color: var(--editorial); }
.tag-user { color: var(--user); }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 2.3rem;
  height: 2.3rem;
  padding: 0 0.3rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
}

/* --- Lists: documents, oposiciones, posts ------------------------------------ */

/* Rows separated by hairlines: faster to scan than a stack of cards, and long
   BOE titles get the full measure instead of a padded box. */
.rows { list-style: none; padding: 0; margin: 0.5rem 0 0; border-top: 1px solid var(--line); }
main section .rows { padding-left: 0; }
.rows > li { padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.rows h3 { font-size: 0.98rem; line-height: 1.38; }
.rows h3 a { text-decoration: none; }
.rows p { margin: 0.25rem 0 0; }
.rows .excerpt { color: var(--ink-2); font-size: 0.93rem; max-width: var(--measure); }
.rows .empty { color: var(--muted); }

.doc-row { display: grid; grid-template-columns: 5.9rem 1fr; gap: 0 1rem; align-items: start; }
.doc-row .tag { margin-top: 0.15rem; justify-self: start; }
.doc-row h3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.snippet { font-size: 0.9rem; color: var(--ink-2); }
/* BOE descriptions are boilerplate (fecha, referencia, organismo): two lines
   are enough to tell rows apart. Visual only — the full text stays in the HTML. */
.doc-row .excerpt, .doc-row .snippet {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* Oposición index rows: grupo badge, then name and facts. */
.op-row { display: grid; grid-template-columns: auto 1fr; gap: 0 1rem; align-items: center; }

/* Featured oposiciones: a dense grid of tiles sharing their borders. */
.op-grid {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.op-grid li { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.op-grid a {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.85rem;
  align-items: center;
  height: 100%;
  padding: 0.95rem 1rem;
  text-decoration: none;
}
.op-grid a:hover { background: var(--hl-soft); }
@media (prefers-color-scheme: dark) { .op-grid a:hover { background: var(--sunken); } }
.op-grid .badge { grid-row: span 2; }
.op-grid strong { font-size: 0.96rem; line-height: 1.3; letter-spacing: -0.01em; }
.op-grid .meta { margin: 0; }

/* Deadlines: a tear-off calendar block for the closing date. */
.deadline { display: grid; grid-template-columns: 3.4rem 1fr auto; gap: 0 1rem; align-items: center; }
.cal {
  display: grid;
  text-align: center;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  line-height: 1;
}
.cal-m {
  padding: 0.2rem 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cal-d { padding: 0.3rem 0 0.35rem; font-size: 1.3rem; font-weight: 800; }
.countdown {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius);
  background: var(--sunken);
}
.countdown.soon { background: var(--hl); color: var(--on-hl); }
.countdown.past { background: none; color: var(--muted); text-decoration: line-through; }

/* Two lists side by side on wide screens (home: documents | apuntes). */
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 2.5rem; }

/* --- Home hero ---------------------------------------------------------------- */

.hero { padding: 1.25rem 0 0.5rem; }
.hero h1 { max-width: 22ch; margin-top: 1.25rem; font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3rem); letter-spacing: -0.035em; line-height: 1.08; }
.hero h1 em { font-style: normal; background: linear-gradient(transparent 60%, var(--hl) 60%); }
@media (prefers-color-scheme: dark) { .hero h1 em { background: linear-gradient(transparent 60%, rgba(255, 234, 61, 0.45) 60%); } }

.big-search { display: flex; max-width: 720px; margin: 1.5rem 0 0.75rem; }
.big-search input[type="search"] {
  flex: 1;
  max-width: none;
  min-width: 0;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--ink);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface);
  font-size: 1.05rem;
}
.big-search button { border-radius: 0 var(--radius) var(--radius) 0; padding: 0 1.4rem; font-size: 1rem; }

.quick-links { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; margin: 0; padding: 0; list-style: none; font-size: 0.9rem; }
.quick-links .label { align-self: center; }

.stats { display: flex; flex-wrap: wrap; gap: 0.3rem 1.5rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.stats strong { color: var(--ink); font-size: 0.85rem; }

/* --- Facts list ------------------------------------------------------------ */

dl.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  margin: 1.25rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.94rem;
}
dl.facts dt, dl.facts dd { padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
dl.facts dt { padding-right: 1.5rem; padding-top: 0.7rem; }
dl.facts dd { margin: 0; color: var(--ink); }

/* --- Detail layouts ------------------------------------------------------------ */

/* Document and oposición pages: content column + a sticky aside holding the
   facts and the primary action, so "Descargar" is always one glance away. */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2.5rem; align-items: start; }
.detail-main > :first-child { margin-top: 0; }
.detail-aside { position: sticky; top: 76px; }
.detail-aside dl.facts { margin-top: 0; grid-template-columns: 1fr; border-top: 2px solid var(--ink); }
.detail-aside dl.facts dt { padding: 0.55rem 0 0; border-bottom: 0; }
.detail-aside dl.facts dd { padding: 0.1rem 0 0.55rem; }
.detail-aside .btn { margin-bottom: 1rem; }
.detail-aside .muted { font-size: 0.82rem; }

.head-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 1.25rem; }
.head-row + h1 { margin-top: 0.6rem; }
/* BOE titles run to 250 characters: a smaller, wider headline keeps them to a few lines. */
h1.doc-title { max-width: 52ch; font-size: clamp(1.3rem, 1.05rem + 1vw, 1.75rem); line-height: 1.28; letter-spacing: -0.015em; }

.preview {
  max-width: var(--measure);
  font-size: 0.97rem;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-line;
}

/* In-page contents for the oposición page. */
.toc { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; margin: 0 0 0.5rem; padding: 0; list-style: none; font-size: 0.9rem; }

ol.temario { padding-left: 2.4rem; max-width: var(--measure); }
ol.temario li { padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
ol.temario li::marker { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }

/* --- Tables ---------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0.5rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { padding: 0.6rem 0.75rem 0.6rem 0; text-align: left; border-bottom: 1px solid var(--line); }
th { border-bottom: 1px solid var(--ink); font-weight: 600; }
td.num, th.num { text-align: right; }

/* --- Facets and pagination -------------------------------------------------- */

.facet-bar { display: grid; gap: 0.6rem; margin: 1rem 0 1.5rem; padding: 0.9rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facet-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.facet-group > strong { min-width: 4.5rem; margin-right: 0.3rem; font-weight: 600; }
.facet-bar a {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--ink-2);
}
.facet-bar a:hover { background: var(--hl-soft); color: var(--ink); border-color: var(--ink); }
@media (prefers-color-scheme: dark) { .facet-bar a:hover { background: var(--sunken); } }
.facet-bar a.active { background: var(--hl); color: var(--on-hl); border-color: var(--on-hl); font-weight: 650; }
.facet-bar .clear { border-style: dashed; }

.result-count { margin: 0 0 0.25rem; }

.pagination { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 2rem 0; font-size: 0.9rem; font-family: var(--font-mono); }
.pagination a, .pagination strong {
  display: inline-grid;
  place-items: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-decoration: none;
}
.pagination strong { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* --- Forms ----------------------------------------------------------------- */

/* Any real form in the page body sits on a surface — including the allauth
   pages, which we do not template-override. Site search and the one-button
   forms in the dashboard are excluded. */
main form:not([role="search"]):not(.inline-form) {
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin: 1.25rem 0;
}
main form:not([role="search"]):not(.inline-form) > p:first-child { margin-top: 0; }

form p { margin: 1rem 0; }
form label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--ink);
}
input[type="text"], input[type="email"], input[type="search"],
input[type="password"], input[type="url"], input[type="number"],
textarea, select {
  width: 100%;
  max-width: 560px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--hl);
}
select[multiple] { padding: 0.3rem; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); width: 1rem; height: 1rem; }

input[type="file"] {
  width: 100%;
  max-width: 560px;
  padding: 0.75rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--sunken);
  font-size: 0.88rem;
}
input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--hl); color: var(--on-hl); }

/* Radio and checkbox groups (licence declaration, oposiciones picker). */
ul#id_license, ul#id_oposiciones { list-style: none; padding: 0; margin: 0.2rem 0; }
ul#id_license li, ul#id_oposiciones li { margin: 0.2rem 0; }
ul#id_license label, ul#id_oposiciones label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 450;
  color: var(--ink);
}

.helptext { display: block; margin-top: 0.3rem; font-size: 0.84rem; color: var(--muted); }

.errorlist {
  list-style: none;
  padding: 0.5rem 0.75rem;
  margin: 0.4rem 0;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.87rem;
}

.messages { list-style: none; padding: 0; margin: 1.25rem 0 0; }
.messages li {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--success);
  background: var(--surface);
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.93rem;
}
.messages li.error { border-left-color: var(--danger); }

/* Search page form: the big search, without the panel around it. */
.search-page-form { margin: 0.5rem 0 1rem; }

/* --- Posts (apuntes) -------------------------------------------------------- */

.post { max-width: 760px; }
.post > h1 { max-width: none; }
.post-byline { margin: -0.2rem 0 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }

/* Rendered markdown. Sanitised at save time, so this is typography only. */
.post-body { max-width: var(--measure); font-size: 1.06rem; line-height: 1.75; color: var(--ink-2); }
.post-body h2 { font-size: 1.35rem; margin: 2.25rem 0 0.6rem; color: var(--ink); }
.post-body h3 { font-size: 1.12rem; margin: 1.75rem 0 0.4rem; color: var(--ink); }
.post-body h4, .post-body h5, .post-body h6 { font-size: 1rem; margin: 1.4rem 0 0.3rem; color: var(--ink); }
.post-body p { margin: 1rem 0; }
.post-body ul, .post-body ol { padding-left: 1.4rem; }
.post-body li { margin: 0.35rem 0; }
.post-body strong { color: var(--ink); }
.post-body blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 4px solid var(--hl);
  color: var(--ink-2);
}
.post-body pre {
  background: var(--sunken);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  font-size: 0.9rem;
}
.post-body code { background: var(--sunken); border-radius: var(--radius); padding: 0.1rem 0.3rem; font-size: 0.87em; }
.post-body pre code { background: none; padding: 0; }
.post-body img { max-width: 100%; height: auto; }
.post-body table { margin: 1.5rem 0; display: block; overflow-x: auto; }
.post-body hr { margin: 2.25rem 0; }

.post-foot { margin-top: 2.5rem; padding-top: 0.5rem; border-top: 2px solid var(--ink); }

/* --- Post editor ------------------------------------------------------------ */

main form.post-editor { max-width: 860px; }
.post-editor input[type="text"] { max-width: none; font-size: 1.1rem; font-weight: 650; }
.post-editor textarea.editor-body {
  max-width: none;
  min-height: 24rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.7;
}
.post-editor select[multiple] { max-width: none; min-height: 150px; }

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  margin: 1.25rem 0 0.4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.editor-actions a { font-size: 0.9rem; }

.autosave-status { min-height: 1.4em; margin: 0.35rem 0 0; font-size: 0.84rem; color: var(--muted); }

.markdown-help { margin: 1.25rem 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 1rem; }
.markdown-help summary { cursor: pointer; font-size: 0.92rem; font-weight: 650; }
.markdown-help table { margin-top: 0.75rem; }

.inline-form { display: inline; }
.inline-form button[type="submit"] {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  padding: 0.25rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 550;
}
.inline-form button[type="submit"]:hover { background: var(--hl); color: var(--on-hl); border-color: var(--on-hl); }

.row-actions { font-size: 0.88rem; margin: 0.5rem 0; }

/* --- Footer ----------------------------------------------------------------- */

.site-footer {
  margin-top: 3rem;
  padding: 2.25rem 0 2.75rem;
  border-top: 1px solid var(--ink);
  font-size: 0.88rem;
  color: var(--muted);
}
.footer-inner { display: grid; grid-template-columns: 1.4fr repeat(2, 1fr); gap: 1.5rem 2.5rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.site-footer a { color: var(--ink-2); }
.site-footer p { margin: 0.35rem 0; max-width: 46ch; }
.site-footer .label { display: block; margin-bottom: 0.5rem; }

/* --- Consent banner ---------------------------------------------------------- */

/* A floating card, never a full-width wall: it sits on top of a page that is
   already complete in the HTML. Both choices get identical weight, so
   rejecting is exactly as easy — and as prominent — as accepting. */
.consent-banner {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 50;
  width: min(460px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 6px 6px 0 var(--ink);
  font-size: 0.9rem;
}
/* An author `display` here would beat the UA's `[hidden] { display: none }`,
   leaving the banner visible no matter what the user chose. */
.consent-banner[hidden] { display: none; }
.consent-banner p { margin: 0 0 0.8rem; color: var(--ink-2); }
.consent-actions { display: flex; gap: 0.5rem; }
.consent-actions .btn { flex: 1; }

/* --- Responsive --------------------------------------------------------------- */

@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; gap: 1.5rem; }
  .detail-aside { position: static; }
  /* Document pages: the download and the facts come before a long preview. */
  .detail-action-first .detail-aside { order: -1; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-inner > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .container { padding: 0 1rem; }
  /* Header: brand + search on one row, nav as a swipeable strip below. */
  .header-inner { flex-wrap: wrap; gap: 0 0.75rem; padding-top: 0.55rem; }
  .header-search { flex: 1; min-width: 0; }
  .header-search input[type="search"] { width: auto; flex: 1; min-width: 0; }
  .main-nav {
    order: 3;
    width: calc(100% + 2rem);
    margin: 0.45rem -1rem 0;
    padding: 0 0.6rem;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--line);
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { padding: 0.55rem 0.5rem; }
  .doc-row { grid-template-columns: 1fr; gap: 0.3rem; }
  .deadline { grid-template-columns: 3.1rem 1fr; }
  .deadline .countdown { grid-column: 2; justify-self: start; margin-top: 0.35rem; }
  main form:not([role="search"]):not(.inline-form) { padding: 1.1rem 1rem; }
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dt { padding: 0.55rem 0 0; border-bottom: 0; }
  dl.facts dd { padding: 0.1rem 0 0.55rem; }
  .ad-slot { height: 100px; }
  .footer-inner { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* --- Print ---------------------------------------------------------------------- */

/* Opositores print temarios and apuntes: give them the content, not the chrome. */
@media print {
  :root { --paper: #fff; --surface: #fff; --ink: #000; --ink-2: #000; --muted: #444; }
  .site-header, .site-footer, .ad-slot, .consent-banner, .skip-link, .crumbs,
  .toc, .detail-aside .btn, .pagination, .facet-bar, .row-actions { display: none !important; }
  .detail { display: block; }
  a { text-decoration: none; }
  .answer-first { border-left-color: #000; }
}
