/*
Theme Name: RankingUniversidad
Theme URI: https://rankinguniversidad.es/
Description: Tema hijo de GeneratePress para RankingUniversidad.es. Solo presentación: los datos y las rutas viven en el plugin RU Core.
Author: RankingUniversidad.es
Template: generatepress
Version: 1.0.1
Requires PHP: 8.1
Text Domain: ru-theme
*/

/* ---------------------------------------------------------------- variables */
:root {
	--ru-bg: #ffffff;
	--ru-surface: #f5f7f6;
	--ru-surface-2: #eaf0ee;
	--ru-border: #d5dedb;
	--ru-text: #14201d;
	--ru-muted: #51605c;
	--ru-brand: #0b5d4e;
	--ru-brand-dark: #073f35;
	--ru-brand-soft: #e3f1ed;
	--ru-accent: #b4500b;
	--ru-focus: #1d4ed8;
	--ru-warn-bg: #fff6e5;
	--ru-warn-border: #e9c46a;
	/* Paleta de datos: un tono por rama de conocimiento, estable en toda la web. */
	--ru-rama-artes: #8a4fbf;
	--ru-rama-sociales: #c2571a;
	--ru-rama-ciencias: #1f7a3d;
	--ru-rama-ingenieria: #1e5fae;
	--ru-rama-salud: #b3264a;
	--ru-radius: 8px;
	--ru-gap: 1rem;
	--ru-col: 45rem;      /* 720 px: columna de lectura */
	--ru-wide: 62rem;     /* tablas */
	--ru-max: 75rem;      /* 1.200 px */
	--ru-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
	--ru-ad-h: 280px;
}
@media (min-width: 48em) { :root { --ru-ad-h: 250px; } }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body { margin: 0; background: var(--ru-bg); color: var(--ru-text); font: 400 1rem/1.55 var(--ru-font); }
img, svg { max-width: 100%; height: auto; }
a { color: var(--ru-brand); text-underline-offset: .15em; }
a:hover { color: var(--ru-brand-dark); }
:focus-visible { outline: 3px solid var(--ru-focus); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.4rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + .8vw, 1.6rem); margin-top: 0; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.25rem; }
button, input, select { font: inherit; color: inherit; }
.screen-reader-text, .ru-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.ru-skip { position: absolute; left: -999px; top: 0; background: var(--ru-brand); color: #fff; padding: .6rem 1rem; z-index: 100; }
.ru-skip:focus { left: .5rem; top: .5rem; }
.ru-wrap { width: 100%; max-width: var(--ru-max); margin-inline: auto; padding-inline: 1rem; }

/* ---------------------------------------------------------------- cabecera */
.ru-header { position: sticky; top: 0; z-index: 50; background: var(--ru-bg); border-bottom: 1px solid var(--ru-border); }
.ru-header__in { display: flex; align-items: center; gap: .75rem; min-height: 3.5rem; }
.ru-logo { font-weight: 800; font-size: 1.05rem; color: var(--ru-text); text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.ru-logo span { color: var(--ru-brand); }
.ru-nav { margin-left: auto; }
.ru-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; align-items: center; }
.ru-nav a, .ru-nav summary { display: block; padding: .5rem .6rem; color: var(--ru-text); text-decoration: none; font-weight: 600; font-size: .95rem; border-radius: 6px; cursor: pointer; }
.ru-nav a:hover, .ru-nav summary:hover, .ru-nav a[aria-current="page"] { background: var(--ru-surface-2); }
.ru-nav details { position: relative; }
.ru-nav summary { list-style: none; }
.ru-nav summary::-webkit-details-marker { display: none; }
.ru-nav summary::after { content: "▾"; margin-left: .25rem; font-size: .8em; }
.ru-nav details ul { position: absolute; right: 0; top: 100%; display: block; min-width: 16rem; background: var(--ru-bg); border: 1px solid var(--ru-border); border-radius: var(--ru-radius); padding: .35rem; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.ru-nav__toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--ru-border); border-radius: 6px; padding: .45rem .7rem; font-weight: 600; cursor: pointer; }
.ru-nav__search { display: inline-flex; align-items: center; gap: .35rem; }
.ru-nav__search svg { width: 1.1rem; height: 1.1rem; }
@media (max-width: 61.99em) {
	.ru-nav__toggle { display: inline-block; }
	.ru-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--ru-bg); border-bottom: 1px solid var(--ru-border); padding: .5rem 1rem 1rem; max-height: calc(100vh - 3.5rem); overflow: auto; }
	.ru-nav.is-open, .no-js .ru-nav { display: block; }
	.no-js .ru-nav { position: static; padding: 0 0 .5rem; border: 0; }
	.no-js .ru-header__in { flex-wrap: wrap; }
	.no-js .ru-nav__toggle { display: none; }
	.ru-nav ul { flex-direction: column; align-items: stretch; }
	.ru-nav details ul { position: static; box-shadow: none; border: 0; padding-left: .75rem; }
	.ru-nav__guides { display: block; }
}

