/* Hoop Toss: game-specific styles. Loaded after games.css.
   Palette and type follow tools/games/design/hoop-toss.md. */

.ht-wrap {
    --ht-ink: #140a26;
    --ht-night: #1b1340;
    --ht-plum: #5b2a7a;
    --ht-cream: #fff3d6;
    --ht-yellow: #ffd23f;
    --ht-orange: #ff5a1f;
    --ht-mint: #5cf2b0;
    --ht-pink: #ff4f8b;
    --ht-display: 'Bungee', 'Inter', system-ui, sans-serif;
    max-width: 520px;
    margin-top: 10px;
}

.ht-lede {
    text-align: center;
    max-width: 640px;
    margin: 14px auto 6px;
    color: #666;
}

/* HUD: a scoreboard strip */
.ht-wrap .game-hud {
    gap: 6px 10px;
    justify-content: space-around;
    flex-wrap: nowrap;
    margin: 0 auto 8px;
    padding: 8px 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, #2a1c58, var(--ht-ink));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 8px 20px -10px rgba(20, 8, 40, 0.7);
}
.ht-wrap .hud-stat { min-width: 50px; }
.ht-wrap .hud-stat .k { color: rgba(255, 243, 214, 0.62); letter-spacing: 0.12em; }
.ht-wrap .hud-stat .v {
    font-family: var(--ht-display);
    font-weight: 400;
    font-size: 1.25rem;
    line-height: 1.1;
    color: var(--ht-yellow);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 14px rgba(255, 210, 63, 0.35);
    display: inline-block;
    transform-origin: left center;
}
.ht-wrap #hud-time { color: var(--ht-mint); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 14px rgba(92, 242, 176, 0.35); }
.ht-wrap .hud-stat .v.is-low { color: var(--ht-pink); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 14px rgba(255, 79, 139, 0.5); }
.ht-wrap .hud-stat .v.is-fire { color: var(--ht-orange); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 16px rgba(255, 90, 31, 0.8); }
.ht-wrap .hud-stat .v.is-bump { animation: ht-bump 0.28s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes ht-bump { 0% { transform: scale(1); } 35% { transform: scale(1.45); } 100% { transform: scale(1); } }

.ht-wrap .ht-actions { margin: 10px 0 0; justify-content: center; gap: 8px; }
.ht-wrap .ht-title.is-new .ht-stats { display: none; }
.ht-wrap .hud-btn {
    padding: 6px 11px;
    min-height: 34px;
    font-size: 0.76rem;
    border: 1px solid #4a2f86;
    background: linear-gradient(180deg, #3a2470, var(--ht-ink));
    color: var(--ht-cream);
}
.ht-wrap .hud-btn:hover { border-color: var(--ht-yellow); box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.18); }
.ht-wrap .hud-btn:active { transform: translateY(1px) scale(0.97); }

/* The frame hugs the canvas so overlays line up with it exactly */
.ht-wrap .stage-frame {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    padding: 7px;
    border-radius: 20px;
    background: linear-gradient(160deg, #4a2f86, var(--ht-ink) 70%);
    box-shadow: 0 2px 0 rgba(255, 255, 255, 0.14) inset, 0 22px 44px -18px rgba(27, 19, 64, 0.75);
}
.ht-wrap .stage-frame canvas { width: 320px; height: auto; max-width: 100%; aspect-ratio: 2 / 3; border-radius: 14px; cursor: grab; }
.ht-wrap .stage-frame canvas:active { cursor: grabbing; }

.ht-wrap .stage-overlay {
    inset: 7px;
    border-radius: 14px;
    gap: 9px;
    padding: 14px 12px;
    overflow: hidden;
    color: var(--ht-cream);
}
.ht-wrap .stage-overlay p { font-size: 0.86rem; line-height: 1.4; margin: 0; }
.ht-wrap .overlay-note { max-width: 32ch; line-height: 1.5; color: rgba(255, 243, 214, 0.75); }
.ht-wrap .overlay-note kbd {
    font: 600 0.72rem 'Inter', sans-serif;
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid rgba(255, 243, 214, 0.4);
    background: rgba(255, 243, 214, 0.1);
    color: var(--ht-cream);
}

/* Title screen: the court stays visible behind a scrim, and the demo ball keeps scoring */
.ht-wrap .ht-title {
    justify-content: flex-end;
    padding-top: 38%;
    padding-bottom: 18px;
    background: linear-gradient(180deg, rgba(20, 8, 40, 0) 30%, rgba(20, 8, 40, 0.5) 52%, rgba(20, 8, 40, 0.82) 100%);
}
.ht-wrap .stage-overlay h2.ht-logo {
    font-family: var(--ht-display);
    font-weight: 400;
    font-size: clamp(2.6rem, 16vw, 4.1rem);
    line-height: 0.9;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: rotate(-5deg);
    letter-spacing: 0.01em;
    animation: ht-logo-in 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.ht-logo span {
    color: var(--ht-yellow);
    text-shadow:
        -2px 0 0 var(--ht-ink), 2px 0 0 var(--ht-ink), 0 -2px 0 var(--ht-ink),
        0 3px 0 var(--ht-orange), 0 6px 0 #c9340a, 0 9px 0 var(--ht-ink), 0 16px 22px rgba(20, 8, 40, 0.6);
}
.ht-logo span + span { color: var(--ht-cream); margin-left: 0.5em; }
@keyframes ht-logo-in { from { transform: rotate(-14deg) scale(0.4); opacity: 0; } to { transform: rotate(-5deg) scale(1); opacity: 1; } }
.ht-tag {
    font-family: var(--ht-display);
    font-size: 0.82rem !important;
    letter-spacing: 0.06em;
    color: var(--ht-mint);
    text-shadow: 0 2px 0 var(--ht-ink);
    margin-top: 6px !important;
}
.ht-wrap .play-btn {
    font-family: var(--ht-display);
    font-weight: 400;
    font-size: 1.35rem;
    letter-spacing: 0.05em;
    padding: 12px 44px 10px;
    color: var(--ht-ink);
    background: linear-gradient(180deg, #ffe37a, var(--ht-yellow) 45%, #ff9a2e);
    border: 3px solid var(--ht-ink);
    box-shadow: 0 6px 0 #c9340a, 0 8px 0 var(--ht-ink), 0 16px 26px rgba(20, 8, 40, 0.55);
    transition: transform 0.08s, box-shadow 0.08s;
    animation: ht-pulse 1.5s ease-in-out infinite;
}
.ht-wrap .play-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #c9340a, 0 10px 0 var(--ht-ink), 0 18px 28px rgba(20, 8, 40, 0.55); }
.ht-wrap .play-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #c9340a, 0 3px 0 var(--ht-ink); animation: none; }
.ht-wrap .play-btn:focus-visible { outline: 3px solid var(--ht-cream); outline-offset: 4px; }
/* glow only: the button must not move or resize, so it stays easy to hit */
@keyframes ht-pulse { 0%, 100% { filter: brightness(1) drop-shadow(0 0 0 rgba(255, 210, 63, 0)); } 50% { filter: brightness(1.14) drop-shadow(0 0 12px rgba(255, 210, 63, 0.85)); } }

.ht-stats { display: flex; gap: 14px; justify-content: center; }
.ht-stat { display: flex; flex-direction: column; gap: 1px; min-width: 64px; }
.ht-stat .k, .ht-row .k {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: rgba(255, 243, 214, 0.62);
}
.ht-stat .v { font-family: var(--ht-display); font-size: 1rem; color: var(--ht-cream); font-variant-numeric: tabular-nums; }
.ht-goal { color: var(--ht-yellow) !important; font-weight: 600; max-width: 32ch !important; font-size: 0.8rem !important; }

.ht-skins { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ht-skin {
    width: 28px; height: 28px; padding: 0;
    border-radius: 50%;
    border: 2px solid var(--ht-ink);
    background: radial-gradient(circle at 34% 28%, var(--ball-hi), var(--ball) 55%, color-mix(in srgb, var(--ball) 45%, #000) 100%);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform 0.15s;
}
.ht-skin:hover:not(:disabled) { transform: scale(1.15) rotate(12deg); }
.ht-skin.is-on { box-shadow: 0 0 0 2px var(--ht-yellow), 0 0 12px rgba(255, 210, 63, 0.7); }
.ht-skin:focus-visible { outline: 3px solid var(--ht-cream); outline-offset: 2px; }
.ht-skin.is-locked { filter: grayscale(1) brightness(0.5); cursor: not-allowed; }

/* Result card */
.ht-wrap .ht-result {
    background:
        radial-gradient(120% 70% at 50% 0%, rgba(255, 122, 60, 0.35), rgba(255, 122, 60, 0) 60%),
        linear-gradient(180deg, rgba(43, 24, 88, 0.93), rgba(20, 8, 40, 0.96));
    animation: ht-card-in 0.3s ease-out both;
}
@keyframes ht-card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.ht-wrap .ht-result h2 {
    font-family: var(--ht-display);
    font-weight: 400;
    font-size: clamp(1.2rem, 6vw, 1.6rem);
    color: var(--ht-cream);
    text-shadow: 0 3px 0 var(--ht-ink);
    margin: 0;
}
.ht-score {
    font-family: var(--ht-display);
    font-size: clamp(3.2rem, 18vw, 4.6rem);
    line-height: 0.95;
    color: var(--ht-yellow);
    text-shadow:
        -2px 0 0 var(--ht-ink), 2px 0 0 var(--ht-ink), 0 -2px 0 var(--ht-ink),
        0 4px 0 var(--ht-orange), 0 7px 0 #c9340a, 0 10px 0 var(--ht-ink), 0 16px 24px rgba(20, 8, 40, 0.6);
    font-variant-numeric: tabular-nums;
}
.ht-score.is-pop { animation: ht-score-pop 0.55s cubic-bezier(0.2, 1.7, 0.4, 1) 0.1s both; }
@keyframes ht-score-pop { from { transform: scale(0.2) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.ht-medal {
    font-family: var(--ht-display);
    font-size: 0.78rem; letter-spacing: 0.04em;
    padding: 5px 16px 4px; border-radius: 999px;
    border: 2px solid var(--ht-ink);
    background: rgba(255, 243, 214, 0.14); color: var(--ht-cream);
}
.ht-medal[data-medal="bronze"] { background: linear-gradient(180deg, #e39a5a, #9a5a24); color: #2a1405; }
.ht-medal[data-medal="silver"] { background: linear-gradient(180deg, #f2f6f5, #9aa8a6); color: #14201e; }
.ht-medal[data-medal="gold"] { background: linear-gradient(180deg, #fff0a0, #f0b422); color: #2b1d02; }
.ht-medal[data-medal="diamond"] { background: linear-gradient(180deg, #d6fbff, #5cc6ea); color: #072431; }
.ht-lines { width: min(100%, 290px); display: flex; flex-direction: column; gap: 3px; }
.ht-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.82rem; color: var(--ht-cream); }
.ht-row .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.ht-news { max-width: 30ch !important; font-size: 0.8rem !important; color: rgba(255, 243, 214, 0.85); }
.ht-news.is-unlock { color: var(--ht-mint) !important; font-weight: 700; }

.ht-wrap .stage-status { color: #5a4a7a; }
.ht-wrap .mode-chip { background: #efe6ff; color: #4a2f86; }

/* Keyboard help only where there is likely to be a keyboard */
@media (hover: none) { .ht-kbd { display: none; } }

@media (max-width: 400px) {
    .ht-wrap .stage-overlay { gap: 7px; }
    .ht-wrap .hud-stat .v { font-size: 1.1rem; }
}
@media (max-width: 699px) {
    .tool-section h1:has(+ .ht-wrap) { font-size: 1.35rem; margin-bottom: 4px; }
}
@media (prefers-reduced-motion: reduce) {
    .ht-skin, .ht-skin:hover, .ht-logo, .ht-wrap .play-btn, .ht-score.is-pop, .ht-wrap .ht-result, .ht-wrap .hud-stat .v.is-bump { transition: none; animation: none; }
}

/* Short stages (small phones, short laptop windows): tighten both cards so nothing spills */
@media (max-height: 700px), (max-width: 380px) {
    .ht-wrap .stage-overlay { gap: 5px; padding: 10px 10px; }
    .ht-wrap .ht-title { padding-top: 30%; padding-bottom: 12px; }
    .ht-wrap .stage-overlay h2.ht-logo { font-size: clamp(2.2rem, 13vw, 3.2rem); }
    .ht-score { font-size: clamp(2.4rem, 13vw, 3.2rem); }
    .ht-wrap .play-btn { font-size: 1.1rem; padding: 9px 34px 7px; }
    .ht-row { font-size: 0.76rem; }
    .ht-news { font-size: 0.74rem !important; }
    .ht-skin { width: 24px; height: 24px; }
    .ht-wrap .ht-result .overlay-note { display: none; }
}

/* Ball swatches use the generated ball art once it has loaded */
.ht-has-balls .ht-skin {
    background: url('/assets/games/hoop-toss/balls-v1.webp') calc(var(--i, 0) * 20%) 0 / 600% 100% no-repeat;
    border-color: transparent;
    width: 32px; height: 32px;
}
