﻿/* ==========================================================================
   Edicions del Bullent · estilos base de la web pública
   Compartido por todas las plantillas (portada, general, libro, colección).
   Sin frameworks: tokens CSS + layout con grid/flex.
   Los colores principal/secundario se sobrescriben en <head> con los valores
   del panel (tbl_valores 133 y 134), ver views/plantillas/bullent/head.ejs
   ========================================================================== */

:root {
	--c-primary: #00818e;
	--c-primary-dark: #00717c;
	--c-primary-soft: #e3f3f4;
	--c-accent: #f2a900;
	--c-ink: #1b2a2d;
	--c-ink-soft: #4a5b5e;
	--c-line: #dfe6e7;
	--c-bg: #faf8f4;
	--c-surface: #ffffff;
	--c-footer: #12282c;

	--font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

	--radius: 14px;
	--radius-sm: 8px;
	--shadow-sm: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .05);
	--shadow-md: 0 6px 24px rgb(18 40 44 / .14);
	--wrap: 1200px;
	--gutter: clamp(1rem, 3vw, 2rem);
	--header-h: 72px;
}

/* ---------- reset mínimo ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1rem); }
body {
	margin: 0;
	font-family: var(--font-body);
	font-size: 1rem;
	line-height: 1.6;
	color: var(--c-ink);
	background: var(--c-bg);
	-webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); line-height: 1.2; font-weight: 700; text-wrap: balance; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--c-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 2px; border-radius: 4px; }
button { font: inherit; cursor: pointer; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only {
	position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
	position: absolute; left: 1rem; top: -4rem; z-index: 200;
	background: var(--c-ink); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; }

/* ---------- botones ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
	padding: .7rem 1.25rem; border-radius: 999px; border: 2px solid transparent;
	font-weight: 600; font-size: .95rem; line-height: 1.2; text-decoration: none;
	transition: background-color .15s, color .15s, border-color .15s, transform .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-dark); color: #fff; }
.btn--accent { background: var(--c-accent); color: #2b1d00; }
.btn--accent:hover { background: #ffbc1f; }
.btn--ghost { border-color: currentColor; color: inherit; background: transparent; }
.btn--ghost:hover { background: rgb(255 255 255 / .14); }

/* ---------- cabecera ---------- */
.topbar { background: var(--c-footer); color: #cfe0e2; font-size: .85rem; }
.topbar .wrap { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 38px; }
.topbar ul { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.topbar a { color: inherit; }
.topbar a:hover, .topbar a[aria-current] { color: #fff; }
.topbar .btn--sm { padding: .2rem .8rem; font-size: .8rem; margin-right: auto; color: #2b1d00; }
.topbar .btn--sm:hover { color: #2b1d00; }
.topbar__abisal { font-weight: 600; white-space: nowrap; }

.site-header {
	position: sticky; top: 0; z-index: 100;
	background: rgb(255 255 255 / .94); backdrop-filter: saturate(1.4) blur(10px);
	border-bottom: 1px solid var(--c-line);
}
.site-header .wrap { display: flex; align-items: center; gap: 1.5rem; min-height: var(--header-h); }

.brand { display: flex; align-items: center; margin-right: auto; padding-block: .35rem; }
.brand:hover { text-decoration: none; }
.brand img { height: 58px; width: auto; }

.nav__list { display: flex; align-items: center; gap: .25rem; }
.nav__item { position: relative; display: flex; align-items: center; }
.nav__link {
	display: block; padding: .55rem .8rem; border-radius: var(--radius-sm);
	color: var(--c-ink); font-weight: 600; font-size: .95rem; background: none; border: 0;
}
.nav__link:hover, .nav__link[aria-current="page"], .has-sub.is-open > .nav__link { color: var(--c-primary-dark); background: var(--c-primary-soft); text-decoration: none; }
.nav__caret {
	width: 28px; height: 28px; margin-left: -.35rem; padding: 0; border: 0; background: none; color: var(--c-ink-soft);
	display: grid; place-items: center; border-radius: 50%;
}
.nav__caret::before {
	content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0;
	transform: translateY(-2px) rotate(45deg); transition: transform .2s;
}
.has-sub.is-open > .nav__caret::before { transform: translateY(1px) rotate(225deg); }

.nav__sub {
	display: none; position: absolute; top: 100%; left: 0; z-index: 10; min-width: 250px; padding: .5rem;
	background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.has-sub:hover > .nav__sub, .has-sub:focus-within > .nav__sub, .has-sub.is-open > .nav__sub { display: block; }
.nav__sub a { display: block; padding: .5rem .75rem; border-radius: var(--radius-sm); color: var(--c-ink); font-size: .92rem; }
.nav__sub a:hover { background: var(--c-primary-soft); color: var(--c-primary-dark); text-decoration: none; }

.header-actions { display: flex; align-items: center; gap: .5rem; }
.icon-btn {
	position: relative; display: grid; place-items: center; width: 44px; height: 44px;
	border-radius: 50%; border: 0; background: var(--c-primary-soft); color: var(--c-primary-dark);
}
.icon-btn:hover { background: var(--c-primary); color: #fff; text-decoration: none; }
.icon-btn svg { width: 22px; height: 22px; }
.nav-toggle { display: none; }

@media (max-width: 960px) {
	.nav-toggle { display: grid; }
	.nav {
		position: absolute; inset: 100% 0 auto 0; max-height: calc(100vh - var(--header-h));
		overflow-y: auto; background: var(--c-surface); border-bottom: 1px solid var(--c-line);
		box-shadow: var(--shadow-md); padding: .5rem var(--gutter) 1.25rem; display: none;
	}
	.nav.is-open { display: block; }
	.nav__list { flex-direction: column; align-items: stretch; gap: 0; }
	.nav__item { flex-wrap: wrap; border-bottom: 1px solid var(--c-line); }
	.nav__link { flex: 1; padding: .85rem .25rem; border-radius: 0; background: none !important; }
	.nav__caret { width: 44px; height: 44px; margin: 0; }
	.nav__sub {
		position: static; flex-basis: 100%; min-width: 0; box-shadow: none; border: 0; background: var(--c-bg);
		padding: .25rem .5rem .5rem; margin-bottom: .5rem;
	}
	.has-sub:hover > .nav__sub, .has-sub:focus-within > .nav__sub { display: none; }
	.has-sub.is-open > .nav__sub { display: block; }
	.topbar .topbar__extra { display: none; }
	.topbar .topbar__inici { display: none; } /* en móvil el enlace a Inici de la barra superior se oculta (el logo ya lleva a la portada) */
}

/* ---------- secciones genéricas ---------- */
.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section--tint { background: var(--c-primary-soft); }
.section__head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.section__title { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.section__title::after {
	content: ""; display: block; width: 56px; height: 4px; margin-top: .6rem;
	border-radius: 2px; background: var(--c-accent);
}
.section__more { font-weight: 600; }
.section__more::after { content: " →"; }

/* ---------- carriles horizontales (novedades, autores) ---------- */
.rail {
	display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 200px); gap: 1.25rem;
	overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: var(--gutter); padding: .5rem var(--gutter) 1.25rem;
	margin-inline: calc(var(--gutter) * -1); scrollbar-width: thin; scrollbar-color: var(--c-primary) transparent;
}
.rail > * { scroll-snap-align: start; }
.rail, .hero__track { cursor: grab; }
.rail.is-arrastrando, .hero__track.is-arrastrando { cursor: grabbing; user-select: none; }
.rail img, .hero__track img { -webkit-user-drag: none; }

.book { display: flex; flex-direction: column; gap: .75rem; }
.book__cover {
	position: relative; display: block; border-radius: 4px 8px 8px 4px; overflow: hidden;
	transition: transform .25s;
}
.book__cover img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: contain; object-position: center bottom; } /* portada completa, sin recortar */
.book:hover .book__cover { transform: translateY(-4px); }
/* tarjeta de libro: la caja mantiene la proporción 2:3 pero la imagen se muestra con la suya, pegada abajo, y las etiquetas
   (Novetat arriba, precio abajo) se colocan sobre la propia portada, no sobre el hueco que queda en la caja */
.book__cover--ajustada { container-type: inline-size; aspect-ratio: 2 / 3; display: flex; align-items: flex-end; }
.book__frame { position: relative; display: block; width: 100%; }
.book__cover--ajustada img { aspect-ratio: auto; height: auto; max-height: 150cqw; }
.book__price {
	position: absolute; right: .5rem; bottom: .5rem; padding: .15rem .6rem; border-radius: 999px;
	background: var(--c-accent); color: #2b1d00; font-weight: 800; font-size: .85rem; box-shadow: var(--shadow-sm);
}
.book__title { font-size: 1.05rem; font-family: var(--font-body); font-weight: 700; line-height: 1.3; }
.book__title a { color: var(--c-ink); }
.book__title a::after { content: ""; position: absolute; inset: 0; } /* toda la tarjeta clicable */
.book { position: relative; }
.book__meta { margin: 0; font-size: .87rem; color: var(--c-ink-soft); }

.author { text-align: center; position: relative; }
.author__photo {
	width: 150px; aspect-ratio: 1; margin: 0 auto .75rem; border-radius: 50%; overflow: hidden;
	border: 4px solid #fff; box-shadow: var(--shadow-sm); background: var(--c-line);
}
.author__photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.author__name { font-family: var(--font-body); font-size: 1rem; font-weight: 700; }
.author__name a { color: var(--c-ink); }
.author__name a::after { content: ""; position: absolute; inset: 0; }

.crumbs { padding-block: 1.1rem; font-size: .88rem; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: .25rem .5rem; }
.crumbs li + li::before { content: "›"; margin-right: .5rem; color: var(--c-ink-soft); }
.crumbs a { color: var(--c-ink-soft); }
.crumbs [aria-current] { color: var(--c-ink); font-weight: 600; }

/* ---------- pie ---------- */
.cta-news { background: var(--c-primary); color: #fff; }
.cta-news .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; padding-block: 2rem; }
.cta-news h2 { font-size: clamp(1.3rem, 2.5vw, 1.75rem); }
.cta-news p { margin: .25rem 0 0; opacity: .9; }

.site-footer { background: var(--c-footer); color: #b9cdd0; font-size: .93rem; }
.site-footer a { color: #e6f1f2; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-grid { display: grid; gap: 2.5rem 2rem; padding-block: 3rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.footer-grid h3 { font-family: var(--font-body); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: #fff; margin-bottom: 1rem; }
.footer-grid li + li { margin-top: .45rem; }
.footer-brand { grid-column: span 2; }
.footer-brand .brand img { height: 90px; filter: brightness(0) invert(1); } /* logo negro -> blanco sobre el pie oscuro */
.footer-brand address { font-style: normal; margin-top: 1rem; }
.social { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.social a {
	padding: .35rem .85rem; border: 1px solid rgb(255 255 255 / .25); border-radius: 999px; font-size: .85rem;
}
.social a:hover { background: rgb(255 255 255 / .12); text-decoration: none; }
.footer-bottom { border-top: 1px solid rgb(255 255 255 / .12); padding-block: 1.25rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; font-size: .85rem; }
@media (max-width: 640px) { .footer-brand { grid-column: auto; } }

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

/* ---------- View Transitions entre páginas (navegadores con soporte; el resto navega normal) ---------- */
@media (prefers-reduced-motion: no-preference) {
	@view-transition { navigation: auto; }
}
.site-header { view-transition-name: cabecera; } /* la cabecera no parpadea al cambiar de página */
::view-transition-group(portada-libro) {
	animation-duration: .55s;
	animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}
::view-transition-old(portada-libro), ::view-transition-new(portada-libro) {
	height: 100%; object-fit: contain; border-radius: 6px 12px 12px 6px;
}
::view-transition-group(foto-autor) {
	animation-duration: .55s;
	animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}
/* la instantánea conserva la forma de cada imagen (círculo en listados, rectángulo completo en la ficha) */
::view-transition-old(foto-autor), ::view-transition-new(foto-autor) {
	height: 100%; object-fit: cover;
}

/* ---------- contador de la cistella en la cabecera ---------- */
.icon-btn--cesta { position: relative; }
.icon-btn__n {
	position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
	background: var(--c-accent); color: #2b1d00; font-size: .72rem; font-weight: 800; line-height: 19px; text-align: center;
	box-shadow: 0 0 0 2px #fff;
}
