/* Draw lots (/draw-lots): only what is the app's own, the slips of paper, the tickets of Everyone draws and their
   short shake. Panels, fields, buttons, the table and the colours come from the app kit (css/app-kit,
   docs/app-kit.md). Loaded only on this app's page (StylePaths in its demo catalog entry). */

/* The shared app layout gives the stage a fixed height with overflow hidden: the stage scrolls on its own, so the
   history below the result stays reachable. */
body .filter-landing-app.draw-lots-landing-app > .filter-landing-stage.ak-stage {
    justify-content: flex-start;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

.draw-lots-landing-app > .filter-landing-stage.ak-stage > * {
    flex-shrink: 0;
    align-self: stretch;
    min-width: 0;
    max-width: 100%;
}

/* The list of names: a text area with the panel's corners (the kit's fields are pills). */
.draw-lots-landing-app textarea.dl-names {
    min-height: 9rem;
    border-radius: var(--ak-radius);
    resize: vertical;
}

/* --- The result ---------------------------------------------------------------------------------------------------- */

.draw-lots-landing-app .dl-result {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 11rem;
    padding: var(--ak-space-3, 0.75rem) 0;
}

.draw-lots-landing-app .dl-placeholder {
    color: var(--ak-muted);
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
    opacity: 0.45;
}

.draw-lots-landing-app .dl-tickets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    max-width: 100%;
}

.draw-lots-landing-app .dl-summary {
    min-height: 1.4em;
    margin: 0;
    color: var(--ak-muted);
    font-size: var(--ak-fs-md);
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.draw-lots-landing-app .dl-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.draw-lots-landing-app .dl-actions > .ak-btn {
    min-width: 9rem;
}

/* A short shake while throw-away tickets flash by; the real draw was made before it started. */
.draw-lots-landing-app .dl-result.is-rolling .dl-tickets > * {
    animation: dl-shake 0.12s ease-in-out infinite alternate;
}

@keyframes dl-shake {
    from { transform: rotate(-4deg) translateY(-2px); }
    to { transform: rotate(4deg) translateY(2px); }
}

@media (prefers-reduced-motion: reduce) {
    .draw-lots-landing-app .dl-result.is-rolling .dl-tickets > * {
        animation: none;
    }
}

/* A drawn name: a folded slip of paper. */
.draw-lots-landing-app .dl-lot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 6rem;
    max-width: 100%;
    padding: 0.7rem 1.2rem;
    border: 1px solid #e7d9a8;
    border-radius: 0.35rem;
    background: linear-gradient(180deg, #fffbea 0%, #fff7d6 49%, #f6ebbf 50%, #fffbea 100%);
    color: #3f3a2a;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
    font-size: var(--ak-fs-lg);
    font-weight: 700;
    overflow-wrap: anywhere;
    transform: rotate(-1.5deg);
}

.draw-lots-landing-app .dl-lot:nth-child(even) {
    transform: rotate(1.5deg);
}

.draw-lots-landing-app .dl-result[data-size="1"] .dl-lot {
    min-width: 12rem;
    padding: 1.2rem 2rem;
    font-size: var(--ak-fs-2xl);
}

/* Everyone draws: one ticket per person, "giver -> name", in a grid. */
.draw-lots-landing-app .dl-pairs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    width: 100%;
    gap: 0.6rem;
}

.draw-lots-landing-app .dl-pair {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius);
    background: var(--ak-field);
    color: var(--ak-text);
}

.draw-lots-landing-app .dl-pair-from,
.draw-lots-landing-app .dl-pair-to {
    flex: 1 1 0;
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.draw-lots-landing-app .dl-pair-arrow {
    flex: 0 0 auto;
    color: var(--ak-muted);
}

[dir="rtl"] .draw-lots-landing-app .dl-pair-arrow {
    transform: scaleX(-1);
}

.draw-lots-landing-app button.dl-pair-to {
    min-height: 2rem;
    padding: 0.25rem 0.6rem;
    border: 1px dashed var(--ak-accent);
    border-radius: var(--ak-radius-sm);
    background: transparent;
    color: var(--ak-accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.draw-lots-landing-app button.dl-pair-to.is-open {
    border-style: solid;
    background: var(--ak-accent);
    color: var(--ak-on-accent);
}

.draw-lots-landing-app button.dl-pair-to:focus-visible {
    outline: 2px solid var(--ak-accent);
    outline-offset: 2px;
}

/* --- History ------------------------------------------------------------------------------------------------------- */

.draw-lots-landing-app .dl-history {
    max-height: 18rem;
    overflow-y: auto;
}

.draw-lots-landing-app .dl-history-time {
    width: 1%;
    color: var(--ak-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.draw-lots-landing-app .dl-history-result {
    font-weight: 600;
    overflow-wrap: anywhere;
}
