/**
 * LocalCross Frontend Styles
 */

.localcross-puzzle-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.localcross-puzzle-iframe {
    width: 100%;
    min-height: 600px;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ── Single puzzle page ───────────────────────────────────────────────── */

/*
 * No author byline on puzzles — they're generated, not written by a person,
 * and "by Jacob Fogg" on every puzzle reads wrong. Divi renders the byline
 * inside .post-meta on singles; scope to the CPT's body class so ordinary
 * posts are untouched.
 */
.single-localcross_puzzle .post-meta {
    display: none;
}

/*
 * The theme's global text and heading colors are white (set for its
 * builder-based layouts, which sit on dark hero sections). Puzzle singles use
 * the default WP layout on a white background, so the title and body both
 * rendered white-on-white and looked missing. Match Divi's stock darks.
 * Elements with their own explicit colors (the play button, links) are
 * unaffected by these inherited values.
 */
.single-localcross_puzzle h1.entry-title {
    color: #333;
}

.single-localcross_puzzle .entry-content,
.single-localcross_puzzle .entry-content p,
.single-localcross_puzzle .entry-content li,
.single-localcross_puzzle .entry-content h2,
.single-localcross_puzzle .entry-content h3 {
    color: #4c4c4c;
}

/*
 * The puzzle-grid preview (featured image) is a teaser, not the game — keep
 * it modest and centered. 50% on desktop, 75% under Divi's mobile breakpoint.
 */
.single-localcross_puzzle .et_post_meta_wrapper img {
    display: block;
    width: 50%;
    height: auto;
    margin: 0 auto 20px;
}

@media (max-width: 767px) {
    .single-localcross_puzzle .et_post_meta_wrapper img {
        width: 75%;
    }
}

.localcross-puzzle-container {
    margin-top: 24px;
}

/* ── Play button ──────────────────────────────────────────────────────── */

.localcross-play-button {
    display: inline-block;
    padding: 14px 32px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: #2271b1;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.localcross-play-button:hover,
.localcross-play-button:focus {
    background: #135e96;
    color: #fff;
}

/* ── Game modal ───────────────────────────────────────────────────────── */

/*
 * Ported from the server's own game overlay (dashboard/puzzles.blade.php).
 *
 * dvh/dvw track the VISIBLE viewport as mobile browser chrome (URL/tool bars)
 * shows and hides; 100vh measures the LARGEST viewport and lets those bars cut
 * off the bottom of the game. The vh/vw lines are the fallback for browsers
 * without dynamic viewport units and must come first.
 */
.localcross-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 999999;
}

.localcross-modal.is-active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.localcross-modal iframe {
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    border: none;
    display: block;
}

/*
 * No close button by design — the game's own Options -> Exit closes the modal
 * via the postMessage bridge, and Escape is kept as a fallback.
 */

.localcross-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: #f9f9f9;
    border-radius: 8px;
}

.localcross-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: localcross-spin 1s linear infinite;
}

@keyframes localcross-spin {
    to {
        transform: rotate(360deg);
    }
}

.localcross-error {
    padding: 20px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    color: #c00;
    text-align: center;
}

.localcross-login-required {
    padding: 40px 20px;
    background: #f5f5f5;
    border-radius: 8px;
    text-align: center;
}

.localcross-login-required a {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 24px;
    background: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
}

.localcross-login-required a:hover {
    background: #2980b9;
}

/* Leaderboard — puzzle page and post-game modal panel. */
.localcross-leaderboard { margin: 24px 0; }
.localcross-lb-title { margin: 0 0 10px; font-size: 1.15em; }
.localcross-lb-table { width: 100%; border-collapse: collapse; font-size: .95em; }
.localcross-lb-table th,
.localcross-lb-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(128,128,128,.25); }
.localcross-lb-table th { font-weight: 600; opacity: .7; font-size: .85em; text-transform: uppercase; letter-spacing: .03em; }
.localcross-lb-row.localcross-lb-you { background: rgba(37,99,235,.12); font-weight: 700; }
.localcross-lb-plays { opacity: .55; font-size: .85em; font-weight: 400; }
.localcross-lb-empty,
.localcross-lb-yourank { opacity: .75; font-size: .95em; }
.localcross-modal-panel { background: #fff; color: #1f2937; border-radius: 12px; padding: 24px 28px; max-width: 560px; width: calc(100% - 32px); max-height: 80dvh; overflow-y: auto; }
.localcross-modal-panel .localcross-lb-title { color: #111827; }
.localcross-lb-close { margin-top: 16px; background: #2563eb; color: #fff; border: 0; border-radius: 8px; padding: 10px 22px; font-weight: 600; cursor: pointer; }
