/* The gate (js/gate.js): shown before everything until the countdown reaches zero and she taps it. */
#gate {
  position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; overflow: hidden;
  background: radial-gradient(ellipse at 50% 85%, #4a2e6a 0%, #1b1238 45%, #07061a 100%);
  color: #fff; font-family: 'Fredoka', sans-serif; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: opacity 1.2s ease, visibility 1.2s;
}
body.gated #start { visibility: hidden; }
body.gated #rotate { display: none !important; }
#gate.g-gone { opacity: 0; visibility: hidden; }

.g-top { text-align: center; padding: clamp(14px, 4vh, 40px) 16px 0; flex: none; }
.g-kicker { margin: 0; font-weight: 500; font-size: clamp(11px, 1.7vh, 15px); letter-spacing: .28em; text-transform: uppercase; color: #ffd9a8; opacity: .85; }
.g-name { margin: clamp(2px, 1vh, 10px) 0 clamp(4px, 1.4vh, 14px); font: italic 700 clamp(40px, 9vh, 92px)/1 'Playfair Display', Georgia, serif;
  text-shadow: 0 0 30px rgba(255, 170, 120, .55), 0 6px 30px rgba(255, 120, 80, .35); animation: gNameGlow 3s ease-in-out infinite; }
@keyframes gNameGlow { 50% { text-shadow: 0 0 44px rgba(255, 190, 130, .8), 0 6px 30px rgba(255, 120, 80, .45); } }
.g-label { margin: 0 0 8px; font-size: clamp(11px, 1.7vh, 14px); letter-spacing: .2em; text-transform: uppercase; color: rgba(255, 255, 255, .6); }
.g-timer { display: flex; gap: clamp(8px, 1.6vw, 16px); justify-content: center; }
.g-cell { display: flex; flex-direction: column; align-items: center; min-width: clamp(54px, 9vh, 84px); padding: clamp(6px, 1.2vh, 12px) 8px clamp(4px, .9vh, 9px);
  border-radius: 14px; background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .05)); border: 1px solid rgba(255, 217, 168, .35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .2); }
.g-cell b { font: 600 clamp(24px, 5.4vh, 50px)/1 'Fredoka', sans-serif; color: #fff1d6; font-variant-numeric: tabular-nums; display: inline-block; }
.g-cell i { font-style: normal; font-size: clamp(9px, 1.3vh, 12px); letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .55); margin-top: 4px; }
.g-cell b.flip { animation: gFlip .45s ease-out; }
@keyframes gFlip { 0% { transform: translateY(-30%) scale(1.1); opacity: .2; } 100% { transform: none; opacity: 1; } }
.g-final .g-cell { border-color: rgba(255, 150, 150, .7); animation: gPulse 1s ease-in-out infinite; }
@keyframes gPulse { 50% { box-shadow: 0 0 26px rgba(255, 140, 140, .55), inset 0 1px 0 rgba(255, 255, 255, .2); } }
.g-timer.g-nudge { animation: gNudge .5s ease; }
@keyframes gNudge { 20% { transform: scale(1.08); } 40% { transform: scale(.97); } 60% { transform: scale(1.03); } }
.g-when { margin: 10px 0 0; font-size: clamp(11px, 1.7vh, 14px); color: rgba(255, 255, 255, .55); }
.g-open-msg { display: none; margin: 6px 0 0; font: 600 clamp(22px, 4.4vh, 36px)/1.2 'Fredoka', sans-serif; color: #ffe7b0; text-shadow: 0 0 24px rgba(255, 200, 120, .7); }
.g-open-msg span { display: block; font-weight: 500; font-size: .5em; letter-spacing: .2em; text-transform: uppercase; color: rgba(255, 255, 255, .7); animation: gBlink 1.4s ease-in-out infinite; }
@keyframes gBlink { 50% { opacity: .35; } }
.g-unlocked .g-count { display: none; }
.g-unlocked .g-open-msg { display: block; animation: gRise .8s ease-out; }
@keyframes gRise { from { opacity: 0; transform: translateY(10px) scale(.96); } }

.g-wrap { flex: 1; min-height: 0; width: 100%; container-type: size; display: flex; align-items: flex-end; justify-content: center; }
.g-stage { position: relative; width: min(100cqw, 156.25cqh); aspect-ratio: 1000 / 640; }
.g-scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }

/* idle life */
.g-flame { transform-box: fill-box; transform-origin: 50% 100%; animation: gFlame .18s ease-in-out infinite alternate; }
.g-tglow { animation: gGlow 1.6s ease-in-out infinite alternate; }
@keyframes gFlame { from { transform: scale(1, 1) rotate(-3deg); } to { transform: scale(.9, 1.1) rotate(3deg); } }
@keyframes gGlow { from { opacity: .7; } to { opacity: 1; } }
.g-crack { animation: gCrack 2.4s ease-in-out infinite; }
@keyframes gCrack { 0%, 100% { stroke-opacity: .35; } 50% { stroke-opacity: .9; } }
.g-unlocked .g-crack { stroke-width: 8; animation-duration: 1s; }
.g-bob { transform-box: fill-box; transform-origin: 50% 100%; animation: gBreathe 3.2s ease-in-out infinite; }
.g-pika .g-bob { animation-delay: -1.4s; }
@keyframes gBreathe { 50% { transform: scale(1.012, .99); } }
.g-guard { cursor: pointer; }
.g-guard.g-poke .g-bob { animation: gPoke .5s ease; }
@keyframes gPoke { 30% { transform: translateY(-12px); } 60% { transform: translateY(0) scale(1.03, .96); } }
.g-hit, .g-taphint { cursor: pointer; }

