/* Decision wheel (/decision-wheel): what is its own, the wheel (canvas, pointer, confetti, result), the option rows and the
   two-column layout on wide screens. Everything else (stage, panels, list rows, fields, buttons, colours) comes from the app
   kit (css/app-kit, docs/app-kit.md). The segment colours are the user's own and are drawn on the canvas.
   Loaded only on this app's page (StylePaths). */

.dwh-landing-app > .filter-landing-stage.dwh-landing-stage {
    position: relative;
    gap: var(--ak-space-3);
}

/* The shared app layout gives the stage a fixed height with overflow hidden, which clipped the options list below the
   wheel: the stage scrolls on its own instead. */
body .filter-landing-app.dwh-landing-app > .filter-landing-stage.dwh-landing-stage {
    justify-content: flex-start;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Full width, also where the shared narrow-screen layout (seo-pages.css, up to 960px) starts the stage's children at
   their own width. */
.dwh-landing-app > .filter-landing-stage.dwh-landing-stage > * {
    flex-shrink: 0;
    align-self: stretch;
    min-width: 0;
    max-width: 100%;
}

/* --- The wheel ------------------------------------------------------------------------------------------------------ */

.dwh-landing-app .dwh-wheel-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.dwh-landing-app .dwh-wheel-wrap {
    position: relative;
    width: min(100%, 28rem);
    aspect-ratio: 1 / 1;
}

.dwh-landing-app .dwh-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    cursor: pointer;
    touch-action: manipulation;
}

.dwh-landing-app .dwh-canvas:focus-visible {
    outline: 3px solid var(--ak-accent);
    outline-offset: 4px;
}

/* The pointer at the top: the text colour, so it stands out on either theme. */
.dwh-landing-app .dwh-pointer {
    position: absolute;
    top: -0.35rem;
    left: 50%;
    z-index: 2;
    width: 0;
    height: 0;
    border-top: 1.6rem solid var(--ak-text);
    border-right: 0.8rem solid transparent;
    border-left: 0.8rem solid transparent;
    transform: translateX(-50%);
    filter: drop-shadow(0 2px 2px rgba(15, 23, 42, 0.35));
    pointer-events: none;
}

.dwh-landing-app .dwh-spin {
    min-width: 9rem;
}

.dwh-landing-app .dwh-result {
    min-height: 2rem;
    margin: 0;
    color: var(--ak-text);
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
}

.dwh-landing-app .dwh-result.is-empty {
    color: var(--ak-muted);
    font-size: var(--ak-fs-md);
    font-weight: 500;
}

/* A dot in an option's colour (the result and the history). */
.dwh-landing-app .dwh-swatch {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    margin-inline-end: 0.35rem;
    border: 1px solid var(--ak-border);
    border-radius: 50%;
    vertical-align: -0.05rem;
}

.dwh-landing-app .dwh-confetti {
    position: absolute;
    inset: 0;
    z-index: 3;
    overflow: hidden;
    pointer-events: none;
}

.dwh-landing-app .dwh-bit {
    position: absolute;
    top: -1rem;
    width: 0.5rem;
    height: 0.8rem;
    border-radius: 0.1rem;
    animation: dwh-fall 2.2s ease-in forwards;
}

@keyframes dwh-fall {
    to {
        transform: translate3d(var(--dwh-dx, 0), 32rem, 0) rotate(var(--dwh-rot, 540deg));
        opacity: 0;
    }
}

/* --- Options: colour, label, weight, chance, remove ----------------------------------------------------------------- */

.dwh-landing-app .dwh-options {
    gap: 0.3rem;
}

.dwh-landing-app .dwh-opt {
    display: grid;
    grid-template-columns: 2.2rem minmax(0, 1fr) 4.6rem 3.4rem 1.85rem;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.4rem;
}

.dwh-landing-app .dwh-color {
    width: 2.2rem;
    height: 2rem;
    padding: 0.1rem;
    border: 1px solid var(--ak-border);
    border-radius: 0.35rem;
    background: var(--ak-field);
    cursor: pointer;
}

.dwh-landing-app .dwh-chance {
    color: var(--ak-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    text-align: end;
}

/* --- History -------------------------------------------------------------------------------------------------------- */

.dwh-landing-app .dwh-history-box {
    align-items: flex-start;
}

.dwh-landing-app .dwh-history {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 14rem;
    margin: 0;
    padding: 0 0 0 1.6rem;
    overflow-y: auto;
    color: var(--ak-text);
    font-size: var(--ak-fs-sm);
}

.dwh-landing-app .dwh-history-time {
    margin-inline-start: 0.4rem;
    color: var(--ak-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.dwh-landing-app .dwh-status-row {
    min-height: 1.2rem;
}

.dwh-landing-app .dwh-form {
    gap: var(--ak-space-4);
    margin: var(--ak-space-2) 0;
}

/* --- Wide screens: the wheel and Spin on the left, the options editor filling the right column at full stage height
       with its own scrollbar. ------------------------------------------------------------------------------------------ */

@media (min-width: 1100px) {
    body .filter-landing-app.dwh-landing-app > .filter-landing-stage.dwh-landing-stage {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.9fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas: "wheel editor" "history editor" "status editor";
        align-items: start;
        column-gap: 1.25rem;
        row-gap: 0.75rem;
    }

    .dwh-landing-app > .filter-landing-stage.dwh-landing-stage > .dwh-wheel-box { grid-area: wheel; }

    /* The history panel is as tall as its list, up to the rest of the column, and scrolls beyond that. */
    .dwh-landing-app > .filter-landing-stage.dwh-landing-stage > .dwh-history-box {
        grid-area: history;
        align-self: start;
        min-height: 0;
        max-height: 100%;
        overflow-y: auto;
    }

    .dwh-landing-app > .filter-landing-stage.dwh-landing-stage > .dwh-status-row,
    .dwh-landing-app > .filter-landing-stage.dwh-landing-stage > [data-ak-live] { grid-area: status; }

    .dwh-landing-app > .filter-landing-stage.dwh-landing-stage > .dwh-editor {
        grid-area: editor;
        align-self: stretch;
        min-height: 0;
        max-height: 100%;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    /* The wheel shrinks with the viewport height so wheel and Spin fit the stage. */
    .dwh-landing-app .dwh-wheel-wrap {
        width: min(100%, 28rem, calc(100vh - 16rem));
        min-width: 12rem;
    }
}

/* Phones: the stage uses the full width and the option rows shrink. */
@media (max-width: 600px) {
    .dwh-landing-app > .filter-landing-stage.dwh-landing-stage {
        width: 100%;
        max-width: none;
        padding: 0.75rem 0.5rem;
    }

    .dwh-landing-app .dwh-opt {
        grid-template-columns: 2.2rem minmax(0, 1fr) 3.8rem 1.85rem;
    }

    .dwh-landing-app .dwh-chance {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dwh-landing-app .dwh-bit {
        display: none;
    }
}
