/* ====== GLOBAL ====== */
body {
    opacity: 0;
    background: #181818;
    color: #fafafa;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    margin: 0;
}
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem 1rem;
}
h1 {
    text-align: center;
    font-family: 'Inter', Arial, sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #262626;
    margin: 2.5rem 0 1.5rem 0;
    letter-spacing: -0.5px;
}
a {
    color: inherit;
    text-decoration: none;
}
a:hover, a:focus {
    color: #ff4081;
}
#gallery-loading {
    text-align: center;
    color: #aaa;
    margin: 2rem 0;
}
.seo-links {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ====== GALLERY GRID (Instagram style) ====== */
.media-grid, #media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    padding: 0;
    margin: 0;
    background: none;
}
@media (max-width: 900px) {
    .media-grid, #media-gallery { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .media-grid, #media-gallery { gap: 0.8rem; }
    main { padding: 1rem 0.5rem 2rem 0.5rem; }
}
@media (max-width: 600px) {
    .media-grid, #media-gallery { grid-template-columns: 1fr; }
}

.media-card {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background: #212121;
    box-shadow: 0 2px 18px rgba(0,0,0,0.16);
    transition: transform .13s cubic-bezier(.4,0,.2,1);
    aspect-ratio: 1/1;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    cursor: pointer;
}
.media-card:hover, .media-card:focus-within {
    transform: scale(1.025);
    z-index: 2;
}

.media-thumb, .video-thumb, .media-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
    background: #222;
    margin: 0;
    transition: filter 0.18s;
}
.media-card:hover .media-thumb,
.media-card:hover .video-thumb {
    filter: brightness(0.85) blur(1px);
}
.video-thumb-container {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 1/1;
    overflow: hidden;
    background: #e9eef8;
    cursor: pointer;
}
.video-preview {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    left: 0; top: 0;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(.4,1.6,.4,1);
    background: #000;
    border-radius: 0 0 18px 18px;
}
.video-thumb-link:hover .video-preview,
.video-thumb-link:focus .video-preview {
    opacity: 1;
    pointer-events: auto;
}

.overlay {
    position: absolute;
    opacity: 0;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(0deg, rgba(24,24,24,0.96) 90%, rgba(24,24,24,0.01) 100%);
    color: #fff;
    padding: 1.1em 1em .6em 1em;
    font-size: 1.05em;
    font-weight: 600;
    display: flex;
    align-items: flex-end;
    min-height: 64px;
    text-align: center;
    z-index: 2;
}
.overlay a {
    color: #fff;
    text-decoration: none;
    flex: 1;
    font-size: 1.08em;
    line-height: 1.2;
    transition: color .16s;
    display: block;
}
.overlay a:hover, .overlay a:focus {
    color: #ff4081;
}
.overlay .material-icons {
    font-size: 1.3em;
    vertical-align: middle;
    margin-right: .4em;
}

/* ====== DETAIL PAGE (contenido.ejs, Instagram style) ====== */
.ig-detail-container {
    display: flex;
    flex-direction: row;
    max-width: 960px;
    margin: 2rem auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 6px 36px #0002;
    overflow: hidden;
    min-height: 540px;
    position: relative;
}
.ig-media {
    flex: 1.3 1 0;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 360px;
    min-height: 400px;
    position: relative;
}
.ig-media video,
.ig-media img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 0;
    background: #000;
    display: block;
    box-shadow: 0 2px 24px #0004;
}
.ig-side {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    padding: 2.5rem 2rem 2rem 2rem;
    min-width: 320px;
    border-left: 1px solid #eee;
    background: #fff;
}
.ig-author {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 1.2rem;
}
.ig-author strong {
    color: #134785;
}
.ig-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid #134785;
    box-shadow: 0 2px 8px #0001;
}
.ig-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #134785;
    margin-bottom: 0.7rem;
}
.ig-description {
    margin-bottom: 1.1rem;
    color: #444;
    font-size: 1.08em;
    line-height: 1.5;
}
.ig-meta {
    font-size: 0.97em;
    color: #888;
    margin-bottom: 1.6rem;
}
.ig-comments {
    flex: 1 1 auto;
    overflow-y: auto;
    margin-bottom: 1rem;
    max-height: 30vh;
}
.ig-comment {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    color: #393939;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.7rem;
    /* Para evitar que todo se apile en móviles: */
    word-break: break-word;
}

