/* ==========================================================================
   El Maletero — Base
   Tokens, reset, tipografia editorial y utilidades.
   ========================================================================== */

:root {
	/* Paleta (el PHP la sobrescribe desde el Customizer) */
	--em-primary: #00353F;
	--em-primary-rgb: 0, 53, 63;
	--em-secondary: #073C5D;
	--em-secondary-rgb: 7, 60, 93;
	--em-sand: #E9D9B8;
	--em-sand-rgb: 233, 217, 184;
	--em-ink: #202020;
	--em-ink-rgb: 32, 32, 32;
	--em-canvas: #FCFBF9;
	--em-canvas-rgb: 252, 251, 249;

	/* Derivados */
	--em-line: rgba(var(--em-ink-rgb), 0.12);
	--em-line-soft: rgba(var(--em-ink-rgb), 0.07);
	--em-muted: rgba(var(--em-ink-rgb), 0.56);
	--em-veil: rgba(var(--em-canvas-rgb), 0.82);
	--em-shadow: 0 24px 70px -30px rgba(var(--em-primary-rgb), 0.28);
	--em-shadow-lift: 0 40px 90px -40px rgba(var(--em-primary-rgb), 0.4);

	/* Tipografia */
	--em-font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
	--em-font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
	--em-font-ui: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
	--em-font-label: 'Source Code Pro', ui-monospace, SFMono-Regular, Menlo, monospace;

	/* Escala fluida */
	--em-fs-micro: 0.6875rem;
	--em-fs-xs: 0.8125rem;
	--em-fs-sm: 0.9375rem;
	--em-fs-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);
	--em-fs-lead: clamp(1.0625rem, 1rem + 0.5vw, 1.375rem);
	--em-fs-h4: clamp(1.25rem, 1.1rem + 0.7vw, 1.75rem);
	--em-fs-h3: clamp(1.5rem, 1.2rem + 1.4vw, 2.5rem);
	--em-fs-h2: clamp(2rem, 1.4rem + 2.6vw, 3.75rem);
	--em-fs-h1: clamp(2.5rem, 1.6rem + 4.2vw, 5.75rem);
	--em-fs-mega: clamp(3rem, 1rem + 9vw, 10rem);

	/* Ritmo */
	--em-container: 1440px;
	--em-gutter: clamp(1.125rem, 4vw, 3.5rem);
	--em-space-xs: 0.5rem;
	--em-space-sm: 1rem;
	--em-space-md: clamp(1.5rem, 3vw, 2.5rem);
	--em-space-lg: clamp(2.5rem, 6vw, 5rem);
	--em-space-xl: clamp(4rem, 10vw, 9rem);

	/* Forma y movimiento */
	--em-radius: 0px;
	--em-card-ratio: 4 / 5;
	--em-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--em-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
	--em-dur: 0.42s;
	--em-dur-slow: 0.9s;

	/* Capas */
	--em-z-header: 500;
	--em-z-dock: 620;
	--em-z-scrim: 700;
	--em-z-layer: 800;
	--em-z-toast: 900;
	--em-z-cursor: 999;

	/* Alturas */
	--em-header-h: 76px;
	--em-dock-h: 64px;
	--em-safe-b: env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
	scroll-padding-top: calc(var(--em-header-h) + 24px);
}

body {
	margin: 0;
	background: var(--em-canvas);
	color: var(--em-ink);
	font-family: var(--em-font-body);
	font-size: var(--em-fs-base);
	font-weight: 300;
	line-height: 1.7;
	letter-spacing: 0.005em;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	overflow-x: hidden;
}

body.em-locked {
	overflow: hidden;
	touch-action: none;
}

img,
picture,
video,
svg,
canvas {
	display: block;
	max-width: 100%;
	height: auto;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

button {
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

a {
	color: inherit;
	text-decoration: none;
	transition: color var(--em-dur) var(--em-ease), opacity var(--em-dur) var(--em-ease);
	-webkit-tap-highlight-color: transparent;
}

ul, ol { margin: 0; padding: 0; list-style: none; }

figure, blockquote, dl, dd { margin: 0; }

hr {
	border: 0;
	border-top: 1px solid var(--em-line);
	margin: var(--em-space-lg) 0;
}

::selection {
	background: var(--em-primary);
	color: var(--em-canvas);
}

:focus-visible {
	outline: 2px solid var(--em-primary);
	outline-offset: 3px;
	border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Tipografia
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
	margin: 0;
	font-family: var(--em-font-display);
	font-weight: 400;
	line-height: 1.04;
	letter-spacing: -0.015em;
	text-wrap: balance;
}

h1 { font-size: var(--em-fs-h1); }
h2 { font-size: var(--em-fs-h2); }
h3 { font-size: var(--em-fs-h3); }
h4 { font-size: var(--em-fs-h4); }
h5, h6 { font-size: var(--em-fs-lead); }

p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }

.em-display {
	font-family: var(--em-font-display);
	font-weight: 300;
	line-height: 1.02;
	letter-spacing: -0.02em;
}

.em-mega {
	font-family: var(--em-font-display);
	font-size: var(--em-fs-mega);
	font-weight: 300;
	line-height: 0.92;
	letter-spacing: -0.035em;
}

/* La firma tipografica del tema: micro-etiqueta en versal fina */
.em-label {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	font-family: var(--em-font-label);
	font-size: var(--em-fs-micro);
	font-weight: 500;
	letter-spacing: 0.2em;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--em-muted);
}

.em-dot { opacity: 0.45; margin: 0 0.15em; }

em, i { font-style: italic; }
strong, b { font-weight: 500; }

