/* FORGE — title / loading screen (title.js): "LIT GAMES presents THE FORGE".
   Static markup lives in index.html so the studio card animates from the first paint, before three.js arrives. */
#title { position: fixed; inset: 0; z-index: 100; overflow: hidden; background: #050407; color: #f3e6cf;
         -webkit-user-select: none; user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
         --gold: #ffd37a; --logo-w: min(50vw, 92vh, 980px); --logo-top: 59vh;
         cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg transform='rotate(-38 16 16)'%3E%3Crect x='14.4' y='12' width='3.2' height='17.5' rx='1.4' fill='%23b07a43' stroke='%231a0d05'/%3E%3Crect x='6.5' y='4.5' width='19' height='8.5' rx='1.6' fill='%23e4e8ee' stroke='%231a0d05'/%3E%3Crect x='6.5' y='4.5' width='4' height='8.5' rx='1.2' fill='%23ffd37a' stroke='%231a0d05'/%3E%3C/g%3E%3C/svg%3E") 7 9, crosshair;
         transition: opacity .9s ease .3s; }
#title[data-phase="entering"] { opacity: 0; pointer-events: none; }
#title > * { position: absolute; }
#title canvas.t-gl { inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.4s ease; }
#title.gl-on canvas.t-gl { opacity: 1; }
#title .t-vignette { inset: 0; pointer-events: none;
                     background: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 50%, rgba(2, 1, 4, .78) 100%); }
#title .t-flash { inset: 0; pointer-events: none; opacity: 0;
                  background: radial-gradient(circle at 50% 42%, rgba(255, 246, 225, .95), rgba(255, 170, 80, .45) 40%, rgba(255, 110, 30, 0) 75%); }
#title .t-flash.go { animation: t-flash .9s ease-out; }
@keyframes t-flash { 0% { opacity: 0; } 8% { opacity: .9; } 100% { opacity: 0; } }

/* ---- the studio card: centred while it presents, then it hands the stage to the story */
#title .t-studio { left: 50%; top: 47%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center;
                   gap: 2.2vh; pointer-events: none; transition: opacity .8s ease, filter .8s ease, transform 1s ease; }
#title .t-studio img { width: min(32vw, 330px, 46vh); height: auto; animation: t-rise 1.5s .25s cubic-bezier(.2, .8, .2, 1) both; }
#title .t-studio span, #title .t-head span { font: 700 clamp(11px, 1.25vw, 15px)/1 "Cinzel", Georgia, serif; letter-spacing: .62em;
                   padding-left: .62em; text-transform: uppercase; color: #cdbfa6; }
#title .t-studio span { animation: t-soft 1.2s 1.15s ease both; }
#title.presents-out .t-studio { opacity: 0; filter: blur(6px); transform: translate(-50%, -50%) scale(1.05); }
@keyframes t-rise { from { opacity: 0; transform: translateY(14px) scale(.94); filter: blur(10px) brightness(2.2); }
                    55% { filter: blur(0) brightness(1.35); } to { opacity: 1; transform: none; filter: none; } }
@keyframes t-soft { from { opacity: 0; letter-spacing: .9em; } to { opacity: 1; } }

/* ---- title card: small studio mark on top, the wordmark over the emblem */
#title .t-head { left: 50%; top: 2.6vh; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: .9vh;
                 pointer-events: none; opacity: 0; transition: opacity 1s ease .2s; }
#title .t-head img { height: clamp(34px, 6.2vh, 64px); width: auto; }
#title .t-head span { font-size: clamp(9px, 1vw, 12px); letter-spacing: .55em; }
#title.show-head .t-head { opacity: 1; }
#title .t-logo { left: 50%; top: var(--logo-top); width: var(--logo-w); margin: 0; transform: translate(-50%, -50%); pointer-events: none;
                 opacity: 0; transition: opacity .5s ease, transform 1s cubic-bezier(.5, 0, .75, 0); }
