/* ===================================================
   LEDE.PAGE — Newspaper-Style News Geography Game
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --ink: #1a1a1a;
    --paper: #f4f1ea;
    --paper-light: #faf8f4;
    --accent: #c0392b;
    --accent-hover: #a93226;
    --accent-green: #27ae60;
    --border: #2c3e50;
    --border-light: #ddd;
    --text-muted: #666;
    --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-sans: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-card: 4px 4px 0px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--paper);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px 20px 60px;
}

/* --- HEADER / BRANDING --- */
header {
    text-align: center;
    border-bottom: 3px double var(--ink);
    padding-bottom: 15px;
    margin-bottom: 10px;
    width: 100%;
    max-width: 650px;
}

h1.masthead {
    font-family: var(--font-serif);
    font-size: 3.8rem;
    font-weight: 900;
    margin: 0;
    letter-spacing: -2px;
    text-transform: uppercase;
    line-height: 1;
}

.tagline {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 8px;
    font-weight: 600;
    color: var(--text-muted);
}

/* --- UNIT TOGGLE (MI / KM) --- */
.unit-toggle {
    width: 100%;
    max-width: 650px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.unit-option {
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px 4px;
    border-radius: 2px;
    transition: color 0.2s, background 0.2s;
    user-select: none;
}

.unit-option:hover {
    color: var(--ink);
}

.unit-option.active {
    color: var(--ink);
    background: var(--border-light);
}

.unit-divider {
    color: var(--border-light);
    font-weight: 400;
}

/* --- GLOBE CONTAINER --- */
.globe-container {
    width: 100%;
    max-width: 650px;
    height: 320px;
    position: relative;
    overflow: hidden;
    margin-bottom: 10px;
    border-radius: 12px;
    touch-action: pan-y;
}

.globe-container canvas {
    display: block;
    pointer-events: auto;
}

/* Directional arrow overlay — positioned via globe.getScreenCoords() */
.globe-arrow {
    position: absolute;
    pointer-events: none;
    z-index: 200;
    transform-origin: center center;
    animation: globeArrowBlink 0.9s ease-in-out infinite;
    will-change: transform, opacity;
    /* width/height come from the SVG child */
    line-height: 0;
}

@keyframes globeArrowBlink {

    0%,
    100% {
        opacity: 1.0;
    }

    50% {
        opacity: 0.15;
    }
}

/* --- GAME BOARD --- */
.game-container {
    max-width: 650px;
    width: 100%;
}

/* Progress Bar */
.progress-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0 4px;
}

.progress-star {
    font-size: 1.6rem;
    opacity: 0.35;
    transition: var(--transition);
    cursor: default;
    line-height: 1;
}

.progress-star.active {
    opacity: 1;
    transform: scale(1.2);
}

.progress-star.correct {
    opacity: 1;
}

.progress-star.wrong {
    opacity: 0.7;
    color: var(--accent);
}

/* Story Card */
.story-card {
    background: white;
    padding: 28px 32px;
    border: 1px solid var(--ink);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    position: relative;
    transition: var(--transition);
}

.dateline {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.story-number {
    background: var(--ink);
    color: white;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.headline {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    line-height: 1.25;
    margin: 0 0 16px 0;
    font-weight: 700;
}

.results-cta {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--accent);
    margin: 0 0 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.results-subtitle {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    margin: 0 0 20px;
    font-size: 1.05rem;
}

.redacted {
    background-color: var(--ink);
    color: var(--ink);
    padding: 1px 6px;
    border-radius: 2px;
    cursor: help;
    user-select: none;
    transition: var(--transition);
}

.redacted.revealed {
    background-color: var(--accent);
    color: white;
    cursor: default;
}

.snippet {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    color: #444;
    line-height: 1.6;
    font-style: italic;
    border-left: 3px solid var(--border-light);
    padding-left: 16px;
}

/* --- INPUT --- */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.input-wrapper {
    flex-grow: 1;
    position: relative;
}

#guess-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--ink);
    font-family: var(--font-sans);
    font-size: 1rem;
    background: white;
    border-radius: 0;
    outline: none;
    transition: var(--transition);
}

#guess-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

/* Custom autocomplete dropdown */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--ink);
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.autocomplete-list.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: var(--paper);
    font-weight: 600;
}

