/* Mostrar menú móvil solo en móvil, ocultar en desktop */
.mobile-nav-bar, .bottom-nav-menu {
    display: none;
}

@media (max-width: 900px), (max-width: 56.25em), (max-device-width: 900px) {
    .mobile-nav-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        background: #fff;
        box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
        justify-content: space-around;
        align-items: center;
        z-index: 1001;
        padding: 0;
        height: 60px;
    }

    /* Refuerzo para evitar que desaparezca por cascada */
    nav.mobile-nav-bar {
        display: flex !important;
    }
    .bottom-nav-menu {
        display: none;
        position: fixed;
        bottom: 75px;
        right: 18px;
        min-width: 120px;
        width: max-content;
        max-width: min(180px, 80vw);
        background: #fff;
        box-shadow: 0 2px 16px rgba(0,0,0,0.18);
        flex-direction: column;
        align-items: flex-end;
        z-index: 3000;
        border-radius: 12px;
        padding: 6px 0;
        animation: slideUp 0.25s;
        overflow: hidden;
        white-space: nowrap;
        text-align: right;
    }
    .bottom-nav-menu a {
        color: #111;
        text-decoration: none;
        font-size: 1rem;
        padding: 10px 18px;
        width: 100%;
        text-align: right;
        border-bottom: 1px solid #eee;
        background: none;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }
    .bottom-nav-menu a:last-child {
        border-bottom: none;
    }
    .bottom-nav-menu.open {
        display: flex;
    }
    /* Eliminados duplicados de .bottom-nav-menu a */
    .main-nav {
        display: none !important;
    }
    .nav-toggle {
        display: flex !important;
    }
}

@media (min-width: 901px) {
    .mobile-nav-bar, .bottom-nav-menu {
        display: none !important;
    }
    .main-nav {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100%;
    }
    .nav-toggle {
        display: none !important;
    }
}
/* --- Centrar y mejorar menú hamburguesa móvil --- */

/* --- Menú hamburguesa móvil alineado a la derecha --- */
@media (max-width: 900px) {
    .main-nav {
        display: none;
        transition: none;
    }
    .main-nav.open {
        display: flex !important;
        flex-direction: column;
        align-items: flex-end;
        justify-content: flex-start;
        position: fixed;
        top: 0;
        right: 0;
        width: 80vw;
        max-width: 320px;
        height: 100vh;
        background: #fff;
        z-index: 2002;
        box-shadow: -4px 0 32px rgba(0,0,0,0.18);
        padding-top: 80px;
        gap: 18px;
        font-size: 1.25rem;
        border-radius: 0 0 0 0;
        animation: slideInMenu 0.22s cubic-bezier(.4,1.3,.6,1);
    }
    .main-nav.open a {
        width: 100%;
        text-align: right;
        padding: 18px 24px 18px 0;
        border-bottom: 1px solid #eee;
        font-size: 1.15em;
    }
    .main-nav.open a:last-child {
        border-bottom: none;
    }
    .nav-toggle.open {
        z-index: 2003;
    }
}

@keyframes slideInMenu {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
/* --- FIX: Mobile nav bar and bottom nav menu --- */
.mobile-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    background: #fff;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1001;
    padding: 0;
    height: 60px;
}

/* Eliminado duplicado: .bottom-nav-menu alineado a la izquierda */

/* Eliminado duplicado: .bottom-nav-menu.open */

.bottom-nav-menu a {
    color: #111;
    text-decoration: none;
    font-size: 1.15rem;
    padding: 12px 0;
    width: 100%;
    text-align: center;
    border-bottom: 1px solid #eee;
    background: none;
}

