/* ============================================================================
   hero-redesign.css — hero + games section redesign layered on portfolio.css:
   animated pixel wizard, playable terminal, character-select overlay,
   game-card key-art + tilt, cursor spell-trail, grain + typography polish.
   ========================================================================== */

/* ----------------------------------------------------------- pixel wizard */
.wizard-sprite {
    position: absolute;
    left: 50%;
    top: 55%;
    transform: translate(-50%, -50%);
    width: calc(var(--w-fw) * var(--w-scale));
    height: calc(var(--w-fh) * var(--w-scale));
    display: none;
    image-rendering: pixelated;
    background-repeat: no-repeat;
    background-image: url('images/hero/wizard-idle.png');
    /* Sheet geometry arrives from images/hero/wizard.json via heroFx.heroWizard. */
    --w-fw: 128px;
    --w-fh: 128px;
    --w-idle-frames: 4;
    --w-idle-dur: 1s;
    --w-cast-frames: 8;
    --w-cast-dur: 0.7s;
    --w-scale: 2;
    background-size: calc(var(--w-fw) * var(--w-idle-frames) * var(--w-scale)) calc(var(--w-fh) * var(--w-scale));
    animation: wizard-sprite-idle var(--w-idle-dur) steps(var(--w-idle-frames)) infinite;
}

.wizard-sprite.sprite-ready {
    display: block;
}

/* Hide the legacy painting once the sprite has loaded its manifest. */
.portrait-inner:has(.wizard-sprite.sprite-ready) .wizard-image {
    opacity: 0;
}

.wizard-sprite.casting {
    background-image: url('images/hero/wizard-cast.png');
    background-size: calc(var(--w-fw) * var(--w-cast-frames) * var(--w-scale)) calc(var(--w-fh) * var(--w-scale));
    animation: wizard-sprite-cast var(--w-cast-dur) steps(var(--w-cast-frames)) 1;
}

@keyframes wizard-sprite-idle {
    to { background-position-x: calc(-1 * var(--w-fw) * var(--w-idle-frames) * var(--w-scale)); }
}

@keyframes wizard-sprite-cast {
    to { background-position-x: calc(-1 * var(--w-fw) * var(--w-cast-frames) * var(--w-scale)); }
}

/* one-shot particle burst around the portrait when the wizard casts */
.cast-spark {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 70;
    box-shadow: 0 0 8px currentColor;
    animation: cast-spark-fly 0.85s ease-out forwards;
}

@keyframes cast-spark-fly {
    from { transform: translate(0, 0) scale(1); opacity: 1; }
    to   { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* full-screen flash for `cast fireball` */
body.spell-flash::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    background: radial-gradient(circle at 30% 60%, rgba(255, 140, 0, 0.35), transparent 60%);
    animation: spell-flash-fade 0.6s ease-out forwards;
}

@keyframes spell-flash-fade {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ---------------------------------------------------------- hero terminal */
.hero-terminal-wrap {
    margin-top: 1.5rem;
    max-width: 640px;
}

.terminal-toggle {
    display: none;
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
    background: rgba(10, 10, 15, 0.85);
    color: var(--cyan, #00ffff);
    border: 1px solid rgba(0, 255, 255, 0.4);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.hero-terminal {
    position: relative;
    background: rgba(8, 8, 14, 0.88);
    border: 1px solid rgba(0, 255, 255, 0.35);
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.12), inset 0 0 40px rgba(0, 0, 0, 0.6);
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: 0.82rem;
    overflow: hidden;
}

/* cheap CRT scanlines — pure CSS, no JS cost */
.hero-terminal::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0 2px,
        rgba(0, 0, 0, 0.12) 2px 3px
    );
}

.term-titlebar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 255, 255, 0.06);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    color: #7aa7a7;
    font-size: 0.72rem;
    user-select: none;
}

