/**
 * Norte — blog, archivos y búsqueda.
 *
 * Solo se carga en esas páginas (y en el editor).
 *
 * 1. Cabecera partida (norte/archive-head): panel de papel con el título
 *    que monta sobre la foto de la entrada más reciente.
 * 2. Filtro (norte/archive-filter): barra fija de noche bajo la cabecera
 *    del sitio, con una fila de categorías y otra de etiquetas.
 * 3. Rejilla con ritmo: la primera entrada grande y, después, un ciclo de
 *    seis (dos medianas, tres pequeñas y una apaisada).
 * 4. Paginación grande.
 */

/* =========================================================================
 * 1. Cabecera partida
 * ====================================================================== */

.norte-ahead {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	min-height: min(72vh, 54vw);
	background: var(--n-night);
	color: var(--n-snow);
}

.norte-ahead__panel {
	position: relative;
	z-index: 1;
	grid-area: 1 / 1 / 2 / 8;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	min-height: calc(min(72vh, 54vw) - 4.5vw);
	padding: 5vw 4vw 4vw 9.5vw;
	background: var(--n-paper);
	color: var(--n-ink);
}

.norte-ahead:not(.has-image) .norte-ahead__panel {
	grid-column: 1 / 10;
}

/* El filete vertical de los paneles de Norte. */
.norte-ahead__panel::before {
	content: "";
	position: absolute;
	top: 3vw;
	bottom: 4vw;
	left: var(--n-rule-x);
	width: 1px;
	background: color-mix(in srgb, currentColor 45%, transparent);
}

.norte-ahead__panel > * {
	margin: 0;
}

.norte-ahead__label {
	font-family: var(--n-mono);
	font-size: var(--n-label);
	letter-spacing: 0.16em;
	text-transform: uppercase;
	opacity: 0.7;
}

.norte-ahead__title {
	max-width: 12ch;
	margin-top: 1.2vw !important;
	font-family: var(--n-display);
	font-size: clamp(2.6rem, 6vw, 7.6rem);
	font-weight: 300;
	line-height: 0.9;
	letter-spacing: -0.03em;
	text-wrap: balance;
}

.norte-ahead__plus {
	display: block;
	margin-top: 0.12em;
	font-size: 0.5em;
	font-style: italic;
	letter-spacing: -0.015em;
	opacity: 0.6;
}

.norte-ahead__lead {
	max-width: 34em;
	margin-top: 1.8vw !important;
	font-size: var(--n-small);
	font-weight: 350;
	line-height: 1.55;
}

.norte-ahead__lead p {
	margin: 0;
}

.norte-ahead__count {
	margin-top: 2.4vw !important;
	padding-top: 0;
}

.norte-ahead__media {
	position: relative;
	grid-area: 1 / 7 / 2 / -1;
	overflow: hidden;
	margin: 0;
}

.norte-ahead__media img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	animation: norte-ahead-settle 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.norte-ahead__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(0deg, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0) 34%);
	pointer-events: none;
}

.norte-ahead__caption {
	position: absolute;
	z-index: 1;
	right: var(--n-gutter);
	bottom: 1.6vw;
	left: calc(100% / 6 + 2vw);
	display: flex;
	gap: 1.2em;
	align-items: baseline;
	justify-content: flex-end;
	font-family: var(--n-mono);
	font-size: var(--n-label);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	text-align: right;
}

.norte-ahead__caption span {
	opacity: 0.65;
}

.norte-ahead__caption a {
	color: inherit;
	text-decoration: none;
	letter-spacing: 0.08em;
}

.norte-ahead__caption a:hover {
	text-decoration: underline;
	text-underline-offset: 4px;
}

@keyframes norte-ahead-settle {
	from {
		transform: scale(1.06);
		opacity: 0.4;
	}
	to {
		transform: none;
		opacity: 1;
	}
}

/* =========================================================================
 * 2. Filtro
 * ====================================================================== */

.norte-filter {
	position: sticky;
	z-index: 30;
	top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--n-header) - 19px);
	display: grid;
	gap: 0.55rem;
	padding: 1rem var(--n-gutter) 1rem 5.1vw;
	border-bottom: 1px solid var(--n-night-line);
	background: var(--n-night);
	color: var(--n-snow);
}

.norte-filter__row {
	position: relative;
	display: flex;
	gap: 1rem;
	align-items: center;
	min-width: 0;
}

