/* ==========================================================================
   DD info : feuille de style
   Esthétique de l'ancien index.html (barres vert-gris, ciel bleu, cartes
   blanches arrondies, cyan DD) + mode sombre + variante « thèmes & émojis ».
   ========================================================================== */

:root {
    --dd-cyan: #14b4c6;
    --page-bg: #000;
    --bg-main: #e2e4df;
    --surface: #fff;
    --surface-alt: #f8f8f8;
    --surface-hover: #f0f7f8;
    --text: #222;
    --text-soft: #666;
    --border: #ddd;
    --line: #ccc;
    --input-bg: #fff;
    --input-border: #eee;
    --overlay: rgba(255, 255, 255, 0.95);
    --modal-backdrop: rgba(0, 0, 0, 0.7);
    --sky: linear-gradient(to bottom, #002b49, #004b7a 45%, var(--bg-main) 45%);
    --bar: linear-gradient(to bottom, #5a6b5c, #313d33);
    --bar-line: #232e24;
    --bar-edge: #111;
    --card-footer: linear-gradient(to bottom, #28a745, #1e7e34);
    --map-land: #445566;
    --map-stroke: #1a2a3a;
    --map-active: #14b4c6;
    --frame-bg: #0c1a26;
}

html.dark-mode {
    --page-bg: #000;
    --bg-main: #0b1118;
    --surface: #141c26;
    --surface-alt: #1a2431;
    --surface-hover: #1d2b3a;
    --text: #e5e9ee;
    --text-soft: #97a3b0;
    --border: #2a3644;
    --line: #26323f;
    --input-bg: #0f1620;
    --input-border: #2a3644;
    --overlay: rgba(8, 12, 18, 0.95);
    --modal-backdrop: rgba(0, 0, 0, 0.8);
    --sky: linear-gradient(to bottom, #02080f, #06192b 45%, var(--bg-main) 45%);
    --bar: linear-gradient(to bottom, #26332a, #121a14);
    --bar-line: #0b110c;
    --bar-edge: #000;
    --card-footer: linear-gradient(to bottom, #1b6b2e, #124d20);
    --map-land: #2d3b4a;
    --map-stroke: #0f1a26;
    --frame-bg: #050a10;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

input, select, textarea { user-select: text; }

html, body {
    width: 100%;
    height: 100%;
    background: var(--page-bg);
    color: var(--text);
    overflow: hidden;
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--dd-cyan); outline-offset: 2px; }

/* ---------- Toast ---------- */
#toast {
    position: fixed;
    top: 20px; right: 20px;
    background: #d63c3c;
    color: #fff;
    padding: 14px 18px;
    border-radius: 10px;
    z-index: 6000;
    display: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: min(320px, calc(100vw - 40px));
    font-size: 0.9rem;
    line-height: 1.35;
}

/* ---------- Loaders ---------- */
#loader-overlay, #refresh-screen {
    position: fixed; inset: 0;
    background: var(--overlay);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 4000;
    font-weight: bold;
    color: var(--dd-cyan);
    text-align: center;
    padding: 20px;
}

.spin-loader {
    width: 80px; height: 80px;
    border: 8px solid var(--border);
    border-top: 8px solid var(--dd-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Animation d'intro ---------- */
#intro-animation {
    position: fixed; inset: 0;
    background: #000;
    color: #fff;
    z-index: 5000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    perspective: 1500px;
}

.globe-container {
    width: min(350px, 70vw);
    aspect-ratio: 1;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.5, 0, 0.2, 1), opacity 1.5s ease-in;
    opacity: 1;
}

.globe {
    width: 100%; height: 100%;
    border-radius: 50%;
    background-color: #0a3d62;
    background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Land_ocean_ice_2048.jpg/1024px-Land_ocean_ice_2048.jpg');
    background-size: auto 100%;
    box-shadow: inset -40px -40px 60px rgba(0, 0, 0, 0.8), 0 0 50px var(--dd-cyan);
    animation: rotate-globe 12s infinite linear;
}
@keyframes rotate-globe {
    from { background-position: 0 0; }
    to   { background-position: -200% 0; }
}

.zoom-in { transform: scale(15) translateZ(300px); opacity: 0; }

.intro-text {
    margin-top: 40px;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 3px;
    text-align: center;
    padding: 0 20px;
    animation: flash-text 1.5s infinite;
}
@keyframes flash-text { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------- Menu ---------- */
#menu-screen {
    position: fixed; inset: 0;
    background: var(--surface);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

.menu-header { text-align: center; margin-bottom: 20px; }
.menu-header h1 { color: var(--dd-cyan); font-size: 2rem; }
.menu-header p { color: var(--text-soft); margin-top: 4px; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 1000px;
}

.menu-item {
    background: var(--surface-alt);
    border: 4px solid var(--border);
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 120px;
}

.menu-item:hover {
    border-color: var(--dd-cyan);
    background: var(--surface);
    transform: scale(1.03);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.menu-item img {
    width: 48px; height: 48px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--border);
    object-fit: contain;
}
.menu-item span { font-weight: bold; color: var(--text); font-size: 0.9rem; overflow-wrap: anywhere; }

.btn-delete {
    position: absolute;
    top: -10px; right: -10px;
    background: #ff4444;
    color: #fff;
    border-radius: 50%;
    width: 25px; height: 25px;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    border: 2px solid #fff;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
}
.btn-delete:hover { background: #d62d2d; }

.menu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
    max-width: 1000px;
}
.menu-actions > .big-btn { flex: 1 1 180px; }
.menu-extra:empty { display: none; }
.menu-extra { flex: 1 1 180px; display: flex; }
.menu-extra .big-btn { width: 100%; }
.menu-auth { width: 100%; }

.user-pill {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-alt);
    border: 2px solid var(--border);
    border-radius: 30px;
    padding: 8px 18px;
    font-weight: bold;
    color: var(--text);
}
.user-pill a { color: #dc2626; font-size: 0.85rem; text-decoration: none; }
.user-pill a:hover { text-decoration: underline; }

/* ---------- Boutons ---------- */
.big-btn {
    background: var(--dd-cyan);
    color: #fff;
    border: none;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s, transform 0.1s;
}
.big-btn:hover { opacity: 0.9; }
.big-btn:active { transform: scale(0.97); }
.big-btn:disabled { opacity: 0.5; cursor: wait; }
.btn-secondary { background: #888; }
.btn-full { width: 100%; margin-top: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .big-btn { flex: 1; }

/* ---------- Modales ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: var(--modal-backdrop);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.modal-card {
    background: var(--surface);
    color: var(--text);
    border-radius: 20px;
    padding: 25px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-height: 92vh;
    overflow-y: auto;
}

.modal-card h2 { margin-bottom: 15px; color: var(--dd-cyan); }
.modal-subtitle { margin: 20px 0 6px; color: var(--text); font-size: 1rem; }
.hint { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 10px; line-height: 1.4; }
.form-error { color: #dc2626; font-size: 0.85rem; margin-bottom: 10px; min-height: 1em; }

.input-group { margin-bottom: 15px; }
.input-group label { display: block; margin-bottom: 5px; font-weight: bold; font-size: 0.9rem; }
.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="number"],
.input-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
}
.input-group input:focus, .input-group select:focus { border-color: var(--dd-cyan); }
.input-group input[type="file"] { margin-top: 8px; font-size: 0.8rem; width: 100%; color: var(--text-soft); }
.input-group input[type="range"] { width: 100%; accent-color: var(--dd-cyan); }

.input-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-alt);
    padding: 10px 12px;
    border-radius: 10px;
}
.input-inline label { margin: 0; }
.input-inline input { width: 20px; height: 20px; cursor: pointer; accent-color: var(--dd-cyan); }

.scroll-list {
    max-height: 380px;
    overflow-y: auto;
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
.list-row .row-main { flex: 1; min-width: 0; }
.list-row strong { display: block; overflow-wrap: anywhere; }
.list-row a { font-size: 0.8rem; color: var(--dd-cyan); display: inline-block; margin-top: 3px; }
.list-row img { width: 60px; height: 40px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.row-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: #dc2626;
}
.row-btn:hover { background: rgba(220, 38, 38, 0.1); }
.list-empty { text-align: center; padding: 20px; color: var(--text-soft); }

/* ---------- Modale article ---------- */
#modal-article .modal-card {
    max-width: 700px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.article-header-img { width: 100%; height: 250px; object-fit: cover; background: var(--border); display: none; }
.article-content { padding: 25px; overflow-y: auto; }
.article-title { font-size: 1.5rem; font-weight: bold; margin-bottom: 8px; color: var(--text); overflow-wrap: anywhere; }
.article-meta { font-size: 0.85rem; color: var(--text-soft); margin-bottom: 15px; }
.article-meta:empty { display: none; }
.article-desc { font-size: 1.1rem; line-height: 1.5; color: var(--text); opacity: 0.85; user-select: text; }
.article-actions {
    padding: 15px 25px;
    background: var(--surface-alt);
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- Application : barres ---------- */
#dd-container {
    position: fixed; inset: 0;
    background: var(--bg-main);
    display: none;
}

.dd-bar {
    position: absolute;
    left: 0; width: 100%;
    height: 60px;
    background: var(--bar);
    display: flex;
    color: #fff;
    z-index: 100;
}
#header { top: 0; border-bottom: 2px solid var(--bar-edge); }
#footer { bottom: 0; border-top: 2px solid var(--bar-edge); }

.bar-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-right: 1px solid var(--bar-line);
    border-radius: 0;
    color: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    position: relative;
    text-align: center;
    padding: 0 5px;
    min-width: 0;
}
div.bar-btn { cursor: default; }
button.bar-btn:hover { background: rgba(255, 255, 255, 0.1); }
.bar-btn:focus-visible { outline-offset: -4px; }

.action-arrow {
    flex: 0 0 50px;
    font-size: 1.3rem;
    background: rgba(20, 180, 198, 0.2);
    transition: background 0.2s, transform 0.1s;
}
button.action-arrow:hover { background: rgba(20, 180, 198, 0.5); }
button.action-arrow:active { background: var(--dd-cyan); transform: scale(0.95); }

.update-dot {
    position: absolute;
    top: 10px; right: 10px;
    width: 10px; height: 10px;
    background: #00ff00;
    border-radius: 50%;
    display: none;
    box-shadow: 0 0 10px #00ff00;
    animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

.tts-active { background: rgba(20, 180, 198, 0.3) !important; font-weight: bold; }

/* ---------- Vues ---------- */
#main-view { position: absolute; top: 60px; bottom: 60px; left: 0; width: 100%; }
.view { display: none; width: 100%; height: 100%; }
.view.active { display: block; }

#btn-exit-fullscreen {
    position: absolute;
    top: 15px; right: 15px;
    width: 40px; height: 40px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    transition: background 0.2s;
}
#btn-exit-fullscreen:hover { background: rgba(255, 0, 0, 0.6); }

:fullscreen #main-view { top: 0; bottom: 0; height: 100vh; }
:fullscreen #btn-exit-fullscreen { display: flex; }
:fullscreen .dd-bar { display: none; }

/* ---------- Sommaire ---------- */
#view-list { background: var(--surface); overflow-y: auto; scroll-behavior: smooth; }
#list-content { max-width: 1000px; margin: 0 auto; }

.news-item {
    padding: 15px 30px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.news-item:hover { background: var(--surface-hover); }
.news-text { flex: 1; min-width: 0; }
.news-text strong { overflow-wrap: anywhere; }
.news-source { display: block; font-size: 0.78rem; color: var(--text-soft); margin-top: 3px; }
.news-item img {
    width: 70px; height: 45px;
    object-fit: cover;
    margin-left: 10px;
    border: 1px solid #999;
    flex-shrink: 0;
}
.fav-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0 6px; }
.list-status { padding: 40px 20px; text-align: center; color: var(--text-soft); }

/* ---------- Diaporama ---------- */
#view-diapo { background: var(--sky); position: relative; overflow: hidden; }
#diapo-container { height: 100%; }

.fade-content { transition: opacity 0.4s ease-in-out, transform 0.4s ease-out; opacity: 1; transform: translateY(0); }
.fade-out { opacity: 0; transform: translateY(10px); }

.diapo-layout { display: flex; height: 48%; padding: 2% 4%; gap: 20px; }

.map-frame, .img-frame {
    flex: 1;
    background: var(--frame-bg);
    border: 4px solid #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.map-badge {
    position: absolute;
    top: 8px; left: 8px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.9rem;
    font-weight: bold;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#world-svg { width: 100%; height: 100%; }
.country { fill: var(--map-land); stroke: var(--map-stroke); stroke-width: 0.5; transition: fill 0.5s; }
.highlight { fill: var(--map-active) !important; }

#main-news-img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.img-frame.no-img #main-news-img { display: none; }
.img-fallback {
    position: absolute; inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: clamp(3rem, 10vw, 6rem);
}
.img-frame.no-img .img-fallback { display: flex; }

/* Variante « nouvelle interface » : thèmes + émoji géant */
.emoji-stage {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 56%;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    padding: 10px;
}
html.ui-new .diapo-layout { display: none; }
html.ui-new .emoji-stage { display: flex; }

.diapo-badges-container {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 1.3rem;
    font-weight: bold;
    text-align: center;
    max-width: 92%;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}
#diapo-giant-emoji {
    font-size: clamp(4rem, 14vh, 8rem);
    line-height: 1;
    animation: pulseEmoji 2s infinite ease-in-out;
}
@keyframes pulseEmoji { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* Carte d'info + navigation */
.info-card-container {
    position: absolute;
    left: 0; right: 0;
    bottom: 6%;
    height: 38%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2%;
}

.info-card {
    flex: 1;
    height: 100%;
    max-width: 900px;
    background: var(--surface);
    color: var(--text);
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}
.info-card:active { transform: scale(0.98); }

.card-body {
    flex: 1;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: clamp(1.05rem, 2.2vw, 1.4rem);
    font-weight: bold;
    overflow-y: auto;
    overflow-wrap: anywhere;
}

.card-footer {
    height: 42px;
    flex-shrink: 0;
    background: var(--card-footer);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 25px;
    color: #fff;
    font-size: 0.9rem;
}
#news-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.footer-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
#dots-container { display: flex; gap: 6px; max-width: 160px; overflow: hidden; justify-content: flex-end; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; transition: all 0.3s ease; flex-shrink: 0; }
#bookmark-btn-diapo { cursor: pointer; font-weight: bold; white-space: nowrap; }
#bookmark-btn-diapo:hover { text-decoration: underline; }

.nav-arrow {
    width: 60px; height: 60px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    cursor: pointer;
    margin: 0 15px;
    transition: all 0.2s;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 200;
}
.nav-arrow:hover { background: var(--dd-cyan); border-color: #fff; transform: scale(1.1); }
.nav-arrow:active { transform: scale(0.9); }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    .hide-mobile { display: none; }
    .bar-btn { font-size: 0.95rem; }
    .action-arrow { flex: 0 0 40px; }
    .news-item { padding: 12px 16px; }
    .nav-arrow { width: 44px; height: 44px; font-size: 20px; margin: 0 6px; border-width: 2px; }
    .info-card-container { height: 42%; padding: 0 1%; }
    .card-body { padding: 14px; }
    .card-footer { padding: 0 14px; }
    .article-header-img { height: 180px; }
    .article-actions .big-btn { flex: 1 1 140px; }
}

@media (max-width: 600px) {
    .diapo-layout { flex-direction: column; height: 52%; gap: 10px; padding: 2% 4%; }
    .emoji-stage { height: 58%; }
    .intro-text { font-size: 1.1rem; letter-spacing: 2px; }
    .map-badge { font-size: 0.75rem; padding: 3px 9px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
