/* CSS Variables for Theme Inversion */
:root {
    --bg-color: #000000;
    --text-name: #ffffff;
    --text-main: #a0a0a0;
    --text-muted: #606060;
    --border-color: #222222;
    --modal-bg: rgba(0, 0, 0, 0.95);
    --font-family: 'Outfit', sans-serif;
    --grid-gap: 20px;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 11px;
    line-height: 1.6;
    letter-spacing: 0.05em;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
    padding: 0;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header styling - Draggable & Collapsible Card (centered on screen) */
.header-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    z-index: 1000;
    border: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 15px;
    transition: border-color 0.4s ease, background-color 0.4s ease;
    border-radius: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.card-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    cursor: grab;
    user-select: none;
}

.card-header-top:active {
    cursor: grabbing;
}

.header-card.collapsed .card-header-top {
    border-bottom: none;
    padding-bottom: 0;
}

.header-card.collapsed .card-body {
    display: none;
}

.logo {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-name);
    letter-spacing: 0.15em;
    margin-bottom: 0;
    transition: color 0.4s ease;
}

.btn-collapse {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 10px;
    letter-spacing: 0.05em;
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.3s ease;
}

.btn-collapse:hover {
    color: var(--text-name);
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 12px;
}

.description {
    font-size: 9px;
    color: var(--text-main);
    margin-bottom: 0;
    line-height: 1.5;
    transition: color 0.4s ease;
}

.contact {
    font-size: 9px;
}

.contact-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.contact-link:hover {
    color: var(--text-name);
}

/* Card footer: REEL text buttons (left) + layout/sound icons (right) */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.footer-left {
    display: flex;
    gap: 6px;
}

.footer-right {
    display: flex;
    gap: 8px;
}

.btn-text {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 5px 7px;
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease;
    white-space: nowrap;
}

.btn-text:hover {
    border-color: var(--text-name);
    color: var(--text-name);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0;
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease;
    border-radius: 0;
}

.btn-icon svg {
    width: 13px;
    height: 13px;
}

.btn-icon:hover {
    border-color: var(--text-name);
    color: var(--text-name);
}

/* Active icon buttons are a bit lighter than the resting gray (but not white); only
   hover pushes them all the way to white. */
.btn-icon.is-active {
    color: var(--text-main);
    border-color: var(--text-main);
}

.btn-icon.is-active:hover {
    color: var(--text-name);
    border-color: var(--text-name);
}

/* Portfolio Layout: Organic Voronoi Mosaic */
/* No top padding: the header is a centered floating card now, so the mosaic fills
   from the very top edge in both layout modes (no black bar). */
.portfolio-grid {
    position: relative;
    display: block;
    width: 100%;
    background-color: var(--bg-color);
}

/* Each cell is an absolutely-positioned, uniquely-shaped polygon (clip-path set inline
   per cell). The mesh is "alive": position/size/clip-path are recomputed every frame
   during mousemove (real weighted-Voronoi geometry, not a CSS transform trick), so
   neighbors physically make room for the hovered cell and the tessellation never
   opens a gap. The short transition just smooths the per-frame jumps. */
.mosaic-cell {
    position: absolute;
    cursor: pointer;
    overflow: hidden;
    background-color: #000;
    z-index: 1;
    transition: left 0.12s linear, top 0.12s linear, width 0.12s linear, height 0.12s linear, clip-path 0.12s linear;
    /* Lets .video-info scale its type/palette with this cell's own live size
       (cqw/cqh units below) instead of fixed px, so the hover panel adapts
       automatically as the mesh grows/shrinks the cell. */
    container-type: size;
}

.mosaic-cell.is-hovered {
    z-index: 20;
}

/* -------- Delaunay overlay: dots at cell centroids + thin lines to neighbours -------- */
/* Drawn by delaunay_overlay.js into an <svg> over the grid. Black + subtle by design:
   shows only over lighter parts of the videos and nearly vanishes over dark ones. */
.delaunay-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 25; /* above .mosaic-cell.is-hovered (20) so the mesh reads over the playing video */
    overflow: visible;
}

.delaunay-lines {
    fill: none;
    stroke: #000;
    stroke-width: 1;
    vector-effect: non-scaling-stroke; /* stays ~1px even though viewBox scales */
    stroke-opacity: 0.9;
}

.delaunay-dot {
    fill: #000;
    fill-opacity: 0.95;
}

/* Edge travelers + the sticky hovered dot: painted on a canvas layered exactly over the
   svg (same box, same z-index) instead of as SVG elements -- animating ~150 dots a frame
   is far cheaper to redraw as pixels than to mutate as real DOM nodes every frame. */
.delaunay-travelers-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 25; /* same stacking as .delaunay-svg -- both must sit above the hovered cell */
}

/* -------- Grid layout mode: perfect squares (~10 per row) -------- */
/* Same cells, same behaviors, but laid out as static square grid items
   instead of absolutely-positioned Voronoi polygons. The 2D "repulsion"
   (grow the hovered square, push neighbors away) is applied inline via
   transform by app.js on mousemove -- the transition below smooths it. */