.term-dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-red { background: #e74c3c; }
.dot-yellow { background: #ffd700; }
.dot-green { background: #2ecc71; }
.term-title { margin-left: 6px; letter-spacing: 0.05em; }

.term-out {
    min-height: 96px;
    max-height: 180px;
    overflow-y: auto;
    padding: 10px 12px 4px;
    color: #cfe8e8;
    line-height: 1.5;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 255, 255, 0.3) transparent;
}

.term-line { white-space: pre-wrap; word-break: break-word; }
.term-sys { color: #8aa; font-style: italic; }
.term-echo { color: #e0e0e0; }
.term-err { color: #e74c3c; }
.term-gold { color: var(--gold, #ffd700); }
.term-cyan { color: var(--cyan, #00ffff); }
.term-purple { color: #c08fdd; }
.term-green { color: #2ecc71; }
.term-prompt-echo { color: var(--gold, #ffd700); }

.term-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 10px;
}

.term-prompt {
    color: var(--gold, #ffd700);
    animation: term-prompt-blink 1.2s steps(2) infinite;
}

@keyframes term-prompt-blink {
    50% { opacity: 0.25; }
}

.term-in {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e8ffff;
    font: inherit;
    caret-color: var(--cyan, #00ffff);
}

.term-in::placeholder { color: #4a6a6a; }

/* mobile: collapse behind the toggle to keep the hero short */
@media (max-width: 768px) {
    .terminal-toggle { display: inline-flex; align-items: center; gap: 6px; }
    .hero-terminal { display: none; margin-top: 0.75rem; }
    .hero-terminal.open { display: block; }
}

/* ------------------------------------------------- character-select overlay */
.character-select-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 50% 30%, rgba(155, 89, 182, 0.12), transparent 60%),
        rgba(6, 6, 10, 0.96);
    opacity: 1;
    transition: opacity 0.45s ease;
}

/* shown only while no visitor mode has ever been chosen (set pre-paint in App.razor) */
html:not([data-visitor-mode]) .character-select-overlay {
    display: flex;
}

.character-select-inner {
    text-align: center;
    padding: 2rem;
    max-width: 1000px;
    animation: select-rise 0.6s ease-out;
}

@keyframes select-rise {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.select-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    letter-spacing: 0.18em;
    color: var(--gold, #ffd700);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    margin: 0 0 0.4rem;
}

.select-subtitle {
    color: #a0a0a0;
    font-style: italic;
    margin: 0 0 2.2rem;
}

.select-cards {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.select-card {
    width: 240px;
    padding: 1.4rem 1.2rem 1.2rem;
    background: linear-gradient(180deg, #16161f 0%, #0d0d14 100%);
    border: 2px solid #3a3a50;
    border-radius: 12px;
    color: #e0e0e0;
    cursor: pointer;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    font-family: inherit;
}

.select-card:hover,
.select-card:focus-visible {
    transform: translateY(-8px);
    outline: none;
}

.select-card.recruiter:hover, .select-card.recruiter:focus-visible { border-color: var(--gold, #ffd700); box-shadow: 0 0 30px rgba(255, 215, 0, 0.25); }
.select-card.player:hover, .select-card.player:focus-visible { border-color: var(--cyan, #00ffff); box-shadow: 0 0 30px rgba(0, 255, 255, 0.25); }
.select-card.dev:hover, .select-card.dev:focus-visible { border-color: #9b59b6; box-shadow: 0 0 30px rgba(155, 89, 182, 0.3); }

.select-avatar-frame {
    width: 132px;
    height: 132px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(155, 89, 182, 0.12), transparent 70%);
    border: 1px solid #2c2c40;
    border-radius: 10px;
    overflow: hidden;
}

.select-avatar {
    --av-fw: 64px;
    --av-fh: 64px;
    --av-frames: 1;
    --av-dur: 1s;
    --av-scale: 2;
    width: calc(var(--av-fw) * var(--av-scale));
    height: calc(var(--av-fh) * var(--av-scale));
    image-rendering: pixelated;
    background-repeat: no-repeat;
    background-size: calc(var(--av-fw) * var(--av-frames) * var(--av-scale)) calc(var(--av-fh) * var(--av-scale));
}

.select-avatar.sprite-ready {
    animation: select-avatar-idle var(--av-dur) steps(var(--av-frames)) infinite;
}

@keyframes select-avatar-idle {
    to { background-position-x: calc(-1 * var(--av-fw) * var(--av-frames) * var(--av-scale)); }
}

.select-class-name {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--gold, #ffd700);
    margin-bottom: 0.35rem;
}

.select-class-desc {
    font-size: 0.85rem;
    color: #a0a0a0;
    min-height: 2.4em;
}

.select-class-perk {
    margin-top: 0.7rem;
    font-size: 0.75rem;
    color: var(--cyan, #00ffff);
    letter-spacing: 0.04em;
}

.select-skip {
    margin-top: 2rem;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.select-skip:hover { color: var(--cyan, #00ffff); }

/* ----------------------------------------------------------- cursor trail */
.spell-trail-dot {
    position: fixed;
    left: -20px;
    top: -20px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 150;
    opacity: 0;
    background: var(--cyan, #00ffff);
    box-shadow: 0 0 6px var(--cyan, #00ffff);
}

.spell-trail-dot:nth-child(odd) {
    background: var(--gold, #ffd700);
    box-shadow: 0 0 6px var(--gold, #ffd700);
}

.spell-trail-dot.live {
    animation: trail-fade 0.6s ease-out forwards;
}

@keyframes trail-fade {
    from { opacity: 0.8; transform: translate(-50%, -50%) scale(1); }
    to   { opacity: 0; transform: translate(-50%, -50%) scale(0.2) translateY(8px); }
}

/* ------------------------------------------------------- game-card polish */
/* JS sets inline perspective transforms; keep the return-to-rest smooth.   */
.game-card {
    transition: transform 0.35s ease, box-shadow 0.3s ease;
    will-change: transform;
}

.game-card[data-tilt]:hover {
    transition: transform 0.06s linear, box-shadow 0.3s ease;
}

/* animated pixel key-art header inside each card */
.game-keyart {
    --ka-fw: 96px;
    --ka-fh: 96px;
    --ka-frames: 1;
    --ka-dur: 1s;
    --ka-scale: 1.5;
    width: calc(var(--ka-fw) * var(--ka-scale));
    height: calc(var(--ka-fh) * var(--ka-scale));
    margin: 0 auto;
    image-rendering: pixelated;
    background-repeat: no-repeat;
    background-size: calc(var(--ka-fw) * var(--ka-frames) * var(--ka-scale)) calc(var(--ka-fh) * var(--ka-scale));
    filter: drop-shadow(0 0 14px var(--game-accent, rgba(0, 255, 255, 0.35)));
}

.game-card:hover .game-keyart.sprite-ready,
.games-section.emphasized .game-keyart.sprite-ready {
    animation: game-keyart-idle var(--ka-dur) steps(var(--ka-frames)) infinite;
}

@keyframes game-keyart-idle {
    to { background-position-x: calc(-1 * var(--ka-fw) * var(--ka-frames) * var(--ka-scale)); }
}

/* until the key-art manifest loads, cards keep their emoji icon */
.game-keyart { display: none; }
.game-keyart.sprite-ready { display: block; position: relative; z-index: 1; }
.game-icon-container:has(.game-keyart.sprite-ready) { width: 144px; height: 144px; }
.game-icon-container:has(.game-keyart.sprite-ready) .keyart-fallback { display: none; }

/* off-screen guard set by an IntersectionObserver in hero-fx.js */
.games-section.offscreen .game-keyart.sprite-ready { animation-play-state: paused; }

.game-name {
    position: relative;
}

.game-name::after {
    content: '';
    display: block;
    width: 48px;
    height: 2px;
    margin: 0.4rem auto 0;
    background: var(--game-accent, var(--gold, #ffd700));
    box-shadow: 0 0 8px var(--game-accent, var(--gold, #ffd700));
}

/* ------------------------------------------------------------ pixel icons */
.pixicon {
    display: inline-block;
    width: 22px;
    height: 22px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    vertical-align: -0.35em;
}

.pixicon-swords    { background-image: url('images/icons/icon-swords.png'); }
.pixicon-flame     { background-image: url('images/icons/icon-flame.png'); }
.pixicon-scroll    { background-image: url('images/icons/icon-scroll.png'); }
.pixicon-eye       { background-image: url('images/icons/icon-eye.png'); }
.pixicon-network   { background-image: url('images/icons/icon-network.png'); }
.pixicon-shield    { background-image: url('images/icons/icon-shield.png'); }
.pixicon-orb       { background-image: url('images/icons/icon-orb.png'); }
.pixicon-lightning { background-image: url('images/icons/icon-lightning.png'); }
.pixicon-gear      { background-image: url('images/icons/icon-gear.png'); }
.pixicon-potion    { background-image: url('images/icons/icon-potion.png'); }
.pixicon-star      { background-image: url('images/icons/icon-star.png'); }
.pixicon-code      { background-image: url('images/icons/icon-code.png'); }
.pixicon-gem-green  { background-image: url('images/icons/icon-gem-green.png'); }
.pixicon-gem-red    { background-image: url('images/icons/icon-gem-red.png'); }
.pixicon-gem-blue   { background-image: url('images/icons/icon-gem-blue.png'); }
.pixicon-gem-purple { background-image: url('images/icons/icon-gem-purple.png'); }

.stat-icon .pixicon { width: 26px; height: 26px; }
.btn-icon .pixicon { width: 20px; height: 20px; }

/* -------------------------------------------------------------- grain */
.hero::after,
.games-section::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hero, .games-section { position: relative; }

/* --------------------------------------------------------- typography pass */
.glitch {
    letter-spacing: 0.06em;
}

.class-title {
    letter-spacing: 0.04em;
}

.section-title {
    letter-spacing: 0.14em;
}

/* ------------------------------------------------------- visitor tailoring */
/* recruiter: surface the "open to opportunities" chip */
.hire-chip {
    display: none;
    margin: 0.6rem 0 0;
    padding: 0.3rem 0.9rem;
    width: fit-content;
    border: 1px solid var(--gold, #ffd700);
    border-radius: 999px;
    color: var(--gold, #ffd700);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    background: rgba(255, 215, 0, 0.07);
}

html[data-visitor-mode='recruiter'] .hire-chip { display: block; }

/* ------------------------------------------------------------ motion guard */
@media (prefers-reduced-motion: reduce) {
    .wizard-sprite,
    .wizard-sprite.casting,
    .select-avatar.sprite-ready,
    .game-keyart.sprite-ready,
    .term-prompt {
        animation: none !important;
    }

    .spell-trail-dot { display: none; }
    body.spell-flash::before { display: none; }
    .hero::after, .games-section::after { mix-blend-mode: normal; opacity: 0.03; }
}