button.submit-btn {
    padding: 14px 28px;
    width: 100%;
    background-color: var(--ink);
    color: white;
    border: 2px solid var(--ink);
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    letter-spacing: 1px;
    font-size: 0.9rem;
    transition: var(--transition);
}

button.submit-btn:hover {
    background-color: #333;
}

button.submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- NOTIFICATIONS --- */
.notification {
    padding: 16px 20px;
    margin-bottom: 20px;
    font-weight: 600;
    text-align: center;
    font-size: 1.05rem;
    animation: slideIn 0.3s ease;
    display: none;
}

.notification.show {
    display: block;
}

.notification.success {
    background: #d1e7dd;
    border: 1px solid #badbcc;
    color: #0f5132;
}

.notification.success a {
    color: #0f5132;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.notification.success a:hover {
    color: #0a3622;
}

.notification.failure {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #842029;
}

/* --- GUESS HISTORY --- */
.history {
    list-style: none;
    padding: 0;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.95rem;
    animation: slideIn 0.3s ease;
}

.history-item:first-child {
    border-top: 2px solid var(--ink);
}

.distance-info {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}

.distance-info .arrow {
    font-size: 1.3rem;
}

/* --- NEXT / ACTION BUTTONS --- */
button.next-btn {
    width: 100%;
    padding: 16px;
    margin-bottom: 20px;
    background-color: var(--accent);
    color: white;
    border: none;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: none;
}

button.next-btn:hover {
    background-color: var(--accent-hover);
}

/* --- RESULTS SCREEN --- */
.results-screen {
    display: none;
    text-align: center;
    padding: 30px 0;
}

.results-screen h2 {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    margin-bottom: 6px;
}

.results-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.stars-container {
    font-size: 3rem;
    margin-bottom: 20px;
    letter-spacing: 8px;
}

