/* MEDLEY Digital Signage — 1080×1920 portrait kiosk */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --screen-w: 1080px;
    --screen-h: 1920px;
    --header-h: 180px;
    --giat-h: 380px;
    --ticker-h: 120px;
    --footer-h: 140px;
    --radius: 20px;
    --gap: 20px;
    --bg-dark: #0a1628;
    --text-light: #ffffff;
    --text-muted: #b0bec5;
    --accent: #1976d2;
}

html, body {
    width: var(--screen-w);
    height: var(--screen-h);
    overflow: hidden;
    cursor: none;
    user-select: none;
    -webkit-user-select: none;
    font-family: "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
    color: var(--text-light);
    background-color: var(--bg-dark);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* === Grid Layout === */
.signage {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: var(--header-h) var(--giat-h) 1fr var(--ticker-h) var(--footer-h);
    grid-template-areas:
        "header"
        "giat"
        "content"
        "ticker"
        "footer";
    gap: 0;
    padding: var(--gap);
}

/* === Header === */
.signage-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
}

.signage-header img {
    max-height: 140px;
    max-width: 100%;
    object-fit: contain;
}

/* === Giat (Kegiatan Carousel) === */
.signage-giat {
    grid-area: giat;
    overflow: hidden;
    position: relative;
}

.giat-track {
    display: flex;
    gap: 16px;
    animation: giat-scroll 30s linear infinite;
    width: max-content;
}

.giat-card {
    flex: 0 0 320px;
    height: 340px;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.08);
}

.giat-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.giat-card .giat-info {
    padding: 12px 16px;
}

.giat-card .giat-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.giat-card .giat-satker {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

@keyframes giat-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

.giat-track:hover {
    animation-play-state: paused;
}

/* === Content Area === */
.signage-content {
    grid-area: content;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius);
    position: relative;
}

.signage-content video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
    display: block;
}

.signage-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
}

.signage-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--radius);
}

/* Slideshow */
.slideshow {
    position: relative;
    width: 100%;
    height: 100%;
}

.slideshow img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    animation: slideshow-fade var(--slide-duration, 15s) infinite;
    border-radius: var(--radius);
}

/* Stagger each slide (set via inline style --slide-delay) */
.slideshow img:nth-child(1) { animation-delay: calc(var(--slide-interval) * 0); }
.slideshow img:nth-child(2) { animation-delay: calc(var(--slide-interval) * 1); }
.slideshow img:nth-child(3) { animation-delay: calc(var(--slide-interval) * 2); }
.slideshow img:nth-child(4) { animation-delay: calc(var(--slide-interval) * 3); }
.slideshow img:nth-child(5) { animation-delay: calc(var(--slide-interval) * 4); }

@keyframes slideshow-fade {
    0%   { opacity: 0; }
    5%   { opacity: 1; }
    25%  { opacity: 1; }
    30%  { opacity: 0; }
    100% { opacity: 0; }
}

/* Fallback / Blank */
.content-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 24px;
    gap: 16px;
}

.content-fallback .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* === Ticker === */
.signage-ticker {
    grid-area: ticker;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 0 20px;
}

.ticker-track {
    display: flex;
    white-space: nowrap;
    animation: ticker-scroll 20s linear infinite;
    width: max-content;
}

.ticker-text {
    font-size: 36px;
    font-weight: 600;
    padding-right: 120px;
    white-space: nowrap;
}

.ticker-separator {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    margin: 0 60px;
    align-self: center;
    flex-shrink: 0;
}

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* === Footer === */
.signage-footer {
    grid-area: footer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    padding: 10px 20px;
}

.signage-footer img {
    max-height: 70px;
    max-width: 80%;
    object-fit: contain;
}

.signage-footer .copyright {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

/* === HTMX swap transitions === */
.htmx-swapping {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.htmx-settling .signage-content,
.htmx-settling .signage-giat {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

/* === No-giat layout: collapse giat row === */
.signage.no-giat {
    grid-template-rows: var(--header-h) 0 1fr var(--ticker-h) var(--footer-h);
}

.signage.no-giat .signage-giat {
    display: none;
}

/* ==============================
   MODE OVERRIDES
   ============================== */

/* --- FULLSCREEN --- */
.signage.mode-fullscreen {
    grid-template-rows: 1fr;
    grid-template-areas: "content";
    padding: 0;
}

.signage.mode-fullscreen .signage-content {
    border-radius: 0;
}

.signage.mode-fullscreen .signage-content video,
.signage.mode-fullscreen .signage-content img,
.signage.mode-fullscreen .signage-content iframe {
    border-radius: 0;
}

/* --- SPLIT --- */
.signage.mode-split {
    grid-template-rows: var(--header-h) 1fr var(--ticker-h) var(--footer-h);
    grid-template-areas:
        "header"
        "content"
        "ticker"
        "footer";
}

.split-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.split-top {
    flex: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
}

.split-top video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.split-bottom {
    flex: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
}

.split-bottom img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- GALLERY --- */
.signage.mode-gallery {
    grid-template-rows: var(--header-h) 1fr var(--ticker-h) var(--footer-h);
    grid-template-areas:
        "header"
        "gallery"
        "ticker"
        "footer";
}

.signage-gallery {
    grid-area: gallery;
    overflow: hidden;
    padding: 10px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    height: 100%;
    overflow: hidden;
}

.gallery-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
}

.gallery-card img {
    width: 100%;
    flex: 1;
    object-fit: cover;
    display: block;
    min-height: 0;
}

.gallery-caption {
    padding: 8px 12px;
    flex-shrink: 0;
}

.gallery-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-satker {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- INFOGRAFIS --- */
.signage.mode-infografis {
    grid-template-rows: var(--header-h) var(--giat-h) 1fr var(--footer-h);
    grid-template-areas:
        "header"
        "giat"
        "content"
        "footer";
}

.infografis-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.infografis-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
}

.infografis-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    padding: 40px 24px 20px;
    border-radius: 0 0 var(--radius) var(--radius);
}

.infografis-caption h2 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
}

.infografis-caption p {
    font-size: 18px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* --- EMBED --- */
.signage.mode-embed {
    grid-template-rows: var(--header-h) 1fr var(--ticker-h) var(--footer-h);
    grid-template-areas:
        "header"
        "content"
        "ticker"
        "footer";
}
