/* splash.css — the intro screen shown over the app until the player presses ENTER.
   Fonts: font-src is 'none' in the CSP, so only locally installed faces are used. */
.splash {
  --ink: #2a1a0b;
  --ink-red: #5a1f0c;
  --parch-hi: #f8eed2;
  --parch: #ecd9aa;
  --parch-lo: #cdae73;
  --edge: #6e4f25;
  --blackletter: "UnifrakturMaguntia", "UnifrakturCook", "Old English Text MT", "Blackadder ITC",
                 "Luminari", "Cloister Black", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L", "P052", Georgia, "Times New Roman", serif;
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--serif);
  background: #b9996a;
  opacity: 1;
  transition: opacity .7s ease, transform .7s ease;
}
html.splash-open, html.splash-open body { overflow: hidden; }

.splash-bg, .splash-art, .splash-vignette { position: absolute; inset: 0; pointer-events: none; }

/* Parchment under the art: what shows while the image is still downloading. */
.splash-bg {
  background:
    repeating-radial-gradient(circle at 30% 40%, rgba(120, 85, 35, .05) 0 2px, transparent 2px 7px),
    radial-gradient(ellipse at 50% 35%, #f3e5c2 0%, #dfc898 50%, #b08f5c 100%);
}
/* The castle sketch (tools/gen-splash.mjs): set straight in CSS and preloaded
   from <head>, so nothing else is ever painted first. 16:9 art for landscape,
   9:16 art (title centred on top) for portrait phones. */
.splash-art {
  background: url("splash.png") center 18% / cover no-repeat;
}
@media (orientation: portrait) {
  .splash-art { background: url("splash-portrait.png") center top / cover no-repeat; }
}
.splash-vignette {
  background:
    radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(35, 20, 6, .55) 100%),
    linear-gradient(to bottom, transparent 45%, rgba(25, 14, 4, .55) 100%);
}

.splash-content {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(.8rem, 2.2vh, 1.6rem);
  padding: max(40vh, 11rem) clamp(1rem, 4vw, 3rem) clamp(1.2rem, 4vh, 2.8rem);
}
.splash-content > * { flex-shrink: 0; }

.splash-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Tagline on a classic ribbon banner: a parchment band whose swallowtail
   ends sit lower and behind it, joined by dark folds where the band turns under. */
