/* ==========================================================
   ALL THINGS SERVE THE BEAM · feixe.css
   The essay's own face over the house template (ensaio.css). The palette and the four
   modes live in the :root of ensaio.css; this file holds what only this essay draws:
   the hero with the Tower, the spoiler at the gate, the contents as a descent, the
   opening without a number, the interludes inside a church arch, the plumb line under
   each aphorism and the closing under the stars.
   ========================================================== */

/* IM Fell English has a single weight: no synthetic bold anywhere */
h1, h2, h3, h4, .hero-titulo, .capitulo-titulo, .capitulo-numeral, .coda, .soco, .fecho-frase, .bio-nome, .citacao p { font-weight: 400; }
.hero-titulo em { font-weight: 400; }

/* ---------- HERO: fig-00 at rest ---------- */
.hero-figura { position: static; margin: 0; }
/* with no script or no canvas, a still dusk with the Tower's shadow stands in for the drawing */
.hero-arte {
  background:
    linear-gradient(to top, var(--fundo) 0%, transparent 30%),
    radial-gradient(ellipse 34% 26% at 66% 74%, color-mix(in srgb, var(--acento) 55%, transparent), transparent 70%),
    linear-gradient(180deg, #1b1119 0%, #3a1a1e 46%, #a5463c 70%, #e3a45c 76%, #2b1512 77%, var(--fundo) 100%);
}
/* the painting stays visible under the canvas (the house hides a hero 'cena' picture until the scene fails) */
html[data-hero="cena"] .hero[data-cena="feixe"] .hero-arte img { opacity: 1; object-fit: cover; object-position: 50% 50%; }
.hero[data-cena="feixe"] .hero-arte picture { display: block; width: 100%; height: 100%; }
html[data-hero="cena"] .hero[data-cena="feixe"] { padding-top: 5rem; padding-bottom: 4rem; }
/* the capsule carries the title's contrast, so the painting keeps its light: only a fade into the page */
html[data-hero="cena"] .hero[data-cena="feixe"]::before { background: linear-gradient(to top, var(--fundo) 0%, color-mix(in srgb, var(--fundo) 55%, transparent) 12%, transparent 30%); }
html[data-hero="cena"] .hero[data-cena="feixe"] .hero-texto { max-width: min(620px, 47vw); gap: 0.85rem; }
.hero[data-cena="feixe"] .hero-titulo { font-size: clamp(2.6rem, 0.9rem + 4.2vw, 6.2rem); line-height: 0.95; letter-spacing: -0.01em; }
.hero[data-cena="feixe"] .hero-sub { font-size: clamp(1.1rem, 0.95rem + 0.6vw, 1.5rem); }
.hero[data-cena="feixe"] .hero-titulo em { color: var(--acento); }
.hero[data-cena="feixe"] .hero-tese { padding: 0.7rem 0; border-color: color-mix(in srgb, var(--acento-2) 50%, transparent); font-family: var(--fonte-titulo); font-style: italic; font-size: clamp(1.1rem, 0.95rem + 0.6vw, 1.45rem); line-height: 1.3; }
.hero-fatos .meta-num { font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  /* on a phone the Tower stands in the upper half and the words sit under it */
  html[data-hero="cena"] .hero[data-cena="feixe"] { padding-top: 46svh; }
  /* the portrait painting fills the first screen and melts into the page under the words */
  .hero[data-cena="feixe"] .hero-arte { bottom: auto; height: 100svh; -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent); }
  html[data-hero="cena"] .hero[data-cena="feixe"] .hero-texto { max-width: none; }
  html[data-hero="cena"] .hero[data-cena="feixe"]::before { background: linear-gradient(to top, var(--fundo) 0%, color-mix(in srgb, var(--fundo) 88%, transparent) 46%, transparent 62%); }
}

/* the house logo keeps the house face (Fraunces): IM Fell is wider and squeezed the bar on a phone */
.barra-logo { font-family: var(--fonte-texto); }
/* under 430 px the chapter pill had no room and slid under the percentage; Contents opens the same index */
@media (max-width: 430px) { html[data-barra="faixa"] .barra-capitulo { display: none; } }

