/* ============================================================
   skylapse.video - base styles
   Dark theme, accent color comes from the :root block emitted
   by components/header.php (THEME_* constants in config.php).
   ============================================================ */

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

:root {
    /* Fallback values (overridden by the header's inline :root block) */
    --color-bg: #0b0f14;
    --color-surface: #12181f;
    --color-text: #e6edf3;
    --color-muted: #8b98a5;
    --color-accent: #4fc3f7;
    --color-accent-dark: #1e9fd3;
    --gap: 3px;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    color: var(--color-accent-dark);
}

.site-main {
    min-height: 60vh;
}

/* ---- Static text pages (page.php) ------------------------- */
.page-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 48px 20px;
}

.page-content h1 {
    font-size: 2rem;
    line-height: 1.2;
    margin: 0 0 16px;
    color: var(--color-text);
}

.page-content p {
    color: var(--color-muted);
    font-size: 1.05rem;
}

.page-404 .page-content {
    text-align: center;
    padding-top: 80px;
}

.page-404 h1 {
    font-size: 3rem;
    color: var(--color-accent);
}

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    .page-content {
        padding: 32px 16px;
    }
}

/* ============================================================
   Main page - video wall, modals, buy form, fullscreen layer
   ============================================================ */

/* ---- Preloader ------------------------------------------- */
.page-preloader {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.page-preloader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.page-preloader__spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(79, 195, 247, 0.25);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: skylapse-spin 0.8s linear infinite;
}

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

/* ---- Video wall: fixed 6x6, 16:9 cells, capped to viewport -----
   Option (b): the wall is sized as 16:9 (6 cols x 6 equal rows),
   capped by max-width calc((100vh - header) * 16/9) so all 6 rows fit
   on screen; media inside cells uses object-fit: cover. Gap stays 3px. */
.video-wall {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: var(--gap);
    width: 100%;
    max-width: calc((100vh - 190px) * 16 / 9);
    aspect-ratio: 16 / 9;
    margin: 12px auto 0;
    padding: 0;
}

.video-cell {
    position: relative;
    min-width: 0;
    min-height: 0;
    background: var(--color-surface);
    overflow: hidden;
    cursor: pointer;
    border-radius: 6px;
}

.video-cell:hover {
    box-shadow: 0 0 18px rgba(79, 195, 247, 0.35);
    z-index: 2;
}

.video-cell.is-empty {
    cursor: default;
}

.video-cell__poster,
.video-cell__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-cell__duration {
    position: absolute;
    right: 6px;
    bottom: 6px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 3px;
}

.video-cell:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.video-cell:hover .video-cell__poster {
    transform: scale(1.04);
    transition: transform 0.3s ease;
}

/* ---- Empty state ------------------------------------------ */
.wall-empty {
    max-width: 640px;
    margin: 80px auto;
    text-align: center;
    padding: 0 20px;
}

.wall-empty h1 {
    color: var(--color-accent);
    font-size: 1.8rem;
    margin: 0 0 8px;
}

.wall-empty p {
    color: var(--color-muted);
}

/* ---- Buttons ---------------------------------------------- */
.btn {
    display: inline-block;
    padding: 9px 18px;
    border: 1px solid var(--color-accent);
    border-radius: 6px;
    background: transparent;
    color: var(--color-accent);
    font: inherit;
    font-size: 0.92rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    background: rgba(79, 195, 247, 0.12);
}

.btn--accent {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #03222f;
    font-weight: 600;
}

.btn--accent:hover {
    background: var(--color-accent-dark);
    border-color: var(--color-accent-dark);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn--block {
    width: 100%;
}

/* ---- Modals ------------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    position: relative;
    width: min(720px, 100%);
    max-height: 92vh;
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal--small {
    width: min(440px, 100%);
}

.modal__close {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 1.6rem;
    line-height: 1;
    background: none;
    border: 0;
    color: var(--color-muted);
    cursor: pointer;
    z-index: 2;
}

.modal__close:hover {
    color: var(--color-text);
}

.modal__video {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 6px;
    display: block;
}

.modal__formats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0 10px;
}

.format-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
}

.format-option.is-unavailable {
    opacity: 0.45;
    cursor: not-allowed;
}

.format-option input[type="radio"] {
    accent-color: var(--color-accent);
    margin: 0;
}

.format-option__name {
    font-weight: 600;
}

.format-option__price {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.modal__title {
    margin: 0 0 6px;
    font-size: 1.3rem;
    color: var(--color-accent);
}

.modal__note {
    margin: 0 0 14px;
    color: var(--color-muted);
    font-size: 0.95rem;
}

/* ---- Watermarked fullscreen layer ------------------------- */
.wm-layer {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: #000;
}

.wm-layer[hidden] {
    display: none;
}

.wm-layer__video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.wm-layer__bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2;
}

/* ---- Order form -------------------------------------------- */
.field {
    display: block;
    margin: 10px 0;
}

.field__label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.field__label em {
    color: #ff5b5b;
    font-style: normal;
}

.field input[type="email"],
.field textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    font: inherit;
}

.field textarea {
    resize: vertical;
}

.field__note {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin: 4px 0 10px;
}

.field__note strong {
    color: var(--color-text);
}

.order-status {
    min-height: 20px;
    font-size: 0.9rem;
    margin: 6px 0;
}

.order-status--ok {
    color: #4ade80;
}

.order-status--error {
    color: #f87171;
}