.share-btn {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 30px;
    padding: 14px 24px;
    background: var(--ink);
    color: white;
    border: none;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.share-btn:hover {
    background: #333;
}

.rank-display {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin: 16px 0 8px;
    letter-spacing: 0.5px;
}

/* --- CUMULATIVE STATS --- */
.stats-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 40px;
    margin-bottom: 24px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

.stat-box {
    text-align: center;
}

.stat-number {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.star {
    display: inline-block;
    transition: all 0.4s ease;
    opacity: 0;
    transform: scale(0.3);
}

.star.show {
    opacity: 1;
    transform: scale(1);
}

.star.empty {
    filter: grayscale(1);
    opacity: 0.3;
    transform: scale(1);
}

.results-articles {
    text-align: left;
    border-top: 2px solid var(--ink);
    margin-top: 10px;
}

.result-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

.result-logo {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    background: var(--border-light);
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-item .result-country {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.result-item .result-headline {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    margin-bottom: 4px;
    line-height: 1.3;
}

.result-item .result-headline a {
    color: var(--ink);
    text-decoration: none;
}

.result-item .result-headline a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.result-item .result-source {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-item .result-source a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.result-item .result-source a:hover {
    text-decoration: underline;
}

.result-icon {
    display: inline-block;
    width: 18px;
    text-align: center;
    margin-right: 4px;
}

/* --- LOADING --- */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

/* --- ANIMATIONS --- */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes popIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- INTRO OVERLAY --- */
.intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--paper);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.intro-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.intro-pub-name {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ink);
    opacity: 0;
    position: absolute;
    white-space: nowrap;
    animation: pubFlash 0.4s ease forwards;
    pointer-events: none;
}

@keyframes pubFlash {
    0% {
        opacity: 0;
        transform: scale(0.7);
    }

    30% {
        opacity: 0.85;
        transform: scale(1.05);
    }

    100% {
        opacity: 0;
        transform: scale(1);
    }
}

.intro-text {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--text-muted);
    margin-top: 20px;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* --- RESPONSIVE --- */
@media (max-width: 600px) {
    body {
        padding: 12px 12px 40px;
    }

    h1.masthead {
        font-size: 2.8rem;
    }

    .globe-container {
        height: 260px;
    }

    .story-card {
        padding: 20px;
    }

    .headline {
        font-size: 1.5rem;
    }

    button.submit-btn {
        padding: 14px;
    }

    .stars-container {
        font-size: 2.4rem;
    }
}

/* --- BONUS TRANSITION --- */
.transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    transition: opacity 0.8s ease;
}

.blinking-intro {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: softBlink 1.5s infinite ease-in-out;
    text-align: center;
}

@keyframes softBlink {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

.sub-instruction {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- BONUS HEADER --- */
.bonus-header {
    width: 100%;
    max-width: 650px;
    text-align: center;
    margin-bottom: 30px;
}

.bonus-title {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bonus-subtitle {
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 auto 24px;
    max-width: 500px;
}

/* --- GAME BOARD --- */
.match-game-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 800px;
}

.match-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- CARDS --- */
.match-item {
    background: white;
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-card);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    position: relative;
    text-align: left;
}

.match-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid transparent;
    transition: var(--transition);
    pointer-events: none;
}

.match-item:hover:not(.active):not(.matched) {
    transform: translateY(-2px);
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.1);
}

.match-item.active {
    background: #e8f5e9;
    border-color: var(--accent-green);
}

.match-item.active::before {
    border-color: var(--accent-green);
}

.match-item.matched {
    background: var(--paper);
    border-color: var(--border-light);
    color: var(--text-muted);
    box-shadow: none;
    cursor: default;
    opacity: 0.6;
    pointer-events: none;
}

.match-item.error {
    background: #fdf5f5;
    border-color: var(--accent);
    animation: shake 0.4s ease-in-out;
}

.headline-text {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.35;
    width: 100%;
}

.source-name {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    width: 100%;
}

/* --- POPUPS --- */
.bonus-result-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: white;
    border: 2px solid var(--ink);
    box-shadow: 8px 8px 0px rgba(0, 0, 0, 0.15);
    padding: 40px;
    text-align: center;
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 90%;
    max-width: 450px;
}

.bonus-result-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.popup-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    margin: 0 0 15px;
}

.popup-title.success-text {
    color: var(--accent-green);
}

.popup-title.failure-text {
    color: var(--accent);
}

.popup-subtitle {
    font-family: var(--font-sans);
    color: var(--text-muted);
    margin-bottom: 25px;
    font-size: 1.05rem;
}

.popup-btn {
    background-color: var(--ink);
    color: white;
    border: 2px solid var(--ink);
    padding: 14px 28px;
    font-family: var(--font-sans);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.popup-btn:hover {
    background-color: #333;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}

@media (max-width: 600px) {
    .match-game-container {
        flex-direction: column;
    }

    .match-item {
        min-height: 80px;
        padding: 15px;
    }

    .headline-text {
        font-size: 1.05rem;
    }
}

/* --- ONBOARDING MODAL --- */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.4s ease;
}

.onboarding-overlay.show {
    display: flex;
}

.onboarding-modal {
    background: var(--paper);
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-card);
    padding: 40px 32px 32px 32px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    position: relative;
    animation: slideUpFade 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.onboarding-title {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 24px;
    line-height: 1.1;
    color: var(--ink);
}

.onboarding-list {
    text-align: left;
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.onboarding-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--ink);
}

.onboarding-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.onboarding-start-btn {
    width: 100%;
    padding: 14px 28px;
    background-color: var(--ink);
    color: white;
    border: 2px solid var(--ink);
    font-family: var(--font-sans);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.onboarding-start-btn:hover {
    background-color: #333;
}