/*
Theme Name: TC Portal
Theme URI: https://www.tc.gob.pe
Author: Equipo de desarrollo – Portal Web TC
Description: Tema de bloques basado en el boceto 4 aprobado del nuevo Portal Web Institucional del Tribunal Constitucional del Perú. Colores y tipografías definidos en theme.json (editables desde Apariencia > Editor > Estilos).
Version: 0.8.3
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: tc-portal
*/

/* ---------- Base ---------- */
:root {
	--tc-radius: 2px;
	--tc-transition: 160ms ease;
}

body {
	-webkit-font-smoothing: antialiased;
}

:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--acento);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* ---------- Etiqueta de sección (línea roja + texto) ---------- */
.tc-kicker {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 0.25rem !important;
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--wp--preset--color--acento);
}
.tc-kicker::before {
	content: "";
	display: inline-block;
	width: 1.75rem;
	height: 2px;
	background: currentColor;
}

/* ---------- Migas de pan ---------- */
.tc-breadcrumb a {
	color: var(--wp--preset--color--texto-suave);
}
.tc-breadcrumb strong {
	color: var(--wp--preset--color--acento);
}

/* ---------- Menú lateral ---------- */
.tc-sidebar {
	position: sticky;
	top: 1.5rem;
}
.tc-sidebar__titulo {
	margin: 0 !important;
}
.tc-sidebar ul {
	list-style: none;
	margin: 0;
	padding: 0.5rem 0;
}
.tc-sidebar li {
	margin: 0;
}
.tc-sidebar li a {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.55rem 1rem;
	font-size: var(--wp--preset--font-size--sm);
	color: var(--wp--preset--color--texto);
	text-decoration: none;
	border-left: 3px solid transparent;
}
.tc-sidebar li a::after {
	content: "›";
	color: var(--wp--preset--color--texto-suave);
}
.tc-sidebar li a:hover,
.tc-sidebar li a[aria-current="page"],
.tc-sidebar li.current-menu-item a {
	background: var(--wp--preset--color--acento-suave);
	border-left-color: var(--wp--preset--color--acento);
	color: var(--wp--preset--color--acento);
	font-weight: 700;
}

/* ---------- Imagen con leyenda superpuesta ---------- */
.tc-foto-sede {
	position: relative;
}
.tc-foto-sede figcaption {
	position: absolute;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 0.85rem 1.1rem;
	background: var(--wp--preset--color--oscuro);
	color: var(--wp--preset--color--blanco);
	font-size: var(--wp--preset--font-size--xs);
	text-align: left;
}

/* ---------- Cifras ---------- */
.tc-cifras > .wp-block-column {
	border-right: 1px solid var(--wp--preset--color--borde);
}
.tc-cifras > .wp-block-column:last-child {
	border-right: 0;
}
.tc-cifra__numero {
	font-family: var(--wp--preset--font-family--serif);
	position: relative;
	padding-bottom: 0.25rem;
}
.tc-cifra__numero::after {
	content: "";
	display: block;
	width: 1.5rem;
	height: 2px;
	margin-top: 0.2rem;
	background: var(--wp--preset--color--acento);
}
@media (max-width: 781px) {
	.tc-cifras > .wp-block-column {
		border-right: 0;
		border-bottom: 1px solid var(--wp--preset--color--borde);
	}
}

/* ---------- Cita destacada ---------- */
.tc-cita {
	border-left: 4px solid var(--wp--preset--color--acento);
}
.tc-cita p {
	font-family: var(--wp--preset--font-family--serif);
}

/* ---------- Pleno ---------- */
.tc-magistrado {
	height: 100%;
	text-align: center;
	overflow: hidden;
}
.tc-magistrado img {
	aspect-ratio: 4 / 5;
	object-fit: cover;
	width: 100%;
}
.tc-magistrado--presidente {
	transform: translateY(-0.75rem);
}

/* ---------- Atribuciones ---------- */
.tc-atribucion {
	border-top: 1px solid var(--wp--preset--color--borde);
}
.tc-atribucion:last-child {
	border-bottom: 1px solid var(--wp--preset--color--borde);
}
.tc-atribucion__numero {
	font-family: var(--wp--preset--font-family--serif);
	min-width: 3.5rem;
}
.tc-atribucion__icono {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	background: var(--wp--preset--color--acento-suave);
	flex-shrink: 0;
}
.tc-atribucion__icono img {
	width: 18px;
	height: 18px;
}

/* ---------- Procesos ---------- */
.tc-proceso {
	height: 100%;
	border-top: 3px solid var(--wp--preset--color--acento);
}
.tc-proceso--control {
	border-top-color: var(--wp--preset--color--oscuro);
}
.tc-proceso--competencial {
	border-top-color: var(--wp--preset--color--dorado);
}
.tc-etiquetas {
	gap: 0.35rem !important;
}
.tc-etiqueta {
	display: inline-block;
	margin: 0 !important;
	padding: 0.15rem 0.45rem;
	border: 1px solid currentColor;
	font-size: 0.6875rem;
	font-weight: 700;
	line-height: 1.4;
}
.tc-clase {
	height: 100%;
}
.tc-clase--derechos { border-top: 3px solid var(--wp--preset--color--acento); }
.tc-clase--control { border-top: 3px solid var(--wp--preset--color--oscuro); }
.tc-clase--competencial { border-top: 3px solid var(--wp--preset--color--dorado); }