/* ---------------------------------------------------------------- estructura de página */
.ru-main { padding-block: 1rem 3rem; }
.ru-main.ru-wrap { max-width: calc(var(--ru-wide) + 2rem); }
.ru-prose, .ru-narrow { max-width: var(--ru-col); }
.ru-section { margin-block: 2rem; }
.ru-section__intro { color: var(--ru-muted); margin-top: -.3rem; }
.ru-kicker { color: var(--ru-muted); font-size: .9rem; margin: -.4rem 0 1rem; }
.ru-tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.ru-tags li { background: var(--ru-surface-2); border-radius: 999px; padding: .15rem .7rem; font-size: .85rem; font-weight: 600; }
.ru-anchors { display: flex; gap: .4rem; overflow-x: auto; padding: .25rem 0 .6rem; margin: 0 0 1rem; list-style: none; scrollbar-width: thin; }
.ru-anchors a { display: block; white-space: nowrap; border: 1px solid var(--ru-border); border-radius: 999px; padding: .3rem .8rem; text-decoration: none; font-size: .9rem; font-weight: 600; color: var(--ru-text); }
.ru-anchors a:hover { background: var(--ru-surface-2); }

/* Breadcrumb */
.ru-crumbs { font-size: .85rem; color: var(--ru-muted); margin-bottom: .75rem; }
.ru-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 0; }
.ru-crumbs li + li::before { content: "›"; margin-right: .25rem; color: var(--ru-muted); }
.ru-crumbs a { color: var(--ru-muted); }

/* DirectAnswer */
.ru-answer { background: var(--ru-brand-soft); border-left: 4px solid var(--ru-brand); border-radius: var(--ru-radius); padding: 1rem 1.1rem; font-size: 1.08rem; max-width: var(--ru-col); margin-block: 1rem 1.5rem; }
.ru-answer p { margin: 0; }

/* MetricCard */
.ru-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; list-style: none; padding: 0; margin: 0 0 1rem; }
@media (min-width: 48em) { .ru-cards { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); } }
.ru-card { background: var(--ru-surface); border: 1px solid var(--ru-border); border-radius: var(--ru-radius); padding: .8rem .9rem; display: flex; flex-direction: column; gap: .1rem; }
.ru-card__value { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ru-card__label { color: var(--ru-muted); font-size: .9rem; }
.ru-card__note { color: var(--ru-muted); font-size: .8rem; }
.ru-card a { font-size: .9rem; font-weight: 600; margin-top: .25rem; }

/* Tablas */
.ru-table-wrap { overflow-x: auto; border: 1px solid var(--ru-border); border-radius: var(--ru-radius); background: var(--ru-bg); }
.ru-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.ru-table th, .ru-table td { padding: .55rem .7rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--ru-border); }
.ru-table thead th { position: sticky; top: 0; background: var(--ru-surface-2); font-size: .85rem; font-weight: 700; white-space: nowrap; z-index: 1; }
.ru-table tbody tr:last-child td { border-bottom: 0; }
.ru-table tbody tr:target { background: var(--ru-warn-bg); }
.ru-table .ru-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ru-table td small { display: block; color: var(--ru-muted); font-size: .8rem; }
.ru-table th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: .25rem; font-weight: 700; }
.ru-table th button::after { content: "↕"; opacity: .45; font-size: .85em; }
.ru-table th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
.ru-table th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
.ru-table th button:focus-visible { outline: 3px solid var(--ru-focus); outline-offset: 2px; }
.ru-table__more { margin-top: .6rem; }
.ru-table__count { color: var(--ru-muted); font-size: .85rem; margin: .4rem 0 0; }
.ru-expand { all: unset; cursor: pointer; display: none; margin-left: .35rem; width: 1.5rem; height: 1.5rem; border: 1px solid var(--ru-border); border-radius: 50%; text-align: center; line-height: 1.4rem; font-weight: 700; color: var(--ru-brand); flex: none; }
.ru-detail td { background: var(--ru-surface); }
.ru-detail dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .9rem; }
.ru-detail dt { color: var(--ru-muted); }
.ru-detail dd { margin: 0; }
.js .ru-table tr.is-more, .js .ru-table tr.is-out { display: none; }
@media (max-width: 47.99em) {
	/* En móvil, tres columnas prioritarias; el resto aparece al expandir la fila. */
	.js .ru-table .ru-x { display: none; }
	.js .ru-table .ru-expand { display: inline-block; }
	.js .ru-table tbody tr > :first-child { position: relative; padding-right: 2.3rem; }
	.js .ru-table .ru-expand { position: absolute; right: .35rem; top: .45rem; margin: 0; }
	.ru-table th, .ru-table td { padding: .5rem .45rem; }
	.ru-table thead th { white-space: normal; }
	.ru-table .ru-num { white-space: nowrap; }
	.ru-table { font-size: .9rem; }
	.ru-table th button::after { display: none; }
}
.ru-comparison th[scope="row"] { font-weight: 600; background: var(--ru-surface); position: sticky; left: 0; }

