/*
   Meeple Dates - Interactive Lander
   Dark theme with Three.js D20 die roller
*/

/* Base */
html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    padding: 0;
    padding-top: var(--header-height, 3.25rem);
    background: #111;
    font-family: Arial, sans-serif;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    box-sizing: border-box;
}

/* Snap Sections */
.snap-section {
    scroll-snap-align: start;
    min-height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* Cards section auto-sizes to content, no forced 100vh */
.snap-section--cards {
    min-height: auto;
    scroll-snap-align: start;
    padding: 2rem 0 6rem;
    flex-direction: column;
    align-items: center;
}

/* Hero */
.hero-parallax {
    position: relative;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    pointer-events: none;
}

/* Collapse hero so snap can't return to it */
#section-hero.hero-collapsed {
    min-height: 0;
    height: 0;
    overflow: hidden;
    scroll-snap-align: none;
    pointer-events: none;
}

.hero-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    box-sizing: border-box;
    pointer-events: none;
}

.hero-bg.fade-out {
    opacity: 0.2;
    transition: opacity 1s;
}

.hero-title {
    position: relative;
    z-index: 2;
    color: #fff;
    font-weight: bold;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    width: 75vw;
    max-width: 75vw;
    margin: 0;
    font-size: clamp(2rem, 8vw, 8rem);
    line-height: 1.05;
    white-space: normal;
    word-break: break-word;
}

.hero-cta {
    position: relative;
    z-index: 2;
    display: inline-block;
    margin-top: 2rem;
    padding: 1.125rem 3.75rem;
    background: var(--c-secondary, #008080);
    color: #fff;
    font-size: clamp(1.2rem, 2.6vw, 1.875rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    text-decoration: none;
    border-radius: 55px;
    box-shadow: 0 5px 24px rgba(0, 128, 128, 0.38);
    transition: transform 0.2s, box-shadow 0.2s;
    pointer-events: auto;
}

.hero-cta:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 128, 128, 0.5);
}

/* Arrow */
.arrow-down {
    position: absolute;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%);
    z-index: 10;
    width: 3rem;
    height: 3rem;
    opacity: 0.8;
    animation: bounce 1.2s infinite;
    pointer-events: none;
}

@keyframes bounce {
    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-20px);
    }
}

.arrow-down.hide {
    display: none;
}

/* Die / Canvas */
.die-section {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    min-height: 15vh;
    background: #111;
    z-index: 2;
    box-sizing: border-box;
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 1.5s ease-out;
}

.die-hidden {
    opacity: 0;
    pointer-events: none;
}

.die-dissolve {
    opacity: 0;
    filter: blur(12px) brightness(2);
    transform: scale(1.2);
    transition: opacity 1.2s ease-out, filter 1.2s ease-out, transform 1.2s ease-out;
    pointer-events: none;
}

#info {
    position: absolute;
    top: 1.25rem;
    width: 100%;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffffff;
    z-index: 100;
}

/* Form Container */
#user-form-container {
    width: 100%;
    max-width: 100vw;
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    position: relative;
    z-index: 10;
    margin: 0 auto;
    padding: 1.5rem;
    box-sizing: border-box;
}

/* Hide snap sections until active */
#section-form,
#section-roll,
#section-cards {
    display: none;
}

#section-form.active {
    display: flex;
}

#section-roll.active {
    display: flex;
}

#section-cards.active {
    display: flex;
}

