/* raphaelaguinaga.com — Máquina de Poesia (v29): great art behind, light words in front, always on a dark field */
:root { --ink: #f6f0e6; --soft: #d6cfc2; --acc: #ecd3a4; --gold: #e8a33a; --disp: Georgia, serif;
  --serif: "Fraunces", Georgia, serif; --sans: "Instrument Sans", system-ui, -apple-system, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #050506; overflow: hidden; }
body { color: var(--ink); font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body.idle { cursor: none; }

/* the picture: each new one rises over the last, stills drift, films run slow */
.mq-media { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #050506; }
.mq-m { position: absolute; inset: 0; opacity: 0; transition: opacity 3.8s cubic-bezier(.4,0,.2,1); }
.mq-m.on { opacity: 1; }
.mq-m img, .mq-m video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; will-change: transform; transform-origin: 50% 50%; }
/* the veil: the art stays rich at the edges and quiet behind the words */
.mq-veil { position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 70% 62% at 50% 50%, rgba(4,4,6,.5), rgba(4,4,6,.3) 70%, rgba(4,4,6,.58)),
              linear-gradient(180deg, rgba(4,4,6,.5), transparent 22%, transparent 74%, rgba(4,4,6,.66)); }
.mq-grain { position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

/* the stage: one cell, the old and the new screen cross in it */
.mq-stage { position: fixed; inset: 0; z-index: 3; display: grid; place-items: center; padding: 11vh 7vw 13vh; pointer-events: none; }
.mq-card { grid-area: 1 / 1; position: relative; isolation: isolate; color: var(--ink); text-align: center; transition: opacity 2.2s ease, filter 2.2s ease, transform 2.6s ease; }
.mq-card::before { content: ""; position: absolute; inset: -30% -22%; z-index: -2; background: radial-gradient(closest-side, rgba(4,4,6,.62), rgba(4,4,6,.34) 60%, transparent); }
.mq-card.out { opacity: 0; filter: blur(14px); transform: scale(1.015); }
.mq-poem { position: relative; width: max-content; font-weight: 400; font-kerning: normal; font-feature-settings: "liga", "kern";
  text-shadow: 0 1px 2px rgba(0,0,0,.45), 0 0 .5em rgba(0,0,0,.4); }
.mq-poem.wrap { width: auto; }
.mq-poem .ln { position: relative; display: block; white-space: nowrap; }
.mq-poem.wrap .ln { white-space: normal; text-wrap: balance; }
.mq-poem.wrap .ln + .ln { margin-top: .18em; }
[data-comp="abertura"] .mq-poem.wrap .ln, [data-comp="inicial"] .mq-poem.wrap .ln, [data-comp="dialogo"] .mq-poem.wrap .ln { padding-left: 1em; text-indent: -1em; }
.mq-poem .wd { display: inline-block; text-indent: 0; }
/* the words that carry the mood sing in the display face and in the colour of the picture */
.mq-poem .k { font-family: var(--disp); color: var(--acc); }

/* compositions */
[data-comp="abertura"] .mq-poem, [data-comp="inicial"] .mq-poem { text-align: left; }
[data-comp="abertura"] .mq-poem::before { content: ""; display: block; width: 2.2em; height: 1px; margin: 0 0 1em; background: var(--acc); opacity: .9; }
[data-comp="abertura"] .ln.d { font-family: var(--disp); font-size: 1.3em; line-height: 1.12; margin-bottom: .32em; font-style: normal; }
[data-comp="dialogo"] .mq-poem { text-align: left; }
[data-comp="dialogo"] .ln.d { font-family: var(--disp); font-size: 1.08em; text-align: right; font-style: normal; }
[data-comp="inscricao"] .mq-poem { font-weight: 400; }
[data-comp="inscricao"] .mq-poem::after { content: ""; display: block; width: 1.4em; height: 1px; margin: 1.1em auto 0; background: var(--acc); }
[data-comp="inicial"] .mq-poem { padding-left: 2.1em; }
.mq-ini { position: absolute; right: calc(100% + .05em); top: .02em; font-family: var(--disp); font-style: normal; font-size: 2.9em; line-height: .8; color: var(--acc); }
[data-comp="margem"] { text-align: left; }
[data-comp="margem"][data-side="l"] { justify-self: start; margin-left: 2vw; }
[data-comp="margem"][data-side="r"] { justify-self: end; margin-right: 2vw; text-align: right; }
[data-comp="margem"][data-side="r"] .mq-poem { text-align: right; }
[data-v="t"] { align-self: start; margin-top: 4vh; } [data-v="b"] { align-self: end; margin-bottom: 2vh; }
/* eco: one word of the poem, hollow and enormous, drifts behind it */
.mq-echo { position: absolute; left: 50%; top: 50%; z-index: -1; font-size: min(26vw, 40vh); line-height: 1; white-space: nowrap; color: transparent;
  -webkit-text-stroke: 1.3px var(--acc); opacity: 0; transform: translate(-50%, -52%); transition: opacity 5s ease 1.5s; animation: mqEcho 60s linear both; pointer-events: none; }
.mq-card.on .mq-echo { opacity: .2; }
@keyframes mqEcho { from { translate: 4% 0; } to { translate: -4% 0; } }

/* reveals: the lines arrive slowly, then stay long enough to be read twice */
[data-r="mist"] .ln { opacity: 0; filter: blur(.3em); transition: opacity 2.4s ease, filter 2.8s ease; transition-delay: calc(var(--l) * 1.25s); }
[data-r="rise"] .ln { opacity: 0; transform: translateY(.45em); transition: opacity 2s ease, transform 2.6s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--l) * 1.25s); }
[data-r="breath"] .ln { opacity: 0; transform: scale(.965); filter: blur(.08em); transition: opacity 2.4s ease, transform 3s cubic-bezier(.2,.7,.2,1), filter 2.4s ease; transition-delay: calc(var(--l) * 1.25s); }
[data-r="word"] .wd { opacity: 0; filter: blur(.12em); transition: opacity 1.5s ease, filter 1.7s ease; transition-delay: calc(var(--w) * .2s); }
[data-r="fade"] .mq-poem { opacity: 0; transition: opacity 1.6s ease; }
.mq-card.on .ln, .mq-card.on .wd, .mq-card.on .mq-poem { opacity: 1; transform: none; filter: none; }

