/* ==========================================================================
   Procrastination Roulette: styles
   Dark theme with purple + teal accents. Mobile-first, responsive.
   ========================================================================== */

:root {
    --bg: #0b0a14;
    --bg-2: #120f22;
    --surface: rgba(255, 255, 255, 0.045);
    --surface-strong: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.09);
    --text: #ecebf5;
    --muted: #9a98b5;

    --purple: #8b5cf6;
    --purple-soft: #a78bfa;
    --purple-deep: #6d3ff0;
    --teal: #2dd4bf;
    --teal-deep: #14b8a6;
    --danger: #fb7185;

    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    line-height: 1.5;
    background:
        radial-gradient(900px 500px at 12% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
        radial-gradient(800px 500px at 100% 10%, rgba(45, 212, 191, 0.14), transparent 60%),
        linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
    background-attachment: fixed;
}

h1,
h2,
h3,
p {
    margin: 0;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

kbd {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface-strong);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
}

:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 3px;
    border-radius: 6px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 100;
    padding: 0.6rem 1rem;
    background: var(--teal);
    color: #04201c;
    font-weight: 700;
    border-radius: 8px;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 1rem;
}

.container {
    width: min(1120px, 100% - 2rem);
    margin-inline: auto;
}

.accent {
    background: linear-gradient(90deg, var(--purple-soft), var(--teal));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

/* ---------- Header ---------- */
.site-header {
    padding: 2rem 0 1rem;
}

.header-inner {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 52px;
    height: 52px;
    font-size: 1.7rem;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(45, 212, 191, 0.25));
    border: 1px solid var(--border);
    animation: float 4s ease-in-out infinite;
}

h1 {
    font-size: clamp(1.5rem, 4.5vw, 2.2rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--muted);
    font-size: 0.98rem;
    margin-top: 0.2rem;
}

/* ---------- Stats ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 0;
}

.stat {
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
}

.stat dt {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat dd {
    margin: 0.15rem 0 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--teal);
    font-variant-numeric: tabular-nums;
}

.stat dd.bump {
    animation: bump 0.4s ease;
}

/* ---------- Layout ---------- */
.layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding-bottom: 2rem;
    align-items: start;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

/* ---------- Panels ---------- */
.panel {
    padding: 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: rise 0.5s ease both;
}

.panel-title {
    font-size: 1.1rem;
    letter-spacing: 0.01em;
    margin-bottom: 1rem;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.panel-head .panel-title {
    margin-bottom: 0;
}

.subtitle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem 0 0.75rem;
    font-size: 0.95rem;
    color: var(--purple-soft);
}

.count {
    min-width: 1.5rem;
    padding: 0.05rem 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    color: #04201c;
    background: var(--teal);
    border-radius: 999px;
    font-weight: 700;
}

/* ---------- Filters ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.75rem;
}

.chip {
    padding: 0.45rem 0.85rem;
    font-size: 0.88rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.chip:hover {
    background: var(--surface-strong);
    transform: translateY(-1px);
}

.chip[aria-pressed="true"] {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.45), rgba(45, 212, 191, 0.3));
    border-color: var(--purple-soft);
    font-weight: 600;
}

/* ---------- Spin button ---------- */
.roulette {
    text-align: center;
}

.roulette .panel-title {
    text-align: left;
}

.spin-wrap {
    position: relative;
    width: min(230px, 62vw);
    aspect-ratio: 1;
    margin: 0.5rem auto 1.25rem;
}

.spin-ring {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--teal), var(--purple), var(--teal-deep), var(--purple-soft), var(--teal));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
    animation: rotate 8s linear infinite;
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.6));
}

.spin-wrap.is-spinning .spin-ring {
    animation-duration: 0.7s;
}

