/* ────────────────────────────────────────────────────────────
   intro.css — Opening animation overlay for Scholia.
   Theme-agnostic: fixed cream palette, independent of data-theme.
   ──────────────────────────────────────────────────────────── */

/* ── Overlay ─────────────────────────────────────────────── */
#intro-overlay {
  position: fixed;
  inset: 0;
  background: #FDFAF5;
  z-index: 9999;
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* Solid #12100e (same as --app-bg-color) — shown via opacity over cream in Phase 6 for dark; no --app-bg stack */
#intro-dim {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #12100e;
  opacity: 0;
  pointer-events: none;
}

/* ── Band — 56 vh, centred ───────────────────────────────── */
#intro-band {
  width: 100%;
  height: 56vh;
  display: flex;
  align-items: stretch;
  position: relative;
  z-index: 1;
}

/* ── Divider — gradient fade, stays inside band ─────────── */
#intro-dv {
  position: absolute;
  left: calc(50% - 0.5px);
  top: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(
    to bottom,
    transparent 0%, #DDD4C8 15%, #DDD4C8 85%, transparent 100%
  );
  transform-origin: top center;
  transform: scaleY(0);
  pointer-events: none;
}

/* ── Left panel ─────────────────────────────────────────── */
#intro-left {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 3vw;
  transform: translateX(20%); /* starts near centre, slides left */
}

/* ── Title — sets em context for cursor ─────────────────── */
#intro-tline {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: clamp(52px, 5.6vw, 80px);
  color: #1C1712;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: -0.5px;
  display: inline-block;
}

#intro-cur {
  display: inline-block;
  width: 0.045em;
  height: 0.82em;
  background: currentColor;
  margin-left: 0.04em;
  vertical-align: -0.06em;
  opacity: 1;
  transition: opacity .35s ease; /* always present so fade-out works */
}

#intro-cur.intro-blink { animation: intro-blink .5s step-end infinite; }

/* ── Right panel ─────────────────────────────────────────── */
#intro-right {
  flex: 1;
  position: relative;
  overflow: hidden;
  opacity: 0;
}

/* ── Greeting ────────────────────────────────────────────── */
#intro-greet {
  position: absolute;
  top: 11%;
  left: 0;
  right: 0;
  padding: 0 9%;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: clamp(17px, 1.8vw, 26px);
  color: #1C1712;
  white-space: nowrap;
  clip-path: inset(0 100% 0 0); /* animated to inset(0 0% 0 0) */
}

/* ── Calendar ────────────────────────────────────────────── */

/* Single seamless keyframe animation:
   Phase 1 (0–19%)  : spring fly-in, crisp          (~600 ms)
   Hold   (19–41%)  : stays put while circles build (~700 ms)
   Phase 2 (41–100%): drifts to blurred background  (~1900 ms)
   Total: 3.2 s                                                 */
@keyframes intro-cal-life {
  0% {
    transform: translate(-48%, -44%) scale(0.22);
    filter: blur(5px); opacity: 0;
    animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  19% {
    transform: translate(-48%, -44%) scale(1.3);
    filter: blur(0px); opacity: 0.92;
    animation-timing-function: linear; /* hold = flat easing */
  }
  41% {
    transform: translate(-48%, -44%) scale(1.3);
    filter: blur(0px); opacity: 0.92;
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  }
  100% {
    transform: translate(-48%, -44%) scale(4.6);
    filter: blur(3.5px); opacity: 0.18;
  }
}

/* Exit: from end-state of intro-cal-life — extra blur + fade, clipped by #intro-right (overflow: hidden) */
@keyframes intro-cal-exit {
  0% {
    transform: translate(-48%, -44%) scale(4.6);
    filter: blur(3.5px);
    opacity: 0.18;
  }
  100% {
    transform: translate(-48%, -44%) scale(5.05);
    filter: blur(22px);
    opacity: 0;
  }
}

#intro-cal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-48%, -44%) scale(0.22); /* initial — animation overrides */
  filter: blur(5px);
  opacity: 0;
  z-index: 1;
}

.intro-cal-hdr {
  font-family: 'Crimson Pro', serif;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #9C8E7E;
  margin-bottom: 8px;
  text-align: center;
}

.intro-cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 22px);
  gap: 4px;
  margin-bottom: 5px;
}

.intro-cal-dow span {
  font-family: 'Crimson Pro', serif;
  font-size: 8px;
  color: #C4B9AC;
  text-align: center;
  line-height: 22px;
}

.intro-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 22px);
  gap: 4px;
}

.intro-cd {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #E8E0D6;
  transform: scale(0);
  opacity: 0;
}