/* ---------- Tarjetas de noticias ---------- */
.tc-noticia {
	height: 100%;
}
.tc-noticia .wp-block-post-title a {
	text-decoration: none;
	color: var(--wp--preset--color--oscuro-profundo);
}
.tc-noticia .wp-block-post-title a:hover {
	color: var(--wp--preset--color--acento);
}

/* =========================================================
   Integración del boceto 4 con WordPress
   ========================================================= */

/* Sin separación automática entre cabecera, contenido y pie */
.wp-site-blocks > * + * {
	margin-block-start: 0;
}

/* Título del banner cuando no es <h1> (páginas internas) */
.hero4 [data-tc-h1] {
	font-size: clamp(2.6rem, 5.6vw, 6rem);
	line-height: .98;
	font-weight: 800;
	letter-spacing: -.035em;
	margin: 0;
}

/* Páginas internas */
.tc-page {
	padding-top: clamp(1.5rem, 3vw, 2.5rem);
}
.tc-page h1,
.tc-page .wp-block-post-title {
	font-size: clamp(1.9rem, 3.2vw, 2.75rem);
	line-height: 1.1;
	letter-spacing: -.02em;
}
.tc-page .wp-block-post-content ul,
.tc-page .wp-block-post-content ol {
	padding-left: 1.5em;
	margin: 0 0 1em;
}
.tc-page .wp-block-post-content ul { list-style: disc; }
.tc-page .wp-block-post-content ol { list-style: decimal; }
.tc-page .wp-block-post-content li { margin-bottom: .35em; }
.tc-page .tc-sidebar ul { list-style: none; padding: .5rem 0; }

/* Buscador de WordPress con el estilo del boceto */
.tc-page .wp-block-search__input {
	border: 2px solid var(--line);
	border-radius: 10px;
	min-height: 50px;
	padding-inline: 1rem;
}
.tc-page .wp-block-search__button {
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
	font-weight: 800;
}

/* La maquetación de flujo de WordPress anula los márgenes del boceto en la portada:
   se restauran los valores originales. */
body .tc-home.is-layout-flow > .bn4 { margin-block-start: 3rem; }
body .tc-home.is-layout-flow > .wrap:not(.bn4):not(.blk4) { margin-block-start: 0; }
body .tc-home.is-layout-flow > .blk4 { margin-block-start: clamp(3rem, 5vw, 5rem); }

/* Título del banner: blanco como en el boceto (los estilos globales de títulos no deben aplicarse aquí) */
.hero4 h1,
.hero4 [data-tc-h1] {
	color: inherit;
}

/* Accesos rápidos: cada tarjeta ocupa todo el alto del recuadro blanco (hover completo) */
.tiles4 ul {
	align-items: stretch;
}
.tiles4 li {
	display: flex;
}
.tiles4 li > .tl4 {
	flex: 1;
}
.tiles4 .tl4.on,
.tiles4 .tl4:hover,
.tiles4 .tl4:focus-visible {
	transform: none;
	min-height: 270px;
}

/* Banner: solo las 3 fotos (sin la escena roja de la balanza). Ciclo de 18 s, 6 s por foto. */
.hero4 .sc { animation-name: tc-sc3; animation-duration: 18s; }
.hero4 .sc img { animation-name: tc-kb3; animation-duration: 18s; }
.hero4 .sc.s4 { display: none; }
@keyframes tc-sc3 { 0% { opacity: 0; } 4% { opacity: 1; } 33% { opacity: 1; } 38% { opacity: 0; } 100% { opacity: 0; } }
@keyframes tc-kb3 { 0% { transform: scale(1.04) translate(0, 0); } 38% { transform: scale(1.24) translate(-2.5%, -1.5%); } 100% { transform: scale(1.24) translate(-2.5%, -1.5%); } }

