/* ==========================================================================
   Archivo de tweets — mariogonzalez.es
   Estética heredada de estilo.css (Lora + Orelega One, fondo #121212,
   acentos #ff9b26 / #fab96f). Este fichero solo añade lo propio del archivo.
   ========================================================================== */

:root {
    --bg: #121212;
    --card: #1a1a1a;
    --card-hover: #1f1f1f;
    --border: #2b2b2b;
    --text: #F8F8F0;
    --text-soft: #E0E0D8;
    --text-muted: #9a9a92;
    --accent: #ff9b26;
    --accent-soft: #fab96f;
}

/* estilo.css pone display:flex en el body para centrar; aquí queremos flujo normal */
body {
    display: block !important;
    align-items: initial !important;
    justify-content: initial !important;
}

/* El header del sitio es position:fixed; dejamos hueco arriba para que no tape
   el contenido. --tw-header-h la mide el JS (fitHeader) según el ancho. */
#main-content {
    padding-top: var(--tw-header-h, 56px);
}

/* el header fijo por encima de la barra de filtros sticky, para que el menú
   hamburguesa desplegado (móvil) no quede tapado por ella */
header {
    z-index: 50;
}

.tw-wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 14px 120px;
}

/* ---------------------------------------------------------------- Cabecera */
.tw-hero {
    text-align: center;
    padding: 46px 10px 26px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.tw-hero img.tw-avatar {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
}

.tw-hero h1 {
    font-family: "Orelega One", serif;
    font-weight: 400;
    font-size: clamp(28px, 7vw, 40px);
    margin: 14px 0 2px;
    text-align: center;
}

.tw-handle {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.tw-bio {
    color: var(--text-soft);
    max-width: 46ch;
    margin: 14px auto 4px;
    line-height: 1.5;
}

.tw-stats {
    color: var(--text-muted);
    font-size: .92rem;
    margin-top: 10px;
}

.tw-archive-note {
    color: var(--text-muted);
    font-size: .82rem;
    margin-top: 16px;
    font-style: italic;
    max-width: 52ch;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.45;
}

/* --------------------------------------------------------------- Barra herramientas */
.tw-toolbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 0 10px;
    margin-bottom: 10px;
}

.tw-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 9px 16px;
    transition: border-color .2s;
}
.tw-search:focus-within { border-color: var(--accent); }
.tw-search svg { width: 18px; height: 18px; fill: var(--text-muted); flex: none; }
.tw-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: "Lora", serif;
    font-size: 1rem;
    min-width: 0;
}
.tw-search input::placeholder { color: var(--text-muted); }
.tw-search .tw-clear {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 1.3rem; line-height: 1;
    padding: 0 2px; display: none;
}
.tw-search .tw-clear:hover { color: var(--accent); }

.tw-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;   /* 2×2 desplegables: nunca queda uno huérfano */
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}
.tw-filters select {
    width: 100%;
    min-width: 0;
    background: var(--card);
    color: var(--text-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 14px;
    font-family: "Lora", serif;
    font-size: .9rem;
    cursor: pointer;
    outline: none;
    text-overflow: ellipsis;
}
.tw-filters select:hover { border-color: var(--accent-soft); }
.tw-filters select:focus { border-color: var(--accent); }

.tw-count {
    grid-column: 1 / -1;      /* fila propia, ocupando todo el ancho */
    color: var(--text-muted);
    font-size: .85rem;
    white-space: nowrap;
    text-align: right;
}

/* ------------------------------------------------------------------- Tarjetas */
.tw-feed { display: flex; flex-direction: column; gap: 12px; }

.tw-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 18px 12px;
    transition: background .15s, border-color .15s;
    /* El navegador no mantiene renderizadas las tarjetas fuera de pantalla:
       reduce muchísimo la memoria y evita que el móvil recargue la página. */
    content-visibility: auto;
    contain-intrinsic-size: auto 520px;
}
.tw-card:hover { background: var(--card-hover); border-color: #363636; }

.tw-rt-tag, .tw-thread-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: .8rem;
    margin-bottom: 8px;
}
.tw-rt-tag a { color: var(--accent-soft); text-decoration: none; }
.tw-rt-tag a:hover { color: var(--accent); }