/* FilterBar */
.ru-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin: 0 0 .75rem; }
.ru-filters label { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; font-weight: 600; color: var(--ru-muted); }
.ru-filters select, .ru-filters input[type="search"], .ru-field input, .ru-field select { border: 1px solid #9aa8a4; border-radius: 6px; padding: .45rem .6rem; background: var(--ru-bg); min-height: 2.6rem; max-width: 100%; }
.ru-filters input[type="search"] { min-width: 12rem; }
.no-js .ru-filters { display: none; }

/* Botones */
.ru-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; background: var(--ru-brand); color: #fff; border: 0; border-radius: 6px; padding: .6rem 1.1rem; font-weight: 700; text-decoration: none; cursor: pointer; min-height: 2.75rem; }
.ru-btn:hover { background: var(--ru-brand-dark); color: #fff; }
.ru-btn--ghost { background: transparent; color: var(--ru-brand); border: 1px solid var(--ru-brand); }
.ru-btn--ghost:hover { background: var(--ru-brand-soft); color: var(--ru-brand-dark); }

/* Chart */
.ru-chart { margin: 0; max-width: var(--ru-col); }
details.ru-data { max-width: var(--ru-col); }
.ru-chart__svg { width: 100%; height: auto; display: block; }
.ru-chart__bar { fill: var(--ru-brand); }
.ru-chart__track { fill: var(--ru-surface-2); }
.ru-chart__grid { stroke: var(--ru-border); stroke-width: 1; }
.ru-chart__tick, .ru-chart__label, .ru-chart__value { font: 12px var(--ru-font); fill: var(--ru-muted); }
.ru-chart__label { fill: var(--ru-text); }
.ru-chart__value { font-weight: 700; fill: var(--ru-text); }
.ru-chart__line { fill: none; stroke: var(--ru-brand); stroke-width: 2.5; }
.ru-chart__dot { fill: var(--ru-brand); stroke: #fff; stroke-width: 2; }
.ru-chart figcaption { color: var(--ru-muted); font-size: .85rem; margin-top: .4rem; }
details.ru-data { margin-top: .5rem; }
details > summary { cursor: pointer; font-weight: 600; }
details.ru-data summary { color: var(--ru-brand); font-size: .9rem; }
details.ru-data .ru-table-wrap { margin-top: .5rem; }

/* RelatedEntities */
.ru-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; grid-template-columns: 1fr; }
@media (min-width: 40em) { .ru-links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 62em) { .ru-links--many { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ru-links li { border: 1px solid var(--ru-border); border-radius: var(--ru-radius); }
.ru-links a { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; padding: .6rem .8rem; text-decoration: none; font-weight: 600; min-height: 2.75rem; }
.ru-links a:hover { background: var(--ru-surface); }
.ru-links small { color: var(--ru-muted); font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* FAQ, avisos, estado vacío */
.ru-faq details { border-bottom: 1px solid var(--ru-border); padding: .7rem 0; max-width: var(--ru-col); }
.ru-faq details p { margin: .5rem 0 0; }
.ru-notice { background: var(--ru-warn-bg); border: 1px solid var(--ru-warn-border); border-radius: var(--ru-radius); padding: .7rem .9rem; font-size: .92rem; max-width: var(--ru-col); }
.ru-empty { background: var(--ru-surface); border: 1px dashed var(--ru-border); border-radius: var(--ru-radius); padding: 1.25rem; }

/* Siguiente paso */
.ru-next { margin-block: 2rem; }

/* SourceBox y LastUpdated */
.ru-sources { border-top: 1px solid var(--ru-border); padding-top: 1.25rem; margin-top: 2.5rem; font-size: .9rem; color: var(--ru-muted); max-width: var(--ru-col); }
.ru-sources h2 { font-size: 1rem; color: var(--ru-text); }
.ru-sources ul { padding-left: 1.1rem; }
.ru-updated { font-weight: 600; color: var(--ru-text); }

/* AdSlot: alto reservado; el anuncio nunca desplaza contenido. */
.ru-ad { margin: 2rem auto; padding-top: .25rem; min-height: calc(var(--ru-ad-h) + 1.5rem); text-align: center; clear: both; contain: layout; }
.ru-ad__label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ru-muted); margin-bottom: .25rem; }
.ru-ad ins { display: block; min-height: var(--ru-ad-h); }

/* Search */
.ru-search { position: relative; max-width: var(--ru-col); }
.ru-search form { display: flex; gap: .5rem; }
.ru-search input[type="search"] { flex: 1; min-width: 0; border: 2px solid var(--ru-brand); border-radius: 8px; padding: .7rem .9rem; font-size: 1.05rem; min-height: 3rem; }
.ru-search__list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: .25rem 0 0; padding: .25rem; list-style: none; background: var(--ru-bg); border: 1px solid var(--ru-border); border-radius: var(--ru-radius); box-shadow: 0 12px 32px rgba(0,0,0,.12); max-height: 22rem; overflow: auto; }
.ru-search__list[hidden] { display: none; }
.ru-search__list li { padding: .5rem .7rem; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: .75rem; }
.ru-search__list li[aria-selected="true"], .ru-search__list li:hover { background: var(--ru-brand-soft); }
.ru-search__list small { color: var(--ru-muted); white-space: nowrap; }
.ru-search__hint { font-size: .9rem; color: var(--ru-muted); margin-top: .5rem; }
.ru-results { list-style: none; padding: 0; }
.ru-results li { padding: .6rem 0; border-bottom: 1px solid var(--ru-border); }
.ru-results small { color: var(--ru-muted); margin-left: .5rem; }

/* Herramientas */
.ru-tool { background: var(--ru-surface); border: 1px solid var(--ru-border); border-radius: var(--ru-radius); padding: 1rem; max-width: var(--ru-col); }
.ru-tool fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.ru-tool legend { font-weight: 700; padding: 0; margin-bottom: .4rem; }
.ru-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
@media (min-width: 40em) { .ru-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ru-field { display: flex; flex-direction: column; gap: .15rem; font-size: .85rem; font-weight: 600; }
.ru-field input, .ru-field select { width: 100%; font-weight: 400; font-size: 1rem; }
.ru-field--wide { grid-column: 1 / -1; }
.ru-result { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 1rem 0; }
.ru-result div { background: var(--ru-bg); border: 1px solid var(--ru-border); border-radius: var(--ru-radius); padding: .8rem; }
.ru-result strong { display: block; font-size: 1.9rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ru-result span { color: var(--ru-muted); font-size: .85rem; }
.ru-tool__msg { color: var(--ru-accent); font-size: .9rem; min-height: 1.2em; }
.ru-row3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; margin-bottom: .5rem; }

/* Portada */
.ru-hero { padding-block: 1.5rem 1rem; }
.ru-hero p { font-size: 1.1rem; color: var(--ru-muted); max-width: var(--ru-col); }

/* Editorial */
.ru-article { max-width: var(--ru-col); }
.ru-article__meta { color: var(--ru-muted); font-size: .9rem; margin-bottom: 1.25rem; }
.ru-article .ru-table-wrap { margin-block: 1rem; }
.ru-article h2 { margin-top: 2rem; }
.ru-postlist { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.ru-postlist li { border: 1px solid var(--ru-border); border-radius: var(--ru-radius); padding: .9rem 1rem; }
.ru-postlist h2, .ru-postlist h3 { font-size: 1.1rem; margin: 0 0 .25rem; }
.ru-postlist p { margin: 0; color: var(--ru-muted); font-size: .95rem; }
.ru-pagination { display: flex; gap: .5rem; margin-top: 1.5rem; }

/* Pie */
.ru-footer { background: var(--ru-surface); border-top: 1px solid var(--ru-border); padding-block: 2rem; font-size: .92rem; }
.ru-footer__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
@media (min-width: 48em) { .ru-footer__cols { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ru-footer h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ru-muted); margin-bottom: .5rem; }
.ru-footer ul { list-style: none; padding: 0; margin: 0; }
.ru-footer li { margin-bottom: .3rem; }
.ru-footer a { color: var(--ru-text); text-decoration: none; display: inline-block; padding: .2rem 0; }
.ru-footer a:hover { text-decoration: underline; }
.ru-footer__legal { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--ru-border); color: var(--ru-muted); }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print { .ru-header, .ru-footer, .ru-ad, .ru-filters, .ru-nav { display: none !important; } }