#title .t-logo::before { content: ""; position: absolute; inset: -18% -10%; z-index: -1;
                         background: radial-gradient(ellipse 50% 46% at 50% 52%, rgba(3, 2, 5, .82), rgba(3, 2, 5, .45) 55%, transparent 76%); }
#title .t-logo img { display: block; width: 100%; height: auto; filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .7)); }
#title.show-logo .t-logo { opacity: 1; }
#title.show-logo .t-logo img { animation: t-slam .85s cubic-bezier(.2, .9, .3, 1) both; }
@keyframes t-slam { 0% { opacity: 0; transform: scale(1.7); filter: blur(14px) brightness(3); }
                    45% { opacity: 1; transform: scale(.97); filter: blur(0) brightness(1.6) drop-shadow(0 10px 26px rgba(0, 0, 0, .7)); }
                    70% { transform: scale(1.012); } 100% { transform: none; } }
/* a light sweep across the chrome, clipped to the wordmark's own shape */
#title .t-shine { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: 0;
                  -webkit-mask: url("./assets/title/theforge-900.webp") center / 100% 100% no-repeat; mask: url("./assets/title/theforge-900.webp") center / 100% 100% no-repeat;
                  background: linear-gradient(105deg, transparent 38%, rgba(255, 236, 205, .0) 42%, rgba(255, 244, 222, .9) 50%, rgba(255, 210, 150, .0) 58%, transparent 62%) no-repeat;
                  background-size: 300% 100%; }
#title.show-logo .t-shine { animation: t-shine 7s 1s ease-in-out infinite; }
@keyframes t-shine { 0% { opacity: 1; background-position: 120% 0; } 18% { opacity: 1; background-position: -20% 0; } 19%, 100% { opacity: 0; background-position: -20% 0; } }
#title[data-phase="entering"] .t-logo { transform: translate(-50%, -50%) scale(1.35); opacity: 0; transition: opacity .7s ease .15s, transform 1.1s cubic-bezier(.5, 0, .75, 0); }
#title[data-phase="entering"] .t-head { opacity: 0; transition: opacity .4s; }

/* ---- the told prologue */
#title .t-story { left: 50%; bottom: 11vh; width: min(780px, calc(100vw - 40px)); margin: 0; transform: translateX(-50%); text-align: center;
                  pointer-events: none; opacity: 0; transition: opacity .6s ease;
                  font: italic 500 clamp(18px, 2.15vw, 27px)/1.45 "Alegreya", Georgia, serif; color: #efe2c8; text-wrap: balance;
                  text-shadow: 0 2px 14px rgba(0, 0, 0, .9), 0 0 2px rgba(0, 0, 0, .8); }
#title[data-phase="story"] .t-story { opacity: 1; }
#title .t-num { display: block; margin-bottom: .55em; font: 900 clamp(11px, 1.1vw, 13px)/1 "Cinzel", Georgia, serif; letter-spacing: .5em;
                padding-left: .5em; color: var(--gold); font-style: normal; opacity: .85; }
#title .t-num::before, #title .t-num::after { content: ""; display: inline-block; vertical-align: middle; width: 34px; height: 1px; margin: 0 14px;
                                              background: linear-gradient(90deg, transparent, rgba(255, 211, 122, .7)); }
#title .t-num::after { background: linear-gradient(270deg, transparent, rgba(255, 211, 122, .7)); margin-left: 6px; }
#title .t-line .c { opacity: 0; transition: opacity .16s linear; }
#title .t-line .c.on { opacity: 1; }
#title .t-line .em { color: var(--gold); font-style: normal; font-weight: 700; text-shadow: 0 0 16px rgba(255, 170, 60, .55), 0 2px 12px rgba(0, 0, 0, .9); }
#title .t-hint { display: block; margin-top: 16px; white-space: nowrap; font-style: normal; text-shadow: none;
                 font: 700 11px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .28em; text-transform: uppercase; color: rgba(243, 230, 207, .5);
                 opacity: 0; transition: opacity .6s; }
#title.hint .t-hint { opacity: 1; animation: t-breathe 2.2s ease-in-out infinite; }
@keyframes t-breathe { 50% { color: rgba(255, 211, 122, .85); } }

