/* ============================================================
   IZVIR PORTFOLIO — MAIN STYLESHEET
   Video mosaic grid, dark VFX-portfolio aesthetic
   ============================================================ */

/* ----------------------------------------------------------
   RESET & BASE
   ---------------------------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a0a;
    --bg-elevated: #141414;
    --bg-card: #1a1a1a;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #ffffff;
    --accent-dim: rgba(255, 255, 255, 0.15);
    --gap-sm: 4px;
    --gap-md: 8px;
    --gap-lg: 24px;
    --radius: 6px;
    --max-width: 1400px;
    --header-height: 56px;
}

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

body {
    min-height: 100vh;
    padding-top: var(--header-height);
}

a {
    color: inherit;
    text-decoration: none;
}

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

/* ----------------------------------------------------------
   HEADER / NAV
   ---------------------------------------------------------- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gap-lg);
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent);
}

.main-nav {
    display: flex;
    gap: 24px;
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    transition: color 0.2s;
    text-transform: uppercase;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent);
}

/* ----------------------------------------------------------
   MOSAIC GRID
   ---------------------------------------------------------- */
.mosaic-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--gap-md);
}

.mosaic-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 200px;
    grid-auto-flow: dense;
    gap: var(--gap-sm);
}

@media (max-width: 1024px) {
    .mosaic-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 180px;
    }
}

@media (max-width: 640px) {
    .mosaic-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 150px;
    }
}

/* ----------------------------------------------------------
   MOSAIC ITEM
   ---------------------------------------------------------- */
.mosaic-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: var(--radius);
    background: var(--bg-card);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mosaic-item:hover {
    transform: scale(1.02);
    z-index: 2;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.mosaic-item.col-span-2 {
    grid-column: span 2;
}

.mosaic-item.row-span-2 {
    grid-row: span 2;
}

.mosaic-item .thumbnail {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.mosaic-item:hover .thumbnail {
    opacity: 0.2;
    transform: scale(1.05);
}

/* Hover overlay */
.mosaic-item .item-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 16px;
    text-align: center;
    pointer-events: none;
}

.mosaic-item:hover .item-overlay {
    opacity: 1;
}

.item-overlay .play-icon {
    width: 48px;
    height: 48px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    transition: background 0.2s;
}

.item-overlay .play-icon::after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-left: 14px solid var(--accent);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    margin-left: 3px;
}

.item-overlay .item-title {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--accent);
}

.item-overlay .item-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Hover video preview (muted, autoplay) */
.mosaic-item .hover-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mosaic-item:hover .hover-video {
    opacity: 1;
}

/* ----------------------------------------------------------
   TOOLS SECTION
   ---------------------------------------------------------- */
.tools-section {
    max-width: var(--max-width);
    margin: 80px auto;
    padding: 0 var(--gap-lg);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    color: var(--accent);
}

.section-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--gap-md);
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color 0.2s, transform 0.2s;
}

.tool-card:hover {
    border-color: var(--accent-dim);
    transform: translateY(-2px);
}

.tool-card .tool-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.tool-card .tool-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.tool-card .tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

.tool-tag {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ----------------------------------------------------------
   ABOUT SECTION
   ---------------------------------------------------------- */
.about-section {
    max-width: 700px;
    margin: 80px auto;
    padding: 0 var(--gap-lg);
}

.about-content p {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.8;
}

/* ----------------------------------------------------------
   CONTACT SECTION
   ---------------------------------------------------------- */
.contact-section {
    max-width: var(--max-width);
    margin: 80px auto 120px;
    padding: 0 var(--gap-lg);
}

.contact-links {
    display: flex;
    gap: 32px;
    margin-top: 16px;
}

.contact-link {
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    transition: color 0.2s;
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
}

.contact-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent-dim);
}

/* ----------------------------------------------------------
   FULLSCREEN VIEWER
   ---------------------------------------------------------- */
.viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.viewer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.viewer-close {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.viewer-container {
    width: 90vw;
    max-width: 1200px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

.viewer-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Loading spinner */
.viewer-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.viewer-loader.active {
    opacity: 1;
    pointer-events: auto;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

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

/* Error state */
.viewer-error {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    z-index: 5;
}

.viewer-error.active {
    display: flex;
}

.viewer-error .error-icon {
    font-size: 2rem;
    margin-bottom: 4px;
}

.viewer-error .error-msg {
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.5;
}

/* ----------------------------------------------------------
   UTILITY
   ---------------------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Fade-in on scroll (simple, no IntersectionObserver dependency yet) */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   MOBILE & RESPONSIVE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --gap-lg: 16px;
    }

    /* --- Header: compact nav --- */
    .site-header {
        padding: 0 12px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .main-nav {
        gap: 14px;
    }

    .nav-link {
        font-size: 0.75rem;
    }

    /* --- Mosaic: 2 columns --- */
    .mosaic-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 140px;
        gap: 3px;
    }

    .mosaic-section {
        padding: 3px;
    }

    /* Disable hover scale on touch — feels janky */
    .mosaic-item:hover {
        transform: none;
    }

    /* Larger tap targets */
    .mosaic-item .item-overlay .play-icon {
        width: 36px;
        height: 36px;
    }

    .item-overlay .play-icon::after {
        border-left-width: 10px;
        border-top-width: 6px;
        border-bottom-width: 6px;
        margin-left: 2px;
    }

    .item-overlay .item-title {
        font-size: 0.8rem;
    }

    .item-overlay .item-category {
        font-size: 0.7rem;
    }

    /* --- Tools: single column --- */
    .tools-grid {
        grid-template-columns: 1fr;
    }

    .tools-section,
    .about-section,
    .contact-section {
        margin: 48px auto;
    }

    .section-title {
        font-size: 1.25rem;
    }

    /* --- Viewer: edge-to-edge --- */
    .viewer-overlay {
        padding: 0;
    }

    .viewer-container {
        width: 100vw;
        max-width: 100vw;
        aspect-ratio: 16 / 9;
        border-radius: 0;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
    }

    .viewer-close {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    /* --- Contact links: stack --- */
    .contact-links {
        gap: 20px;
    }
}

/* ============================================================
   SMALL MOBILE (≤400px)
   ============================================================ */
@media (max-width: 400px) {
    .mosaic-grid {
        grid-auto-rows: 120px;
    }

    .main-nav {
        gap: 10px;
    }

    .nav-link {
        font-size: 0.7rem;
        letter-spacing: 0.02em;
    }

    .contact-links {
        flex-direction: column;
        gap: 12px;
    }
}

/* ============================================================
   NO-THUMBNAIL FALLBACK
   When Vimeo thumbnail fails to load or is empty.
   ============================================================ */
.mosaic-item.no-thumb::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        var(--bg-card) 0%,
        #1e1e1e 50%,
        var(--bg-card) 100%
    );
}

.mosaic-item.no-thumb .item-overlay {
    opacity: 0.6;
}

.mosaic-item.no-thumb:hover .item-overlay {
    opacity: 1;
}

/* ============================================================
   HOVER VIDEO LOADING PULSE
   Subtle animation on thumbnail while hover video buffers.
   ============================================================ */
.mosaic-item.video-loading .thumbnail {
    animation: thumbnailPulse 1.2s ease-in-out infinite;
}

@keyframes thumbnailPulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 0.7; }
}
