@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&display=swap');

/* ---------- Tokens ---------- */
:root {
  --paper: #f5f3ed;
  --paper-2: #ece9e1;
  --frame: #e2ddd2;
  --frame-hover: #d9d2c4;
  --ink: #45252f;
  --muted: #6e6560;
  --line: #d7d0c6;
  --line-strong: #c4bbaf;
  --burgundy: #4b2430;
  --on-burgundy: #f2e9ea;
  --on-burgundy-muted: #d7c2c7;
  --accent: #9b3f43;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'DM Sans', Arial, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --gutter: clamp(20px, 6vw, 112px);
  --header: 88px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.7 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: #d6b9be; color: #321b24; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
ol, ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(46px, 6vw, 92px); line-height: .98; letter-spacing: -.04em; }
h3 { font-size: clamp(26px, 2.2vw, 32px); line-height: 1.1; letter-spacing: -.015em; }
em, i { font-style: italic; font-weight: 400; }
p { margin: 0; text-wrap: pretty; }

.eyebrow { display: block; font-size: 11px; line-height: 1.6; letter-spacing: .16em; text-transform: uppercase; font-weight: 500; }
.source-note { font-size: 13px; line-height: 1.6; color: var(--muted); }
.editorial-label { font-size: 13px; line-height: 1.6; color: var(--muted); max-width: 340px; padding-left: 16px; border-left: 2px solid var(--accent); }

.skip { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--ink); color: var(--paper); padding: 10px 16px; font-size: 14px; }
.skip:focus { top: 12px; }

.reading-progress { position: fixed; z-index: 100; inset: 0 0 auto; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; pointer-events: none; }

