/* ================================================================
   ÁLBUM SANTO TOMÁS — Sistema visual
   Las variables permiten personalizar la identidad desde un solo lugar.
   ================================================================ */
:root {
  --primary: #3157d5;
  --primary-dark: #1e3b9b;
  --accent: #f3bb3b;
  --navy: #101a30;
  --stage: #252831;
  --paper: #fff;
  --text: #17213a;
  --muted: #778097;
  --radius: 22px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--navy);
  -webkit-font-smoothing: antialiased;
}
button { color: inherit; font: inherit; }
button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 75%, white); outline-offset: 3px; }

/* Pantalla de presentación */
.welcome {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 15%, rgba(70, 105, 216, .22), transparent 36%),
    linear-gradient(145deg, #f9faff 0%, #eef2fb 100%);
  transition: opacity .75s var(--ease), visibility .75s;
}
.welcome::before {
  position: absolute;
  inset: 24px;
  border: 1px solid rgba(49, 87, 213, .1);
  border-radius: 30px;
  content: "";
  pointer-events: none;
}
.welcome.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.welcome__card { position: relative; z-index: 1; text-align: center; animation: reveal 1s var(--ease) both; }
.welcome__glow { position: absolute; width: 360px; height: 360px; border-radius: 50%; filter: blur(5px); opacity: .22; }
.welcome__glow--one { top: -200px; right: -100px; background: var(--accent); }
.welcome__glow--two { bottom: -230px; left: -100px; background: var(--primary); }
.school-logo {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  margin: 0 auto 32px;
  border: 1px solid rgba(49, 87, 213, .13);
  border-radius: 30px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 20px 50px rgba(35, 55, 115, .12);
}
.school-logo img { width: 82px; height: 88px; object-fit: contain; }
.eyebrow { margin: 0 0 13px; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.welcome h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.35rem, 6vw, 4.65rem); font-weight: 500; letter-spacing: -.035em; line-height: .98; }
.welcome h1 span { color: var(--primary); }
.year { margin: 17px 0 35px; color: #8490a8; font-size: 1rem; font-weight: 700; letter-spacing: .45em; text-indent: .45em; }
.open-button {
  display: inline-flex;
  align-items: center;
  gap: 17px;
  min-height: 60px;
  padding: 0 24px 0 30px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 14px 30px rgba(49, 87, 213, .3);
  cursor: pointer;
  font-size: .83rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
  transition: transform .25s, box-shadow .25s;
}
.open-button:hover { transform: translateY(-3px); box-shadow: 0 19px 37px rgba(49, 87, 213, .36); }
.open-button svg { width: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; transition: transform .25s; }
.open-button:hover svg { transform: translateX(3px); }
.welcome__hint { position: absolute; bottom: 28px; margin: 0; color: #9299aa; font-family: Georgia, serif; font-size: .9rem; font-style: italic; }

/* Marco principal del visor */
.viewer { position: fixed; inset: 0; display: grid; grid-template-rows: 70px minmax(0, 1fr) auto; opacity: 0; visibility: hidden; background: var(--stage); transition: opacity .65s var(--ease), visibility .65s; }
.viewer.is-visible { opacity: 1; visibility: visible; }
.viewer__header { z-index: 4; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; color: white; background: rgba(18, 20, 27, .72); border-bottom: 1px solid rgba(255, 255, 255, .07); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 39px; height: 45px; padding: 3px; object-fit: contain; border-radius: 9px; background: white; }
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: .89rem; }
.brand span { color: #aeb4c2; font-size: .73rem; }
.text-button { display: flex; align-items: center; gap: 6px; padding: 9px 13px; border: 0; border-radius: 11px; color: #dfe2e9; background: transparent; cursor: pointer; font-size: .79rem; transition: color .2s, background .2s; }
.text-button:hover { color: white; background: rgba(255, 255, 255, .08); }
.text-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.book-stage { position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at center, #454954 0%, var(--stage) 55%, #1c1e25 100%); }
.book-stage::after { position: absolute; z-index: 0; bottom: 7%; left: 20%; width: 60%; height: 8%; border-radius: 50%; background: rgba(0, 0, 0, .4); filter: blur(25px); content: ""; }
.book-zoom { position: relative; z-index: 1; display: grid; place-items: center; transform: scale(1); transform-origin: center; transition: transform .28s var(--ease); will-change: transform; }
#book { opacity: 0; transition: opacity .45s; }
#book.is-ready { opacity: 1; }
.page { position: relative; overflow: hidden; background: #f3f1ec; box-shadow: inset 0 0 16px rgba(0, 0, 0, .06); }
.page canvas { display: block; width: 100%; height: 100%; background: white; }
.page__placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #a4a4a4; background: #f9f8f5; font-size: .75rem; }
.page.--left { border-right: 1px solid rgba(0, 0, 0, .12); }
.page.--right { border-left: 1px solid rgba(255, 255, 255, .8); }

/* Carga y mensajes */
.loader, .error-panel { position: absolute; z-index: 5; display: grid; justify-items: center; text-align: center; }
.loader.is-hidden { opacity: 0; visibility: hidden; transition: opacity .35s, visibility .35s; }
.loader p { margin: 18px 0 5px; color: white; font-size: .96rem; font-weight: 650; }
.loader small { color: #aeb2bd; }
.loader__spinner { position: relative; width: 54px; height: 54px; animation: rotate 1.2s linear infinite; }
.loader__spinner i { position: absolute; inset: 0; border: 3px solid transparent; border-top-color: var(--accent); border-radius: 50%; }
.loader__spinner i:nth-child(2) { inset: 8px; border-top-color: #6e8dfa; animation: rotate .8s linear infinite reverse; }
.loader__spinner i:nth-child(3) { inset: 18px; border: 0; background: white; opacity: .85; }
.error-panel { max-width: 390px; padding: 26px; border-radius: 20px; color: white; background: #30343e; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.error-panel[hidden] { display: none; }
.error-panel p { color: #c4c7cf; line-height: 1.55; }
.error-panel button { padding: 10px 16px; border: 0; border-radius: 10px; color: white; background: var(--primary); cursor: pointer; }

/* Controles flotantes inferiores */
.controls { z-index: 4; display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 72px; padding: 9px 18px calc(9px + var(--safe-bottom)); color: white; background: rgba(18, 20, 27, .85); border-top: 1px solid rgba(255, 255, 255, .07); backdrop-filter: blur(16px); }
.control { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 13px; color: #e9eaf0; background: transparent; cursor: pointer; transition: background .2s, transform .2s, opacity .2s; }
.control:hover:not(:disabled) { background: rgba(255, 255, 255, .1); transform: translateY(-1px); }
.control:disabled { opacity: .27; cursor: default; }
.control svg { width: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.page-indicator { min-width: 125px; text-align: center; color: #aeb2bd; font-size: .79rem; }
.page-indicator strong { color: white; font-size: .88rem; }
.controls__separator { width: 1px; height: 25px; margin: 0 8px; background: rgba(255, 255, 255, .13); }
.zoom-value { width: 44px; text-align: center; color: #b9bdc7; font-size: .7rem; font-variant-numeric: tabular-nums; }
.fullscreen-exit { display: none; }
.viewer:fullscreen .fullscreen-enter { display: none; }
.viewer:fullscreen .fullscreen-exit { display: block; }

@keyframes reveal { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes rotate { to { transform: rotate(360deg); } }

/* Una página en pantallas estrechas; doble página en pantallas amplias. */
@media (max-width: 700px) {
  .viewer { grid-template-rows: 58px minmax(0, 1fr) auto; }
  .viewer__header { padding: 0 12px; }
  .brand span { display: none; }
  .text-button span { display: none; }
  .controls { min-height: 62px; gap: 1px; padding-inline: 8px; }
  .control { width: 38px; height: 38px; border-radius: 11px; }
  .page-indicator { min-width: 102px; font-size: .7rem; }
  .controls__separator { margin: 0 3px; }
  .zoom-value { display: none; }
  .welcome { padding: 18px; }
  .welcome::before { inset: 12px; }
  .school-logo { width: 92px; height: 92px; margin-bottom: 25px; border-radius: 25px; }
  .school-logo img { width: 62px; height: 62px; }
}
@media (max-width: 380px) {
  .page-indicator { min-width: 86px; }
  .control { width: 34px; }
  .controls__separator { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