/* credits and controls */
.mq-cap { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; margin: 0; padding: 0 20px 16px; display: flex; justify-content: space-between; gap: 18px; pointer-events: none;
  font: 500 10.5px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--soft); text-shadow: 0 1px 3px rgba(0,0,0,.7); opacity: .78; transition: opacity 1s; }
.mq-cap span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mq-mus { flex: none; }
body.idle .mq-cap { opacity: .55; }
.mq-ui { position: fixed; inset: 0 0 auto; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; opacity: 0; pointer-events: none; transition: opacity .6s; }
body.running:not(.idle) .mq-ui { opacity: 1; pointer-events: auto; }
.mq-back { padding: 10px 16px; border-radius: 999px; background: rgba(6,6,8,.55); color: var(--ink); text-decoration: none; font: 500 14px/1 var(--sans); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.mq-ctl { display: flex; gap: 8px; }
.mq-ctl button, .mq-x { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid rgba(246,240,230,.25); border-radius: 50%;
  background: rgba(6,6,8,.55); color: var(--ink); cursor: pointer; text-decoration: none; font: 300 26px/1 var(--sans); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: border-color .3s, transform .3s; }
.mq-ctl button:hover, .mq-x:hover, .mq-ctl button:focus-visible { border-color: var(--ink); transform: translateY(-1px); }
.mq-ctl svg, .mq-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mq-ctl button[data-a="pause"] svg path[d^="M7 5"] { fill: currentColor; }

/* the intro: a picture breathing behind a dark field */
.mq-intro { position: fixed; inset: 0; z-index: 6; display: grid; align-content: center; padding: 90px clamp(18px, 6vw, 96px) 60px; color: #f6f0e6;
  background: linear-gradient(90deg, rgba(4,4,6,.86), rgba(4,4,6,.62) 55%, rgba(4,4,6,.38)); transition: opacity 1.5s ease, visibility 0s 1.5s; }
.mq-intro.gone { opacity: 0; visibility: hidden; }
.mq-top { position: absolute; top: 18px; left: clamp(18px, 6vw, 96px); right: clamp(18px, 6vw, 96px); display: flex; justify-content: space-between; font: 500 14px/1 var(--sans); }
.mq-top a { color: #ddd6ca; text-decoration: none; } .mq-top a:hover { color: #fff; }
.mq-in { max-width: 980px; }
.mq-eyebrow { margin: 0 0 18px; font: 600 12.5px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.mq-intro h1 { margin: 0; font: 300 clamp(50px, 9.5vw, 148px)/.94 var(--serif); letter-spacing: -.03em; text-shadow: 0 2px 30px rgba(0,0,0,.5); }
.mq-lede { margin: 28px 0 0; max-width: 42ch; font: italic 300 clamp(19px, 2vw, 25px)/1.5 var(--serif); color: #e2dbcf; }
.mq-go { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 38px; }
.mq-btn { display: inline-flex; align-items: center; gap: 10px; padding: 16px 24px; border-radius: 999px; border: 1px solid rgba(246,240,230,.4); background: rgba(5,5,6,.5); color: #f6f0e6; font: 600 15px/1 var(--sans); cursor: pointer; transition: transform .3s, background .3s, border-color .3s; }
.mq-btn:hover, .mq-btn:focus-visible { transform: translateY(-2px); border-color: #f6f0e6; }
.mq-btn.on { background: var(--gold); border-color: var(--gold); color: #120d05; }
.mq-hint { margin: 26px 0 0; font: 500 13px/1.4 var(--sans); color: #b3ada3; letter-spacing: .04em; }
.mq-intro .mq-in > * { animation: mqIn 1.4s cubic-bezier(.2,.7,.2,1) both; } .mq-intro .mq-in > :nth-child(2) { animation-delay: .14s; } .mq-intro .mq-in > :nth-child(3) { animation-delay: .28s; } .mq-intro .mq-in > :nth-child(4) { animation-delay: .42s; } .mq-intro .mq-in > :nth-child(5) { animation-delay: .56s; }
@keyframes mqIn { from { opacity: 0; transform: translateY(22px); } }

@media (max-width: 760px) {
  .mq-stage { padding: 13vh 6vw 15vh; }
  .mq-veil { background: radial-gradient(ellipse 90% 60% at 50% 50%, rgba(4,4,6,.56), rgba(4,4,6,.4) 70%, rgba(4,4,6,.62)), linear-gradient(180deg, rgba(4,4,6,.55), transparent 24%, transparent 72%, rgba(4,4,6,.7)); }
  [data-v] { align-self: center; margin: 0; }
  .mq-cap { flex-direction: column; gap: 4px; padding: 0 16px 14px; font-size: 9.5px; }
  .mq-ctl button[data-a="full"] { display: none; }
  .mq-back { font-size: 0; padding: 0; width: 46px; height: 46px; display: grid; place-items: center; }
  .mq-back::before { content: "←"; font-size: 20px; }
  .mq-ctl button, .mq-x { width: 44px; height: 44px; }
  .mq-intro { background: linear-gradient(180deg, rgba(4,4,6,.6), rgba(4,4,6,.86)); }
  body.running .mq-ui { opacity: 1; pointer-events: auto; } body.running.idle .mq-ui { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .mq-intro .mq-in > * { animation: none; } .mq-echo { animation: none; } }