.portfolio-grid.mode-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0;
}

.portfolio-grid.mode-grid .mosaic-cell {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    height: auto;
    aspect-ratio: 1 / 1;
    clip-path: none !important;
    transform-origin: center center;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

@media (max-width: 900px) {
    .portfolio-grid.mode-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 560px) {
    .portfolio-grid.mode-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* -------- Diamond mode: same square grid cells, masked into diamonds and interlocked.
   The diamond shape is a clip-path (the video inside stays upright, only cropped). The
   interlock (odd-row half-shift + 50% vertical row overlap) is applied per cell in JS via
   the --dx/--dy custom properties + a negative margin (JS knows the live cell size). The
   base offset composes with the hover repulsion transform inside repel(). -------- */
/* !important to beat the `clip-path: none !important` inherited from .mode-grid above. */
.portfolio-grid.mode-diamond .mosaic-cell {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%) !important;
    transform: translate(var(--dx, 0px), var(--dy, 0px));
}

.video-thumbnail-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

/* -------- Monochrome mode (toggle via card button): all cells grayscale, only the
   hovered cell in color. Applied as a `.mono` class on the grid so it's trivial to
   remove -- delete this block + the button and the site is back to full colour. -------- */
.portfolio-grid.mono .video-thumbnail-container {
    filter: grayscale(1);
    transition: filter 0.4s ease;
}

/* Cells adjacent to the hovered one: half saturation (mono mode only). Kept above the
   is-hovered rule so a hovered cell always wins with full colour. */
.portfolio-grid.mono .mosaic-cell.is-neighbor .video-thumbnail-container {
    filter: grayscale(0.5);
}

.portfolio-grid.mono .mosaic-cell.is-hovered .video-thumbnail-container {
    filter: grayscale(0);
}

/* The video fills the cell and shows a still frame at rest (seeked to 20-80% via JS).
   Its `poster` .jpg covers the brief moment before that frame is decoded, so the cell
   is never black. On hover it plays; on mouse-out it pauses (freeze-frame). */
.video-thumbnail-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.mosaic-cell.is-hovered .video-thumbnail-container video {
    transform: scale(1.08);
}

/* Video Metadata Reveal Panel -- sized in cqw/cqmin (container query units) so
   text/palette scale with this specific cell's own live width/height as the
   living mesh grows or shrinks it, instead of a fixed px size for every cell. */
.video-info {
    position: absolute;
    inset: 0;
    padding: 4cqh 6cqw;
    /* No dark veil over the image on hover -- info text sits directly on the video. */
    color: #ffffff;
    opacity: 0;
    transform: translateY(15px);
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.5cqh;
}

.mosaic-cell.is-hovered .video-info {
    opacity: 1;
    transform: translateY(0);
}

.video-name {
    font-size: clamp(8px, 6.5cqmin, 16px);
    font-weight: 500;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Second line of the title (the part after " - ") -- sits tight under the brand line,
   as a lighter continuation of the same title. */
.video-subtitle {
    font-size: clamp(7px, 5.2cqmin, 13px);
    font-weight: 400;
    color: #dddddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin-top: -1cqh;
}

/* Category sits alone on its own line just below the name */
.video-category {
    font-size: clamp(6px, 4.5cqmin, 11px);
    color: #888888;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Color Palette Squares -- square size tracks the cell's own container size */
.color-palette {
    display: flex;
    justify-content: center;
    gap: 0.6cqmin;
}

.color-square {
    width: clamp(5px, 3.2cqmin, 12px);
    height: clamp(5px, 3.2cqmin, 12px);
    border: 1px solid rgba(128,128,128,0.2);
    transition: transform 0.2s ease;
}

.color-square:hover {
    transform: scale(1.25);
}


/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--modal-bg);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: background-color 0.4s ease;
}

.modal.active {
    display: flex;
}

.modal-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
}

/* The box shrinks to fit the video: the <video> is constrained by max-width/height and
   keeps its own intrinsic aspect ratio, so the container adopts the video's proportion
   directly. No fixed default ratio -> no "flash" of a 16:9 box that then jumps to the
   real (e.g. vertical) ratio. The poster on the video paints the correct-shaped frame
   immediately, even before the (possibly slow) metadata loads. */
.modal-content {
    border: 1px solid var(--border-color);
    background-color: #000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 0;
}

.modal-content video {
    display: block;
    max-width: 90vw;
    max-height: 75vh;
    width: auto;
    height: auto;
    object-fit: contain;
    background-color: #000;
}

.modal-info {
    width: 100%;
    max-width: 1000px;
    padding: 14px 4px 0 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-name);
    letter-spacing: 0.05em;
}

.modal-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 30px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-name);
}

/* Load More Button for long lists */
.btn-load-more {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    padding: 8px;
    font-family: var(--font-family);
    font-size: 9px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
}

.btn-load-more:hover {
    border-style: solid;
    border-color: var(--text-name);
    color: var(--text-name);
}
