/* Styles for the Home page */
:root {
    /* Re-using variables from rewards.styles.css for consistency */
    --card-bg-subtle: #fefbf9; /* Slightly different background for home cards */
    --welcome-card-bg: #fff5ec; /* Light orange background for welcome */
    --play-section-bg: #fff5ec; /* Light orange background for play section */
    --game-card-bg: #ffffff;
    --game-card-shadow:
        0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

.home-content {
    display: grid;
    gap: var(--spacing-unit);
    padding-bottom: var(--spacing-unit); /* Add some padding at the bottom */
}

/* Top Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
}

.stat-card {
    background-color: var(
        --welcome-card-bg
    ); /* Apply welcome color to all cards */
    border-radius: var(--border-radius);
    padding: var(--spacing-unit);
    border: 1px solid var(--border-color);
    box-shadow: var(--game-card-shadow);
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 0.5);
}

.stat-card.welcome-card {
    /* background-color: var(--welcome-card-bg); */ /* Removed, now default */
    grid-column: span 1 / span 1; /* Default span */
}

.stat-card .label {
    font-size: 0.85rem;
    color: var(--text-light);
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 0.35);
}

.stat-card .value .material-symbols-outlined {
    font-size: 1.5em; /* Larger icons in stat cards */
    color: var(--button-primary-bg); /* Orange icons */
    font-variation-settings: "FILL" 1;
}

.stat-card .value.username {
    font-size: 1.5rem; /* Slightly smaller for username */
}

/* Let's Play Section */
.play-section {
    background-color: var(--play-section-bg);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 1.5);
    border: 1px solid var(--border-color);
    display: grid; /* Use grid for layout */
    gap: var(--spacing-unit);
    align-items: center; /* Vertically align items */
}

.play-section-header {
    grid-column: 1 / -1; /* Span full width initially */
}

.play-section h2 {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.2;
    margin-block-end: calc(var(--spacing-unit) * 0.5);
    color: var(--text-color);
}

.play-section-image {
    display: none; /* Hide image by default, show on larger screens */
    max-width: 150px; /* Limit image size */
    justify-self: end; /* Align image to the right */
}

.game-cards {
    grid-column: 1 / -1; /* Span full width */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-unit);
}

.game-card {
    background-color: var(--game-card-bg);
    border-radius: var(--border-radius);
    overflow: hidden; /* Clip image */
    box-shadow: var(--game-card-shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.game-card img {
    width: 100%;
    aspect-ratio: 16 / 9; /* Maintain aspect ratio */
    object-fit: cover;
}

.game-card-content {
    padding: var(--spacing-unit);
    flex-grow: 1; /* Allow content to take remaining space */
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 0.25);
}

.game-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-block-end: 0;
}

.game-card p {
    font-size: 0.85rem;
    color: var(--text-light);
    flex-grow: 1; /* Push button down if needed */
}

.play-game-button {
    /* Re-use button styles if a component exists, or define here */
    background-color: var(--button-primary-bg);
    color: var(--button-primary-text);
    padding: calc(var(--spacing-unit) * 0.5) var(--spacing-unit);
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
    margin-top: calc(var(--spacing-unit) * 0.5);
    transition: background-color 0.2s ease;
}

.play-game-button:hover,
.play-game-button:focus {
    background-color: #92400e; /* Darker shade */
}

/* Responsive Adjustments */

/* Desktop view adjustments */
@media (min-width: 769px) {
    .stats-grid {
        grid-template-columns:
            2fr 1fr 1fr 1fr; /* Explicit columns: 2 for welcome, 1 for others */
        /* grid-template-columns: repeat(4, 1fr); */ /* Previous attempt */
    }

    .stat-card.welcome-card {
        /* Make welcome card span 2 columns worth of space */
        grid-column: 1 / 3; /* Span first two columns */
        display: flex;
        flex-direction: column;
        justify-content: center; /* Center content vertically */
    }

    /* Explicitly place the other cards */
    .stat-card:not(.welcome-card):nth-of-type(2) {
        /* Winning Tickets */
        grid-column: 3 / 4;
    }
    .stat-card:not(.welcome-card):nth-of-type(3) {
        /* Reward Tickets */
        grid-column: 4 / 5;
    }
    .stat-card.coin-balance-card {
        /* Coin Balance */
        grid-column: 5 / 6;
    }

    .stat-card .value {
        font-size: 2rem; /* Slightly larger value text */
    }
    .stat-card .value.username {
        font-size: 1.75rem;
    }

    .play-section {
        grid-template-columns: 1fr auto; /* Text on left, image on right */
        padding: calc(var(--spacing-unit) * 2);
    }

    .play-section-header {
        grid-column: 1 / 2; /* Only first column */
    }

    .play-section-image {
        display: block; /* Show image on desktop */
        grid-column: 2 / 3; /* Second column */
        grid-row: 1 / 2; /* Align with header */
    }

    .game-cards {
        grid-template-columns: repeat(3, 1fr); /* Three game cards per row */
        grid-column: 1 / -1; /* Span full width below header/image */
    }
}

/* Mobile view adjustments (already handled by default styles and media query in rewards.styles.css) */
@media (max-width: 768px) {
    .home-content {
        padding-top: calc(
            var(--spacing-unit) * 0.5
        ); /* Less padding top on mobile */
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr; /* Two columns on mobile */
    }

    .stat-card.welcome-card {
        grid-column: span 2 / span 2; /* Welcome card full width */
    }

    /* Ensure coin balance card is visible and placed correctly on mobile */
    .stat-card.coin-balance-card {
        grid-column: span 1; /* Takes one column */
    }

    .stat-card .value {
        font-size: 1.5rem;
    }
    .stat-card .value.username {
        font-size: 1.3rem;
    }

    .play-section h2 {
        font-size: 1.75rem;
    }

    .game-cards {
        grid-template-columns: 1fr; /* Single column for games */
    }

    /* Ensure main content padding accounts for bottom nav */
    .main-content {
        padding-bottom: 80px; /* Match padding in rewards.styles.css */
    }
}

/* Apply responsive margins using container queries based on main-content width */
/* Consistent with rewards.styles.css */
@container main-content (min-width: 1200px) {
    .home-content {
        margin-left: 200px;
        margin-right: 200px;
    }
}

@container main-content (min-width: 800px) and (max-width: 1199px) {
    .home-content {
        margin-left: 100px;
        margin-right: 100px;
    }
}

@container main-content (max-width: 799px) {
    .home-content {
        margin-left: var(--spacing-unit);
        margin-right: var(--spacing-unit);
    }
}
