/* ============================================================================
   index.html — hub / front door
   Mobile first. Today card → swipe carousel → full list with on-demand setup.
   Built on the shared tokens/components in base.css (loaded after this file,
   so we hook its classes/tokens instead of fighting them).
   ========================================================================== */

:root {
    --glass-surface: var(--global-bg-surface-glass);
    /* Pre-theme fallbacks: once GlobalApp sets data-theme, the bars.html theme
       blocks define --glass-border/--glass-shadow at higher specificity and
       these self-references are discarded. */
    --glass-border: var(--glass-border, oklch(100% 0 0 / 0.1));
    --glass-shadow: var(--glass-shadow, 0 8px 32px oklch(0% 0 0 / 0.1));
    --text-main: var(--global-text-primary);
    --text-muted: var(--global-text-secondary);
    --card-hover-bg: var(--global-bg-surface-2);
}

body {
    margin: 0;
    font-family: var(--global-font-main);
    color: var(--text-main);
    min-height: 100vh;
    background: var(--global-bg-body);
    overflow-x: hidden;
}

.hub {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: var(--s-6) var(--s-4) 120px;
}

/* --- Header (the page is about the games) ------------------------- */
.hub-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    margin-bottom: var(--s-4);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-3);
}

.section-head .hint {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}

.lbl-foryou { display: none; }

/* --- Today card: the answer, not a question ----------------------- */
.today {
    margin-bottom: var(--s-6);
}

.today-card {
    position: relative;
    padding: var(--s-5);
    border-radius: var(--r-lg);
    border: 1px solid color-mix(in oklab, var(--accent) 32%, var(--glass-border));
    background:
        radial-gradient(120% 140% at 0% 0%, var(--accent-soft, color-mix(in oklab, var(--accent) 16%, transparent)), transparent 60%),
        var(--glass-surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
}

.today-card.is-done {
    border-color: color-mix(in oklab, var(--accent) 55%, var(--glass-border));
}

/* --- Goals + progress (right side on desktop) --------------------- */
.today-side {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    margin-top: var(--s-4);
}

.goal {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.goal-ring {
    position: relative;
    width: 62px;
    height: 62px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), var(--global-bg-surface-2) 0);
}

.goal-ring::before {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: var(--global-bg-surface);
}

.goal-ring span {
    position: relative;
    font-weight: 900;
    font-size: var(--fs-sm);
    font-variant-numeric: tabular-nums;
}

.goal-meta {
    display: flex;
    flex-direction: column;
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.goal-meta strong {
    font-size: var(--fs-md);
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: -0.01em;
}

.today-stats {
    display: flex;
    gap: var(--s-5);
}

.ts {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ts-val {
    font-size: 1.2rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.ts-lbl {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    white-space: nowrap;
}

.today-done {
    color: var(--accent);
    border-color: color-mix(in oklab, var(--accent) 40%, transparent);
    background: var(--accent-soft, color-mix(in oklab, var(--accent) 12%, transparent));
    white-space: nowrap;
}

.today-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-2);
}

.today-tags {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-shrink: 0;
}

.today-label {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    background: var(--accent-soft, color-mix(in oklab, var(--accent) 12%, transparent));
    border: 1px solid color-mix(in oklab, var(--accent) 34%, transparent);
    color: var(--accent);
    font-size: var(--fs-xs);
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.today-title {
    font-size: clamp(1.6rem, 6vw, 2.4rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin: 0 0 var(--s-2);
}

.today-reason {
    color: var(--text-secondary);
    font-size: var(--fs-md);
    line-height: 1.5;
    margin: 0 0 var(--s-4);
    max-width: 52ch;
}

.today-actions {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-wrap: wrap;
}

.today-start {
    font-weight: 800;
    gap: var(--s-2);
}

.today-alt {
    font-weight: 700;
}

/* Desktop: hero is two columns; the carousel becomes a curated rail. */
@media (min-width: 769px) {
    .hub {
        /* Clear the fixed global top bar (theme / streak / login) */
        padding-top: 64px;
    }

    .today-card {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: var(--s-6);
        align-items: center;
        padding: var(--s-6);
    }

    .today-side {
        align-items: flex-end;
        margin-top: 0;
        padding-left: var(--s-6);
        border-left: 1px solid var(--border);
    }

    .today-stats {
        justify-content: flex-end;
    }

    .lbl-browse { display: none; }
    .lbl-foryou { display: inline; }

    #browse-count { display: none; }

    #carousel .focus-card:not(.is-for-you) {
        display: none;
    }

    #carousel {
        scroll-snap-type: none;
    }
}

/* --- Carousel: swipe through every game --------------------------- */
.browse {
    margin-bottom: var(--s-7);
}

.carousel {
    display: flex;
    gap: var(--s-3);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: var(--s-1) var(--s-1) var(--s-2);
    margin: 0 calc(-1 * var(--s-1));
    scroll-padding-left: var(--s-1);
}

.carousel::-webkit-scrollbar {
    display: none;
}

.focus-card {
    flex: 0 0 auto;
    width: 168px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-3) var(--s-3);
    border-radius: var(--r-lg);
    border: 1px solid var(--glass-border);
    background: var(--glass-surface);
    backdrop-filter: blur(16px);
}