small { font-size: var(--em-fs-xs); }

code, pre, kbd {
	font-family: var(--em-font-label);
	font-size: 0.9em;
}

blockquote {
	margin: var(--em-space-md) 0;
	padding-left: clamp(1rem, 3vw, 2.25rem);
	border-left: 1px solid var(--em-primary);
	font-family: var(--em-font-display);
	font-size: var(--em-fs-h4);
	font-weight: 300;
	font-style: italic;
	line-height: 1.32;
}

/* Subrayado que crece desde la izquierda */
.em-link-underline {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.55em;
}

.em-link-underline::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: -2px;
	width: 100%;
	height: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: right center;
	transition: transform 0.5s var(--em-ease);
}

.em-link-underline:hover::after,
.em-link-underline:focus-visible::after {
	transform: scaleX(1);
	transform-origin: left center;
}

/* --------------------------------------------------------------------------
   Estructura
   -------------------------------------------------------------------------- */

.em-shell {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100svh;
}

.em-main {
	flex: 1 0 auto;
	padding-block: var(--em-space-lg) var(--em-space-xl);
}

.em-container {
	width: 100%;
	max-width: var(--em-container);
	margin-inline: auto;
	padding-inline: var(--em-gutter);
}

.em-container--narrow { max-width: 820px; }
.em-container--wide { max-width: 1760px; }

.em-grid {
	display: grid;
	gap: clamp(1.5rem, 3vw, 3rem) clamp(1rem, 2vw, 2rem);
}

.em-grid--posts { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }

.em-skip {
	position: absolute;
	left: 50%;
	top: -100px;
	transform: translateX(-50%);
	z-index: 1000;
	padding: 0.9rem 1.6rem;
	background: var(--em-primary);
	color: var(--em-canvas);
	font-family: var(--em-font-label);
	font-size: var(--em-fs-micro);
	letter-spacing: 0.2em;
	text-transform: uppercase;
	transition: top 0.3s var(--em-ease);
}

.em-skip:focus { top: 12px; }

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --------------------------------------------------------------------------
   Revelado al hacer scroll
   -------------------------------------------------------------------------- */

[data-reveal] {
	opacity: 0;
	transform: translate3d(0, 26px, 0);
	transition:
		opacity var(--em-dur-slow) var(--em-ease-out),
		transform var(--em-dur-slow) var(--em-ease-out);
	transition-delay: var(--em-reveal-delay, 0ms);
	will-change: opacity, transform;
}

[data-reveal].is-in {
	opacity: 1;
	transform: none;
}

.em-no-motion [data-reveal],
html.no-js [data-reveal] {
	opacity: 1;
	transform: none;
	transition: none;
}

/* Cortina sobre imagenes: la imagen se descubre al entrar en pantalla */
.em-veil-reveal {
	position: relative;
	overflow: hidden;
}

.em-veil-reveal::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--em-canvas);
	transform-origin: bottom;
	transition: transform 1.1s var(--em-ease-out);
	z-index: 2;
}

.em-veil-reveal.is-in::after { transform: scaleY(0); }

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}

	[data-reveal] { opacity: 1; transform: none; }
	.em-veil-reveal::after { display: none; }
}

/* --------------------------------------------------------------------------
   Contenido enriquecido (entradas, paginas, descripciones)
   -------------------------------------------------------------------------- */

.em-prose {
	font-size: var(--em-fs-lead);
	line-height: 1.78;
}

.em-prose > * + * { margin-top: 1.4em; }

.em-prose h2 { margin-top: 1.8em; font-size: var(--em-fs-h3); }
.em-prose h3 { margin-top: 1.6em; font-size: var(--em-fs-h4); }

.em-prose a {
	background-image: linear-gradient(currentColor, currentColor);
	background-size: 100% 1px;
	background-position: 0 100%;
	background-repeat: no-repeat;
	transition: background-size 0.4s var(--em-ease);
}

.em-prose a:hover { background-size: 0 1px; }

.em-prose ul,
.em-prose ol { padding-left: 1.3em; }
.em-prose ul { list-style: none; }
.em-prose ul li { position: relative; }
.em-prose ul li::before {
	content: "";
	position: absolute;
	left: -1.1em;
	top: 0.82em;
	width: 14px;
	height: 1px;
	background: var(--em-primary);
}
.em-prose ol { list-style: decimal; }
.em-prose li + li { margin-top: 0.4em; }

.em-prose img,
.em-prose figure { border-radius: var(--em-radius); }

.em-prose figcaption {
	margin-top: 0.75rem;
	font-family: var(--em-font-label);
	font-size: var(--em-fs-micro);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--em-muted);
}

/* --------------------------------------------------------------------------
   Utilidades
   -------------------------------------------------------------------------- */

.em-hide { display: none !important; }
.em-mt-0 { margin-top: 0 !important; }
.em-center { text-align: center; }
.em-muted { color: var(--em-muted); }

.alignwide { width: min(100%, 1200px); margin-inline: auto; }
.alignfull { width: 100vw; margin-left: calc(50% - 50vw); }
.alignleft { float: left; margin: 0 1.5rem 1rem 0; }
.alignright { float: right; margin: 0 0 1rem 1.5rem; }
.aligncenter { margin-inline: auto; }

/* Barra de desplazamiento discreta */
@supports (scrollbar-width: thin) {
	* {
		scrollbar-width: thin;
		scrollbar-color: rgba(var(--em-ink-rgb), 0.25) transparent;
	}
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
	background: rgba(var(--em-ink-rgb), 0.2);
	border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(var(--em-ink-rgb), 0.35); }