.norte-filter__label {
	flex: none;
	width: 7.5rem;
	color: var(--n-ash);
	font-family: var(--n-mono);
	font-size: var(--n-label);
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.norte-filter__chips {
	display: flex;
	flex-wrap: nowrap;
	gap: 0.4rem;
	min-width: 0;
	margin: 0;
	padding: 0;
	overflow-x: auto;
	list-style: none;
	scrollbar-width: none;
	-webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 2.5rem), transparent);
	mask-image: linear-gradient(90deg, #000 calc(100% - 2.5rem), transparent);
}

.norte-filter__chips::-webkit-scrollbar {
	display: none;
}

.norte-filter__chips > li {
	flex: none;
	margin: 0;
}

.norte-chip {
	display: inline-flex;
	gap: 0.55em;
	align-items: baseline;
	padding: 0.5em 0.85em 0.45em;
	border: 1px solid var(--n-night-line);
	border-radius: 999px;
	color: var(--n-ash);
	font-family: var(--n-mono);
	font-size: var(--n-label);
	line-height: 1.2;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.norte-chip:hover,
.norte-chip:focus-visible {
	border-color: color-mix(in srgb, var(--n-snow) 55%, transparent);
	color: var(--n-snow);
}

.norte-chip.is-active {
	border-color: var(--n-snow);
	background: var(--n-snow);
	color: var(--n-night);
}

.norte-chip__n {
	font-size: 0.85em;
	opacity: 0.55;
}

/* «+ 8 etiquetas»: el resto, en un panel que se despliega bajo la barra. */
.norte-filter__more {
	flex: none;
}

.norte-filter__more > summary {
	list-style: none;
}

.norte-filter__more > summary::-webkit-details-marker {
	display: none;
}

.norte-filter__more[open] > summary {
	border-color: var(--n-snow);
	color: var(--n-snow);
}

.norte-filter__chips--all {
	position: absolute;
	z-index: 2;
	top: calc(100% + 0.9rem);
	right: 0;
	left: 8.5rem;
	flex-wrap: wrap;
	padding: 1rem;
	border: 1px solid var(--n-night-line);
	background: var(--n-night);
	-webkit-mask-image: none;
	mask-image: none;
	box-shadow: 0 1.2rem 2.4rem rgb(0 0 0 / 0.35);
}

.norte-filter__clear {
	justify-self: start;
	margin-left: 8.5rem;
	color: var(--n-ash);
	font-family: var(--n-mono);
	font-size: var(--n-label);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	text-decoration: underline;
	text-underline-offset: 4px;
}

.norte-filter__clear:hover {
	color: var(--n-snow);
}

/* Mientras se cargan los resultados (assets/js/archive.js). */
.norte-archive.is-loading :is(.norte-ahead, .norte-archive__query) {
	opacity: 0.35;
	transition: opacity 0.25s ease;
}

.norte-archive :is(.norte-ahead, .norte-archive__query) {
	transition: opacity 0.4s ease;
}

/* =========================================================================
 * 3. Rejilla con ritmo
 * ====================================================================== */

.norte-archive__query--rhythm {
	padding: 3vw var(--n-gutter) 5vw 5.1vw;
}

.norte-rhythm {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	gap: 2vw;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: norte-tile;
}

.norte-rhythm > li {
	display: flex;
	grid-column: span 4;
	min-width: 0;
	margin: 0;
	counter-increment: norte-tile;
}

/* Tarjeta: foto de fondo con velo y el texto encima. */
.norte-tile {
	position: relative;
	isolation: isolate;
	display: flex;
	flex: 1;
	flex-direction: column;
	justify-content: flex-end;
	aspect-ratio: 4 / 5;
	padding: 1.6vw;
	overflow: hidden;
	background: var(--n-coal);
	color: var(--n-snow);
}

.norte-tile::before {
	content: counter(norte-tile, decimal-leading-zero);
	position: absolute;
	top: 1.4vw;
	left: 1.6vw;
	font-family: var(--n-mono);
	font-size: var(--n-label);
	letter-spacing: 0.16em;
}

.norte-tile__media {
	position: absolute;
	inset: 0;
	z-index: -1;
	margin: 0;
	height: auto !important;
}

.norte-tile__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgb(0 0 0 / 0.74), rgb(0 0 0 / 0.1) 55%, rgb(0 0 0 / 0.18));
}

.norte-tile__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.norte-tile:hover .norte-tile__media img {
	transform: scale(1.04);
}

.norte-tile__text {
	display: flex;
	flex-direction: column;
	gap: 0.7vw;
}

.norte-tile__text > * {
	margin: 0 !important;
}