.splash-tagline {
  --drop: .55em;          /* how far the ends hang below the band */
  --fold: .9em;           /* width of the turned-under part */
  --tail: 2.6em;          /* visible length of each end */
  position: relative;
  isolation: isolate;
  display: inline-block;
  max-width: min(92vw, 44rem);
  margin: 0 calc(var(--tail) + .2em) var(--drop);
  font-style: italic;
  font-weight: bold;
  font-size: clamp(1rem, 2vw, 1.35rem);
  color: var(--ink-red);
  text-align: center;
  letter-spacing: .03em;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .45));
}
.ribbon-band {
  position: relative;
  z-index: 2;
  display: block;
  padding: .5em 1.6em;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, .35), transparent 35%, transparent 70%, rgba(90, 55, 15, .25)),
    linear-gradient(to right, var(--parch-lo), var(--parch-hi) 18%, var(--parch) 50%, var(--parch-hi) 82%, var(--parch-lo));
  border-top: 2px solid var(--edge);
  border-bottom: 2px solid var(--edge);
  text-shadow: 0 1px 0 rgba(255, 244, 214, .7);
}
.splash-tagline::before,
.splash-tagline::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: var(--drop);
  bottom: calc(-1 * var(--drop));
  width: calc(var(--tail) + var(--fold));
  border-top: 2px solid var(--edge);
  border-bottom: 2px solid var(--edge);
}
.splash-tagline::before {
  left: calc(-1 * var(--tail));
  background: linear-gradient(to right, #b8955c, #d9bd85);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, .9em 50%);
}
.splash-tagline::after {
  right: calc(-1 * var(--tail));
  background: linear-gradient(to left, #b8955c, #d9bd85);
  clip-path: polygon(0 0, 100% 0, calc(100% - .9em) 50%, 100% 100%, 0 100%);
}
.ribbon-fold {
  position: absolute;
  z-index: 1;
  top: 100%;
  width: var(--fold);
  height: var(--drop);
  background: #5b3d17;
}
.ribbon-fold-l { left: 0;  clip-path: polygon(0 0, 100% 0, 100% 100%); }
.ribbon-fold-r { right: 0; clip-path: polygon(0 0, 100% 0, 0 100%); }

.splash-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(.8rem, 2vw, 1.8rem);
  width: 100%;
  max-width: 72rem;
}
.splash-card {
  position: relative;
  padding: 1.3rem 1.4rem 1.4rem;
  background:
    repeating-radial-gradient(circle at 70% 30%, rgba(120, 80, 30, .04) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 30% 20%, var(--parch-hi) 0%, var(--parch) 58%, var(--parch-lo) 100%);
  border: 1px solid var(--edge);
  border-radius: 4px 9px 5px 10px / 9px 4px 10px 5px;
  box-shadow: inset 0 0 24px rgba(110, 70, 22, .45), inset 0 0 3px rgba(80, 50, 15, .6), 0 12px 26px rgba(0, 0, 0, .5);
  transform: rotate(var(--tilt, 0deg));
}
.splash-card:nth-child(1) { --tilt: -1.2deg; }
.splash-card:nth-child(2) { --tilt: .6deg; }
.splash-card:nth-child(3) { --tilt: 1.3deg; }
.splash-card h2 {
  font-family: var(--blackletter);
  font-weight: normal;
  font-size: clamp(1.3rem, 2.1vw, 1.75rem);
  line-height: 1.15;
  color: var(--ink-red);
  margin-bottom: .55rem;
}
.splash-card h2::after {
  content: "\2766";
  display: block;
  font-family: var(--serif);
  font-size: .8rem;
  color: var(--edge);
  margin-top: .3rem;
  opacity: .8;
}
.splash-card p { font-size: clamp(.95rem, 1.15vw, 1.05rem); line-height: 1.5; }

.splash-enter {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 3.2vw, 2.3rem);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .38em;
  padding: .5em 1.6em .5em 2em;   /* extra left pad balances the trailing letter-spacing */
  color: var(--ink-red);
  cursor: pointer;
  background: radial-gradient(ellipse at 40% 30%, var(--parch-hi) 0%, var(--parch) 60%, var(--parch-lo) 100%);
  border: 3px double var(--edge);
  border-radius: 6px 12px 7px 13px / 12px 6px 13px 7px;
  box-shadow: inset 0 0 18px rgba(110, 70, 22, .5), 0 10px 26px rgba(0, 0, 0, .55);
  transition: transform .15s ease, box-shadow .2s ease;
}
.splash-enter:hover { transform: scale(1.04); box-shadow: inset 0 0 18px rgba(110, 70, 22, .5), 0 0 26px rgba(255, 214, 140, .55), 0 10px 26px rgba(0, 0, 0, .55); }
.splash-enter:active { transform: scale(.98); }
.splash-enter:focus-visible { outline: 3px solid #f6d27a; outline-offset: 5px; }

.splash-hint {
  font-size: .85rem;
  letter-spacing: .12em;
  color: #eadbb8;
  text-shadow: 0 1px 2px #000;
  opacity: .85;
}

.splash.is-leaving { opacity: 0; transform: scale(1.04); pointer-events: none; }

@media (max-width: 760px) {
  .splash-cols { grid-template-columns: 1fr; max-width: 30rem; }
  .splash-card { --tilt: 0deg !important; padding: 1rem 1.1rem 1.1rem; }
  .splash-content { padding-top: max(34vh, 9rem); }
}
@media (max-height: 640px) and (min-width: 761px) {
  .splash-content { padding-top: 8rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .splash-art { animation: splash-drift 40s ease-in-out infinite alternate; }
  .splash-card { animation: splash-rise .9s cubic-bezier(.2, .7, .2, 1) both; }
  .splash-card:nth-child(2) { animation-delay: .15s; }
  .splash-card:nth-child(3) { animation-delay: .3s; }
  .splash-tagline { animation: splash-fade 1.2s ease both; }
  .splash-enter { animation: splash-fade .9s ease .5s both, splash-glow 2.8s ease-in-out 1.4s infinite; }
}
@media (prefers-reduced-motion: reduce) {
  .splash, .splash-enter { transition: none; }
  .splash.is-leaving { transform: none; }
}
@keyframes splash-rise { from { opacity: 0; transform: translateY(22px) rotate(var(--tilt, 0deg)); } to { opacity: 1; transform: rotate(var(--tilt, 0deg)); } }
@keyframes splash-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes splash-drift { from { transform: scale(1); } to { transform: scale(1.06) translateY(-1%); } }
@keyframes splash-glow {
  0%, 100% { box-shadow: inset 0 0 18px rgba(110, 70, 22, .5), 0 10px 26px rgba(0, 0, 0, .55); }
  50%      { box-shadow: inset 0 0 18px rgba(110, 70, 22, .5), 0 0 30px rgba(255, 214, 140, .6), 0 10px 26px rgba(0, 0, 0, .55); }
}