.bottom-nav-menu a:last-child {
    border-bottom: none;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
body {
    margin: 0;
    font-family: "Courier New", monospace;
    background: #ffffff;
}

/* HEADER */
.top-header {
    background: #bce8fc;
    padding: 20px 40px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

/* SEARCH */
.search-container input {
    text-align: left;
    position: relative;
    padding: 8px 15px;
    border-radius: 20px;
    border: none;
    width: 180px;
    font-family: "Courier New", monospace;
}

/* HEADER CENTER */
.header-center {
    text-align: center;
    position: relative;
}

.header-center h1 {
    margin: 0;
    font-size: 38px;
}

.header-center h2 {
    margin: 0;
    font-size: 16px;
    font-weight: normal;
    opacity: 0.8;
    margin-top: 5px;
}

.decor-line {
    width: 2px;
    height: 64px;
    background: white;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.decor-dot {
    width: 14px;
    height: 14px;
    background: #ffeb56;
    border-radius: 50%;
    position: absolute;
    left: 6px;
    top: calc(50% + 28px);
    box-shadow: 0 0 0 4px rgba(255,235,86,0.06);
}

.header-center {
    padding-left: 48px;
}

.header-center h1,
.header-center h2 {
    position: relative;
    z-index: 2;
}

/* CART */
.cart {
    text-align: right;
    position: relative;
    display: inline-block;
    text-decoration: none;
    color: inherit;
}

.cart img {
    width: 28px;
    vertical-align: middle;
    opacity: 0.8;
}

.cart span {
    position: absolute;
    top: -8px;
    right: -8px;
    background: white;
    color: black;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* NAV */
.main-nav {
    background: white;
    text-align: center;
    padding: 12px 0;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-nav a {
    text-decoration: none;
    color: #333;
    margin: 0 15px;
    font-weight: bold;
    font-size: 14px;
    transition: transform 200ms ease;
    display: inline-block;
}

.main-nav a:hover {
    transform: scale(1.1);
}

.main-nav a.active {
    color: #64b5f6;
}

/* Hide mobile nav in desktop */

/* Eliminar display:none conflictivo para mobile nav bar y bottom nav menu */

html, body {
    height: 100%;
}

.hero {
    position: relative;
    height: 100vh;
    overflow: hidden;
}

.hero img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    filter: brightness(0.5) hue-rotate(180deg);
}

.hero .overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 120, 255, 0.25);
    pointer-events: none;
}

.hero-text {
    position: absolute;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    color: white;
    font-size: 28px;
    line-height: 1.4;
    padding: 0 20px;
}

.yellow {
    color: #ffd95a;
}

/* NOVEDADES */
.novedades {
    background: #ffffff;
    padding: 60px 20px;
}

.novedades .container {
    max-width: 1100px;
    margin: 0 auto;
}

.novedades h3 {
    font-size: 22px;
    margin: 0 0 18px 0;
    text-align: left;
    color: #111;
}

.novedades-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Libros specific grid (override inline) */
.libros-grid {
    display: grid; /* default from inline too */
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
}

.card {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 200ms ease, box-shadow 200ms ease;
    box-shadow: 0 6px 18px rgba(10,10,10,0.03);
    animation: fadeUp .5s ease both;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(10,10,10,0.08);
}

.card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.card-body {
    padding: 16px;
}

.card-body h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.card-body p {
    margin: 0 0 12px 0;
    color: #444;
    font-size: 14px;
}

.btn {
    display: inline-block;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #64b5f6;
    color: #1e88e5;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
}

@media (max-width: 760px) {
    .novedades-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .search-results-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 15px;
    }

    .card img {
        height: 120px;
    }
}

@media (max-width: 1024px) and (min-width: 761px) {
    .search-results-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 18px;
    }
}

@media (max-width: 768px) {
    .search-results-page .container {
        max-width: 100%;
        padding: 0 15px;
    }
}

@keyframes fadeUp {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* FOOTER */
.site-footer {
    background: #bce8fc; /* same as header */
    color: #0e1330;
}

.site-footer .footer-top {
    padding: 28px 20px;
}

.site-footer .footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 320px;
    align-items: start;
    gap: 20px;
}

.site-footer h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    letter-spacing: 0.6px;
}

.footer-info ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-info li { margin: 6px 0; }

.footer-info a {
    color: #0e1330;
    text-decoration: none;
    opacity: 0.95;
}

