/* Signed-in home dashboard: calm surfaces matching the game library, one accent colour.
   Loaded after components.css; the :is() prefix outranks the older theme overrides there. */

.page.theme-dark .home-auth-shell {
    --hd-surface: var(--tt-surface);
    --hd-border: var(--tt-line);
    --hd-shadow: none;
    --hd-tile-bg: var(--tt-field);
    --hd-tile-border: var(--tt-line);
    --hd-accent: var(--tt-accent);
    --hd-accent-soft: var(--tt-accent-soft);
    --hd-text-muted: var(--tt-muted);
    --hd-heading: var(--tt-ink);
}

.page.theme-light .home-auth-shell {
    --hd-surface: var(--tt-surface);
    --hd-border: var(--tt-line);
    --hd-shadow: none;
    --hd-tile-bg: var(--tt-field);
    --hd-tile-border: var(--tt-line);
    --hd-accent: var(--tt-accent);
    --hd-accent-soft: var(--tt-accent-soft);
    --hd-text-muted: var(--tt-muted);
    --hd-heading: var(--tt-ink);
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-card::before {
    display: none;
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-icon,
.page:is(.theme-dark, .theme-light) .home-auth-shell .home-planner-overview .planner-overview-head-icon {
    box-shadow: none;
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-planner-overview .planner-overview-kpi:nth-child(n),
.page:is(.theme-dark, .theme-light) .home-auth-shell .home-planner-overview .planner-overview-top-btn,
.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-stat,
.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-list,
.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-empty {
    background: var(--hd-tile-bg);
    border-color: var(--hd-tile-border);
    box-shadow: none;
}

/* Most played games sit side by side once each tile fits its minimum width. */
.home-auth-shell .home-planner-overview .planner-overview-top-list {
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 0.55rem;
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-stat span,
.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-card > p {
    color: var(--hd-text-muted);
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-timeline-row::before {
    background: var(--hd-tile-border);
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-timeline-thumb {
    box-shadow: none;
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-timeline-date {
    color: var(--hd-accent);
}

/* --- Step 2: no glow or lift; only the game draw button keeps its highlight --- */

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-cta-primary:not(.home-game-draw-actions *) {
    box-shadow: none;
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-dash-card:hover {
    transform: none;
    border-color: var(--hd-border);
    box-shadow: none;
}

/* --- Step 3: every block spans the full shell width; system card corners (square-ish bottom-left) --- */

.home-auth-shell .home-dash-grid,
.home-auth-shell .home-game-draw-card {
    width: 100%;
    margin: 0;
}

/* Library and ranking share the row; without the ranking card the library fills it. */
@media (min-width: 1451px) {
    .home-dash-grid .home-dash-card--library,
    .home-dash-grid .home-dash-card--rank {
        grid-column: span 3;
    }

    .home-dash-grid:not(:has(.home-dash-card--rank)) .home-dash-card--library {
        grid-column: span 6;
    }
}

/* --- Step 4: quick links row --- */

.home-auth-shell .home-dash-card.home-dash-shortcuts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
    padding: 0.8rem;
}

.home-auth-shell .home-shortcut {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease;
}

.home-auth-shell .home-shortcut:hover {
    border-color: var(--hd-accent);
}

.home-auth-shell .home-shortcut-title {
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-auth-shell .home-shortcut .home-dash-plan-badge {
    margin-left: auto;
}

@media (max-width: 900px) {
    .home-auth-shell .home-dash-card.home-dash-shortcuts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .home-auth-shell .home-dash-card.home-dash-shortcuts {
        grid-template-columns: 1fr;
    }
}

/* --- Step 6: top 10 in two columns (1-5 left, 6-10 right) --- */

.home-auth-shell .home-dash-card--rank .home-dash-list {
    display: grid;
    grid-template-rows: repeat(5, auto);
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
}

.home-auth-shell .home-dash-card--rank .home-dash-list li:nth-child(n+6) {
    border-left: 1px solid;
}

.home-auth-shell .home-dash-card--rank .home-dash-list li:nth-child(5n) {
    border-bottom: none;
}

@media (max-width: 700px) {
    .home-auth-shell .home-dash-card--rank .home-dash-list {
        grid-template-rows: none;
        grid-auto-flow: row;
    }

    .home-auth-shell .home-dash-card--rank .home-dash-list li:nth-child(n+6) {
        border-left: none;
    }

    .home-auth-shell .home-dash-card--rank .home-dash-list li:nth-child(5n):not(:last-child) {
        border-bottom: 1px solid;
    }
}

/* --- Step 8: neutral placeholder for games without a cover --- */

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-timeline-thumb {
    border-color: var(--hd-tile-border);
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-timeline-thumb-fallback {
    background: var(--hd-accent-soft);
    color: var(--hd-accent);
}

/* --- Brand meeple: shared silhouette (mask) and colours --- */

.home-auth-shell {
    --hd-meeple: linear-gradient(135deg, var(--tt-accent-from), var(--tt-accent-to));
}

.home-auth-shell .home-header-meeple {
    background: var(--hd-meeple);
    -webkit-mask: url("../img/meeple.svg") center / contain no-repeat;
    mask: url("../img/meeple.svg") center / contain no-repeat;
    aspect-ratio: 470 / 570;
    pointer-events: none;
}

/* --- Idea 1: meeple peeking in from the right edge of the greeting card --- */

.home-auth-shell .home-app-header {
    position: relative;
    overflow: hidden;
    padding-right: 7.5rem;
}

.home-auth-shell .home-header-meeple {
    position: absolute;
    right: 0.6rem;
    bottom: -2.4rem;
    height: 112px;
    transform-origin: 50% 100%;
    transform: translateX(42%) rotate(-16deg);
    animation: home-meeple-peek 9s ease-in-out 1.2s infinite;
}

.home-auth-shell .home-header-meeple-eyes {
    position: absolute;
    left: 34%;
    top: 11%;
    width: 32%;
    height: 9%;
    background: linear-gradient(135deg, var(--tt-accent-from), var(--tt-accent-to)),
        linear-gradient(135deg, var(--tt-accent-from), var(--tt-accent-to));
    transform-origin: 50% 50%;
    animation: home-meeple-blink 4.6s steps(1, end) infinite;
    /* Eyes hidden for comparison with the plain logo silhouette. */
    display: none;
}

.home-auth-shell .home-app-header:hover .home-header-meeple {
    animation: home-meeple-wave 0.9s ease-in-out;
}

@keyframes home-meeple-peek {
    0%, 62%, 100% { transform: translateX(42%) rotate(-16deg); }
    70%, 84% { transform: translateX(8%) translateY(-6px) rotate(-26deg); }
    77% { transform: translateX(8%) translateY(-6px) rotate(-20deg); }
}

@keyframes home-meeple-wave {
    0% { transform: translateX(42%) rotate(-16deg); }
    30% { transform: translateX(6%) translateY(-8px) rotate(-30deg); }
    50% { transform: translateX(6%) translateY(-8px) rotate(-14deg); }
    70% { transform: translateX(6%) translateY(-8px) rotate(-30deg); }
    100% { transform: translateX(42%) rotate(-16deg); }
}

@keyframes home-meeple-blink {
    0%, 94%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(0.1); }
}

@media (max-width: 560px) {
    .home-auth-shell .home-app-header {
        padding-right: 5rem;
    }

    .home-auth-shell .home-header-meeple {
        height: 88px;
        bottom: -1.9rem;
    }
}

/* --- Idea 3: recent sessions drawn as a dashed board track --- */

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-timeline-row::before {
    height: 6px;
    background: transparent;
}

.page:is(.theme-dark, .theme-light) .home-auth-shell .home-timeline-thumb {
    border-width: 3px;
    outline: 3px solid;
}

@media (prefers-reduced-motion: reduce) {
    .home-auth-shell .home-header-meeple,
    .home-auth-shell .home-header-meeple-eyes,
    .home-auth-shell .home-app-header:hover .home-header-meeple {
        animation: none;
    }
}

/* --- Play summary cards (spec 061) --- */

.home-auth-shell .home-summary-card {
    border: 1px solid;
    padding: 1rem 1.1rem;
}

.home-auth-shell .home-summary-head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.home-auth-shell .home-summary-head p {
    margin: 0.25rem 0 0.8rem;
    color: var(--hd-text-muted);
    font-size: 0.9rem;
}

.home-auth-shell .home-summary-periods {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 0.6rem;
}

.home-auth-shell .home-summary-period {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid;
    color: var(--hd-heading);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s ease;
}

.home-auth-shell .home-summary-period:hover:not(:disabled),
.home-auth-shell .home-summary-period:focus-visible {
    border-color: var(--hd-accent);
}

.home-auth-shell .home-summary-period:disabled {
    cursor: default;
    opacity: 0.55;
}

.home-auth-shell .home-summary-period-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--hd-accent);
}

.home-auth-shell .home-summary-period-name {
    font-size: 1.05rem;
    font-weight: 800;
}

.home-auth-shell .home-summary-period-meta {
    font-size: 0.82rem;
    color: var(--hd-text-muted);
}

.home-summary-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.home-summary-modal {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: min(460px, 100%);
    max-height: calc(100dvh - 2rem);
    padding: 1rem;
    border: 1px solid;
    outline: none;
    overflow: auto;
}

.home-summary-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.home-summary-modal-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.home-summary-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.home-summary-status {
    margin: 2rem 0;
    text-align: center;
    color: var(--tt-muted);
}

.home-summary-error {
    color: var(--tt-ink);
}

.home-summary-preview {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100dvh - 10rem);
    object-fit: contain;
}

.home-summary-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.home-summary-actions .home-cta {
    cursor: pointer;
}

/* Spec 329 rule 11: the order and extra stats rows of the month and year cards, under the actions. */
.home-summary-modal:has(.summary-options:not([hidden])) .home-summary-preview {
    max-height: calc(100dvh - 22rem);
}

.summary-options {
    display: grid;
    gap: 0.6rem;
}

.summary-options[hidden] {
    display: none;
}

.summary-options-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.summary-options-label {
    flex-basis: 100%;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
}

.summary-option {
    min-height: 36px;
    padding: 0 12px;
    font-size: 14px;
}

.summary-option[hidden] {
    display: none;
}

.summary-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.summary-option[aria-pressed="true"],
html.tabletop:not(#tabletop) .page .summary-options .summary-option[aria-pressed="true"] {
    box-shadow: 0 0 0 3px var(--tt-accent);
}

/* Spec 245 rule 4: the background row of the play and ranking cards, under the actions. */
.home-summary-modal:has(.card-bg-picker:not([hidden])) .home-summary-preview {
    max-height: calc(100dvh - 15rem);
}

.card-bg-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 0.75rem;
}

.card-bg-swatch {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--tt-line);
    border-radius: 0;
    cursor: pointer;
}

.card-bg-swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 3px var(--tt-accent);
}

.card-bg-season {
    background: linear-gradient(135deg, #e8ae80 0%, #8a5a32 50%, #2a1c13 100%);
}

/* "Own" is a cardboard piece of the app (game-pager-btn); chosen, it takes the accent frame like the swatches. */
.card-bg-own {
    min-height: 40px;
    padding: 0 14px;
}

.card-bg-own[aria-pressed="true"],
html.tabletop:not(#tabletop) .page .card-bg-picker .card-bg-own[aria-pressed="true"] {
    box-shadow: 0 0 0 3px var(--tt-accent);
}

.card-bg-own-fields {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.card-bg-own-fields[hidden] {
    display: none;
}

/* The colour field and the pattern list are the app's fields (game-filter-input / game-filter-select). */
.card-bg-color,
html.tabletop:not(#tabletop) .page .card-bg-picker input.card-bg-color {
    width: 48px;
    min-width: 48px;
    height: 40px;
    padding: 3px;
    cursor: pointer;
}

.card-bg-pattern {
    height: 40px;
    padding: 0 10px;
    font: inherit;
    font-size: 14px;
}

/* Spec 122: "What should we play tonight?" - the dashboard's card style, chips with the shared selected look. */
.home-auth-shell .home-tonight-card {
    width: 100%;
    padding: 1rem 1.15rem;
    border: 1px solid;
    color: var(--hd-heading);
}

.home-tonight-head h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.home-tonight-head p {
    margin: .2rem 0 .8rem;
    font-size: .88rem;
    color: var(--hd-text-muted);
}

.home-tonight-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1.25rem;
}

.home-tonight-field {
    display: grid;
    gap: .3rem;
}

.home-tonight-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--hd-text-muted);
}

.home-tonight-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid;
    overflow: hidden;
}