/* ---- enter prompt + loading line */
#title .t-prompt { left: 50%; bottom: 10vh; transform: translateX(-50%); pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity .7s ease;
                   font: 900 clamp(14px, 1.5vw, 19px)/1 "Cinzel", Georgia, serif; letter-spacing: .42em; padding-left: .42em; text-transform: uppercase; color: #ffe7b0;
                   text-shadow: 0 0 18px rgba(255, 160, 60, .75), 0 2px 10px rgba(0, 0, 0, .9); }
#title .t-prompt::before, #title .t-prompt::after { content: ""; display: inline-block; vertical-align: middle; width: clamp(24px, 5vw, 70px); height: 1px;
                                                    margin: 0 18px; background: linear-gradient(90deg, transparent, #ffd37a); }
#title .t-prompt::after { background: linear-gradient(270deg, transparent, #ffd37a); margin-left: 0; }
#title.can-enter[data-phase="title"] .t-prompt { opacity: 1; animation: t-beckon 2.4s ease-in-out infinite; }
@keyframes t-beckon { 50% { color: #fff; text-shadow: 0 0 26px rgba(255, 180, 70, 1), 0 2px 10px rgba(0, 0, 0, .9); } }
#title .t-load { left: 50%; bottom: max(3.4vh, 18px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 9px;
                 pointer-events: none; transition: opacity .8s ease; }
#title .t-load i { display: block; width: min(260px, 50vw); height: 2px; border-radius: 2px; background: rgba(255, 220, 160, .12); overflow: hidden; }
#title .t-load b { display: block; height: 100%; width: calc(var(--p, 0) * 100%);
                   background: linear-gradient(90deg, #7a1d05, #ff7a1e 60%, #ffe2a0); box-shadow: 0 0 10px #ff8a2a; }
#title .t-load span { font: 600 10.5px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .3em; text-transform: uppercase; color: rgba(243, 230, 207, .55); }
#title .t-load.nudge span { animation: t-nudge .5s ease; }
@keyframes t-nudge { 30% { color: #ffd37a; transform: translateX(-3px); } 60% { transform: translateX(3px); } }
#title.loaded .t-load { opacity: 0; transition-delay: 1.4s; }
#title[data-phase="presents"] .t-load { opacity: 0; }

/* ---- corner controls */
#title button { font: 600 12px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: rgba(243, 230, 207, .72);
                background: rgba(14, 11, 8, .55); border: 1px solid rgba(255, 220, 160, .22); border-radius: 999px; padding: 9px 14px; cursor: pointer;
                transition: color .2s, border-color .2s, opacity .5s; }
#title button:hover, #title button:focus-visible { color: #fff; border-color: rgba(255, 220, 160, .6); outline: none; }
#title .t-skip { right: max(14px, env(safe-area-inset-right)); top: max(14px, env(safe-area-inset-top)); }
#title .t-skip::after { content: " ›"; }
#title[data-phase="title"] .t-skip, #title[data-phase="entering"] .t-skip { opacity: 0; pointer-events: none; }
#title .t-replay { left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); opacity: 0; pointer-events: none; }
#title .t-replay::before { content: "↺ "; }
#title[data-phase="title"] .t-replay { opacity: 1; pointer-events: auto; transition-delay: 1.8s; }
#title .t-sound { left: max(14px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); width: 38px; height: 38px; padding: 0;
                  display: grid; place-items: center; }
#title .t-sound svg { width: 18px; height: 18px; }

@media (max-aspect-ratio: 1/1) {
  #title { --logo-w: min(90vw, 560px); --logo-top: 62vh; }
  #title .t-story { bottom: 12vh; }
  #title .t-studio img { width: min(62vw, 300px); }
}
@media (prefers-reduced-motion: reduce) {
  #title .t-studio img, #title.show-logo .t-logo img { animation-duration: .01s; }
  #title.show-logo .t-shine, #title.can-enter[data-phase="title"] .t-prompt, #title.hint .t-hint, #title .t-flash.go { animation: none; }
}