/* ---------- SPOILER at the gate ---------- */
.portao { max-width: calc(var(--coluna) + 2 * var(--margem)); margin: 0 auto; padding: 3.5rem var(--margem) 0; }
.portao .spoiler {
  display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1.1rem; align-items: start;
  padding: 1.3rem 1.5rem; border-radius: var(--raio); border: 1px solid color-mix(in srgb, var(--acento-2) 45%, transparent);
  background: color-mix(in srgb, var(--acento-2) 7%, var(--fundo)); color: var(--texto); font-size: var(--t-sm); line-height: 1.65;
}
.portao .spoiler::before {
  content: ''; grid-row: 1 / span 2; width: 18px; height: 46px; margin-top: 0.2rem; background: var(--acento-2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 46'%3E%3Cpath d='M5 46 L6.5 9 L4 9 L4 5 L6 5 L6 2 L8 2 L8 5 L10 5 L10 2 L12 2 L12 5 L14 5 L14 9 L11.5 9 L13 46 Z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 46'%3E%3Cpath d='M5 46 L6.5 9 L4 9 L4 5 L6 5 L6 2 L8 2 L8 5 L10 5 L10 2 L12 2 L12 5 L14 5 L14 9 L11.5 9 L13 46 Z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
}
.portao .spoiler strong { color: var(--titulo); font-weight: 600; }
.portao .spoiler em { color: var(--titulo); }

/* ---------- CONTENTS as a descent: the plumb line runs from the desert to the stars ---------- */
.descida { max-width: calc(var(--coluna) + 2 * var(--margem)); margin: 0 auto; padding: 3rem var(--margem) 1rem; }
.descida-rotulo { font-size: var(--t-xs); letter-spacing: 0.3em; text-transform: uppercase; color: var(--suave); }
.descida-titulo { margin-top: 0.4rem; font-family: var(--fonte-titulo); font-style: italic; font-size: var(--t-xl); }
.descida-lista { list-style: none; position: relative; margin-top: 1.6rem; padding-left: 2.2rem; }
.descida-lista::before {
  content: ''; position: absolute; left: 0.55rem; top: 0.6rem; bottom: 0.9rem; width: 1px;
  /* the color descends section by section: one stop per theme, written by build_feixe.py into #temas-feixe */
  background: var(--modo-1a);
}
.descida-lista::after { content: '\2726'; position: absolute; left: 0.2rem; bottom: -0.35rem; font-size: 0.9rem; line-height: 1; color: var(--modo-4a); }
.descida-item { position: relative; }
.descida-item::before {
  content: ''; position: absolute; left: -1.88rem; top: 0.95rem; width: 7px; height: 7px; border-radius: 50%;
  background: var(--fundo); border: 1px solid var(--cor-ponto, var(--modo-1a));
}
.descida-item[data-tema] { --cor-ponto: var(--tom); }
.descida-link { display: grid; grid-template-columns: 2.6rem 1fr; align-items: baseline; gap: 0.6rem; min-height: 44px; padding: 0.45rem 0; text-decoration: none; color: var(--texto); border-bottom: 1px solid var(--linha); }
a.descida-link:hover .descida-nome { color: var(--titulo); text-decoration: underline; text-decoration-color: var(--acento); text-underline-offset: 3px; }
.descida-num { font-family: var(--fonte-mono); font-size: var(--t-xs); letter-spacing: 0.08em; color: var(--suave); }
.descida-nome { font-family: var(--fonte-titulo); font-size: var(--t-lg); line-height: 1.25; }
.descida-item.is-interludio .descida-nome { font-style: italic; }
.descida-item.is-ausente .descida-link { color: var(--fraco); }
.descida-nota { margin-top: 1.4rem; font-size: var(--t-xs); letter-spacing: 0.06em; color: var(--suave); }

/* ---------- THE OPENING: a chapter without a number ---------- */
.capitulo-livre {
  display: grid; grid-template-columns: minmax(var(--margem), 1fr) minmax(0, var(--coluna)) minmax(var(--margem), 1fr);
  padding: 4.5rem 0 3rem;
}
.capitulo-livre > * { grid-column: 2; }
.capitulo-livre > * + * { margin-top: 1.6rem; }
.capitulo-livre .capitulo-titulo { font-style: italic; font-size: var(--t-2xl); }
/* the first sentence of the saga, in the gold of the low sun, in the Opening and again in the Closing */
.epigrafe { margin-top: 2.2rem; font-style: italic; font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.3rem); line-height: 1.2; }