.spin-btn {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    border: none;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.28), transparent 45%),
        linear-gradient(145deg, var(--purple), var(--purple-deep) 55%, #4c2bc0);
    color: #fff;
    box-shadow:
        0 0 0 6px rgba(139, 92, 246, 0.15),
        0 18px 45px rgba(109, 63, 240, 0.55),
        inset 0 -8px 20px rgba(0, 0, 0, 0.3);
    animation: pulse 2.6s ease-in-out infinite;
    transition: transform 0.15s ease, filter 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.spin-btn:hover {
    transform: scale(1.04);
    filter: brightness(1.1);
}

.spin-btn:active {
    transform: scale(0.96);
}

.spin-btn:focus-visible {
    outline: 4px solid var(--teal);
    outline-offset: 8px;
    border-radius: 50%;
}

.spin-btn[aria-disabled="true"] {
    cursor: progress;
    animation: none;
    filter: saturate(0.8);
}

.spin-btn[aria-disabled="true"]:hover {
    transform: none;
}

.spin-emoji {
    font-size: clamp(2.6rem, 11vw, 3.6rem);
    line-height: 1;
}

.spin-wrap.is-spinning .spin-emoji {
    animation: dice 0.5s linear infinite;
}

.spin-label {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.25em;
    padding-left: 0.25em;
}

.hint {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---------- Result ---------- */
.empty {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    padding: 1.25rem 0.5rem;
    text-align: center;
    color: var(--muted);
}

.empty-emoji {
    font-size: 2.4rem;
}

.result-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
}

.result-body.reveal {
    animation: pop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.result-body.is-spinning .result-task,
.result-body.is-spinning .result-emoji {
    filter: blur(1.5px);
    opacity: 0.8;
}

.result-body.is-spinning .result-message {
    visibility: hidden;
}

.result-body.celebrate {
    animation: celebrate 0.8s ease;
}

.result-emoji {
    font-size: clamp(3.2rem, 14vw, 4.6rem);
    line-height: 1;
    filter: drop-shadow(0 8px 18px rgba(139, 92, 246, 0.5));
}

.badge {
    padding: 0.25rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #04201c;
    background: var(--teal);
    border-radius: 999px;
}

.badge.custom::after {
    content: " · yours";
    opacity: 0.75;
}

.result-task {
    font-size: clamp(1.25rem, 4.5vw, 1.7rem);
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.result-body.done .result-task {
    text-decoration: line-through;
    text-decoration-color: var(--teal);
    text-decoration-thickness: 3px;
    opacity: 0.75;
}

.result-message {
    max-width: 34ch;
    color: var(--purple-soft);
    font-style: italic;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    width: 100%;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.15rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: transform 0.15s ease, filter 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn:hover:not(:disabled):not([aria-disabled="true"]) {
    transform: translateY(-2px);
    filter: brightness(1.08);
}

.btn:active:not(:disabled):not([aria-disabled="true"]) {
    transform: translateY(0);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    color: #04201c;
    background: linear-gradient(135deg, var(--teal), var(--teal-deep));
    box-shadow: 0 8px 22px rgba(45, 212, 191, 0.25);
}

.btn-secondary {
    color: #fff;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    box-shadow: 0 8px 22px rgba(139, 92, 246, 0.3);
}

.btn-ghost {
    padding: 0.45rem 0.8rem;
    font-size: 0.85rem;
    background: var(--surface);
    border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--danger);
}

/* ---------- Form ---------- */
.task-form {
    display: grid;
    gap: 0.9rem;
}

.field {
    display: grid;
    gap: 0.35rem;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

input[type="text"],
select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]::placeholder {
    color: #6f6d8a;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.25);
}

select option {
    background: #1a1630;
    color: var(--text);
}

.form-error {
    min-height: 1.2em;
    font-size: 0.88rem;
    color: var(--danger);
}

.task-form .btn {
    justify-self: start;
}

/* ---------- Lists ---------- */
.list {
    display: grid;
    gap: 0.55rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.history-list {
    max-height: 380px;
    overflow-y: auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--purple) transparent;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.8rem;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: slide-in 0.35s ease both;
}

.list-item.is-done {
    border-color: rgba(45, 212, 191, 0.4);
}

.item-emoji {
    flex: none;
    font-size: 1.4rem;
}

.item-main {
    flex: 1;
    min-width: 0;
}

.item-text {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.is-done .item-text {
    text-decoration: line-through;
    text-decoration-color: var(--teal);
    opacity: 0.8;
}

.item-meta {
    font-size: 0.78rem;
    color: var(--muted);
}

.status {
    flex: none;
    padding: 0.15rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
}

.status.done {
    color: #04201c;
    background: var(--teal);
}

.status.pending {
    color: var(--purple-soft);
    background: rgba(139, 92, 246, 0.18);
}

.icon-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.icon-btn:hover {
    transform: scale(1.08);
}

.icon-btn.delete:hover {
    border-color: var(--danger);
    background: rgba(251, 113, 133, 0.15);
}

.icon-btn.check:hover {
    border-color: var(--teal);
    background: rgba(45, 212, 191, 0.15);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    z-index: 50;
    max-width: calc(100% - 2rem);
    padding: 0.7rem 1.1rem;
    font-weight: 600;
    color: var(--text);
    background: #1d1838;
    border: 1px solid var(--purple-soft);
    border-radius: 999px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translate(-50%, 20px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- Footer ---------- */
.site-footer {
    padding: 1.5rem 1rem 2.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---------- Animations ---------- */
@keyframes rotate {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        box-shadow:
            0 0 0 6px rgba(139, 92, 246, 0.15),
            0 18px 45px rgba(109, 63, 240, 0.5),
            inset 0 -8px 20px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow:
            0 0 0 14px rgba(139, 92, 246, 0.08),
            0 18px 60px rgba(45, 212, 191, 0.4),
            inset 0 -8px 20px rgba(0, 0, 0, 0.3);
    }
}

@keyframes dice {
    0% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(180deg) scale(1.15);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pop {
    0% {
        opacity: 0;
        transform: scale(0.85);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bump {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes celebrate {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.04) rotate(-1deg);
    }

    60% {
        transform: scale(1.04) rotate(1deg);
    }

    100% {
        transform: scale(1) rotate(0);
    }
}

/* ---------- Responsive ---------- */
@media (min-width: 720px) {
    .header-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .stats {
        min-width: 340px;
    }
}

@media (min-width: 900px) {
    .layout {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .panel {
        padding: 1.6rem;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding-top: 1.25rem;
    }

    .panel {
        padding: 1.1rem;
    }

    .actions .btn {
        flex: 1 1 100%;
    }

    .task-form .btn {
        justify-self: stretch;
    }

    .stat dd {
        font-size: 1.25rem;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}