/* Form */
#user-form {
    background: var(--c-primary, #3A3A57);
    padding: 2.5rem 2.5rem;
    border-radius: 1.25rem;
    box-shadow: 0 4px 32px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 26rem;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Form Labels & Inputs */
.form-label {
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input-row {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.form-text-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: #fff;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-text-input:focus {
    outline: none;
    border-color: var(--c-secondary, #008080);
    box-shadow: 0 0 0 2px rgba(0, 128, 128, 0.3);
}

.form-range {
    width: 100%;
    margin-top: 0.5rem;
    accent-color: var(--c-secondary, #008080);
}

.form-age-value {
    color: var(--c-secondary, #008080);
    font-size: 1.1rem;
    font-weight: 700;
    margin-left: 0.75rem;
}

.form-radio-group {
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-option-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 1rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #fff;
}

.form-option-label input[type="radio"],
.form-option-label input[type="checkbox"] {
    transform: scale(1.2);
    accent-color: var(--c-secondary, #008080);
}

/* Random Name Button */
#random-name-btn {
    padding: 0 0.875rem;
    font-size: 1.1rem;
    border-radius: 0.5rem;
    background: var(--c-secondary, #008080);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    box-sizing: border-box;
    flex-shrink: 0;
}

#random-name-btn:hover {
    background: rgba(0, 128, 128, 0.2);
    border-color: var(--c-secondary, #008080);
}

/* Submit / YOLO Buttons */
.btn-submit {
    margin-top: 0.5rem;
    font-size: 1rem;
    padding: 0.875rem 2rem;
    background: var(--c-secondary, #008080);
    color: #fff;
    border: none;
    border-radius: 50px;
    box-shadow: 0 2px 8px #0004;
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn-submit:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 16px rgba(0, 128, 128, 0.4);
}

.btn-yolo {
    font-size: 0.95rem;
    padding: 0.75rem 2rem;
    background: transparent;
    color: var(--c-secondary, #008080);
    border: 2px solid var(--c-secondary, #008080);
    border-radius: 50px;
    box-shadow: none;
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn-yolo:hover {
    background: rgba(0, 128, 128, 0.15);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 128, 128, 0.3);
}

/* Form responsive — wider screens */
@media (min-width: 48em) {
    #user-form {
        max-width: 28rem;
        padding: 3rem 3rem;
    }
}

@media (min-width: 75em) {
    #user-form {
        max-width: 30rem;
        padding: 3rem 3.5rem;
    }
}

/* Form responsive — smaller screens */
@media (max-width: 30em) {
    #user-form {
        padding: 1.5rem 1.25rem;
        gap: 1.25rem;
        border-radius: 1rem;
    }
    .form-label,
    .form-radio-group {
        font-size: 0.8rem;
    }
    .form-option-label {
        font-size: 0.9rem;
    }
}

/* Roll Area */
#roll-area {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    box-sizing: border-box;
}

#roll-text {
    position: absolute;
    top: 2.5rem;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 10;
    font-size: 2.2rem;
    color: #fff;
    font-family: Arial, sans-serif;
    font-weight: bold;
    text-shadow: 0 2px 8px #000;
    pointer-events: none;
}

/* Party Grid — 4 columns max, centered */
#party-grid {
    display: none;
    position: relative;
    margin: 0 auto;
    max-width: 64rem;
    z-index: 20;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1rem;
    justify-items: center;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 56em) {
    #party-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 36em) {
    #party-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; padding: 0.75rem; }
}

/* Card dealing animation */
.card-in-deck {
    opacity: 0;
    pointer-events: none;
}

.party-card:not(.card-in-deck) {
    opacity: 1;
}

.card-dealing {
    transition: transform var(--deal-duration, 0.5s) cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.3s ease;
}

/* Interstitial pulse text */
.pulse-text {
    animation: pulseGlow 1s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* ===================== Party Cards ===================== */
.party-card {
    background: linear-gradient(145deg, #2a2a45 0%, #1e1e35 100%);
    border: 2px solid #484870;
    border-radius: 0.75rem;
    box-shadow: 0 2px 12px #0006;
    padding: 0;
    text-align: center;
    color: #e0e0e0;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    transition: transform 0.2s, box-shadow 0.2s;
    aspect-ratio: 2.5 / 3.5;
}

.party-card:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 6px 24px #0008;
    border-color: #84C8C6;
}

.party-card.selected {
    border: 3px solid transparent;
    z-index: 2;
    animation: shimmerRotate 2s linear infinite;
    background:
        linear-gradient(145deg, #2a2a45 0%, #1e1e35 100%) padding-box,
        conic-gradient(
            from var(--shimmer-angle, 0deg),
            var(--c-secondary, #008080) 0deg,
            transparent 60deg,
            transparent 300deg,
            var(--c-secondary, #008080) 360deg
        ) border-box;
}

/* Centred selection checkmark */
.card-select-check {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(46, 204, 64, 0.92);
    color: #fff;
    font-size: 1.6rem;
    font-weight: bold;
    line-height: 3rem;
    text-align: center;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 12px rgba(46, 204, 64, 0.5);
}

.party-card.selected .card-select-check {
    display: block;
}

@keyframes shimmerRotate {
    to { --shimmer-angle: 360deg; }
}

@property --shimmer-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* Card header — name bar */
.card-header {
    flex: 0 0 auto;
    background: linear-gradient(90deg, #3a3a57, #4a4a6a);
    color: #fff;
    padding: 0.4rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(0.7rem, 1.4vw, 0.9rem);
    font-weight: 700;
    line-height: 1.2;
    gap: 0.25rem;
}

.card-header .card-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-header .card-level {
    flex-shrink: 0;
    font-size: 0.85em;
    opacity: 0.7;
    color: #84C8C6;
}

/* Image window */
.card-img-frame {
    position: relative;
    margin: 0.3rem;
    border: 2px solid #484870;
    border-radius: 0.4rem;
    overflow: hidden;
    background: #111;
    flex: 1 1 auto;
    min-height: 0;
}

.card-img-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Verified badge on image */
.card-verified-badge {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    background: linear-gradient(135deg, #2ecc40, #27ae60);
    color: #fff;
    font-size: 0.55rem;
    padding: 0.2rem 0.4rem 0.2rem 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    border-radius: 0.35rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    z-index: 3;
    box-shadow: 0 2px 6px #0004;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
}

/* Holographic shimmer overlay for verified cards on hover */
.party-card.card-verified:hover .card-img-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent 20%,
        rgba(132, 200, 198, 0.25) 30%,
        rgba(199, 81, 192, 0.2) 40%,
        transparent 50%,
        rgba(255, 224, 102, 0.2) 60%,
        rgba(132, 200, 198, 0.25) 70%,
        transparent 80%
    );
    background-size: 200% 200%;
    animation: holoShift 1.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
    border-radius: 0.4rem;
}

@keyframes holoShift {
    0% { background-position: 0% 0%; }
    50% { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

/* Info bar under image */
.card-info {
    flex: 0 0 auto;
    min-width: 0;
    font-size: clamp(0.55rem, 1vw, 0.7rem);
    color: #999;
    padding: 0.1rem 0.4rem;
    text-align: right;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Skills / interests list */
.card-skills {
    flex: 0 0 auto;
    margin: 0 0.3rem 0.3rem;
    padding: 0.2rem 0.35rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid #484870;
    border-radius: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    overflow: hidden;
}

.card-skill-row {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: clamp(0.6rem, 1.1vw, 0.75rem);
    font-weight: 600;
    color: #ccc;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-skill-row::before {
    content: "\2726";
    color: var(--c-accent, #C751C0);
    font-size: 0.7em;
    flex-shrink: 0;
}

/* Party section title */
.party-title {
    text-align: center;
    color: #fff;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    margin: 0 0 1rem;
    padding-top: 1.5rem;
    text-shadow: 0 2px 12px #C751C066;
    letter-spacing: 0.02em;
    width: 100%;
}

/* Quest Button */
#start-quest-btn {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%);
    width: clamp(16.25rem, 60vw, 26.25rem);
    max-width: 90vw;
    margin: 0 auto;
    z-index: 100;
    font-size: 1.1rem;
    padding: 1rem 2.5rem;
    background: var(--c-secondary, #008080);
    color: #fff;
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 24px rgba(0, 128, 128, 0.3);
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: transform 0.2s, box-shadow 0.2s;
}

#start-quest-btn:hover {
    transform: translateX(-50%) scale(1.03);
    box-shadow: 0 6px 20px rgba(0, 128, 128, 0.45);
}

/* No Results */
.no-results {
    color: #fff;
    font-size: 1.2rem;
    text-align: center;
    padding: 2rem;
}
