/* The wheel of fortune (/wheel), on top of draw.css (shared tool controls: panel, fields, switches,
   steppers, export bar). One panel: the wheel on one side, its options on the other. */

/* ------------------------------------------------ the wheel */

/* The turning canvas's square corners must not widen the page (overflow: clip, hidden as a fallback). */
.pane-wheel { display: flex; flex-direction: column; align-items: center; overflow: hidden; overflow: clip; }
.wheel-box { position: relative; width: min(100%, 420px); aspect-ratio: 1; margin: 10px auto 0; }
.wheel {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(28, 33, 30, .16), 0 0 0 6px var(--surface), 0 0 0 7px var(--line);
    transform: rotate(var(--turn, 0deg));
    cursor: pointer;
    touch-action: manipulation;
}
.pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    z-index: 2;
    width: 0;
    height: 0;
    margin-left: -14px;
    border-inline: 14px solid transparent;
    border-top: 28px solid var(--text);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25));
    transform-origin: 50% 0;
}
.pointer.tick { animation: pointer-tick .12s var(--ease); }
@keyframes pointer-tick { 40% { transform: rotate(-14deg); } }

.hub {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 21%;
    height: 21%;
    padding: 0;
    border: 4px solid #FFB300;
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent-ink);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: transform .15s var(--spring);
}
.hub .ic { width: 42%; height: 42%; fill: currentColor; }
.hub:hover:not([disabled]) { transform: translate(-50%, -50%) scale(1.06); }
.hub[disabled] { cursor: default; }
.mini.is-spinning .wheel { cursor: default; }

/* The winner: a card over the wheel. */
.winner-card {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    width: min(88%, 300px);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 16px 40px rgba(0, 0, 0, .25);
    text-align: center;
    transform: translate(-50%, -50%);
    animation: card-in .35s var(--spring);
}
@keyframes card-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.85); } }
.winner-label { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--gold); color: #1C1B1F; font-size: 12px; font-weight: 700; }
.winner-big { display: block; margin: 8px 0 12px; font-size: clamp(20px, 5.5vw, 26px); font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.winner-big:focus { outline: none; }
.winner-actions { display: flex; justify-content: center; gap: 8px; }
.winner-actions .btn { flex: 1; }
.winner-actions [hidden] { display: none; }

.spin-bar { width: min(100%, 420px); margin-top: 18px; }
.wheel-tools { display: flex; justify-content: center; width: min(100%, 420px); margin-top: 12px; }
.wheel-tools .export { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; grid-template-columns: none; }
.pane-wheel .export-note { width: min(100%, 420px); }

/* History of this visit. */
.history { width: 100%; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.history .pane-head { margin-bottom: 8px; }
.history-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hist { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 30px; padding-inline: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-size: 13.5px; animation: chip-in .22s var(--spring); }
.hist:last-child { border-color: var(--accent); background: var(--accent-soft); }
.hist-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }

/* ------------------------------------------------ options */

.opts { display: grid; gap: 4px; margin: 12px 0 0; padding: 0; list-style: none; max-height: 360px; overflow-y: auto; scrollbar-width: thin; scrollbar-gutter: stable; }
.opts:empty { display: none; }
.opt { display: flex; align-items: center; gap: 8px; min-height: 38px; padding-inline: 10px 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); font-size: 14px; }
.opt.fresh { animation: chip-in .22s var(--spring); }
.opt-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
.opt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-step { display: inline-flex; align-items: center; flex: none; height: 28px; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.mini-step-btn { display: grid; place-items: center; width: 26px; height: 100%; padding: 0; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.mini-step-btn:hover { background: var(--surface-2); }
.mini-step-btn[disabled] { opacity: .3; cursor: not-allowed; background: transparent; }
.mini-step-btn .ic { width: 15px; height: 15px; fill: currentColor; }
.mini-step-value { min-width: 24px; font-size: 13px; font-weight: 700; text-align: center; }

.pane-side > .row:first-of-type, .templates { margin-top: 14px; }
.pane-side > .tip { margin: 8px 0 0; }
.list-save { margin-top: 10px; }
.list-save .field { height: 36px; font-size: 14px; }
.list-save .add-btn { width: 36px; height: 36px; }
.mini.is-spinning .pane-side { opacity: .6; pointer-events: none; transition: opacity .2s var(--ease); }

/* ------------------------------------------------ full screen */

.pane-wheel:fullscreen { justify-content: center; padding: 24px; background: var(--bg); overflow: auto; }
.pane-wheel:fullscreen .wheel-box { width: min(78vh, 92vw); }
.pane-wheel:fullscreen .spin-bar, .pane-wheel:fullscreen .wheel-tools { width: min(420px, 92vw); }
.pane-wheel:fullscreen .history, .pane-wheel:fullscreen .export-note { display: none; }
.pane-wheel:fullscreen .winner-big { font-size: clamp(26px, 4vw, 44px); }

/* ------------------------------------------------ wider screens */

@media (min-width: 900px) {
    .wheel-app { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
    .wheel-app .pane-side { border-top: 0; border-inline-start: 1px solid var(--line); }
    .pane-wheel { padding-block: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .pointer.tick, .winner-card, .hist, .opt.fresh { animation: none; }
}