.intro-cd.intro-cd-fut {
  background: transparent;
  box-shadow: inset 0 0 0 1px #E0D8CE;
}

.intro-cd.intro-cd-tod {
  box-shadow: inset 0 0 0 1.5px #C4873E;
}

.intro-cd.intro-cd-in {
  transform: scale(1);
  opacity: 1;
}

/* ── Floating stats ─────────────────────────────────────── */
.intro-stat {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  transform: scale(0.1);
  opacity: 0;
}

.intro-sn {
  font-family: 'EB Garamond', serif;
  font-weight: 400;
  line-height: 1;
}

.intro-su {
  font-family: 'Crimson Pro', serif;
  font-size: 10px;
  margin-top: 4px;
  color: #C0B5A8;
}

/* ── CTA ─────────────────────────────────────────────────── */
#intro-cta {
  position: absolute;
  bottom: 5%;
  right: 8%;
  display: flex;
  gap: 14px;
  align-items: center;
  opacity: 0;
  transform: translateY(10px);
  z-index: 3;
}

.intro-btn-start {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px;
  color: #1C1712;
  background: transparent;
  border: 1.5px solid #1C1712;
  border-radius: 3px;
  padding: 9px 24px;
  cursor: pointer;
  letter-spacing: .01em;
  transition: background .2s, color .2s;
}

.intro-btn-start:hover { background: #1C1712; color: #FDFAF5; }

.intro-btn-login {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px;
  color: #FDFAF5;
  background: #1C1712;
  border: 1.5px solid #1C1712;
  border-radius: 3px;
  padding: 9px 24px;
  cursor: pointer;
  transition: background .2s;
}

.intro-btn-login:hover { background: #2E2A22; border-color: #2E2A22; }

.intro-btn-about {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px;
  color: #9C8E7E;
  background: transparent;
  border: 1.5px solid #DDD4C8;
  border-radius: 3px;
  padding: 9px 24px;
  cursor: not-allowed;
  opacity: .45;
}

.intro-nav-text {
  font-family: 'Crimson Pro', serif;
  font-size: 13px;
  color: #9C8E7E;
  opacity: .65;
  letter-spacing: .04em;
}

/* ── Progress strip ──────────────────────────────────────── */
#intro-pg {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(196, 135, 62, .1);
  z-index: 4;
}

#intro-pgf {
  height: 100%;
  width: 0%;
  background: #C4873E;
}

/* ── Keyframes ───────────────────────────────────────────── */
@keyframes intro-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Exit animation — fly toward viewer: scale + blur + fade ─ */
/* Each element rushes at the camera: grows large, blurs out of
   focus, and dissolves — like it's flying past you.            */
@keyframes intro-fly-out {
  0% {
    transform: scale(1);
    filter: blur(0px);
    opacity: 1;
  }
  100% {
    transform: scale(2.4);
    filter: blur(18px);
    opacity: 0;
  }
}

/* ── Dark end-state — added when theme=dark in Phase 6 ───── */
/* Transitions title, greeting, and cursor to light colours
   in sync with the overlay background darkening.             */
#intro-overlay.intro-dk #intro-tline {
  color: #DDDDE8;
  transition: color .88s ease;
}
#intro-overlay.intro-dk #intro-greet {
  color: #DDDDE8;
  transition: color .88s ease;
}
#intro-overlay.intro-dk #intro-cur {
  background: #DDDDE8;
  transition: background .88s ease;
}
#intro-overlay.intro-dk .intro-btn-start {
  color: #DDDDE8;
  border-color: #555;
  transition: color .88s ease, border-color .88s ease, background .2s, opacity .4s ease, transform .4s ease;
}
#intro-overlay.intro-dk .intro-btn-start:hover {
  background: #DDDDE8;
  color: #0d0d10;
}
#intro-overlay.intro-dk .intro-btn-login {
  background: #DDDDE8;
  color: #0d0d10;
  border-color: #DDDDE8;
}
#intro-overlay.intro-dk #intro-dv {
  background: linear-gradient(
    to bottom,
    transparent 0%, #2a2a30 15%, #2a2a30 85%, transparent 100%
  );
  transition: background .88s ease;
}
#intro-overlay.intro-dk .intro-nav-text {
  color: #9C8E7E;
}

/* ── Library page entrance (after intro exits) ───────────── */
@keyframes intro-page-enter {
  from { opacity: 0; transform: scale(0.97) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

@keyframes intro-header-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Reduced-motion fallback ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #intro-overlay * {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  #page-content, #topnav {
    animation-duration: .01ms !important;
  }
}
