/* APS Crossword Puzzle pages
 *
 * The puzzle grid itself lives inside iPuzzler's shadow DOM, so CSS in
 * this file intentionally styles only the APS-side wrapper (header,
 * hints, index list). Grid appearance is controlled by the CSS embedded
 * inside static/js/vendor/ipuzzler-1.0.0-aps.js.
 */

.crossword-page .crossword-header {
    margin-bottom: 1.25rem;
}

.crossword-page .crossword-authors {
    font-size: 1.05rem;
    font-style: italic;
    color: #555;
}

.crossword-page .crossword-intro {
    margin-top: 1rem;
}

/* Grid size kept in sync with the JS patch in
 * aps_site/static/js/vendor/ipuzzler-1.0.0-aps.js (cellSize × 15 + 16). */
.crossword-page {
    --crossword-grid-size: 691px;
}

.crossword-page .crossword-container {
    position: relative;
    margin: 1.5rem 0 0;
    /* Reserve room for the absolutely-positioned hint, button group,
     * status line, and congrats banner that stack below the grid on
     * desktop. */
    min-height: calc(var(--crossword-grid-size) + 13rem);
}

.crossword-page ipuzzler-puzzle {
    display: block;
    width: 100%;
}

.crossword-page .crossword-hint {
    margin: 1rem 0 0;
}

.crossword-page .crossword-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0 0;
}

.crossword-page .crossword-buttons .btn-group {
    gap: 0;
}

.crossword-page .crossword-status {
    margin: 0.75rem 0 0;
    color: var(--aps-blue, #3a53a4);
    font-weight: 600;
}

.crossword-page .crossword-congrats {
    margin-top: 0.75rem;
    padding: 1rem 1.25rem;
    background-color: var(--aps-blue, #3a53a4);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: 6px;
    max-width: var(--crossword-grid-size);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.crossword-page .crossword-congrats[hidden] {
    display: none;
}

.crossword-page .crossword-congrats-emoji {
    font-size: 1.6rem;
    line-height: 1;
}

@media (min-width: 769px) {
    /* Stack the hint, buttons, status, and congrats banner in the
     * bottom-left of the grid footprint so they sit directly under the
     * puzzle (not below the taller Down clue column). Values chosen to
     * flow naturally one below the other. */
    .crossword-page .crossword-hint {
        position: absolute;
        top: calc(var(--crossword-grid-size) + 0.75rem);
        left: 0;
        max-width: var(--crossword-grid-size);
        margin: 0;
    }
    .crossword-page .crossword-buttons {
        position: absolute;
        top: calc(var(--crossword-grid-size) + 4.25rem);
        left: 0;
        max-width: var(--crossword-grid-size);
        margin: 0;
    }
    .crossword-page .crossword-status {
        position: absolute;
        top: calc(var(--crossword-grid-size) + 9.5rem);
        left: 0;
        max-width: var(--crossword-grid-size);
        margin: 0;
    }
    .crossword-page .crossword-congrats {
        position: absolute;
        top: calc(var(--crossword-grid-size) + 11.25rem);
        left: 0;
        margin: 0;
    }
}

/* Index page */
.crossword-index-list .crossword-index-item {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

.crossword-index-list .crossword-index-item:last-child {
    border-bottom: 0;
}

.crossword-index-list a {
    text-decoration: none;
}

.crossword-index-list a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .crossword-page .crossword-container {
        margin-top: 1rem;
    }
}