.home-tonight-stepper button {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
}

.home-tonight-stepper button:disabled {
    opacity: .4;
    cursor: default;
}

.home-tonight-stepper output {
    min-width: 2ch;
    text-align: center;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.home-tonight-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.home-tonight-chip {
    min-height: 36px;
    padding: .35rem .75rem;
    border: 1px solid;
    color: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}

.home-tonight-chip:hover,
.home-tonight-chip.active {
    border-color: var(--hd-accent);
}

.home-tonight-shelf {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 36px;
    font-size: .88rem;
}

.home-tonight-actions {
    display: flex;
    gap: .5rem;
    margin-left: auto;
}

.home-tonight-results {
    margin-top: .9rem;
}

.home-tonight-empty {
    margin: 0;
    color: var(--hd-text-muted);
}

.home-tonight-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: .6rem;
}

.home-tonight-pick {
    display: flex;
    gap: .7rem;
    align-items: center;
    height: 100%;
    padding: .55rem .65rem;
    border: 1px solid var(--hd-tile-border);
    border-radius: 0;
    background: var(--hd-tile-bg);
    color: inherit;
    text-decoration: none;
}

.home-tonight-pick:hover {
    border-color: var(--hd-accent);
    color: inherit;
}

.home-tonight-pick img,
.home-tonight-pick-fallback {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 0;
    object-fit: cover;
}

.home-tonight-pick-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--hd-accent-soft);
    color: var(--hd-accent);
    font-weight: 800;
    font-size: 1.3rem;
}

.home-tonight-pick-text {
    display: grid;
    gap: .3rem;
    min-width: 0;
}

.home-tonight-pick-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-tonight-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

.home-tonight-reason {
    padding: .1rem .45rem;
    border-radius: 0;
    background: var(--hd-accent-soft);
    color: var(--hd-accent);
    font-size: .74rem;
    font-weight: 600;
}

@media (max-width: 640px) {
    .home-tonight-actions {
        margin-left: 0;
        width: 100%;
    }

    .home-tonight-actions .home-cta {
        flex: 1 1 auto;
    }
}