/* the numeral of IM Fell is a thin outline: it reads as a carving in the Tower's stone */
/* the carved numeral is Roman, like the seven books (data-numeral, written by build_feixe.py) */
html[data-capitulo="numeral-vazado"] .capitulo-numeral { font-weight: 400; letter-spacing: 0.04em; -webkit-text-stroke: 1px color-mix(in srgb, var(--tom, var(--m1)) var(--numeral-k, 43.4%), transparent); opacity: 1; }   /* strength per theme, proven 3:1 by build_feixe.py */

/* ---------- EACH CHAPTER IN ITS OWN THEME (sub-variations of the same descent) ----------
   The 17 themes live in build_feixe.py (TEMAS) and arrive as <style id="temas-feixe">: --tom, --tom-b,
   the text colors already proven AA (--cor-titulo, --cor-soco, --cor-coda), --face, --estilo and --orn.
   body[data-modo-ativo] takes each section's --m1, --m2 and --fundo, and the Pollen follows them.
   The body text never changes: Fraunces in --texto, so reading stays the same from desert to stars. */
/* the theme face is switched on near the screen (feixe.js marks .perto), so each IM Fell cut downloads
   when the reader approaches its chapter; without JS every section has its face from the start */
[data-tema].perto, html:not(.js) [data-tema] { --face: var(--face-tema); }
.capitulo-titulo { color: var(--cor-titulo, var(--titulo)); font-family: var(--face, var(--fonte-titulo)); }
html[data-capitulo="numeral-vazado"] .capitulo-titulo { font-style: var(--estilo, italic); text-shadow: 0 0 34px color-mix(in srgb, var(--tom, var(--m1)) 45%, transparent); }
.epigrafe { color: var(--acento); font-family: var(--face, var(--fonte-titulo)); }
.soco { color: var(--cor-soco, var(--titulo)); font-family: var(--face, var(--fonte-titulo)); }
html[data-soco="martelo"] .soco::after { background: var(--tom, var(--acento)); }
.coda { color: var(--cor-coda, var(--titulo)); font-family: var(--face, var(--fonte-titulo)); }
/* the small mark of each chapter, above its label, in the theme's second color */
.capitulo[data-tema] .capitulo-rotulo::before {
  content: ''; display: block; width: 64px; height: 24px; margin-bottom: 0.7rem;
  background: var(--tom-b); -webkit-mask: var(--orn) center left / contain no-repeat; mask: var(--orn) center left / contain no-repeat;
}
.capitulo.is-interludio .capitulo-rotulo::before { display: none; }
/* the English SC cut is small caps already: letter-spacing opens it a little */
.capitulo[data-tema="cap-02"] .capitulo-titulo, .capitulo[data-tema="cap-06"] .capitulo-titulo,
.capitulo[data-tema="cap-09"] .capitulo-titulo, .capitulo[data-tema="cap-14"] .capitulo-titulo { letter-spacing: 0.02em; }

/* ---------- THE BEAM IN THE MARGINS: the veil of the house stays under the reading column only ---------- */
@media (min-width: 1100px) {
  html[data-fundo="cena"] .fundo-camada {
    background: linear-gradient(90deg, transparent calc(50% - var(--coluna) / 2 - 10rem), color-mix(in srgb, var(--fundo) 88%, transparent) calc(50% - var(--coluna) / 2 - 3rem), color-mix(in srgb, var(--fundo) 88%, transparent) calc(50% + var(--coluna) / 2 + 3rem), transparent calc(50% + var(--coluna) / 2 + 10rem));
  }
}
@media (max-width: 1099px) {
  html[data-fundo="cena"] .fundo-camada { background: color-mix(in srgb, var(--fundo) 88%, transparent); }
}

/* ---------- INTERLUDES: inside a church arch (chapters 6 and 9) ---------- */
.capitulo.is-interludio .capitulo-cabeca { padding-top: 7.5rem; text-align: center; }
.capitulo.is-interludio .capitulo-cabeca::before {
  content: ''; position: absolute; left: 50%; top: 0; width: 120px; height: 108px; transform: translateX(-50%);
  background: color-mix(in srgb, var(--tom-b, var(--m2)) 75%, var(--titulo));   /* the arch is the interludes' ornament: theme color b */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 108'%3E%3Cpath d='M8 108 V58 Q8 14 60 2 Q112 14 112 58 V108 M24 108 V60 Q24 26 60 16 Q96 26 96 60 V108 M60 16 V108' stroke='black' stroke-width='1.4' fill='none'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 108'%3E%3Cpath d='M8 108 V58 Q8 14 60 2 Q112 14 112 58 V108 M24 108 V60 Q24 26 60 16 Q96 26 96 60 V108 M60 16 V108' stroke='black' stroke-width='1.4' fill='none'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.85;
}
html[data-capitulo="numeral-vazado"] .capitulo.is-interludio .capitulo-numeral { display: none; }
.capitulo.is-interludio .capitulo-rotulo { color: color-mix(in srgb, var(--m2) 55%, var(--titulo)); }