/* Tribunal Constitucional TV: distintivo según estado */
.b-tv .tc-ev-next b,
.b-tv .tc-ev-last b { letter-spacing: .02em; }
.b-tv .tc-ev-live b::before { content: "● "; color: #e0162b; }
.b-tv a.btn.red4 { text-decoration: none; }

/* Ventana TC TV: reproductor 16:9 */
#m-video .tc-tv-player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 4px; overflow: hidden; margin-bottom: 1rem; }
#m-video .tc-tv-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.b-tv button.btn.red4 { cursor: pointer; }

/* Videoteca (Histórico de filmaciones) */
.tc-vt-f { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1rem; margin: 0 0 1.5rem; }
.tc-vt-f label { display: grid; gap: .25rem; font-weight: 700; font-size: .875rem; }
.tc-vt-f select { min-height: 44px; padding: 0 .75rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.tc-vt-n { margin-left: auto; color: var(--muted); font-size: .9rem; }
.tc-page .wp-block-post-content ul.tc-vt-g { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.tc-vt-i { margin: 0 !important; }
.tc-vt-b { display: grid; gap: .45rem; width: 100%; padding: 0 0 1rem; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s; }
.tc-vt-b:hover, .tc-vt-b:focus-visible { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.12); }
.tc-vt-th { position: relative; display: block; aspect-ratio: 16 / 9; background: #111; }
.tc-vt-th img { width: 100%; height: 100%; object-fit: cover; }
.tc-vt-play { position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 1.3rem; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.tc-vt-d { padding: 0 1rem; font-size: .8rem; font-weight: 700; color: var(--accent-text); text-transform: uppercase; letter-spacing: .03em; }
.tc-vt-t { padding: 0 1rem; font-weight: 700; line-height: 1.3; }
.tc-vt-p { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 2rem; }
#tc-vt-dlg .tc-tv-player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 4px; overflow: hidden; margin-bottom: 1rem; }
#tc-vt-dlg .tc-tv-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Audiencias (base externa) ---------- */
.tc-aud-msg { padding: 1rem 1.25rem; border-left: 4px solid var(--accent); background: #faf6f5; border-radius: 6px; }
.tc-aud-tw { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--line); border-radius: 12px; }
.tc-aud-tw:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tc-aud-t { width: 100%; border-collapse: collapse; font-size: .92rem; background: #fff; }
.tc-aud-t th { position: sticky; top: 0; background: var(--dark, #1A2230); color: #fff; text-align: left; font-weight: 700; padding: .75rem .9rem; white-space: nowrap; }
.tc-aud-t td { padding: .7rem .9rem; border-top: 1px solid var(--line); vertical-align: top; }
.tc-aud-t tbody tr:nth-child(even) td { background: #fafafa; }
.tc-aud-t tbody tr:hover td { background: #fbeeed; }
.tc-aud-t td:first-child { white-space: nowrap; }
.tc-aud-lugar { min-width: 16rem; font-size: .85rem; color: var(--muted); }
.tc-aud-t .btn.sm { white-space: nowrap; }
.tc-aud-exp td:nth-child(3), .tc-aud-exp td:nth-child(4) { min-width: 14rem; }
.tc-aud-t tr.is-anulada td { color: var(--muted); }
.tc-aud-t tr.is-anulada strong { text-decoration: line-through; }
.tc-aud-anul { display: block; margin-top: .25rem; font-size: .8rem; color: var(--accent-text, #A31915); font-weight: 600; }
.tc-aud-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin: 1rem 0 1.25rem; }
.tc-aud-dl > div { padding: .8rem 1rem; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 10px; }
.tc-aud-dl dt { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tc-aud-dl dd { margin: .2rem 0 0; font-weight: 700; }
.tc-aud-nota { font-size: .9rem; color: var(--muted); }
.tc-aud-v { margin: 0 0 2.5rem; }
.tc-aud-yt { position: relative; aspect-ratio: 16 / 9; max-width: 900px; background: #000; border-radius: 12px; overflow: hidden; }
.tc-aud-yt iframe, .tc-aud-play { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; background: #000; }
.tc-aud-play img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }
@media (max-width: 720px) {
  .tc-aud-t thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tc-aud-t, .tc-aud-t tbody, .tc-aud-t tr, .tc-aud-t td { display: block; width: 100%; }
  .tc-aud-t tr { border-top: 1px solid var(--line); padding: .5rem 0; }
  .tc-aud-t td { border: 0; padding: .3rem .9rem; }
  .tc-aud-t td[data-th]::before { content: attr(data-th); display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
  .tc-aud-lugar { min-width: 0; }
}

/* Agenda: tarjeta del día con el color de la leyenda (como el portal actual) */
.c4 .cal-ev { border-left: 6px solid var(--c, var(--accent)); }
.c4 .cal-ev-go { display: inline-flex; margin-top: .6rem; font-weight: 800; color: var(--accent-text, #A31915); text-decoration: none; }
.c4 .cal-ev-go:hover, .c4 .cal-ev-go:focus-visible { text-decoration: underline; }
/* Menú lateral de Audiencias */
.tc-aud-menu { list-style: none; margin: 0; padding: 0; }
.tc-aud-menu li { margin: 0; border-bottom: 1px solid var(--line); }
.tc-aud-menu a { display: block; padding: .85rem 1rem; font-weight: 700; color: var(--fg); text-decoration: none; border-left: 4px solid transparent; }
.tc-aud-menu a:hover, .tc-aud-menu a:focus-visible { background: #faf6f5; border-left-color: var(--accent); }
.tc-aud-menu a[aria-current="page"] { background: var(--accent); color: #fff; border-left-color: var(--primary, #7D1210); }
.tc-aud-desc { padding: 1rem 1.25rem; background: #f3f4f6; border-radius: 10px; color: var(--fg); line-height: 1.6; }
.tc-aud-det h2 { display: flex; align-items: center; gap: .75rem; }
.tc-aud-back { display: inline-grid; place-items: center; width: 44px; height: 40px; border-radius: 6px; background: var(--accent); color: #fff !important; text-decoration: none; font-size: 1.2rem; }