.fc-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.fc-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: var(--bg-surface-2);
    color: var(--text-secondary);
}

.fc-icon svg {
    width: 20px;
    height: 20px;
}

.fc-title {
    font-size: var(--fs-md);
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

.fc-tag {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
}

.fc-start {
    margin-top: auto;
    font-weight: 800;
}

/* --- Setup hub: slim rows, settings on demand --------------------- */
.setup-hub {
    margin-bottom: var(--s-8);
}

.panel-list {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.game-panel {
    border-radius: var(--r-lg);
    border: 1px solid var(--glass-border);
    background: var(--glass-surface);
    backdrop-filter: blur(16px);
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.game-panel.pulse {
    border-color: color-mix(in oklab, var(--accent) 60%, transparent);
    box-shadow: 0 0 0 3px var(--accent-soft, color-mix(in oklab, var(--accent) 18%, transparent));
}

.gp-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
}

.gp-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: var(--bg-surface-2);
    color: var(--text-secondary);
}

.gp-icon svg {
    width: 20px;
    height: 20px;
}

.gp-id {
    min-width: 0;
    flex: 1 1 auto;
}

.gp-title {
    font-size: var(--fs-md);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.gp-tag {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
}

.gp-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-shrink: 0;
}

.gp-settings {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.gp-settings:hover,
.gp-settings:focus-visible {
    color: var(--accent);
    border-color: color-mix(in oklab, var(--accent) 40%, transparent);
}

.gp-settings svg {
    width: 13px;
    height: 13px;
    transition: transform 0.18s var(--ease);
}

.gp-settings[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.gp-start {
    flex-shrink: 0;
    font-weight: 800;
}

.gp-controls {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-4) var(--s-4);
    border-top: 1px solid var(--border);
}

.gp-controls[hidden] {
    display: none;
}

/* --- Controls ----------------------------------------------------- */
.ctl {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    flex-wrap: wrap;
}

.ctl-label {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--text-secondary);
}

.ctl-seg {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
}

.ctl-seg button {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 700;
    padding: 6px 10px;
    border-radius: var(--r-pill);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.ctl-seg button[aria-selected="true"] {
    background: var(--accent);
    color: var(--accent-contrast);
}

.ctl-step {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    padding: 3px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
}

.ctl-step button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.ctl-step button:hover,
.ctl-step button:focus-visible {
    color: var(--accent);
}

.ctl-val {
    min-width: 28px;
    text-align: center;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.ctl-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.ctl-switch {
    position: relative;
    flex-shrink: 0;
    width: 42px;
    height: 24px;
    border-radius: var(--r-pill);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.ctl-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}

.ctl-toggle[aria-pressed="true"] .ctl-switch {
    background: var(--accent);
    border-color: var(--accent);
}

.ctl-toggle[aria-pressed="true"] .ctl-switch::after {
    background: var(--accent-contrast);
    transform: translateX(18px);
}

/* --- Groups ------------------------------------------------------- */
.game-group {
    margin-bottom: var(--s-5);
    scroll-margin-top: var(--s-5);
}

.game-group:last-child {
    margin-bottom: 0;
}

.group-head {
    display: flex;
    align-items: baseline;
    gap: var(--s-3);
    margin-bottom: var(--s-3);
    flex-wrap: wrap;
}

.group-title {
    font-size: var(--fs-lg);
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
}

.group-desc {
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    line-height: 1.55;
    margin: 0;
    max-width: 60ch;
}

@media (max-width: 560px) {
    .hub {
        padding: var(--s-4) var(--s-3) 110px;
    }

    .gp-settings {
        padding: 7px 9px;
    }

    .gp-settings span,
    .gp-settings {
        font-size: 0;
    }

    .gp-settings svg {
        width: 16px;
        height: 16px;
    }
}

/* iOS install modal */
.ios-install-modal {
    position: fixed;
    inset: 0;
    background: oklch(0% 0 0 / 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--s-5);
}

.ios-install-modal.show {
    display: flex;
}

.ios-install-content {
    background: var(--glass-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    padding: var(--s-6);
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.ios-install-content h3 {
    font-size: var(--fs-lg);
    margin: 0 0 var(--s-3);
}

.ios-install-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 var(--s-4);
    font-size: var(--fs-md);
}

.ios-install-steps {
    text-align: left;
    margin: 0 0 var(--s-4);
    padding: var(--s-3) var(--s-4) var(--s-3) var(--s-8);
    background: var(--bg-surface-2);
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
}

.ios-install-steps li {
    margin: var(--s-2) 0;
}
