/* MovieGridDisplay — flip card grid */

/* ── Grid wrapper ─────────────────────────────────────── */
.mgd-wrap {
    display: grid;
    grid-template-columns: repeat(var(--mgd-cols, 5), 1fr);
    gap: 20px;
    padding: 10px 0 30px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Card shell ─────────────────────────────────────────  */
.mgd-card {
    position: relative;
    perspective: 1000px;
    cursor: default;
}

/* ── Flip container ──────────────────────────────────── */
.mgd-front,
.mgd-back {
    border-radius: 10px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.55s cubic-bezier(.4,0,.2,1), box-shadow 0.3s;
}

.mgd-front {
    position: relative;
    transform: rotateY(0deg);
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.1);
}

.mgd-back {
    position: absolute;
    inset: 0;
    transform: rotateY(180deg);
    background: #0d1117;
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.mgd-card:hover .mgd-front { transform: rotateY(-180deg); box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.mgd-card:hover .mgd-back  { transform: rotateY(0deg);   box-shadow: 0 12px 40px rgba(0,0,0,.5); }

/* ── Front: poster ─────────────────────────────────────── */
.mgd-thumb {
    position: relative;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: #1a1a2e;
}
.mgd-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .4s;
}
.mgd-card:hover .mgd-thumb img { transform: scale(1.04); }

.mgd-no-poster {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    color: #2d3748;
}

.mgd-pg-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    color: #f5c518;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 4px;
    border: 1px solid rgba(245,197,24,.25);
    letter-spacing: .3px;
}

/* ── Front: text area ──────────────────────────────────── */
.mgd-front-body {
    padding: 12px;
}

.mgd-title {
    font-size: 13.5px;
    font-weight: 700;
    margin: 0 0 5px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #1a202c;
}

.mgd-date {
    font-size: 11.5px;
    color: #718096;
    margin-bottom: 10px;
}

/* ── Back ──────────────────────────────────────────────── */
.mgd-back-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(.18) blur(1px);
    z-index: 0;
}

.mgd-back-body {
    position: relative;
    z-index: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.mgd-back-title {
    font-size: 14px;
    font-weight: 800;
    margin: 0 0 6px;
    line-height: 1.3;
}
.mgd-back-title a {
    color: #fff;
    text-decoration: none;
}
.mgd-back-title a:hover { color: #f5c518; }

.mgd-back .mgd-pg-badge {
    position: static;
    display: inline-block;
    margin-bottom: 8px;
}

.mgd-back-meta {
    flex: 1;
    overflow: hidden;
}

.mgd-back-meta p {
    font-size: 12px;
    color: #a0aec0;
    margin: 0 0 5px;
    line-height: 1.4;
}
.mgd-back-meta p span {
    color: #e2e8f0;
    font-weight: 700;
}

.mgd-star { color: #4a5568; font-size: 13px; }
.mgd-star.on { color: #f5c518; }

/* ── Buttons ───────────────────────────────────────────── */
.mgd-btns,
.mgd-back-btns {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.mgd-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: background .18s, transform .15s, box-shadow .15s;
    white-space: nowrap;
}
.mgd-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.mgd-btn:hover { transform: translateY(-1px); }

.mgd-btn-trailer {
    background: #f5c518;
    color: #000;
}
.mgd-btn-trailer:hover { background: #e0b312; box-shadow: 0 4px 12px rgba(245,197,24,.35); }

.mgd-btn-detail {
    background: #6c47ff;
    color: #fff;
}
.mgd-btn-detail:hover { background: #5a38e0; box-shadow: 0 4px 12px rgba(108,71,255,.35); }

/* Back buttons — slightly transparent backgrounds */
.mgd-back .mgd-btn-trailer { background: rgba(245,197,24,.9); }
.mgd-back .mgd-btn-detail  { background: rgba(108,71,255,.85); }

/* ── Trailer popup ──────────────────────────────────────── */
.mgd-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(8px);
    animation: mgdFadeIn .25s ease;
}
@keyframes mgdFadeIn { from { opacity:0 } to { opacity:1 } }

.mgd-popup-box {
    width: 100%;
    max-width: 900px;
    background: #0d1117;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 40px 120px rgba(0,0,0,.9);
    border: 1px solid rgba(255,255,255,.08);
    animation: mgdSlideUp .3s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes mgdSlideUp { from { transform:scale(.92) translateY(30px); opacity:.5 } to { transform:scale(1) translateY(0); opacity:1 } }

.mgd-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #161b27;
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.mgd-popup-close {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background .18s;
    display: flex;
    align-items: center;
    gap: 5px;
}
.mgd-popup-close:hover { background: rgba(255,255,255,.2); }

.mgd-popup-video {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}
.mgd-popup-video iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
    .mgd-wrap { grid-template-columns: repeat(min(var(--mgd-cols,5), 4), 1fr); }
}
@media (max-width: 820px) {
    .mgd-wrap { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}
@media (max-width: 560px) {
    .mgd-wrap { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .mgd-title { font-size: 12px; }
    .mgd-btn { font-size: 11px; padding: 6px 9px; }
}

/* Touch: JS adds .mgd-flipped class on tap */
.mgd-card.mgd-flipped .mgd-front { transform: rotateY(-180deg); }
.mgd-card.mgd-flipped .mgd-back  { transform: rotateY(0deg); }

/* ── Section headers ──────────────────────────────────── */
.mgd-grid-container { width: 100%; }

.mgd-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 32px 0 16px;
    font-size: 18px;
    font-weight: 800;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: .2px;
    padding-bottom: 10px;
    border-bottom: 2px solid currentColor;
}
.mgd-section-header:first-child { margin-top: 0; }

.mgd-section-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
    animation: mgdPulse 1.8s ease-in-out infinite;
}

.mgd-section-today    { color: #16a34a; }  /* green — live now */
.mgd-section-tomorrow { color: #d97706; }  /* amber — tomorrow */
.mgd-section-upcoming { color: #6c47ff; }  /* purple — future  */

.mgd-section-today .mgd-section-dot { animation: mgdPulse 1.2s ease-in-out infinite; }
.mgd-section-tomorrow .mgd-section-dot { animation: none; }
.mgd-section-upcoming .mgd-section-dot { animation: none; opacity: .7; }

@keyframes mgdPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.75); }
}

.mgd-section-date {
    font-size: 13px;
    font-weight: 600;
    opacity: .65;
    margin-left: 4px;
}

/* First mgd-wrap after a header needs no top margin */
.mgd-section-header + .mgd-wrap { margin-top: 0; }
