/* =========================================================
   Newticia — Modal Fake-Single
   ========================================================= */

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

/* ---- Overlay ---- */
.nwt-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    /* Scroll en el overlay — crítico para que funcione en iOS */
    overflow-y: scroll;       /* scroll en vez de auto: fuerza scrollbar en iOS */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;  /* inercia en iOS */
    overscroll-behavior: contain;       /* evita que el scroll se propague al body */
    padding: 32px 16px 80px;
    opacity: 0;
    transition: opacity .25s ease;
    box-sizing: border-box;
}

.nwt-modal-overlay.nwt-modal--visible { opacity: 1; }
.nwt-modal-overlay[hidden] { display: none !important; }

/* Bloquear scroll del body — en iOS usamos position:fixed en lugar de overflow:hidden */
body.nwt-modal-open {
    overflow: hidden;
    /* iOS Safari fix: position fixed evita que el body se desplace bajo el modal */
    position: fixed;
    width: 100%;
    /* Guardamos la posición de scroll vía JS para restaurarla al cerrar */
    left: 0;
    right: 0;
}

/* ---- Panel ---- */
.nwt-modal-inner {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 800px;
    min-height: 60vh;
    box-shadow: 0 24px 80px rgba(0,0,0,.3);
    position: relative;
    transform: translateY(24px);
    transition: transform .32s cubic-bezier(.22,.61,.36,1);
    /* El inner NO hace overflow: hidden — permite que el overlay haga scroll */
    overflow: visible;
    flex-shrink: 0;
}

.nwt-modal--visible .nwt-modal-inner { transform: translateY(0); }

/* ---- Toolbar ---- */
.nwt-modal-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #f0f0f1;
}

/* Logo en toolbar */
.nwt-modal-logo-link {
    display: block;
    line-height: 0;
    flex: 1;
    text-align: center;
}

.nwt-modal-logo {
    height: 32px;          /* se ajusta a la altura de la toolbar sin agrandarla */
    width: auto;
    max-width: 160px;
    object-fit: contain;
    display: inline-block;
}

.nwt-modal-close,
.nwt-modal-share {
    background: none;
    border: 1px solid #e2e2e2;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    transition: background .2s, color .2s, border-color .2s;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
}

.nwt-modal-close:hover { background: #fee2e2; color: #c0392b; border-color: #c0392b; }

.nwt-modal-share {
    border-radius: 20px;
    padding: 0 14px;
    width: auto;
    font-size: 13px;
    font-weight: 600;
    gap: 6px;
}
.nwt-modal-share:hover { background: #f0f6fc; color: #2271b1; border-color: #2271b1; }

.nwt-share-copied { color: #2ecc71; font-size: 12px; }

/* ---- Hero ---- */
.nwt-modal-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;   /* mismo ratio que la imagen generada */
    overflow: hidden;
    background: #111;
}

.nwt-modal-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.nwt-modal-hero-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55%;
    background: linear-gradient(to top, #fff 0%, transparent 100%);
}

/* ---- Body ---- */
.nwt-modal-body {
    padding: 28px 36px 48px;
    font-family: 'Inter', system-ui, sans-serif;
}

/* ---- Meta top ---- */
.nwt-modal-meta-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.nwt-modal-date {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ---- Título modal ---- */
#nwt-modal-title,
.nwt-modal-title {
    font-family: 'Playfair Display', Georgia, serif !important;
    font-size: clamp(1.5rem, 3.5vw, 2.2rem);
    line-height: 1.2;
    font-weight: 800;
    color: #111;
    margin: 0 0 28px;
    letter-spacing: -.02em;
    text-transform: uppercase;
}

/* ---- Texto ---- */
.nwt-modal-text {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.05rem;
    line-height: 1.8;
    color: #374151;
    margin-bottom: 36px;
}

.nwt-modal-text p { margin: 0 0 1.3em; }
.nwt-modal-text p:last-child { margin-bottom: 0; }

/* ---- Fuente original ---- */
.nwt-modal-source {
    border-top: 1px solid #f0f0f1;
    padding-top: 22px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    font-family: 'Inter', sans-serif;
}

.nwt-modal-source-label {
    color: #9ca3af;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 10px;
}

.nwt-modal-source-link {
    color: #c0392b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: color .2s;
}
.nwt-modal-source-link:hover { color: #962d22; text-decoration: underline; }

/* ---- Loader ---- */
.nwt-modal-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    gap: 16px;
    color: #9ca3af;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.nwt-modal-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f1;
    border-top-color: #c0392b;
    border-radius: 50%;
    animation: nwt-modal-spin .7s linear infinite;
}

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

/* ---- Error ---- */
.nwt-modal-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    gap: 12px;
    color: #c0392b;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    padding: 32px;
    text-align: center;
}

/* ==========================================================
   MOBILE
   ========================================================== */
@media (max-width: 640px) {
    .nwt-modal-overlay {
        padding: 0;
        align-items: flex-start; /* siempre desde arriba para que el scroll empiece desde el top */
    }

    .nwt-modal-inner {
        border-radius: 0;        /* en móvil ocupa toda la pantalla */
        max-width: 100%;
        width: 100%;
        min-height: 100%;        /* ocupa todo el overlay */
        overflow: visible;       /* el overlay hace el scroll, no el inner */
    }

    .nwt-modal-body {
        padding: 20px 20px 56px;
    }

    #nwt-modal-title,
    .nwt-modal-title {
        font-size: 1.45rem;
    }

    .nwt-modal-hero {
        aspect-ratio: 16 / 9;
    }
}