.footer-news { text-align: right; }

.socials { display: inline-flex; gap: 14px; align-items: center; }

.social {
    display: inline-flex;
    width: 56px;
    height: 56px;
    background: #0e1330;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.social svg { display: block; width: 28px; height: 28px; }

.footer-bottom {
    background: #ffffff;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.footer-bottom .footer-inner.center { display: block; text-align: center; padding: 10px 20px; }

.footer-bottom p { margin: 8px 0; color: #6b6b6b; font-size: 13px; letter-spacing: 1px; }

/* Footer responsive adjustments */
@media (max-width: 700px) {
    .site-footer .footer-top {
        padding: 18px 12px;
    }

    .site-footer .footer-inner {
        max-width: 100%;
        margin: 0 auto;
        display: grid;
        grid-template-columns: 1fr; /* stack columns */
        gap: 14px;
        box-sizing: border-box;
        padding: 0 8px;
    }

    .footer-news { text-align: left; }

    .social { width: 44px; height: 44px; }
    .social svg { width: 22px; height: 22px; }

    .footer-info ul { display: block; }
    .footer-info li { word-break: break-word; }

    .footer-bottom .footer-inner.center { padding: 12px 10px; }
}

@media (max-width: 380px) {
    .social { width: 40px; height: 40px; }
    .social svg { width: 18px; height: 18px; }
    .site-footer .footer-top { padding: 14px 10px; }
}

/* Sobre-mi: keep desktop layout, change order on small screens */
@media (max-width: 700px) {
    .sobre-section .sobre-container {
        /* force single column on mobile - override inline styles */
        display: grid !important;
        grid-template-columns: 1fr !important; /* stack */
        grid-auto-flow: row !important;
        gap: 18px !important;
    }
    /* Stack libros grid in mobile and adjust image sizes */
    .libros-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 18px !important;
    }
    .libros-grid img {
        width: 100%;
        max-width: 220px;
        height: auto;
        display: block;
        margin-bottom: 10px;
    }
    .sobre-section .sobre-text { order: 1; }
    .sobre-section .sobre-img { order: 2; display: flex; justify-content: center; }
    .sobre-section .sobre-img img { max-width: 220px; width: 100%; height: auto; }
    .sobre-section { padding: 40px 12px; }
}

/* NAV */
.main-nav {
    background: #ffffff;
    padding: 0;
    text-align: center;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.main-nav a {
    display: inline-block;
    padding: 16px 20px;
    text-decoration: none;
    color: #111;
    font-weight: bold;
    transition: background 0.3s;
}

.main-nav a:hover,
.main-nav a.active {
    background: #bce8fc;
    color: #111;
}

/* HAMBURGER MENU */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 10px;
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.nav-toggle span {
    width: 30px;
    height: 3px;
    background: #111;
    transition: all 0.3s;
    transform-origin: center;
}

.nav-toggle.open span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* MOBILE NAV */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .main-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 250px;
        height: 100vh;
        background: #ffffff;
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 80px;
        transition: left 0.3s;
        z-index: 999;
        border-right: 1px solid rgba(0,0,0,0.06);
    }

    .main-nav.open {
        left: 0;
    }

    .main-nav a {
        display: block;
        padding: 20px;
        text-align: left;
        border-bottom: 1px solid rgba(0,0,0,0.06);
    }

    .main-nav a:hover,
    .main-nav a.active {
        background: #bce8fc;
    }
}

/* SOBRE MI */
.about {
    background: #f0f4f8;
    padding: 40px 20px;
    text-align: center;
}

.about .container {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr; /* stacked by default: title above text */
    gap: 40px;
    align-items: center;
}

.search-results-page .container {
    max-width: 1400px;
    margin: 0 auto;
    display: block;
}

.about h3 {
    font-size: 22px;
    margin: 0 0 20px 0;
    color: #111;
}

.about p {
    font-size: 16px;
    line-height: 1.6;
    color: #555;
    margin: 0 0 24px 0;
}

.btn-primary {
    background: #64b5f6;
    color: #ffffff !important;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
}

.btn-primary:hover {
    background: #42a5f5;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(100, 181, 246, 0.3);
}

/* MOBILE STYLES */
@media (max-width: 768px) {
    .top-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 20px;
        text-align: center;
    }

    .header-center {
        order: 1;
        margin-left: -50px;
    }

    .search-container {
        order: 2;
        margin-top: 10px;
    }


    .header-center h1 {
        font-size: 28px;
    }

    .header-center h2 {
        font-size: 14px;
    }

    .search-container {
        margin-top: 10px;
    }

    .search-container input {
        width: 250px;
    }

    .cart {
        display: none; /* Hide desktop cart in mobile */
    }

    /* About section mobile */
    .about {
        padding: 40px 20px;
    }

    .about .container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Ensure the about block has extra top padding on small screens
       so large images don't overlap the header */
    .about .container {
        padding-top: 18px;
    }

    .about h3 {
        font-size: 18px;
    }

    .about p {
        font-size: 14px;
    }

    .about img {
        max-width: 200px;
    }

    /* Specific for Sobre Mí page */
    .sobre-mi-page .container > div:first-child {
        margin-top: -100px;
    }
    /* Contact page mobile */
    .contact-buttons {
        flex-direction: row;
        gap: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .contact-btn .social {
        width: 60px !important;
        height: 60px !important;
    }

    .contact-btn svg {
        width: 24px !important;
        height: 24px !important;
    }
    /* Ensure book/detail images sit lower on mobile to avoid overlapping header */
    .about .container img {
        margin-top: 20px !important;
    }

    /* On very small screens push the image further down for visual spacing */
    @media (max-width: 420px) {
        .about .container img {
            margin-top: 60px !important;
            max-width: 90% !important;
        }
        /* larger padding on very small screens to avoid overlap */
        .about .container {
            padding-top: 100px;
        }
    }
    /* Hide desktop nav in mobile */
    .nav-toggle, .main-nav {
        display: none;
    }

    /* Mobile nav bar */
    .mobile-nav-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #ffffff;
        border-top: 1px solid rgba(0,0,0,0.06);
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 10px 20px;
        z-index: 1000;
    }

    .nav-icon {
        text-decoration: none;
        color: inherit;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 12px;
        position: relative;
    }

    .nav-icon img, .nav-icon svg {
        width: 24px;
        height: 24px;
        margin-bottom: 2px;
    }

    .nav-icon.cart span {
        position: absolute;
        top: -8px;
        right: -8px;
        background: #ffeb56;
        color: #111;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 10px;
        font-weight: bold;
    }

    .nav-toggle-bottom {
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0;
    }

    .nav-toggle-bottom span {
        width: 20px;
        height: 2px;
        background: #111;
        margin: 2px 0;
        transition: all 0.3s;
    }

    .nav-toggle-bottom.open span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav-toggle-bottom.open span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle-bottom.open span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

}

/* Ensure mobile nav is visible on larger small screens (tablets/large phones) */
@media (max-width: 1024px) {
    .mobile-nav-bar {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: #ffffff !important;
        border-top: 1px solid rgba(0,0,0,0.06) !important;
        justify-content: space-around !important;
        align-items: center !important;
        padding: 10px 20px !important;
        z-index: 2000 !important;
    }
    /* NO display: flex !important en .bottom-nav-menu aquí */
}

/* Additional mobile tweak: nudge Sobre Mí image up so it's visible on load */
@media (max-width: 768px) {
    .about {
        /* reduce top padding so image appears sooner */
        padding-top: 10px;
    }

    .about img {
        /* pull image slightly up without overlapping header */
        display: block;
        margin: -30px auto 0 auto;
        max-width: 180px;
    }
}

/* Mobile nav bar visibility */
@media (max-width: 768px) {
    .main-nav {
        display: none;
    }
    .mobile-nav-bar {
        display: flex;
    }
}
