/*
Theme Name: Histoire de Dodo
Theme URI: https://histoiresdodo.fr
Description: Un thème simple pour les histoires d'enfants avec ambiance nocturne - Version Responsive avec emplacements publicitaires
Version: 1.2
Author: Votre Nom
Author URI: https://histoiresdodo.fr
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: histoiredodo
*/

/* ===================
   VARIABLES & RESET
   =================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --night-blue: #1a237e;
    --deep-blue: #0d47a1;
    --soft-blue: #3f51b5;
    --star-yellow: #ffd700;
    --moon-yellow: #fff59d;
    --white: #ffffff;
    --light-gray: #f5f5f5;
    --text-gray: #666;
}

/* Fix pour le background sur tous les appareils */
html {
    background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
    background-attachment: fixed;
    min-height: 100%;
}

body {
    font-family: 'Quicksand', sans-serif;
    background: linear-gradient(135deg, var(--night-blue) 0%, var(--deep-blue) 100%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    color: var(--white);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Alternative pour les navigateurs qui ne supportent pas background-attachment: fixed */
@supports not (background-attachment: fixed) {
    body {
        background-attachment: scroll;
    }
    
    body::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
        z-index: -2;
    }
}

img {
    max-width: 100%;
    height: auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ===================
   STARS & MOON BACKGROUND
   =================== */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.star {
    position: absolute;
    font-size: 20px;
    animation: twinkle 3s infinite ease-in-out;
}

.star1 { top: 10%; left: 10%; animation-delay: 0s; }
.star2 { top: 20%; right: 15%; animation-delay: 1s; }
.star3 { top: 60%; left: 20%; animation-delay: 2s; }
.star4 { bottom: 30%; right: 10%; animation-delay: 0.5s; }
.star5 { bottom: 10%; left: 30%; animation-delay: 1.5s; }

.moon {
    position: absolute;
    top: 5%;
    right: 5%;
    font-size: 60px;
    animation: float 4s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

/* ===================
   HEADER
   =================== */
.site-header {
    background: rgba(26, 35, 126, 0.9);
    padding: 20px 0;
    backdrop-filter: blur(10px);
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
    position: relative;
    z-index: 1000;
}

.site-title {
    font-size: clamp(1.8em, 5vw, 2.5em);
    font-weight: 600;
    text-align: center;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.site-title a {
    color: var(--star-yellow);
    text-decoration: none;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.site-title a:hover {
    color: var(--moon-yellow);
    transition: color 0.3s ease;
}

.site-description {
    text-align: center;
    font-size: clamp(0.9em, 3vw, 1.1em);
    color: var(--moon-yellow);
    margin-bottom: 20px;
    padding: 0 10px;
}

/* ===================
   MENU CATÉGORIES
   =================== */
.categories-navigation {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 100;
}

.categories-menu {
    list-style: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

.categories-menu > li {
    position: relative;
    z-index: 100;
}

.categories-menu > li > a {
    color: var(--white);
    text-decoration: none;
    padding: 10px 18px;
    border-radius: 20px;
    background: rgba(255, 215, 0, 0.2);
    border: 2px solid rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: clamp(0.85em, 2.5vw, 0.95em);
    white-space: nowrap;
}

.cat-home a {
    background: rgba(255, 215, 0, 0.3);
    border-color: var(--star-yellow);
}

.categories-menu > li > a:hover,
.categories-menu > li.has-children:hover > a {
    background: var(--star-yellow);
    color: var(--night-blue);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
}

.dropdown-arrow {
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.categories-menu > li.has-children:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* Sous-catégories (dropdown) */
.sub-categories {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 35, 126, 0.98);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 15px;
    padding: 10px 0;
    margin-top: 5px;
    min-width: 200px;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.categories-menu > li.has-children:hover .sub-categories {
    opacity: 1;
    visibility: visible;
    margin-top: 10px;
}

.sub-categories li {
    margin: 0;
}

.sub-categories li a {
    display: block;
    padding: 10px 20px;
    color: var(--white);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.sub-categories li a:hover {
    background: rgba(255, 215, 0, 0.2);
    color: var(--star-yellow);
    padding-left: 25px;
}

.main-navigation {
    text-align: center;
    margin-bottom: 15px;
}

.nav-menu {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 0;
}

.nav-menu li {
    margin: 5px 0;
}

.nav-menu li a {
    color: var(--white);
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    font-weight: 400;
    display: inline-block;
    font-size: clamp(0.85em, 2.5vw, 1em);
}

.nav-menu li a:hover {
    background: var(--star-yellow);
    color: var(--night-blue);
    transform: translateY(-2px);
}

/* ===================
   ZONES PUBLICITAIRES
   =================== */
.ad-zone {
    margin: 20px auto;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
}

.ad-widget {
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.ad-label {
    display: block;
    font-size: 0.7em;
    color: rgba(255, 215, 0, 0.6);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Zone pub header - bannière horizontale 728x90 ou responsive */
.ad-header-zone {
    margin: 15px auto 0;
    max-width: 728px;
}

.ad-header-zone .ad-widget {
    min-height: 90px;
}

/* Zone pub avant contenu */
.ad-before-content-zone {
    margin: 20px auto 30px;
    max-width: 970px;
}

.ad-before-content-zone .ad-widget {
    min-height: 90px;
}

/* Zone pub entre les articles */
.ad-between-posts-zone {
    grid-column: 1 / -1;
    margin: 20px 0;
    max-width: 100%;
}

.ad-between-posts-zone .ad-widget {
    min-height: 250px;
    max-width: 970px;
    margin: 0 auto;
}

/* Zone pub dans l'article */
.ad-in-content-zone,
.ad-in-content-middle {
    margin: 30px auto;
    max-width: 100%;
}

.ad-in-content-zone .ad-widget,
.ad-in-content-middle .ad-widget {
    min-height: 250px;
}

/* Zone pub après l'article */
.ad-after-content-zone {
    margin: 30px auto;
    max-width: 970px;
}

.ad-after-content-zone .ad-widget {
    min-height: 250px;
}

/* Zone pub footer */
.ad-footer-zone {
    margin: 20px auto;
    max-width: 728px;
}

.ad-footer-zone .ad-widget {
    min-height: 90px;
}

/* ===================
   MAIN CONTENT
   =================== */
.site-main {
    padding: 30px 0;
    min-height: calc(100vh - 200px);
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.story-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    border: 2px solid rgba(255, 215, 0, 0.2);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.story-card:hover {
    transform: translateY(-5px);
    border-color: var(--star-yellow);
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.2);
    z-index: 2;
}

.story-thumbnail {
    width: 100%;
    overflow: hidden;
    border-radius: 15px;
    margin-bottom: 15px;
}

.story-thumbnail img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 15px;
    transition: transform 0.3s ease;
}

.story-thumbnail:hover img {
    transform: scale(1.05);
}

.story-title {
    font-size: clamp(1.2em, 4vw, 1.4em);
    margin-bottom: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.story-title a {
    color: var(--star-yellow);
    text-decoration: none;
    word-wrap: break-word;
}

.story-title a:hover {
    color: var(--moon-yellow);
}

.story-categories {
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-tag {
    display: inline-block;
    background: var(--star-yellow);
    color: var(--night-blue);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: clamp(0.75em, 2.5vw, 0.85em);
    font-weight: 600;
}

.story-excerpt {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
    line-height: 1.6;
    flex-grow: 1;
    font-size: clamp(0.9em, 2.5vw, 1em);
}

.read-story-btn {
    display: inline-block;
    background: var(--star-yellow);
    color: var(--night-blue);
    padding: 12px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    font-size: clamp(0.9em, 2.5vw, 1em);
    align-self: flex-start;
}

.read-story-btn:hover {
    background: var(--moon-yellow);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
}

/* ===================
   SINGLE STORY PAGE
   =================== */
.single-story {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: clamp(20px, 5vw, 40px);
    margin: 20px 0;
    border: 2px solid rgba(255, 215, 0, 0.2);
}

.single-story .story-title {
    font-size: clamp(1.5em, 6vw, 2.2em);
    text-align: center;
    color: var(--star-yellow);
    margin-bottom: 20px;
    line-height: 1.3;
    word-wrap: break-word;
}

.single-story .story-categories {
    justify-content: center;
    margin-bottom: 30px;
}

.single-story .story-featured-image {
    margin-bottom: 30px;
    border-radius: 15px;
    overflow: hidden;
}

.single-story .story-featured-image img {
    width: 100%;
    height: auto;
    border-radius: 15px;
}

.single-story .story-content {
    font-size: clamp(1em, 3vw, 1.1em);
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.95);
}

.single-story .story-content p {
    margin-bottom: 20px;
}

.single-story .story-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 20px 0;
}

.story-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 215, 0, 0.2);
    gap: 15px;
    flex-wrap: wrap;
}

.nav-previous, .nav-next {
    background: rgba(255, 215, 0, 0.1);
    padding: 15px 20px;
    border-radius: 15px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    flex: 1;
    min-width: 200px;
}

.nav-previous a, .nav-next a {
    color: var(--star-yellow);
    text-decoration: none;
    font-size: clamp(0.85em, 2.5vw, 1em);
    word-wrap: break-word;
    display: block;
}

.nav-previous a:hover, .nav-next a:hover {
    color: var(--moon-yellow);
}

/* ===================
   PAGINATION
   =================== */
.pagination {
    text-align: center;
    margin: 40px 0;
}

.page-numbers {
    display: inline-block;
    padding: 10px 15px;
    margin: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-size: clamp(0.85em, 2.5vw, 1em);
}

.page-numbers.current {
    background: var(--star-yellow);
    color: var(--night-blue);
    font-weight: 600;
}

.page-numbers:hover {
    background: var(--star-yellow);
    color: var(--night-blue);
}

/* ===================
   FOOTER
   =================== */
.site-footer {
    background: rgba(13, 71, 161, 0.9);
    padding: 30px 0;
    text-align: center;
    border-top: 2px solid rgba(255, 215, 0, 0.3);
    margin-top: 40px;
}

.site-footer p {
    color: var(--moon-yellow);
    font-size: clamp(0.85em, 2.5vw, 1em);
    padding: 0 15px;
}

/* ===================
   NO POSTS MESSAGE
   =================== */
.no-posts {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    border: 2px solid rgba(255, 215, 0, 0.2);
}

.no-posts h2 {
    color: var(--star-yellow);
    font-size: clamp(1.5em, 5vw, 2em);
    margin-bottom: 20px;
}

/* ===================
   RESPONSIVE DESIGN
   =================== */

/* Tablettes */
@media (max-width: 768px) {
    /* Fix background tablette */
    html, body {
        background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
        background-attachment: scroll;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .site-header {
        padding: 15px 0;
    }
    
    /* Menu catégories responsive tablette */
    .categories-menu {
        gap: 8px;
    }
    
    .categories-menu > li > a {
        padding: 8px 14px;
        font-size: 0.85em;
    }
    
    .sub-categories {
        min-width: 180px;
    }
    
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .story-card {
        padding: 20px;
    }
    
    .story-thumbnail img {
        height: 180px;
    }
    
    .single-story {
        padding: 25px 15px;
        margin: 10px;
        border-radius: 15px;
    }
    
    .nav-menu {
        gap: 10px;
    }
    
    .nav-menu li a {
        padding: 8px 12px;
    }
    
    .story-navigation {
        flex-direction: column;
    }
    
    .nav-previous, .nav-next {
        width: 100%;
        min-width: auto;
    }
    
    .moon {
        font-size: 50px;
        top: 3%;
        right: 3%;
    }
    
    .star {
        font-size: 16px;
    }
    
    /* Ajustements publicités tablette */
    .ad-header-zone,
    .ad-footer-zone {
        max-width: 468px;
    }
    
    .ad-between-posts-zone .ad-widget {
        max-width: 100%;
    }
}

/* Smartphones */
@media (max-width: 480px) {
    /* Fix spécifique pour le background sur mobile */
    html, body {
        background: #1a237e;
        background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
        background-attachment: scroll;
        min-height: 100vh;
        width: 100%;
    }
    
    body::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
        z-index: -2;
        pointer-events: none;
    }
    
    body {
        font-size: 16px;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .site-header {
        padding: 15px 0;
    }
    
    .site-title {
        margin-bottom: 8px;
    }
    
    .site-description {
        margin-bottom: 15px;
    }
    
    .main-navigation {
        margin-bottom: 10px;
    }
    
    /* Menu catégories mobile */
    .categories-navigation {
        margin-bottom: 15px;
    }
    
    .categories-menu {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .categories-menu > li {
        width: 100%;
    }
    
    .categories-menu > li > a {
        display: flex;
        width: 100%;
        padding: 12px 15px;
        justify-content: center;
        font-size: 0.95em;
    }
    
    /* Sous-catégories en mode mobile - en dessous */
    .categories-menu > li.has-children {
        position: relative;
    }
    
    .sub-categories {
        position: static;
        transform: none;
        width: 100%;
        margin-top: 0;
        border-radius: 10px;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        opacity: 1;
        visibility: visible;
    }
    
    .categories-menu > li.has-children:hover .sub-categories,
    .categories-menu > li.has-children.active .sub-categories {
        max-height: 500px;
        padding: 10px 0;
        margin-top: 5px;
    }
    
    .sub-categories li a {
        padding: 12px 20px;
        font-size: 0.9em;
    }
    
    .dropdown-arrow {
        margin-left: auto;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .nav-menu li {
        margin: 0;
        width: 100%;
    }
    
    .nav-menu li a {
        display: block;
        width: 100%;
        padding: 12px 15px;
    }
    
    .site-main {
        padding: 20px 0;
    }
    
    .posts-grid {
        gap: 15px;
    }
    
    .story-card {
        padding: 15px;
        border-radius: 15px;
    }
    
    .story-thumbnail img {
        height: 160px;
        border-radius: 10px;
    }
    
    .story-title {
        margin-bottom: 12px;
    }
    
    .story-excerpt {
        margin-bottom: 15px;
    }
    
    .read-story-btn {
        width: 100%;
        text-align: center;
        padding: 12px 20px;
    }
    
    .single-story {
        padding: 20px 12px;
        margin: 10px 5px;
        border-radius: 15px;
    }
    
    .single-story .story-title {
        margin-bottom: 15px;
    }
    
    .single-story .story-categories {
        margin-bottom: 20px;
    }
    
    .single-story .story-content {
        line-height: 1.7;
    }
    
    .single-story .story-content p {
        margin-bottom: 18px;
    }
    
    .story-navigation {
        margin-top: 30px;
        padding-top: 15px;
        gap: 10px;
    }
    
    .nav-previous, .nav-next {
        padding: 12px 15px;
        border-radius: 10px;
    }
    
    .pagination {
        margin: 30px 0;
    }
    
    .page-numbers {
        padding: 8px 12px;
        margin: 3px;
        font-size: 0.9em;
    }
    
    .moon {
        font-size: 35px;
        top: 2%;
        right: 2%;
    }
    
    .star {
        font-size: 12px;
    }
    
    .site-footer {
        padding: 25px 0;
        margin-top: 30px;
    }
    
    /* Publicités mobile - format adaptatif */
    .ad-zone {
        margin: 15px auto;
        min-height: 50px;
    }
    
    .ad-widget {
        padding: 10px;
        border-radius: 8px;
    }
    
    .ad-header-zone,
    .ad-before-content-zone,
    .ad-footer-zone {
        max-width: 320px;
    }
    
    .ad-header-zone .ad-widget,
    .ad-footer-zone .ad-widget {
        min-height: 50px;
    }
    
    .ad-between-posts-zone,
    .ad-in-content-zone,
    .ad-in-content-middle,
    .ad-after-content-zone {
        margin: 20px auto;
    }
    
    .ad-between-posts-zone .ad-widget,
    .ad-in-content-zone .ad-widget,
    .ad-in-content-middle .ad-widget,
    .ad-after-content-zone .ad-widget {
        min-height: 250px;
    }
}

/* Très petits écrans */
@media (max-width: 360px) {
    .story-card {
        padding: 12px;
    }
    
    .story-thumbnail img {
        height: 140px;
    }
    
    .single-story {
        padding: 15px 10px;
    }
    
    .category-tag {
        padding: 4px 10px;
        font-size: 0.75em;
    }
}

/* Mode paysage mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .story-thumbnail img {
        height: 150px;
    }
    
    .moon {
        font-size: 40px;
    }
    
    .star {
        font-size: 14px;
    }
}

/* ===================
   AMÉLIORATION ACCESSIBILITÉ
   =================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Amélioration du contraste pour lisibilité */
@media (prefers-contrast: high) {
    .story-card {
        border-width: 3px;
    }
    
    .category-tag {
        border: 2px solid var(--night-blue);
    }
}

/* ===================
   PRINT STYLES
   =================== */
@media print {
    .stars-bg,
    .moon,
    .star,
    .site-header,
    .main-navigation,
    .categories-navigation,
    .site-footer,
    .story-navigation,
    .pagination,
    .ad-zone,
    .ad-widget {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .single-story .story-content {
        color: black;
    }
    
    .story-title,
    .story-title a {
        color: black;
    }
}