.ig-comment-content {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ig-comment-header {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin-bottom: 0.1em;
}

.ig-comment-author {
    font-weight: 600;
    color: #134785;
    margin-right: 0.3rem;
    font-size: 1em;
    white-space: nowrap;
}

.ig-comment-date {
    font-size: 0.92em;
    color: #888888;
    margin-left: auto;
    white-space: nowrap;
    font-weight: 400;
}

.ig-comment-message {
    font-size: 1em;
    color: #222;
    margin-top: 0.15em;
    white-space: pre-line;
    word-break: break-word;
}
.ig-comment .ig-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid #134785;
    margin-top: 2px;
    box-shadow: 0 1px 4px #0001;
}
.ig-comment-author {
    font-weight: 600;
    color: #134785;
    margin-right: 0.5rem;
}
.ig-comment-date {
    font-size: 0.85em;
    color: #888888;
}
.ig-comment-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.2rem;
    flex-flow: column;
}
.ig-comment-form input,
.ig-comment-form textarea {
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1em;
    flex: 1 1 auto;
    background: #f7faff;
    transition: border 0.2s;
}
.ig-comment-form input:focus,
.ig-comment-form textarea:focus {
    border: 1.5px solid #134785;
    outline: none;
}
.ig-comment-form button {
    background: linear-gradient(90deg, #134785 0%, #2b90d9 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.3rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px #13478522;
    transition: background 0.15s, box-shadow 0.15s;
}
.ig-comment-form button:active {
    background: #134785;
    box-shadow: none;
}
.ig-nav-arrow, .ig-close-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    font-size: 2.2rem;
    color: #134785;
    cursor: pointer;
    box-shadow: 0 2px 12px #0002;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    text-decoration: none;
}
.ig-nav-arrow:active, .ig-close-btn:active {
    background: #e0e8f5;
}
.ig-nav-arrow.left {
    left: 18px;
}
.ig-nav-arrow.right {
    right: 18px;
}
.ig-close-btn {
    top: 24px;
    right: 24px;
    left: auto;
    transform: none;
    font-size: 1.7rem;
    background: #fff;
    color: #888888;
    width: 38px;
    height: 38px;
}
.ig-nav-arrow .material-icons,
.ig-close-btn .material-icons {
    font-size: inherit;
}
@media (max-width: 800px) {
    .ig-detail-container {
        flex-direction: column;
        min-width: 0;
        margin: 0;
        border-radius: 0;
    }
    .ig-media, .ig-side {
        min-width: 0;
        width: 100%;
    }
    .ig-side {
        border-left: none;
        border-top: 1px solid #eee;
    }
    .ig-nav-arrow.left {
        left: 4px;
    }
    .ig-nav-arrow.right {
        right: 4px;
    }
    .ig-close-btn {
        right: 8px;
        top: 8px;
    }
}

/* ====== FOOTER, MISC ====== */
footer {
    background: #fff;
    color: #999;
    text-align: center;
    padding: 2rem 0 1rem 0;
    font-size: 0.93rem;
    border-top: 1px solid #eee;
    margin-top: 2rem;
}
footer a { color: #3897f0; text-decoration: none; }
footer a:hover { text-decoration: underline; }
#pagination { display: none; }
.upload-date {
    color: #999999;
    font-family: 'Inter', Arial, sans-serif;
    font-size: 0.4rem;
    text-decoration: none;
}
.video-info, .media-info {
    display: none !important;
}
.gallery-search-bar {
    max-width: 480px;
    margin: 2em auto 2em auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.gallery-search-label {
    font-weight: 600;
    margin-bottom: 0.5em;
    color: #2d2d2d;
    letter-spacing: 0.02em;
}

.gallery-search-input {
    padding: 0.7em 1em;
    font-size: 1.1em;
    border: 1.5px solid #bdbdbd;
    border-radius: 2em;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafbfc;
    color: #222;
    box-shadow: 0 1px 8px 0 rgba(60,60,60,0.03);
}

.gallery-search-input:focus {
    border-color: #8ecae6;
    background: #fff;
    box-shadow: 0 2px 12px 0 rgba(30,144,255,0.06);
}