.tw-head { display: flex; align-items: center; gap: 10px; }
.tw-head img {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover; flex: none; border: 1px solid var(--border);
}
.tw-name { font-family: "Orelega One", serif; font-size: 1.05rem; line-height: 1.1; }
.tw-sub  { color: var(--text-muted); font-size: .82rem; }
.tw-date {
    margin-left: auto;
    color: var(--text-muted);
    font-size: .82rem;
    white-space: nowrap;
    align-self: flex-start;
}

.tw-body {
    margin: 12px 0 6px;
    font-size: 1.06rem;
    line-height: 1.55;
    color: var(--text);
    white-space: normal;
    overflow-wrap: anywhere;
}
.tw-body .tw-link { color: var(--accent-soft); text-decoration: none; }
.tw-body .tw-link:hover { color: var(--accent); text-decoration: underline; }

/* ------------------------------------------------------------------- Media */
.tw-media {
    margin: 12px 0 6px;
    border-radius: 14px;
    overflow: hidden;
    display: grid;
    gap: 3px;
}
.tw-media.n1 { grid-template-columns: 1fr; }
.tw-media.n2 { grid-template-columns: 1fr 1fr; }
.tw-media.n3 { grid-template-columns: 1fr 1fr; }
.tw-media.n3 > :first-child { grid-row: span 2; }
.tw-media.n4 { grid-template-columns: 1fr 1fr; }

.tw-media img, .tw-media video {
    width: 100%;
    display: block;
    background: #000;
}
/* Imagen/vídeo único: conserva su proporción real (evita saltos de scroll) */
.tw-media.n1 img, .tw-media.n1 video {
    height: auto;
    max-height: 620px;
    object-fit: contain;
    cursor: zoom-in;
}
/* Rejilla de varias fotos: recorte cuadrado uniforme */
.tw-media img.grid-crop {
    aspect-ratio: 1 / 1;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
}
.tw-media video { cursor: default; }

/* ------------------------------------------------------------------- Hilo */
.tw-thread .tw-thread-top {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-soft);
    font-size: .82rem;
    margin-bottom: 10px;
}
.tw-titem { display: flex; gap: 11px; }
.tw-tcol { display: flex; flex-direction: column; align-items: center; flex: none; width: 40px; }
.tw-tav {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; border: 1px solid var(--border); flex: none;
}
.tw-tline {
    flex: 1 1 auto;
    width: 2px;
    background: var(--border);
    margin: 4px 0 0;
    min-height: 6px;
}
.tw-titem.last .tw-tline { display: none; }
.tw-tmain { flex: 1; min-width: 0; padding-bottom: 14px; }
.tw-titem.last .tw-tmain { padding-bottom: 0; }
.tw-thead { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; line-height: 1.15; }
.tw-thead .tw-name { font-family: "Orelega One", serif; font-size: .98rem; }
.tw-thead .tw-date { margin-left: auto; }
.tw-titem .tw-body { font-size: 1rem; margin: 6px 0 6px; }
.tw-titem .tw-foot { border-top: none; padding-top: 4px; margin-top: 6px; }

