/*
 * InMedia Frontend Styles
 * (For Shortcodes and Single News Page)
 */

/* --- General & Shared Styles --- */
.inmedia-news-wrapper {
    width: 100%;
}

.feed-logo {
    width: 21px;
    height: 21px;
    vertical-align: middle;
    border-radius: 3px;
    margin: 0px 3px !important;
}

.feed-name {
    font-weight: normal;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 8px;
}

.news-item-source .feed-name {
    color: #666;
}

.inmedia-loader {
    text-align: center;
    padding: 20px 0;
    width: 100%;
}

.inmedia-loader .dashicons-update {
    color: #0073aa;
    font-size: 30px;
    width: 30px;
    height: 30px;
    display: inline-block;
    animation: inmedia-spin 1s linear infinite;
}

@keyframes inmedia-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Layout 1: List View --- */
.inmedia-news-list .news-item {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.inmedia-news-list .news-item-image-list {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.inmedia-news-list .news-item-content h2 {
    margin: 0;
    font-size: 1.2em;
    line-height: 1.4;
}

/* --- Layout 2: Grid View --- */
.inmedia-news-grid {
    column-count: 3;
    column-gap: 15px;
}

.inmedia-news-grid .news-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    break-inside: avoid;
}

.inmedia-news-grid .news-item-image {
    width: 100%;
    padding-top: 75%; /* Default: 4:3 */
    background-size: cover;
    background-position: center;
    transition: transform 0.4s ease;
}

.inmedia-news-grid .news-item:hover .news-item-image {
    transform: scale(1.05);
}

/* Varied aspect ratios */
.inmedia-news-grid .news-item:nth-child(11n + 1) .news-item-image,
.inmedia-news-grid .news-item:nth-child(11n + 8) .news-item-image {
    padding-top: 150%; /* 2:3 */
}
.inmedia-news-grid .news-item:nth-child(11n + 4) .news-item-image,
.inmedia-news-grid .news-item:nth-child(11n + 10) .news-item-image {
    padding-top: 100%; /* 1:1 */
}
.inmedia-news-grid .news-item:nth-child(11n + 6) .news-item-image {
    padding-top: 56.25%; /* 16:9 */
}

/* Grid overlay and buttons */
.inmedia-news-grid .news-item-content-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 60%, rgba(0,0,0,0) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.inmedia-news-grid .news-item:hover .news-item-content-overlay {
    opacity: 1;
}

.inmedia-item-buttons {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 10;
    display: flex;
    gap: 15px;
    opacity: 0;
    transform: translate(-50%, -60%);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.inmedia-news-grid .news-item:hover .inmedia-item-buttons {
    opacity: 1;
    transform: translate(-50%, -50%);
}

.inmedia-icon-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background-color: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    color: #fff;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.inmedia-icon-button:hover {
    background-color: rgba(0,0,0,0.7);
    transform: scale(1.1);
}

.inmedia-icon-button svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Grid bottom content */
.inmedia-news-grid .news-item-content-bottom {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
    z-index: 5;
}

.inmedia-news-grid .news-item-content-bottom h2 {
    color: #fff;
    font-size: 1.1em;
    margin: 0;
    line-height: 1.3;
}

.inmedia-news-grid .news-item-source .feed-name {
    color: #fff;
    font-size: 0.75em;
    font-weight: normal;
}


/* --- Single News Page --- */
.inmedia-main-content {
    max-width: 960px;
    margin: 20px auto;
    padding: 40px;
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    border-radius: 8px;
    line-height: 1.7;
}

.inmedia-single-news h1.entry-title {
    font-size: 2.2em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

.inmedia-single-news .entry-meta {
    font-size: 0.9em;
    color: #777;
    margin-bottom: 1.5em;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.inmedia-news-source {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.inmedia-single-news-image {
    text-align: center;
    margin-bottom: 25px;
}

.inmedia-single-news-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 0 auto 20px;
}

.read-more-link {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

.read-more-link a {
    display: inline-block;
    background-color: #0073aa;
    color: #fff;
    padding: 12px 24px;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s ease;
    font-weight: 500;
}

.read-more-link a:hover {
    background-color: #005177;
}

/* --- YouTube & Video Styles --- */
.news-item-image {
	position: relative;
}

.inmedia-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 42px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    pointer-events: none;
    z-index: 3;
}

.inmedia-play-icon::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 18px solid #fff;
    margin-left: 3px;
}

.news-item:hover .inmedia-play-icon {
    background-color: rgba(255, 0, 0, 0.8);
}

.inmedia-video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background: #000;
}

.inmedia-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- Lightbox Styles (for JS Control) --- */

/* Prevent body scrolling when lightbox is active */
body.inmedia-lightbox-active {
    overflow: hidden;
}

/* Default hidden state for the lightbox */
.inmedia-lightbox {
    display: flex; /* Use flex for centering, NOT "none" */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

/* The visible state, triggered by JavaScript */
.inmedia-lightbox.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

/* The actual content (image or video wrapper) */
.inmedia-lightbox .inmedia-lightbox-content,
.inmedia-lightbox .inmedia-lightbox-image {
	position: relative;
	z-index: 100001; /* Must be higher than the close button overlay */
	box-shadow: 0 0 40px rgba(0,0,0,0.5);
	border-radius: 4px;
	max-width: 95%;
	max-height: 95vh;
}

/* The wrapper for video content to control its size */
.inmedia-lightbox .inmedia-lightbox-content {
	width: 90%;
	max-width: 960px;
}

/* The close link acts as a full-screen clickable background */
.inmedia-lightbox .inmedia-lightbox-close {
	position: fixed;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	z-index: 100000;
	cursor: default;
	text-decoration: none;
}

/* The "X" symbol itself */
.inmedia-lightbox .inmedia-lightbox-close::after {
	content: '×';
	position: absolute;
	top: 15px;
	right: 30px;
	font-size: 40px;
	font-weight: bold;
	color: #fff;
	line-height: 1;
	transition: transform 0.2s ease;
	cursor: pointer;
}

/* --- Responsive Adjustments --- */
@media (max-width: 992px) {
    .inmedia-news-grid {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .inmedia-main-content {
        padding: 20px;
        margin: 10px;
    }
}

@media (max-width: 576px) {
    .inmedia-news-grid {
        column-count: 1;
    }
    .inmedia-main-content {
        padding: 15px;
        margin: 0;
        border-radius: 0;
    }
}