/* Motor de presentacions: estructura, navegació i components comuns.
   Cada presentació defineix els seus tokens a :root (vegeu motor/plantilla/index.html)
   i hi afegeix el CSS propi del tema. Aquí no hi ha cap color ni tipografia fixos. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { color: var(--fg); font-family: var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; font-weight: 400; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.acc { color: var(--accent); }
.muted { color: var(--muted); }
.sm { font-size: 22px; }

/* Escenari: llenç fix de 1600×900 escalat a la pantalla per fit() */
#stage { position: absolute; left: 50%; top: 50%; width: 1600px; height: 900px; font-size: 29px; line-height: 1.42; transform: translate(-50%, -50%); }

/* ——— diapositives i transicions ——— */
.slide { position: absolute; inset: 0; padding: 104px 120px 112px; display: flex; flex-direction: column; isolation: isolate;
  opacity: 0; visibility: hidden; transform: translateX(70px);
  transition: opacity .5s var(--ease), transform .75s var(--ease), visibility 0s linear .75s; }
.slide.before { transform: translateX(-70px); }
.slide.on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes letter { from { opacity: 0; transform: translateY(.25em); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
.slide.on .rv { animation: rise .9s var(--ease) both; animation-delay: calc(140ms + var(--i, 0) * 75ms); }
.letters span { display: inline-block; }
.slide.on .letters span { animation: letter 1.1s var(--ease) both; animation-delay: calc(250ms + var(--l) * 70ms); }
.frag { opacity: 0; transform: translateY(16px); transition: opacity .55s var(--ease), transform .65s var(--ease); }
.frag.shown { opacity: 1; transform: none; }

/* ——— ornament del tema (la greca, a Antígona) ——— */
.orn { height: var(--orn-h, 22px); background: var(--ornament) repeat-x; }

/* ——— marc fix (l'injecta motor.js) ——— */
#prog { position: absolute; left: 0; right: 0; bottom: 0; opacity: .22; }
#progFill { position: absolute; left: 0; bottom: 0; width: 0; transition: width .8s var(--ease); }
#actLabel, #count { position: absolute; top: 40px; font-family: var(--display); font-size: 17px; letter-spacing: .3em; color: var(--muted); transition: opacity .4s; text-transform: uppercase; }
#actLabel { left: 120px; }
#actLabel b { color: var(--accent); font-weight: 400; margin-right: 14px; }
#count { right: 120px; font-variant-numeric: tabular-nums; letter-spacing: .15em; }
#ctrls { position: absolute; right: 108px; bottom: 38px; display: flex; gap: 6px; }
#ctrls button { height: 40px; min-width: 40px; padding: 0 12px; border: 1px solid transparent; color: var(--muted); font-family: var(--display); font-size: 16px; letter-spacing: .15em; transition: color .2s, border-color .2s; }
#ctrls button:hover { color: var(--accent); border-color: var(--line); }
#ctrls button:disabled { opacity: .25; cursor: default; }
.is-cover #actLabel, .is-cover #count { opacity: 0; }

/* índex */
#ov { position: absolute; inset: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 97%, transparent); padding: 90px 120px; opacity: 0; visibility: hidden; transition: opacity .35s, visibility 0s .35s; }
#ov.open { opacity: 1; visibility: visible; transition-delay: 0s; }
#ov h2 { font-size: 40px; letter-spacing: .08em; margin: 0; }
#ov .cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px 60px; margin-top: 34px; }
#ov h3 { font-size: 17px; letter-spacing: .3em; color: var(--accent); margin-bottom: 8px; text-transform: uppercase; }
#ov h3 b { color: var(--muted); font-weight: 400; margin-right: 10px; }
#ov ol { list-style: none; margin: 0; padding: 0; }
#ov li button { display: flex; gap: 14px; width: 100%; text-align: left; font-size: 23px; line-height: 1.3; padding: 3px 0; color: var(--fg); }
#ov li button span { color: var(--muted); font-family: var(--display); font-size: 15px; width: 24px; padding-top: 5px; font-variant-numeric: tabular-nums; flex: none; }
#ov li button:hover, #ov li button.cur { color: var(--accent); }
#ov .foot { position: absolute; left: 120px; right: 120px; bottom: 60px; font-size: 20px; color: var(--muted); display: flex; justify-content: space-between; gap: 40px; }

/* ——— separadors d'acte ——— */
.act { justify-content: center; padding-left: 200px; }
.act .num { font-family: var(--display); font-size: 230px; line-height: .9; color: transparent; -webkit-text-stroke: 1.5px var(--accent); letter-spacing: .02em; }
.act h2 { font-size: 84px; margin: 22px 0 18px; letter-spacing: .08em; text-transform: uppercase; }
.act .q { font-size: 36px; font-style: italic; color: var(--muted); max-width: 30ch; }
.act .orn { position: absolute; left: 200px; width: 0; top: 150px; opacity: .8; }
.slide.on.act .orn { transition: width 1.4s var(--ease) .15s; width: 520px; }

/* ——— tipografia i components comuns ——— */
.kick { font-family: var(--display); color: var(--accent); letter-spacing: .3em; font-size: 18px; text-transform: uppercase; }
h2 { font-size: 62px; letter-spacing: .03em; line-height: 1.08; margin: 12px 0 24px; }
h2 small { font-size: .45em; color: var(--muted); letter-spacing: .05em; margin-left: 16px; }
.lede { max-width: 62ch; }
.lede.sm { max-width: 88ch; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: start; }
.panel { border-left: 3px solid var(--accent); padding: 14px 22px; background: var(--bg-2); font-size: 25px; }
.panel h3 { font-size: 23px; color: var(--accent); margin-bottom: 6px; letter-spacing: .04em; }
.panel p + p { margin-top: 8px; }
.panel .src { font-size: 19px; color: var(--muted); margin-top: 10px; font-style: italic; }
.facts { list-style: none; padding: 0; margin: 0; }
.facts li { padding: 11px 0 11px 30px; border-top: 1px solid var(--line); position: relative; font-size: 25px; line-height: 1.35; }
.facts li::before { content: ""; position: absolute; left: 3px; top: 21px; width: 9px; height: 9px; background: var(--accent); transform: rotate(45deg); }
.facts small { display: block; color: var(--muted); font-style: italic; font-size: 21px; }
.quote { font-size: 27px; font-style: italic; }
.quote cite { display: block; font-style: normal; font-family: var(--display); font-size: 15px; letter-spacing: .25em; color: var(--muted); margin-top: 6px; text-transform: uppercase; }
.quote .g { display: block; color: var(--accent); font-size: 23px; margin-bottom: 4px; }
.tog { align-self: flex-start; border: 1px solid var(--accent); color: var(--accent); padding: 8px 18px; font-family: var(--display); font-size: 16px; letter-spacing: .12em; transition: background .25s, color .25s; }
.tog:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.tog[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.tog:disabled { opacity: .3; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { border: 1px solid var(--line); padding: 2px 12px; font-size: 22px; }
.chips span.hl { border-color: var(--accent); color: var(--accent); }
.chips span small { color: var(--muted); font-size: 17px; margin-left: 6px; }

/* Fil conductor: a cada diapositiva general, el lligam amb l'obra de referència */
.anchor { margin-top: auto; display: flex; gap: 22px; align-items: baseline; border-top: 1px solid var(--line); padding-top: 16px; font-size: 24px; line-height: 1.35; }
.anchor b { flex: none; font-family: var(--display); font-weight: 400; color: var(--accent); letter-spacing: .25em; font-size: 15px; display: flex; align-items: center; gap: 10px; text-transform: uppercase; }
.anchor b::before { content: ""; width: 8px; height: 8px; background: var(--accent); transform: rotate(45deg); }

/* Pestanyes: .tabs seguit de germans .tabpane (motor.js les connecta) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 18px 10px; font-family: var(--display); font-size: 17px; letter-spacing: .14em; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .2s, border-color .2s; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.tabpane { padding-top: 20px; }
.tabpane[hidden] { display: none; }
.tabpane:not([hidden]) { animation: fade .45s var(--ease); }

/* Elements SVG clicables (svgHit) */
svg text { font-family: var(--body); fill: var(--fg); }
.hit { cursor: pointer; }
.hit .shape { transition: stroke .2s; }
.hit:hover .shape, .hit.on .shape { stroke: var(--accent); }
.hit text { transition: fill .2s; }
.hit.on text, .hit:hover text { fill: var(--accent); }

/* ——— mitjans: imatges i vídeo ———
   --media-filter (del tema) harmonitza fotos de procedències diverses amb la paleta. */
.fig { margin: 0; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.fig img, .fig video { display: block; max-width: 100%; max-height: var(--fig-h, 540px); object-fit: contain; align-self: flex-start;
  border: 1px solid var(--line); background: var(--bg-2); filter: var(--media-filter, none); }
.fig img { cursor: zoom-in; }
.fig figcaption { font-size: 20px; line-height: 1.35; color: var(--muted); font-style: italic; }
.fig figcaption .cr { display: block; font-style: normal; font-family: var(--display); font-size: 13px; letter-spacing: .12em; margin-top: 3px; opacity: .8; }
/* Diapositiva amb imatge de fons: <div class="bg"><img …></div> com a primer fill */
.slide > .bg { position: absolute; inset: 0; z-index: -1; }
.slide > .bg img { width: 100%; height: 100%; object-fit: cover; filter: var(--media-filter, none); }
.slide > .bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg) 28%, color-mix(in srgb, var(--bg) 55%, transparent) 60%, transparent); }
/* Ampliació (fora de l'escenari, a mida de pantalla) */
#lb { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 96%, transparent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 3vh 3vw; opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; cursor: zoom-out; }
#lb.open { opacity: 1; visibility: visible; transition-delay: 0s; }
#lb img { max-width: 94vw; max-height: 86vh; object-fit: contain; }
#lb p { color: var(--muted); font-family: var(--body); font-style: italic; font-size: clamp(14px, 1.6vw, 20px); text-align: center; max-width: 80ch; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .frag.shown { opacity: 1; transform: none; }
}
