/* The title screen (js/ui/title.js): the town at night, far off and dimmed,
   the game's name under a lantern's light, and what to press. Over every
   layer of the game but the connection notice (connection.css, 200), so a
   visit that cannot connect is still told why. It paints the whole screen,
   under a notch, and pads what it says in from the safe edges. */

#title-screen {
  position: fixed; inset: 0; z-index: 150;
  display: grid; place-items: center;
  padding: calc(var(--edge-top) + 16px) calc(var(--edge-right) + 16px) calc(var(--edge-bottom) + 16px) calc(var(--edge-left) + 16px);
  background: #07090b; color: var(--parchment); cursor: pointer; overflow: hidden;
  font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: 0;
  transition: opacity 700ms ease;
}
#title-screen[data-leaving="true"] { opacity: 0; pointer-events: none; }

/* The town, as if seen from the road at night: the same painting, softened
   and dark at the edges, drifting closer very slowly. */
.title-backdrop {
  position: absolute; inset: -4%;
  background:
    radial-gradient(ellipse 70% 60% at 50% 46%, transparent 0 30%, #07090bcc 72%, #07090b 100%),
    linear-gradient(#07090b99, #07090b55 40%, #07090bdd),
    url("../assets/city/city-scene-backdrop.webp") center 40% / cover no-repeat;
  filter: saturate(0.8) brightness(0.62) blur(1.5px);
  animation: title-drift 48s ease-in-out infinite alternate;
}
#title-screen[data-leaving="true"] .title-backdrop { transform: scale(1.08); transition: transform 700ms ease-in; animation: none; }
@keyframes title-drift { from { transform: scale(1); } to { transform: scale(1.06) translate(-0.8%, -0.6%); } }

/* Sparks off the town's fires, rising and winking out. */
.title-embers { position: absolute; inset: 0; pointer-events: none; }
.title-embers span {
  position: absolute; left: var(--x); bottom: -8px; width: var(--size); height: var(--size); border-radius: 50%;
  background: #ffcf7a; box-shadow: 0 0 6px 1px #ff9b3d99; opacity: 0;
  animation: title-ember var(--rise) linear var(--delay) infinite;
}
@keyframes title-ember {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 0.85; }
  55% { opacity: 0.5; }
  70% { opacity: 0.75; }
  100% { transform: translate(var(--drift), -78vh); opacity: 0; }
}

.title-content { position: relative; display: grid; justify-items: center; gap: 10px; text-align: center; max-width: 720px; }

/* The logo (assets/brand/logo.svg): twelve flames, one lit at eleven
   o'clock. Its name stays the heading's text, for a screen reader and for
   anything that reads the title; the picture says it to everyone else. */
.title-name {
  position: relative; margin: 0; width: clamp(220px, 44vh, 360px); aspect-ratio: 1;
  font-size: 0; line-height: 0;
}
.title-logo { display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 6px #000c); }
.title-name-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* The lantern's light, on the one flame still lit: light, not a picture of
   one. It breathes unevenly - two flickers on different clocks - like the
   town's own fires. */
.title-light {
  position: absolute; left: 28.4%; top: 12.6%; width: 62%; height: 62%; transform: translate(-50%, -50%);
  border-radius: 50%; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle, #ffd894aa 0 3%, #ffb44f55 10%, #f08a2a1c 32%, transparent 62%);
  animation: title-flicker 3.7s ease-in-out infinite, title-sway 5.3s ease-in-out infinite;
}
@keyframes title-flicker { 0%, 100% { opacity: 0.92; } 18% { opacity: 0.78; } 23% { opacity: 1; } 51% { opacity: 0.86; } 77% { opacity: 0.97; } }
@keyframes title-sway { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.05); } 65% { transform: translate(-50%, -50%) scale(0.97); } }

.title-tagline { margin: 2px 0 0; font-size: clamp(15px, 1.9vw, 19px); font-style: italic; color: #c9b893; text-shadow: 0 1px 2px #000; }

.title-go { display: grid; justify-items: center; gap: 6px; margin-top: clamp(22px, 6vh, 56px); min-height: 52px; }
.title-prompt {
  margin: 0; font-size: 14px; letter-spacing: 0.22em; text-transform: uppercase; color: #e2cf9f;
  font-family: "Segoe UI", system-ui, sans-serif; font-weight: 600; text-shadow: 0 1px 2px #000;
}
#title-screen[data-ready="true"] .title-prompt { animation: title-prompt 2.6s ease-in-out infinite; }
@keyframes title-prompt { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.title-hero { margin: 0; font-size: 15px; font-style: italic; color: #a99a7c; }

/* The real control under the prompt: what a keyboard's Tab and a screen
   reader land on. Drawn as a thin outline so the prompt stays the voice. */
.title-begin {
  margin-top: 10px; min-width: 132px; min-height: 44px; padding: 8px 22px;
  font: 600 13px "Segoe UI", system-ui, sans-serif; letter-spacing: 0.18em; text-transform: uppercase;
  color: #e9d7aa; background: #0b0e10aa; border: 1px solid #c8994866; border-radius: 2px; cursor: pointer;
  opacity: 0; transition: opacity 400ms ease, border-color 160ms ease, background 160ms ease;
}
#title-screen[data-ready="true"] .title-begin { opacity: 1; }
.title-begin:hover, .title-begin:focus-visible { border-color: #e2b766; background: #1a1610cc; outline: none; }

.title-foot {
  position: absolute; left: calc(var(--edge-left) + 18px); bottom: calc(var(--edge-bottom) + 12px); margin: 0;
  font: 600 11px "Segoe UI", system-ui, sans-serif; letter-spacing: 0.16em; text-transform: uppercase; color: #8a7d64;
}

/* A phone held sideways: everything closer together. */
@media (max-height: 440px) {
  .title-name { width: clamp(150px, 46vh, 200px); }
  .title-go { margin-top: 14px; }
  .title-begin { margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .title-backdrop, .title-light, #title-screen[data-ready="true"] .title-prompt { animation: none; }
  #title-screen { transition: none; }
}