/* spears: upright, crossed when she knocks too early, raised when the gate opens */
.g-arm { transform-origin: 0 0; transition: transform .2s cubic-bezier(.3, 1.6, .5, 1); }
.g-deny .g-armL { transform: rotate(58deg); }
.g-deny .g-armR { transform: rotate(-58deg); }
.g-deny .g-door { animation: gRattle .45s ease; }
.g-deny .g-lock { animation: gRattle .45s ease; }
@keyframes gRattle { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.g-deny .g-guard .g-bob { animation: gStern .5s ease; }
@keyframes gStern { 30% { transform: translateY(-14px); } 60% { transform: translateY(0); } }

/* open: the lock clicks, the guards bow and lift their spears, the doors swing in */
.g-shackle { transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); }
.g-unlocked .g-shackle { transform: translateY(-12px); }
.g-unlocked .g-armL { transform: rotate(-8deg); }
.g-unlocked .g-armR { transform: rotate(8deg); }
.g-opening .g-arm { transition-duration: .6s; }
.g-opening .g-armL { transform: rotate(-22deg); }
.g-opening .g-armR { transform: rotate(22deg); }
.g-opening .g-guard .g-bob { animation: gBow 1.2s ease-in-out .2s 2; }
@keyframes gBow { 50% { transform: rotate(var(--bow, 10deg)) translateY(6px); } }
.g-pika { --bow: -10deg; }
.g-lock { transition: opacity .5s, transform .6s; transform-box: fill-box; transform-origin: 50% 50%; }
.g-opening .g-lock { opacity: 0; transform: translateY(40px) rotate(30deg); }
.g-door { transform-box: fill-box; transition: transform 1.6s cubic-bezier(.5, 0, .3, 1) .35s; }
.g-doorL { transform-origin: 0% 50%; }
.g-doorR { transform-origin: 100% 50%; }
.g-opening .g-doorL, .g-opening .g-doorR { transform: scaleX(.05); }
.g-opening .g-crack { opacity: 0; transition: opacity .3s .3s; }

/* what the guards say */
.g-say { position: absolute; bottom: 52%; max-width: 32%; padding: .6em .9em; border-radius: 16px; background: #fffaf2; color: #3b2440;
  font: 600 clamp(11px, 2.2cqh, 16px)/1.25 'Fredoka', sans-serif; text-align: center; box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
  opacity: 0; transform: translateY(8px) scale(.9); transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none; }
.g-say:empty { display: none; }
.g-say::after { content: ""; position: absolute; top: 100%; width: 0; height: 0; border: 9px solid transparent; border-top-color: #fffaf2; }
.g-sayL { left: 4%; bottom: 46%; }
.g-sayL::after { left: 30%; }
.g-sayR { right: 3%; bottom: 53%; }
.g-sayR::after { right: 30%; }
.g-saying .g-say { opacity: 1; transform: none; }
.g-sayR { transition-delay: .25s; }

.g-taphint { position: absolute; left: 50%; top: 5%; transform: translateX(-50%); padding: 5px 14px; border-radius: 999px; white-space: nowrap;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 217, 168, .5); color: #ffe7b0; font-size: clamp(11px, 2cqh, 14px); letter-spacing: .08em;
  animation: gBlink 2s ease-in-out infinite; }
.g-unlocked .g-taphint { background: rgba(255, 210, 120, .3); border-color: #ffd98a; color: #fff; font-weight: 600; animation: gPulseHint 1.1s ease-in-out infinite; }
@keyframes gPulseHint { 50% { transform: translateX(-50%) scale(1.1); box-shadow: 0 0 22px rgba(255, 210, 120, .7); } }
.g-opening .g-taphint { display: none; }

/* the warm welcome */
.g-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.4s ease;
  background: radial-gradient(ellipse at 50% 70%, #fff8e4 0%, #ffd890 40%, #ff9a7a 100%); }
.g-welcomed .g-flash { opacity: .96; }
.g-welcome { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; opacity: 0; transition: opacity 1s ease .4s; padding: 24px; }
.g-welcomed .g-welcome { opacity: 1; }
.g-w1 { margin: 0; font: italic 700 clamp(40px, 10vh, 96px)/1.05 'Playfair Display', Georgia, serif; color: #7a2a3a; text-shadow: 0 4px 30px rgba(255, 255, 255, .7); }
.g-w2 { margin: 14px 0 0; font: 500 clamp(14px, 2.6vh, 20px)/1.5 'Fredoka', sans-serif; color: #6a3a3a; }
.g-welcomed .g-w1 { animation: gRise 1.2s ease-out .4s both; }

.g-sparks { position: absolute; inset: 0; pointer-events: none; }
.g-sparks span { position: absolute; transform: translate(-50%, -50%); animation: gSpark 2.4s ease-out both; }
@keyframes gSpark { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1); } }

/* sideways phones: words on the left, the gate on the right */
@media (max-height: 500px) and (orientation: landscape) {
  #gate { flex-direction: row; }
  .g-top { width: 42%; align-self: center; padding: 0 8px 0 max(16px, env(safe-area-inset-left)); }
  .g-wrap { height: 100%; }
  .g-cell { min-width: 50px; }
}
@media (prefers-reduced-motion: reduce) { .g-flame, .g-bob, .g-crack, .g-name, .g-tglow { animation: none; } }
/* tall phones: keep the words and the gate together in the middle, and the gate a bit bigger */
@media (orientation: portrait) {
  #gate { justify-content: flex-end; gap: 5vh; }
  .g-wrap { flex: none; height: calc(min(100vw, 600px) * .74); container-type: normal; overflow: visible; }
  .g-stage { width: min(118vw, 700px); }
}