/* --------------------------------------------------------- Tweet citado */
.tw-quote {
    display: block;
    margin: 12px 0 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 13px;
    color: inherit;
    background: #141414;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.tw-quote .tw-link { position: relative; z-index: 1; }
.tw-quote:hover { border-color: #3a3a3a; background: #171717; }
.tw-q-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.tw-q-av { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.tw-q-name { font-family: "Orelega One", serif; font-size: .95rem; color: var(--text); }
.tw-q-handle { color: var(--text-muted); font-size: .85rem; }
.tw-q-text {
    margin-top: 6px;
    font-size: .98rem;
    line-height: 1.45;
    color: var(--text-soft);
    overflow-wrap: anywhere;
}
.tw-q-text .tw-link { color: var(--accent-soft); text-decoration: none; }
.tw-q-img {
    position: relative;
    margin-top: 9px;
    border-radius: 12px;
    overflow: hidden;
}
.tw-q-img img { width: 100%; max-height: 340px; object-fit: cover; display: block; background: #000; }
.tw-q-play {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; color: #fff;
    background: rgba(0,0,0,.35);
    pointer-events: none;
}
.tw-q-play::before {
    content: "";
    position: absolute;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
}

/* --------------------------------------------------------- Tarjeta de enlace */
.tw-card-link {
    display: block;
    margin: 12px 0 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background: #141414;
    transition: border-color .15s, background .15s;
}
.tw-card-link:hover { border-color: #3a3a3a; background: #171717; }
.tw-card-img {
    width: 100%;
    background: #000;
    border-bottom: 1px solid var(--border);
}
.tw-card-img img {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    display: block;
}
.tw-card-body { padding: 11px 14px; }
.tw-card-dom {
    color: var(--text-muted);
    font-size: .78rem;
    text-transform: lowercase;
    margin-bottom: 3px;
}
.tw-card-title {
    font-family: "Orelega One", serif;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tw-card-desc {
    color: var(--text-soft);
    font-size: .88rem;
    line-height: 1.4;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ------------------------------------------------------------------- Pie */
.tw-foot {
    display: flex;
    gap: 22px;
    color: var(--text-muted);
    font-size: .85rem;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.tw-foot span { display: inline-flex; align-items: center; gap: 6px; }
.tw-foot svg { width: 15px; height: 15px; fill: currentColor; }
.tw-foot .fav svg { fill: #f9436b; }
.tw-foot .rt  svg { fill: #23c552; }
.tw-foot-link {
    margin-left: auto;
    color: var(--accent-soft);
    text-decoration: none;
    white-space: nowrap;
}
.tw-foot-link:hover { color: var(--accent); text-decoration: underline; }

/* ------------------------------------------------------------------- Varios */
.tw-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
    font-size: 1.1rem;
}
.tw-sentinel { height: 1px; }
.tw-loading { text-align: center; color: var(--text-muted); padding: 20px; font-size: .9rem; }

.tw-top {
    position: fixed;
    right: 18px; bottom: 18px;
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--accent);
    color: #121212;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.5);
    z-index: 60;
    transition: background .2s, transform .1s;
}
.tw-top:hover { background: var(--accent-soft); }
.tw-top:active { transform: scale(.94); }

/* ------------------------------------------------------------------- Lightbox */
.tw-lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.tw-lightbox.open { display: flex; }
.tw-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}
.tw-lightbox .tw-lb-close {
    position: absolute; top: 16px; right: 20px;
    background: none; border: none; color: #fff;
    font-size: 2.4rem; line-height: 1; cursor: pointer;
}
.tw-lightbox .tw-lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.1); border: none; color: #fff;
    font-size: 2rem; width: 52px; height: 52px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.tw-lightbox .tw-lb-nav:hover { background: rgba(255,255,255,.22); }
.tw-lightbox .tw-lb-prev { left: 14px; }
.tw-lightbox .tw-lb-next { right: 14px; }

/* ------------------------------------------------------------------- Móvil */
@media (max-width: 600px) {
    .tw-wrap { padding: 0 10px 100px; }
    .tw-hero { padding: 30px 6px 20px; }
    .tw-hero img.tw-avatar { width: 78px; height: 78px; }
    .tw-hero h1 { font-size: clamp(24px, 8vw, 34px); }
    .tw-bio { font-size: .96rem; }

    .tw-card { padding: 14px 14px 10px; }
    .tw-body { font-size: 1.02rem; }

    /* filtros: desplegables un poco más compactos para que no se corten */
    .tw-filters { gap: 7px; }
    .tw-filters select { padding: 7px 11px; font-size: .85rem; }

    /* hilo: columna del avatar más estrecha */
    .tw-titem { gap: 9px; }
    .tw-tcol { width: 36px; }
    .tw-tav { width: 36px; height: 36px; }

    /* botones del lightbox más pequeños y pegados al borde */
    .tw-lightbox { padding: 12px; }
    .tw-lightbox .tw-lb-nav { width: 42px; height: 42px; font-size: 1.6rem; }
    .tw-lightbox .tw-lb-prev { left: 6px; }
    .tw-lightbox .tw-lb-next { right: 6px; }
    .tw-lightbox .tw-lb-close { top: 10px; right: 12px; }
}

@media (max-width: 360px) {
    .tw-filters select { padding: 6px 9px; font-size: .8rem; }
    .tw-foot { gap: 16px; }
}