/* ---------- Cabecera ---------- */
header { position: sticky; top: 0; z-index: 20; height: var(--header); padding: 0 var(--gutter); display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); background: rgb(245 243 237 / .94); backdrop-filter: blur(14px); transition: height .35s var(--ease), box-shadow .35s; }
body.scrolled header { height: 72px; box-shadow: 0 1px 0 var(--line); }
/* Logo aprobado (assets/logo-ec.png): se usa sin recortar; el margen transparente del archivo es su área de protección. */
.brand { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand-logo { width: auto; height: 60px; flex-shrink: 0; }
.brand-text { display: block; font: 34px/1 var(--serif); letter-spacing: -.04em; }
.brand-sub { display: block; margin-top: 8px; font: 500 10px var(--sans); letter-spacing: .22em; text-transform: uppercase; }
.brand-footer .brand-logo { height: 76px; }
nav { display: flex; gap: clamp(20px, 3vw, 40px); font-size: 14px; }
nav a { position: relative; padding: 10px 0; }
nav a::after, .underlink::after { content: ''; position: absolute; left: 0; bottom: 4px; height: 1px; width: 100%; background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform .45s var(--ease); }
nav a:hover::after, nav a[aria-current]::after, .underlink:hover::after { transform: scaleX(1); transform-origin: left; }
.header-tools { display: flex; align-items: center; gap: 14px; }
.lang-switch { display: flex; border: 1px solid var(--line-strong); }
.lang-switch button { border: 0; background: none; font-size: 13px; letter-spacing: .06em; padding: 10px 11px; min-width: 40px; transition: background .25s, color .25s; }
.lang-switch button:hover { background: var(--paper-2); }
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.catalog-link { font-size: 14px; border: 1px solid var(--line-strong); padding: 11px 16px; white-space: nowrap; transition: background .3s, color .3s; }
.catalog-link:hover { background: var(--ink); color: var(--paper); }
.catalog-link span { margin-left: 22px; }

/* ---------- Portada ---------- */
.hero { padding: 36px var(--gutter) 0; overflow: hidden; }
.hero-meta { margin: 0; text-align: center; color: var(--muted); }
h1 { max-width: 1180px; font-size: clamp(64px, 9.4vw, 150px); letter-spacing: -.05em; line-height: .9; margin: 36px auto 52px; padding: 0; text-align: center; }
/* Ambas líneas centradas sobre el eje de la obra: sin sangría ni desplazamiento horizontal. */
.title-line, .title-line > span, .title-line > em { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; text-indent: 0; text-align: center; }
.title-line { display: block; overflow: hidden; padding-bottom: .12em; margin-bottom: -.1em; }
.title-line > span, .title-line > em { display: block; animation: title-enter 1.3s var(--ease) both; }
.title-line > em { animation-delay: .12s; }
.hero-stage { max-width: 1180px; margin: 0 auto; animation: art-enter 1.4s .2s var(--ease) both; }
.hero-art { position: relative; display: block; width: 100%; padding: 0; border: 0; background: var(--frame); overflow: hidden; }
.hero-art img { width: 100%; transition: transform 1.2s var(--ease); }
.hero-art:hover img { transform: scale(1.012); }
.art-expand { position: absolute; bottom: 20px; right: 20px; background: var(--paper); padding: 12px 18px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: opacity .4s, transform .4s var(--ease); }
.hero-art:hover .art-expand, .hero-art:focus-visible .art-expand { opacity: 1; transform: none; }
.hero-stage figcaption { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 10px; margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.hero-stage figcaption span::before { content: '·'; margin-right: 10px; }
.hero-bottom { display: flex; flex-direction: column; align-items: center; gap: 22px; margin: 44px 0 76px; text-align: center; }
.hero-bottom p { font: 26px/1.35 var(--serif); }
.round-link { display: flex; align-items: center; gap: 16px; font-size: 14px; flex-shrink: 0; }
.round-icon { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 18px; transition: transform .4s var(--ease), background .3s; }
.round-link:hover .round-icon { transform: translateY(4px); background: var(--paper-2); }

/* ---------- 01 Colección ---------- */
.intro { padding: clamp(80px, 10vw, 140px) var(--gutter); display: grid; grid-template-columns: 1fr 1fr; column-gap: 8%; row-gap: 32px; border-top: 1px solid var(--line); }
.intro > .eyebrow { grid-column: 1 / -1; }
.intro-text { display: grid; gap: 20px; max-width: 560px; }
.intro-text .lead { font: 30px/1.28 var(--serif); letter-spacing: -.01em; }
.intro-text p:not(.lead):not(.source-note) { font-size: 17px; line-height: 1.75; }
.facts { grid-column: 1 / -1; margin: 40px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.facts > div { padding: 24px 24px 0 0; }
.facts > div + div { padding-left: 24px; border-left: 1px solid var(--line); }
.facts dt { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.facts dd { margin: 0; font: 24px/1.3 var(--serif); }

/* ---------- Encabezados de sección ---------- */
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; }
.section-heading h2 { margin-top: 22px; }

/* ---------- 02 Obras ---------- */
.collection { padding: clamp(80px, 9vw, 120px) var(--gutter); background: var(--paper-2); }
.underlink { position: relative; display: inline-block; font-size: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.gallery-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 48px 0 40px; padding: 12px 0; border-block: 1px solid var(--line-strong); }
#count { margin-left: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gallery-toolbar > div { display: flex; gap: 4px; }
.view-button { border: 0; background: none; font-size: 14px; padding: 9px 14px; transition: background .25s, color .25s; }
.view-button:hover:not(.active) { background: var(--frame); }
.view-button.active { background: var(--ink); color: var(--paper); }
.view-button span { margin-right: 6px; }

.art-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 56px 32px; }
.work { display: block; width: 100%; min-width: 0; padding: 0; border: 0; background: none; text-align: left; grid-column: span 4; }
.work:nth-child(1) { grid-column: span 8; }
.work:nth-child(6), .work:nth-child(7), .work:nth-child(11), .work:nth-child(12) { grid-column: span 6; }
.work-frame { position: relative; height: 440px; padding: 40px; display: flex; align-items: center; justify-content: center; background: var(--frame); overflow: hidden; transition: background .5s; }
.work-frame img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; filter: drop-shadow(2px 6px 8px rgb(52 34 22 / .1)); transition: transform .8s var(--ease); }
.work.is-wide .work-frame img { width: 100%; }
.work:hover .work-frame { background: var(--frame-hover); }
.work:hover .work-frame img { transform: translateY(-4px) scale(1.02); }
.work-frame > span { position: absolute; bottom: 16px; right: 18px; font-size: 20px; opacity: .6; transition: transform .4s var(--ease), opacity .4s; }
.work:hover .work-frame > span { transform: translate(3px, -3px); opacity: 1; }
.work-caption { display: flex; justify-content: space-between; gap: 16px; padding-top: 18px; }
.work h3 { font-size: 28px; margin-bottom: 6px; }
.work p { font-size: 14px; color: var(--muted); line-height: 1.5; }
.work-num { font-size: 13px; color: var(--muted); padding-top: 6px; font-variant-numeric: tabular-nums; }
.load-error { grid-column: 1 / -1; font-size: 16px; }

.art-grid.list-view { display: block; }
.list-view .work { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 32px; padding: 18px 0; border-bottom: 1px solid var(--line-strong); }
.list-view .work-frame { height: 110px; padding: 12px; }
.list-view .work-frame > span { display: none; }
.list-view .work-caption { align-items: center; padding: 0; gap: 20px; }
.list-view .work-caption > div { flex: 1; }
.list-view .work h3 { font-size: 34px; }
.list-view .work-caption::after { content: '↗'; font-size: 22px; transition: transform .4s var(--ease); }
.list-view .work:hover .work-caption::after { transform: translate(3px, -3px); }
.list-view .work:hover .work-frame img { transform: none; }

/* ---------- 04 Materia ---------- */
.matter { display: grid; grid-template-columns: 1fr 1fr; gap: 8%; align-items: center; padding: clamp(80px, 10vw, 140px) var(--gutter); }
.matter-art { display: block; width: 100%; padding: clamp(28px, 4vw, 56px); border: 0; background: var(--frame); transition: background .4s; }
.matter-art img { margin: 0 auto; max-height: 76vh; width: auto; }
.matter-art:hover { background: var(--frame-hover); }
.matter-full figcaption, .matter-detail figcaption { margin-top: 12px; font-size: 13px; color: var(--muted); }
.matter-copy { display: grid; gap: 20px; max-width: 520px; }
.matter-copy h2 { margin: 6px 0 8px; }
.matter-copy > p:not(.source-note) { font-size: 17px; line-height: 1.75; }
.matter-detail { margin: 12px 0 4px; }
.detail-crop { aspect-ratio: 4 / 3; max-width: 400px; background: var(--frame) url('assets/obra-2.png') 38% 42% / 230% auto no-repeat; }

/* ---------- 04 Artista ---------- */
.artist { padding: clamp(80px, 10vw, 140px) var(--gutter); display: grid; grid-template-columns: 1fr 1.4fr; gap: 8%; }
/* Monograma aprobado (logo-ec.png) revelado por una máscara SVG que sigue sus trazos. */
.monogram { display: block; width: min(100%, 400px); height: auto; margin-top: 28px; overflow: visible; }
.ec-strokes path { stroke-dasharray: 1 2; stroke-dashoffset: 0; }
.monogram.is-armed .ec-strokes path { stroke-dashoffset: 1.02; }
.monogram.is-drawing .ec-strokes path { animation: ec-write var(--t) var(--d) ease-in-out forwards; }
.ec-strokes path:nth-child(1) { --d: 0s;    --t: .78s; }
.ec-strokes path:nth-child(2) { --d: .74s;  --t: .16s; }
.ec-strokes path:nth-child(3) { --d: .9s;   --t: .7s; }
.ec-strokes path:nth-child(4) { --d: 1.56s; --t: .46s; }
.ec-strokes path:nth-child(5) { --d: 1.98s; --t: .8s; }
@keyframes ec-write { from { stroke-dashoffset: 1.02; } to { stroke-dashoffset: 0; } }
.artist h2 { font-size: clamp(58px, 7vw, 108px); }
.artist-sub { display: block; margin: 22px 0 32px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.artist-copy p { font-size: 17px; line-height: 1.8; max-width: 560px; margin-bottom: 20px; }
.artist-copy .underlink { margin-top: 12px; }

/* ---------- 05 Documentación ---------- */
.closing { background: var(--burgundy); color: var(--on-burgundy); padding: clamp(80px, 9vw, 120px) var(--gutter); display: grid; grid-template-columns: 1fr 1fr; gap: 32px 8%; align-items: end; }
.docs-note { margin-top: 24px; font-size: 14px; color: var(--on-burgundy-muted); max-width: 360px; }
.closing > .eyebrow { grid-column: 1 / -1; color: var(--on-burgundy-muted); }
.dossier-links { display: grid; gap: 4px; }
.dossier-links a { display: flex; justify-content: space-between; align-items: center; gap: 32px; padding: 22px 0; border-bottom: 1px solid rgb(242 233 234 / .3); transition: color .3s, padding .4s var(--ease); }
.dossier-links a:hover { color: #e3c9a4; padding-left: 6px; }
.dossier-links strong { display: block; font: 30px/1.15 var(--serif); }
.dossier-links small { display: block; margin-top: 6px; font-size: 14px; line-height: 1.5; color: var(--on-burgundy-muted); }
.dossier-links a > span:last-child { font-size: 22px; }

footer { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 44px var(--gutter); }
footer p, footer > a:last-child { font-size: 13px; color: var(--muted); }

/* ---------- Visor ---------- */
dialog { border: 0; padding: 0; background: var(--paper); color: var(--ink); width: min(1180px, 94vw); max-width: none; max-height: 92dvh; overflow: auto; overscroll-behavior: contain; }
dialog[open] { display: grid; grid-template-columns: 1.35fr 1fr; grid-template-rows: auto 1fr auto; grid-template-areas: "image close" "image copy" "image nav"; column-gap: 48px; animation: dialog-in .45s var(--ease); }
dialog::backdrop { background: rgb(25 18 20 / .82); backdrop-filter: blur(6px); animation: fade-in .35s ease; }
.close { grid-area: close; justify-self: end; margin: 20px 22px 0 0; border: 0; background: none; font-size: 14px; padding: 10px; }
.dialog-image { grid-area: image; background: var(--frame); min-height: 520px; padding: 40px; display: flex; align-items: center; justify-content: center; }
.dialog-image img { max-width: 100%; max-height: 74dvh; width: auto; height: auto; object-fit: contain; }
.dialog-image img.changing { animation: image-change .45s var(--ease); }
.dialog-copy { grid-area: copy; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding-right: 44px; }
.dialog-copy .eyebrow { color: var(--muted); }
.dialog-copy h2 { font-size: clamp(40px, 4vw, 56px); margin: 18px 0 10px; }
.dialog-copy > p { font-size: 15px; color: var(--muted); }
dialog dl { width: 100%; margin: 28px 0; font-size: 15px; }
dialog dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; text-align: right; }
.dialog-nav { grid-area: nav; display: flex; justify-content: space-between; gap: 12px; padding: 20px 44px 28px 0; }
.dialog-nav button { border: 0; background: none; font-size: 15px; padding: 10px 0; transition: color .25s; }
.dialog-nav button:hover { color: var(--accent); }
body.modal-open { overflow: hidden; }

/* ---------- Movimiento ---------- */
.reveal { opacity: 1; transform: none; }
.motion-ready .reveal:not(.is-visible) { opacity: 0; transform: translateY(24px); }
.motion-ready .reveal { transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: var(--delay, 0ms); }
@keyframes title-enter { from { transform: translateY(115%); } to { transform: none; } }
@keyframes art-enter { from { clip-path: inset(8% 0 8% 0); opacity: 0; transform: translateY(20px); } to { clip-path: inset(0); opacity: 1; transform: none; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes image-change { from { opacity: .25; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (min-width: 1600px) {
  .work-frame { height: 520px; }
}

@media (max-width: 1100px) {
  .work-frame { height: 340px; padding: 30px; }
  .art-grid { gap: 40px 24px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts > div:nth-child(3) { padding-left: 0; border-left: 0; }
}

@media (max-width: 860px) {
  :root { --header: 112px; }
  header { flex-wrap: wrap; align-content: center; row-gap: 6px; padding-block: 12px; }
  body.scrolled header { height: 104px; }
  nav { order: 3; width: 100%; justify-content: space-between; gap: 12px; }
  nav a { padding: 6px 0; }
  .intro, .matter, .artist, .closing { grid-template-columns: 1fr; }
  .intro { row-gap: 28px; }
  .section-heading { flex-direction: column; align-items: flex-start; gap: 24px; }
  .matter { gap: 48px; }
  .monogram { width: min(58vw, 240px); margin: 18px 0 0 -4%; }
  .dossier-links { margin-top: 16px; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .brand { gap: 2px; }
  .brand-logo { height: 44px; }
  .brand-text { font-size: 25px; }
  .brand-sub { font-size: 9px; letter-spacing: .06em; margin-top: 5px; }
  .brand-footer .brand-logo { height: 60px; }
  nav { font-size: 14px; }
  .catalog-link { font-size: 13px; padding: 9px 12px; }
  header { column-gap: 10px; }
  .header-tools { gap: 8px; }
  .catalog-link span { display: none; }
  .hero-stage figcaption { flex-direction: column; }
  .hero-stage figcaption span::before { content: none; }
  .lang-switch button { font-size: 12px; padding: 8px 7px; min-width: 34px; }
  .catalog-link span { margin-left: 10px; }
  .hero { padding-top: 24px; }
  .hero-meta { font-size: 10px; letter-spacing: .12em; }
  h1 { font-size: clamp(50px, 14.6vw, 92px); margin: 24px auto 30px; line-height: .94; }
  .art-expand { display: none; }
  .hero-bottom { gap: 18px; margin: 30px 0 56px; }
  .hero-bottom p { font-size: 22px; }
  h2 { font-size: clamp(44px, 12.5vw, 64px); }
  .intro-text .lead { font-size: 26px; }
  .facts { grid-template-columns: 1fr 1fr; margin-top: 16px; }
  .facts > div { padding: 18px 12px 18px 0; }
  .facts > div + div { padding-left: 12px; }
  .facts > div:nth-child(3) { padding-left: 0; }
  .facts > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .facts dd { font-size: 21px; }
  .gallery-toolbar { margin: 36px 0 28px; }
  .view-button { font-size: 13px; padding: 8px 10px; }
  .art-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 14px; }
  .work, .work:nth-child(n) { grid-column: span 1; }
  .work:first-child { grid-column: 1 / -1; }
  .work-frame { height: 230px; padding: 18px; }
  .work:first-child .work-frame { height: auto; padding: 20px; }
  .work h3 { font-size: 21px; line-height: 1.1; }
  .work p { font-size: 13px; }
  .work-num { font-size: 12px; padding-top: 3px; }
  .work-frame > span { display: none; }
  .list-view .work { grid-template-columns: 80px 1fr; gap: 16px; padding: 14px 0; }
  .list-view .work-frame, .list-view .work:first-child .work-frame { height: 84px; padding: 8px; }
  .list-view .work h3 { font-size: 25px; }
  .list-view .work-num { display: none; }
  .list-view .work-caption::after { font-size: 18px; }
  .matter-art img { max-height: 62vh; }
  .artist-sub { line-height: 1.7; }
  .dossier-links strong { font-size: 26px; }
  .dossier-links a { gap: 16px; }
  footer { flex-wrap: wrap; gap: 12px 24px; }
  footer p { display: none; }

  /* Visor en móvil: cierre y navegación fijos mientras se desplaza la ficha */
  dialog { width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; }
  dialog[open] { display: flex; flex-direction: column; }
  .close { position: sticky; top: 0; z-index: 2; align-self: stretch; text-align: right; margin: 0; padding: 16px 20px; background: var(--paper); }
  .dialog-image { min-height: 0; padding: 20px; margin: 0 16px; flex-shrink: 0; }
  .dialog-image img { max-height: 52dvh; }
  .dialog-copy { padding: 24px 20px 8px; }
  .dialog-copy h2 { font-size: 40px; }
  dialog dl { margin: 20px 0 24px; font-size: 14px; }
  .dialog-nav { position: sticky; bottom: 0; z-index: 2; margin-top: auto; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: rgb(245 243 237 / .96); border-top: 1px solid var(--line); background: var(--paper); }
  .dialog-nav button { padding: 10px 4px; }
}

@media (max-width: 370px) {
  nav { font-size: 13px; }
  .catalog-link { padding: 8px 9px; }
  .brand-logo { height: 40px; }
  .brand-text { font-size: 24px; }
  header .brand-sub { display: none; }
  .work-frame { height: 190px; padding: 14px; }
  .work h3 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .motion-ready .reveal:not(.is-visible) { opacity: 1; transform: none; }
}
