/* Bestiário de Eivor, Mago da Corte de Windhelm: estilo do livro */

:root {
  color-scheme: dark;
  /* tintas (canais RGB, para variar a carga de tinta palavra a palavra) */
  --tinta: 34 22 12;
  --rubrica: 112 32 16;
  /* materiais */
  --papel: #b3a27c;
  --couro: #2c1811;
  /* interface, como os avisos de tecla de Skyrim */
  --ui: #ebe5d5;
  --ui-fraco: rgba(235, 229, 213, .62);
  --ui-linha: rgba(235, 229, 213, .26);
  --ui-fundo: #15120f;
  /* letras */
  --f-titulo: 'Meddon', 'Segoe Script', 'Apple Chancery', cursive;
  --f-mao: 'Homemade Apple', 'Segoe Script', 'Bradley Hand', cursive;
  --f-runa: 'Noto Sans Runic', 'Segoe UI Historic', serif;
  --f-ui: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ui-fundo);
  color: var(--ui);
  font-family: var(--f-ui);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- a sala escura ao fundo ---------- */
#cena {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: manipulation;
  background:
    radial-gradient(ellipse 55% 45% at 50% 46%, rgba(120, 106, 88, .22), transparent 72%),
    radial-gradient(ellipse 75% 42% at 50% 110%, rgba(86, 60, 38, .55), transparent 70%),
    linear-gradient(180deg, #1c1d1f 0%, #26241f 52%, #1b1612 100%);
}
.fundo { position: absolute; pointer-events: none; }
.fundo.coluna { top: -10%; bottom: -10%; width: 15vw; background: linear-gradient(90deg, #0c0c0d, #1d1c1a 45%, #0d0d0e); filter: blur(30px); opacity: .85; }
.fundo.c1 { left: -4vw; }
.fundo.c2 { right: -5vw; width: 19vw; }
.fundo.chama { left: 2%; bottom: 0; width: 42vw; height: 42vw; background: radial-gradient(circle, rgba(255, 150, 60, .17), rgba(255, 120, 40, .05) 45%, transparent 70%); animation: chama 5.5s infinite; }
.fundo.bruma { inset: 0; background: radial-gradient(ellipse 120% 70% at 50% 125%, rgba(160, 172, 188, .08), transparent 60%); }
.fundo.vinheta { inset: 0; background: radial-gradient(ellipse 85% 80% at 50% 50%, transparent 52%, rgba(0, 0, 0, .72)); }
@keyframes chama {
  0%, 100% { opacity: .85; } 13% { opacity: .62; } 27% { opacity: .95; } 41% { opacity: .7; }
  58% { opacity: 1; } 72% { opacity: .76; } 86% { opacity: .92; }
}

/* ---------- palco e livro (medidas de desenho: página 540 × 700) ---------- */
#palco {
  position: absolute;
  left: 50%;
  top: var(--cy, 50%);
  width: 1108px;
  height: 728px;
  transform: translate(-50%, -50%) scale(var(--s, 1));
}
#livro {
  position: absolute;
  inset: 0;
  transition: transform .85s cubic-bezier(.35, .1, .2, 1);
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
#livro.arrastando { cursor: grabbing; }

.sombra-livro {
  position: absolute;
  top: 0;
  width: 554px;
  height: 728px;
  border-radius: 4px;
  box-shadow: 0 34px 60px 6px rgba(0, 0, 0, .62), 0 8px 18px rgba(0, 0, 0, .5);
  transition: opacity .5s;
  pointer-events: none;
}
.sombra-livro.esq { left: 0; }
.sombra-livro.dir { left: 554px; }

/* folhas soltas sob a pilha: só as beiradas rasgadas aparecem */
.enchimento { position: absolute; top: 14px; width: 540px; height: 700px; z-index: 15; opacity: 0; transition: opacity .25s; pointer-events: none; }
.enchimento.on { opacity: 1; }
.enchimento.dir { left: 554px; }
.enchimento.esq { left: 14px; }
.enchimento .papel { filter: brightness(.8) saturate(.9); }

.sombra-virada { position: absolute; top: 14px; width: 540px; height: 700px; z-index: 999; opacity: 0; pointer-events: none; }
.sombra-virada.dir { left: 554px; }
.sombra-virada.esq { left: 14px; }

.folha {
  position: absolute;
  left: 554px;
  top: 14px;
  width: 540px;
  height: 700px;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}
.folha.capa { top: 0; width: 554px; height: 728px; }
.folha.movendo { will-change: transform; }
.face {
  position: absolute;
  inset: 0;
  z-index: 0;
  isolation: isolate;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face.frente { transform: rotateY(0deg); }
.face.verso { transform: rotateY(180deg); }
.sombra-folha { position: absolute; inset: 0; opacity: 0; pointer-events: none; z-index: 5; }
.face.direita .sombra-folha { background: linear-gradient(90deg, rgba(24, 13, 4, .1), rgba(24, 13, 4, .5)); }
.face.esquerda .sombra-folha { background: linear-gradient(270deg, rgba(24, 13, 4, .1), rgba(24, 13, 4, .5)); }

/* ---------- papel ---------- */
.papel { position: absolute; inset: 0; background: var(--papel) 0 0 / 100% 100% no-repeat; }
.texturas .papel { background-color: transparent; }
.direita .papel.v0 { background-image: var(--pd0); }
.direita .papel.v1 { background-image: var(--pd1); }
.direita .papel.v2 { background-image: var(--pd2); }
.esquerda .papel.v0 { background-image: var(--pe0); }
.esquerda .papel.v1 { background-image: var(--pe1); }
.esquerda .papel.v2 { background-image: var(--pe2); }

/* sombra da lombada: o papel afunda na costura */
.pagina::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.pagina.direita::after { background: linear-gradient(90deg, rgba(26, 14, 5, .66) 0, rgba(26, 14, 5, .3) 2.4%, rgba(26, 14, 5, .09) 7%, transparent 14%); }
.pagina.esquerda::after { background: linear-gradient(270deg, rgba(26, 14, 5, .66) 0, rgba(26, 14, 5, .3) 2.4%, rgba(26, 14, 5, .09) 7%, transparent 14%); }

/* ---------- escrita à mão ---------- */
.conteudo {
  position: absolute;
  top: 58px;
  bottom: 60px;
  left: 64px;
  right: 50px;
  overflow: hidden;
  font-family: var(--f-mao);
  font-size: 17px;
  line-height: 1.78;
  --c: var(--tinta);
  color: rgb(var(--c));
  filter: url(#tinta);
  z-index: 2;
}
.esquerda .conteudo { left: 50px; right: 64px; }
.conteudo p { margin: 0; }
.pal { display: inline-block; color: rgb(var(--c) / var(--o, 1)); transform: translateY(var(--y, 0)) rotate(var(--r, 0)); }

.folio {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--f-mao);
  font-size: 15px;
  color: rgb(var(--tinta) / .75);
  filter: url(#tinta);
  z-index: 2;
}

.t-grande, .t-medio, .t-pagina, .t-sobre, .t-nome, .t-legenda {
  font-family: var(--f-titulo);
  font-weight: 400;
  text-align: center;
  margin: 0;
  text-wrap: balance;
}
.t-grande { font-size: 3.9em; line-height: 1.25; }
.t-medio { font-size: 2.1em; line-height: 1.3; }
.t-pagina { font-size: 2.2em; line-height: 1.35; }
.t-sobre { font-size: 1.55em; line-height: 1.3; }
.t-nome { font-size: 3.3em; line-height: 1.15; }
.t-legenda { font-size: 2.3em; line-height: 1.2; white-space: nowrap; }
.t-legenda.longa { font-size: 1.75em; }

.runas { font-family: var(--f-runa); text-align: center; letter-spacing: .5em; text-indent: .5em; font-size: .95em; opacity: .7; }
.rubrica, dt, .capitular { --c: var(--rubrica); }

.floreio { display: block; width: 12em; height: 1.2em; margin: .55em auto; fill: rgb(var(--tinta) / .82); }
.borrao { position: absolute; fill: rgb(var(--tinta) / .8); pointer-events: none; }

.capitular {
  float: left;
  font-family: var(--f-titulo);
  font-size: 4.1em;
  line-height: .95;
  margin: .02em .1em 0 -.05em;
  color: rgb(var(--c));
}

dl { margin: 0; }
dt { display: inline; font-family: var(--f-titulo); font-size: 1.32em; line-height: 1; margin-right: .25em; }
dt::after { content: ':'; }
dd { display: inline; margin: 0; }
.campos > div { margin: 0 0 .22em; }
.aviso {
  display: block;
  margin: .15em 0 .2em .3em;
  padding-left: .7em;
  border-left: 2px solid rgb(var(--rubrica) / .7);
  font-size: .86em;
  line-height: 1.7;
  --c: var(--rubrica);
}

/* página de rosto */
.rosto { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; padding: 1.4em 0 .6em; }
.rosto .topo { display: flex; flex-direction: column; align-items: center; }
.pata-tinta { width: 6.4em; height: auto; fill: rgb(var(--tinta) / .8); }
.rosto .livro-n { font-size: 1.25em; }
.rosto .autoria { font-size: .9em; max-width: 17em; opacity: .9; }
.rosto .subtitulo { font-size: 1.05em; margin-top: .3em !important; }

/* ao leitor */
.legenda { margin: .5em 0 .7em; }
.legenda > div { margin: 0 0 .1em; }
.legenda dt { font-size: 1.2em; }
.fecho-texto { text-align: center; margin-top: .4em !important; }
.assinatura { font-family: var(--f-titulo); font-size: 2em; line-height: 1.2; text-align: right; margin: .1em .4em 0 0 !important; transform: rotate(-3deg); }

/* sumário */
.indice { list-style: none; margin: .6em 0 0; padding: 0; }
.indice li { margin: 0 0 .35em; }
.indice a { display: flex; align-items: baseline; gap: .35em; color: inherit; text-decoration: none; cursor: pointer; border-radius: 2px; }
.indice a:hover, .indice a:focus-visible { --c: var(--rubrica); outline: none; }
.indice a:focus-visible .nm { text-decoration: underline; }
.indice .num { font-family: var(--f-titulo); font-size: 1.3em; --c: var(--rubrica); color: rgb(var(--c)); min-width: 1.6em; }
.indice .pontos { flex: 1; border-bottom: 2px dotted rgb(var(--tinta) / .45); transform: translateY(-.35em); min-width: 1em; }
.indice .cap-titulo { font-family: var(--f-titulo); font-size: 1.35em; margin: .7em 0 .25em; text-align: center; }
.obs { margin-top: 1.4em !important; text-align: center; font-size: .9em; opacity: .85; }

/* retrato */
.pg-retrato { display: flex; flex-direction: column; align-items: center; }
.retrato { margin: 0; flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; width: 100%; }
.retrato img { display: block; flex: 0 1 auto; min-height: 0; width: 100%; height: auto; max-height: 468px; object-fit: contain; pointer-events: none; }
.retrato .t-legenda { flex: none; margin-top: .1em; }
.sem-retrato { margin: 5em 0 2em; font-size: 1.1em; opacity: .7; }
.nota-margem {
  position: relative;
  flex: none;
  margin-top: auto !important;
  margin-bottom: 6px !important;
  padding-top: .6em;
  align-self: flex-start;
  width: 72%;
  font-size: .9em;
  line-height: 1.65;
  transform: rotate(-2.5deg);
  transform-origin: 0 100%;
}
.seta { position: absolute; right: -3.2em; top: -1.9em; width: 2.4em; height: 2.6em; fill: none; stroke: rgb(var(--tinta) / .85); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* notas e fim */
.pautas { position: absolute; left: 0; right: 0; top: 7.4em; bottom: .5em; background: repeating-linear-gradient(to bottom, transparent 0 29px, rgba(70, 46, 22, .2) 29px 30px); }
.fim { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .2em; }

/* ---------- capa de couro ---------- */
.capa-face { background: var(--couro) 0 0 / 100% 100% no-repeat; border-radius: 3px 7px 7px 3px; }
.capa-face.esquerda { border-radius: 7px 3px 3px 7px; }
.texturas .capa-face { background-image: var(--tx-couro); }
.arte { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.arte .fio-f { fill: none; stroke: #140a06; stroke-width: 6.4; stroke-opacity: .92; }
.arte .fio { fill: none; stroke: url(#ouro); stroke-width: 3; }
.arte .regra { fill: none; stroke: url(#ouro); stroke-width: 1.6; }
.arte .ouro { fill: url(#ouro); }
.arte .dourado { filter: url(#desgaste); }
.arte .cego { fill: none; stroke: rgba(0, 0, 0, .55); stroke-width: 1.5; }
.arte .cego-luz { fill: none; stroke: rgba(255, 214, 170, .09); stroke-width: 1; }
.arte .relevo { fill: url(#relevo); }
.arte .ferro { fill: url(#ferro); stroke: #151210; stroke-width: 1.2; }
.arte .ferro-dobra { fill: rgba(255, 255, 255, .08); }
.arte .ferro-linha { fill: none; stroke: rgba(0, 0, 0, .55); stroke-width: 1.2; }
.arte .ferro-luz { fill: none; stroke: rgba(255, 255, 255, .14); stroke-width: .8; }
.arte .rebite { fill: url(#rebite); stroke: #121010; stroke-width: .8; }
.arte .ferrugem { fill: rgba(128, 60, 20, .38); }
.arte .runas-anel, .arte .runas-base { font-family: var(--f-runa); fill: url(#ouro); }
.arte .runas-anel { font-size: 15px; }
.arte .runas-base { font-size: 19px; letter-spacing: 7px; }
.arte .arranhao { fill: none; stroke: #9a6a50; stroke-width: 2.2; stroke-linecap: round; opacity: .6; }
.arte .arranhao-s { fill: none; stroke: #0d0503; stroke-width: 1.5; stroke-linecap: round; opacity: .75; }
.arte .correia { fill: #3a2118; stroke: #120804; stroke-width: 1.2; }
.arte .costura { fill: none; stroke: rgba(200, 170, 130, .45); stroke-width: 1; stroke-dasharray: 3 3; }
.arte .dobradica { fill: rgba(0, 0, 0, .45); }
.arte .dobradica-luz { fill: rgba(255, 210, 170, .07); }

/* etiqueta de papel colada na capa, escrita à mão */
.etiqueta {
  position: absolute;
  left: 116px;
  top: 100px;
  width: 348px;
  height: 188px;
  transform: rotate(-1.3deg);
  filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, .75)) drop-shadow(0 0 7px rgba(0, 0, 0, .35));
}
.etiqueta .papel {
  background-size: 540px 700px;
  background-position: -96px -250px;
  box-shadow: inset 0 0 22px rgba(70, 40, 14, .55);
}
.etiqueta .conteudo { inset: 12px 18px 10px; text-align: center; overflow: visible; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.etiqueta .t-grande { font-size: 2.75em; line-height: 1.2; }
.etiqueta .t-medio { font-size: 1.75em; line-height: 1.15; }
.etiqueta .subtitulo { font-size: .92em; margin-top: .35em !important; }
.etiqueta .livro-n { font-size: .78em; margin-top: .3em !important; opacity: .85; }

/* contracapas por dentro: couro dobrado e papel colado */
.colado { position: absolute; top: 10px; bottom: 10px; overflow: hidden; box-shadow: 0 0 5px rgba(0, 0, 0, .45); }
.guarda.direita .colado { left: 0; right: 10px; }
.guarda.esquerda .colado { left: 10px; right: 0; }
.exlibris { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .5em; }
.exlibris .t-medio { font-size: 2.3em; }
.exlibris .pequeno { font-size: .88em; max-width: 18em; opacity: .9; }
.exlibris .runas { font-size: 1.8em; letter-spacing: 0; text-indent: 0; margin-top: .3em; }

/* livro fechado: a grossura do miolo e da contracapa aparece de lado */
.fechado-frente .capa-1 .face.frente {
  box-shadow: 1px 1px 0 #1c0f0a, 2px 2px 0 #c9b58d, 3px 3px 0 #a18a62, 4px 4px 0 #c6b088, 5px 5px 0 #9a845d, 6px 6px 0 #c0aa80, 8px 8px 0 #1d0f09, 9px 9px 0 #140a06, 12px 22px 34px rgba(0, 0, 0, .55);
}
.fechado-verso .capa-2 .face.verso {
  box-shadow: -1px 1px 0 #1c0f0a, -2px 2px 0 #c9b58d, -3px 3px 0 #a18a62, -4px 4px 0 #c6b088, -5px 5px 0 #9a845d, -6px 6px 0 #c0aa80, -8px 8px 0 #1d0f09, -9px 9px 0 #140a06, -12px 22px 34px rgba(0, 0, 0, .55);
}

/* ---------- barra de comandos, como em Skyrim ---------- */
.dicas {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 4px 22px;
  padding: 16px max(16px, 3vw) calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, rgba(0, 0, 0, .75), rgba(0, 0, 0, .35) 65%, transparent);
}
.dicas::before {
  content: '';
  position: absolute;
  left: max(16px, 3vw);
  right: max(16px, 3vw);
  top: 8px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ui-linha) 12%, var(--ui-linha) 88%, transparent);
}
.aviso-abrir {
  margin-right: auto;
  font: 500 16px/1 var(--f-ui);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ui-fraco);
  text-shadow: 0 1px 2px #000;
  transition: opacity .6s;
  animation: pulso 2.8s ease-in-out infinite;
}
.aviso-abrir.oculto { opacity: 0; animation: none; }
@keyframes pulso { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.dica {
  appearance: none;
  background: none;
  border: 0;
  color: var(--ui);
  font: 500 17px/1 var(--f-ui);
  letter-spacing: .07em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 2px;
  min-height: 40px;
  cursor: pointer;
  text-shadow: 0 1px 2px #000;
  opacity: .88;
  transition: opacity .2s;
}
.dica:hover { opacity: 1; }
.dica:disabled { opacity: .3; cursor: default; }
.dica:focus-visible { outline: 1px solid var(--ui); outline-offset: 3px; }
.dica[aria-pressed="false"] #rotulo-som { text-decoration: line-through; }
.tecla {
  display: inline-grid;
  place-items: center;
  min-width: 27px;
  height: 25px;
  padding: 0 6px;
  border: 1.5px solid var(--ui);
  border-radius: 4px;
  font: 600 14px/1 var(--f-ui);
  letter-spacing: 0;
  box-shadow: 0 1px 3px #000, inset 0 0 6px rgba(0, 0, 0, .5);
}

@media (max-width: 720px) {
  .dicas { justify-content: center; gap: 0 14px; padding-top: 12px; }
  .aviso-abrir { flex-basis: 100%; text-align: center; margin: 0 0 4px; font-size: 14px; }
  .dica { font-size: 15px; gap: 6px; }
}
@media (hover: none) {
  .tecla.letra { display: none; }
}
@media (max-width: 480px) {
  .tecla.letra, #bt-fechar { display: none; }
  .dicas { gap: 0 16px; }
  .dica { font-size: 14px; letter-spacing: .05em; }
}
@media (prefers-reduced-motion: reduce) {
  #livro { transition-duration: .01s; }
  .fundo.chama, .aviso-abrir { animation: none; }
}