.norte-tile__terms,
.norte-tile__date {
	font-family: var(--n-mono);
	font-size: var(--n-label);
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.norte-tile__terms {
	position: relative;
	z-index: 2;
	opacity: 0.75;
}

.norte-tile__terms a {
	color: inherit;
	text-decoration: none;
}

.norte-tile__terms a:hover {
	text-decoration: underline;
}

.norte-tile__date {
	opacity: 0.6;
}

.norte-tile__title {
	max-width: 22ch;
	font-family: var(--n-headline);
	font-size: clamp(1.2rem, 1.6vw, 2rem);
	font-weight: 400;
	line-height: 1.08;
	text-wrap: balance;
}

.norte-tile__title a {
	color: inherit;
	text-decoration: none;
	background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
	transition: background-size 0.5s ease;
}

/* Toda la tarjeta es el enlace de la entrada. */
.norte-tile__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.norte-tile:hover .norte-tile__title a {
	background-size: 100% 1px;
}

.norte-tile__excerpt {
	display: none;
	max-width: 44ch;
	font-size: var(--n-small);
	font-weight: 350;
	line-height: 1.45;
	opacity: 0.85;
}

.norte-tile__excerpt .wp-block-post-excerpt__excerpt {
	margin: 0;
}

.norte-tile__excerpt .wp-block-post-excerpt__more-text {
	display: none;
}

/* La primera: a todo el ancho, con el título en Freight Big. */
.norte-rhythm > li:first-child {
	grid-column: 1 / -1;
}

.norte-rhythm > li:first-child .norte-tile {
	aspect-ratio: 21 / 9;
	padding: 3vw;
}

.norte-rhythm > li:first-child .norte-tile::before {
	top: 2.6vw;
	left: 3vw;
}

.norte-rhythm > li:first-child .norte-tile__text {
	gap: 1.1vw;
}

.norte-rhythm > li:first-child .norte-tile__title {
	max-width: 16ch;
	font-family: var(--n-display);
	font-size: clamp(2.2rem, 4.6vw, 6rem);
	font-weight: 300;
	line-height: 0.92;
	letter-spacing: -0.03em;
}

.norte-rhythm > li:first-child .norte-tile__excerpt {
	display: block;
}

/* Dos medianas. */
.norte-rhythm > li:is(:nth-child(6n + 2), :nth-child(6n + 3)) {
	grid-column: span 6;
}

.norte-rhythm > li:is(:nth-child(6n + 2), :nth-child(6n + 3)) .norte-tile {
	aspect-ratio: 4 / 3;
}

.norte-rhythm > li:is(:nth-child(6n + 2), :nth-child(6n + 3)) .norte-tile__title {
	font-size: clamp(1.4rem, 2.2vw, 2.8rem);
}

/* La apaisada: foto a la izquierda y el texto al lado, sobre la noche. */
.norte-rhythm > li:nth-child(6n + 7) {
	grid-column: 1 / -1;
}

.norte-rhythm > li:nth-child(6n + 7) .norte-tile {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: 2vw;
	align-items: center;
	aspect-ratio: auto;
	padding: 0;
	background: none;
}

.norte-rhythm > li:nth-child(6n + 7) .norte-tile__media {
	position: relative;
	grid-area: 1 / 1 / 2 / 8;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	z-index: 0;
}

.norte-rhythm > li:nth-child(6n + 7) .norte-tile__media::after {
	content: none;
}

.norte-rhythm > li:nth-child(6n + 7) .norte-tile::before {
	top: 1.4vw;
	left: 1.6vw;
	z-index: 1;
}

.norte-rhythm > li:nth-child(6n + 7) .norte-tile__text {
	grid-area: 1 / 8 / 2 / -1;
	gap: 1vw;
	padding: 2vw 0;
}

.norte-rhythm > li:nth-child(6n + 7) .norte-tile__title {
	font-family: var(--n-display);
	font-size: clamp(1.8rem, 3.2vw, 4rem);
	font-weight: 300;
	line-height: 0.95;
	letter-spacing: -0.025em;
}

.norte-rhythm > li:nth-child(6n + 7) .norte-tile__excerpt {
	display: block;
}

.norte-archive .norte-empty {
	padding: 4vw 0;
}

/* =========================================================================
 * 4. Paginación grande
 * ====================================================================== */

.norte-pagination--big {
	align-items: baseline;
	margin-top: 4vw !important;
	padding-top: 2vw;
}

.norte-pagination--big :is(.wp-block-query-pagination-previous, .wp-block-query-pagination-next) {
	display: inline-flex;
	gap: 0.4em;
	align-items: baseline;
	font-family: var(--n-display);
	font-size: clamp(1.6rem, 3vw, 3.6rem);
	font-weight: 300;
	line-height: 1;
	letter-spacing: -0.02em;
	text-transform: none;
	transition: opacity 0.2s ease;
}

.norte-pagination--big :is(.wp-block-query-pagination-previous, .wp-block-query-pagination-next):hover {
	font-style: italic;
}

.norte-pagination--big .wp-block-query-pagination-next {
	margin-left: auto;
}

.norte-pagination--big .wp-block-query-pagination-numbers {
	display: flex;
	gap: 0.3em;
}

.norte-pagination--big .page-numbers {
	padding: 0.4em 0.6em;
	color: var(--n-ash);
}

.norte-pagination--big a.page-numbers:hover {
	color: var(--n-snow);
}

.norte-pagination--big .page-numbers.current {
	border-bottom: 1px solid var(--n-snow);
	color: var(--n-snow);
}

/* =========================================================================
 * Pantallas medianas y móviles
 * ====================================================================== */

@media (max-width: 959px) {

	.norte-ahead {
		display: flex;
		flex-direction: column;
		min-height: 0;
	}

	.norte-ahead__media {
		order: -1;
		aspect-ratio: 4 / 3;
	}

	.norte-ahead__caption {
		bottom: auto;
		top: calc(var(--n-header) + 0.75rem);
		left: var(--n-gutter);
		justify-content: flex-start;
		text-align: left;
	}

	.norte-ahead.has-image .norte-ahead__panel {
		margin: -14vw var(--n-gutter) 0 0;
	}

	.norte-ahead__panel {
		min-height: 0;
		padding: 2.5rem var(--n-gutter) 2.5rem calc(var(--n-gutter) + 1.25rem);
	}

	.norte-ahead__panel::before {
		top: 1.5rem;
		bottom: 2.5rem;
		left: var(--n-gutter);
	}

	.norte-ahead__title {
		margin-top: 0.8rem !important;
		font-size: clamp(2.4rem, 11vw, 4.4rem);
	}

	.norte-ahead__lead,
	.norte-ahead__count {
		margin-top: 1.4rem !important;
	}

	.norte-filter {
		position: relative;
		top: auto;
		padding: 1rem var(--n-gutter);
	}

	.norte-filter__row {
		flex-direction: column;
		align-items: stretch;
		gap: 0.5rem;
	}

	.norte-filter__label {
		width: auto;
	}

	.norte-filter__chips {
		margin-right: calc(-1 * var(--n-gutter));
		padding-right: var(--n-gutter);
	}

	.norte-filter__more {
		align-self: flex-start;
	}

	.norte-filter__chips--all {
		position: static;
		margin: 0.6rem 0 0;
		padding: 0.75rem 0 0;
		border: 0;
		border-top: 1px solid var(--n-night-line);
		box-shadow: none;
	}

	.norte-filter__clear {
		margin-left: 0;
	}

	.norte-archive__query--rhythm {
		padding: 1.75rem var(--n-gutter) 3rem;
	}

	.norte-rhythm {
		gap: 1rem;
	}

	.norte-rhythm > li,
	.norte-rhythm > li:nth-child(n) {
		grid-column: 1 / -1;
	}

	.norte-tile,
	.norte-rhythm > li:nth-child(n) .norte-tile {
		aspect-ratio: 4 / 3;
		padding: 1.1rem;
	}

	.norte-tile::before,
	.norte-rhythm > li:nth-child(n) .norte-tile::before {
		top: 1rem;
		left: 1.1rem;
	}

	.norte-tile__text {
		gap: 0.5rem;
	}

	.norte-tile__title,
	.norte-rhythm > li:nth-child(n) .norte-tile__title {
		font-size: clamp(1.35rem, 6vw, 2rem);
	}

	.norte-rhythm > li:first-child .norte-tile {
		aspect-ratio: 4 / 5;
	}

	.norte-rhythm > li:first-child .norte-tile__title {
		font-size: clamp(2.2rem, 10vw, 3.6rem) !important;
	}

	.norte-rhythm > li:nth-child(6n + 7) .norte-tile {
		display: flex;
		aspect-ratio: auto;
		padding: 0;
	}

	.norte-rhythm > li:nth-child(6n + 7) .norte-tile__text {
		padding: 1rem 0 0.5rem;
	}

	.norte-pagination--big {
		flex-wrap: wrap;
		gap: 1rem;
	}

	.norte-pagination--big .wp-block-query-pagination-numbers {
		order: 3;
		width: 100%;
		justify-content: center;
	}
}

/* Editor: el editor da position: relative a todos los bloques. */
.editor-styles-wrapper .norte-tile__media {
	position: absolute !important;
}

.editor-styles-wrapper .norte-rhythm > li:nth-child(6n + 7) .norte-tile__media {
	position: relative !important;
}

.editor-styles-wrapper .norte-filter {
	position: relative;
	top: auto;
}