/* ---------- APHORISMS: a plumb line in place of the star, pointing down ---------- */
html[data-coda="estrela"] .coda::before {
  content: ''; width: 9px; height: 2.6rem; margin: 0 auto 0.9rem;
  background: linear-gradient(180deg, transparent, var(--tom, var(--m1)) 70%);
  -webkit-mask: linear-gradient(#000, #000) center top / 1px calc(100% - 8px) no-repeat, radial-gradient(circle at 50% calc(100% - 4px), #000 3.5px, transparent 4px);
  mask: linear-gradient(#000, #000) center top / 1px calc(100% - 8px) no-repeat, radial-gradient(circle at 50% calc(100% - 4px), #000 3.5px, transparent 4px);
}
.coda { max-width: 32ch; }

/* the chapter painting spans the whole width: the house 2:1 box stopped at 78vh and left a strip on wide
   short screens (1404 of 1440 px); here the height is capped and the painting is cropped by cover */
@media (min-width: 861px) {
  html[data-pranchas="larga"] .prancha { width: 100%; aspect-ratio: auto; height: min(50vw, 78vh); max-height: none; }
  html[data-pranchas="larga"] .prancha img { width: 100%; height: 100%; object-fit: cover; }
}

/* the two Browning stanzas are verse, not a pull quote: smaller, kept in their lines */
html[data-citacao="destaque"] .citacao p { font-size: var(--t-lg); line-height: 1.45; }

/* ---------- THE CLOSING, under the stars ---------- */
.fecho.fecho-ensaio { max-width: none; padding: 0 0 4rem; gap: 0; }
.fecho-ensaio .capitulo-livre { width: 100%; text-align: left; padding-top: 3rem; }
.fecho-ensaio .capitulo-livre .capitulo-cabeca { text-align: center; }

/* the crack: two walls of basalt share one jagged edge, lit from the far side; they part once */
.fresta { position: relative; width: 100%; height: clamp(15rem, 52vh, 34rem); overflow: hidden; isolation: isolate; -webkit-mask-image: linear-gradient(#000 72%, transparent); mask-image: linear-gradient(#000 72%, transparent); }
/* the sky seen through the crack: its own stars (build_feixe.py writes them as box-shadows), over the night */
.fresta-ceu { position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse 60% 90% at 50% 30%, #16204a 0%, #0a0f26 45%, #05070f 100%); }
.fresta-ceu::before { content: ''; position: absolute; left: 0; top: 0; width: 1px; height: 1px; border-radius: 50%; background: transparent; box-shadow: var(--estrelas-fresta); }
.fresta-ceu::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(170, 190, 240, 0.12) 46%, rgba(239, 227, 184, 0.10) 52%, transparent 66%); }
.fresta svg { position: absolute; inset: 0; width: 100%; height: 100%; transition: transform 2.6s cubic-bezier(0.22, 0.61, 0.36, 1); }
/* basalt: warmer and lighter than the page, so the walls read as rock against the night */
.fresta-rocha { fill: #2a1f1b; }
.fresta-esquerda .fresta-rocha { fill: url(#fresta-pedra-e); }
.fresta-direita .fresta-rocha { fill: url(#fresta-pedra-d); }
.fresta-luz { fill: none; stroke: var(--modo-4a); stroke-width: 1.6; opacity: 0.85; filter: drop-shadow(0 0 5px var(--modo-4a)); }
.fresta.is-aberta .fresta-esquerda { transform: translateX(-34%); }
.fresta.is-aberta .fresta-direita { transform: translateX(34%); }
html:not(.js) .fresta-esquerda { transform: translateX(-34%); }
html:not(.js) .fresta-direita { transform: translateX(34%); }

/* the night: a fixed sky behind main (the veil under the column still keeps the reading) */
.ceu-noturno {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity 1.6s ease;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, rgba(12, 17, 40, 0.86) 0%, rgba(5, 7, 18, 0.84) 55%, rgba(4, 5, 12, 0.88) 100%);
}
body.ceu-aberto .ceu-noturno { opacity: 1; }
.ceu-tela { display: block; width: 100%; height: 100%; }

/* the last sentence, written letter by letter once (feixe.js); whole for screen readers and without JS */
.fecho-ensaio .fecho-frase { margin-top: 3rem; max-width: 20ch; font-size: clamp(2.4rem, 1.4rem + 3.4vw, 4.6rem); line-height: 1.1; text-align: center; color: var(--titulo); text-shadow: 0 0 44px color-mix(in srgb, var(--modo-4a) 40%, transparent); }
.fecho-ensaio .fecho-frase::before { content: '\2726'; display: block; margin-bottom: 1rem; font-size: 1.1rem; color: var(--modo-4a); text-shadow: none; }
.fecho-frase.a-escrever .letra { opacity: 0; }
.fecho-frase.a-escrever.is-escrita .letra { opacity: 1; transition: opacity 0.55s ease; transition-delay: calc(var(--i) * 62ms); }
.fecho-ensaio .botao { margin-top: 2.2rem; }

/* ---------- THE AUTHOR, in a window of the Tower (house text, this essay's night) ---------- */
.bio.bio-feixe { padding-top: 3rem; }
.bio-feixe .bio-cartao {
  grid-template-columns: 1fr; justify-items: center; text-align: center; max-width: 720px; margin: 0 auto; padding: 2.8rem 2rem 2.4rem;
  background: linear-gradient(rgba(6, 8, 20, 0.86), rgba(6, 8, 20, 0.86)) padding-box, linear-gradient(160deg, var(--modo-4a), var(--modo-4b) 50%, var(--acento-2)) border-box;
  border: 1px solid transparent; border-radius: var(--raio-grande);
}
.bio-janela { padding: 46px 12px 12px; border: 1px solid color-mix(in srgb, var(--modo-4a) 55%, transparent); border-radius: 50% 50% 14px 14px / 70px 70px 14px 14px; box-shadow: 0 0 46px color-mix(in srgb, var(--modo-4a) 16%, transparent), inset 0 0 22px color-mix(in srgb, var(--modo-4a) 10%, transparent); }
.bio-feixe .bio-foto { border-radius: 12px; }
.bio-feixe .bio-rotulo { margin-top: 1.5rem; color: color-mix(in srgb, var(--acento-2) 72%, var(--titulo)); letter-spacing: 0.34em; }
.bio-prumo { position: relative; display: block; width: 1px; height: 2.4rem; margin: 0.4rem auto 1.2rem; background: linear-gradient(var(--acento-2), var(--modo-4a)); }
.bio-prumo::after { content: '\2726'; position: absolute; left: 50%; bottom: -1rem; transform: translateX(-50%); font-size: 0.8rem; line-height: 1; color: var(--modo-4a); }
.bio-feixe .bio-nome { font-size: clamp(2.4rem, 1.5rem + 2.8vw, 3.8rem); line-height: 1.05; color: var(--titulo); background: linear-gradient(180deg, var(--titulo) 20%, var(--modo-4a)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.bio-feixe .bio-texto, .bio-feixe .bio-pub { max-width: 52ch; margin-inline: auto; }

/* the figures' styles live in figuras/ (_kit.css and fig-NN.css), joined into figuras.css by build_feixe.py */

/* ---------- MOCK note ---------- */
.mock-faixa { max-width: calc(var(--coluna) + 2 * var(--margem)); margin: 0 auto; padding: 0.7rem var(--margem); font-family: var(--fonte-mono); font-size: var(--t-xs); color: var(--suave); }

@media (prefers-reduced-transparency: reduce) {
  .portao .spoiler { background: var(--painel); }
}
@media print {
  .hero-figura, .fresta, .ceu-noturno, .bio-prumo { display: none !important; }
  .fecho-frase .letra { opacity: 1 !important; }
  .bio-feixe .bio-cartao { background: none; border: 1px solid #000; }
  .bio-feixe .bio-nome { background: none; -webkit-text-fill-color: #000; color: #000; }
  .bio-janela { border-color: #000; box-shadow: none; }
  .descida-lista::before, .descida-item::before, .descida-lista::after, .capitulo.is-interludio .capitulo-cabeca::before, html[data-coda="estrela"] .coda::before { display: none !important; }
  .portao .spoiler { border: 1px solid #000; background: none; color: #000; }
  .descida-link { color: #000; border-color: #999; }
  .fecho-ensaio .fecho-frase { text-shadow: none; color: #000; }
}
