/* ==========================================================================
   SHOHRAH — Drag canvas (shared)

   The portfolio tile field: a window onto a canvas that is larger than it in
   both axes and pans under the pointer. Used full-bleed on the portfolio index
   (/projects/projects.html) and as a compact strip on the home page.

   Mechanics only — no page chrome. `assets/js/showcase.js` drives every
   `[data-sc-viewport]` on the page. Below 992px, and under
   prefers-reduced-motion, the canvas collapses to a plain vertical grid.

   Any host that is NOT `.sc-page` must carry `.sc-scope` so the `--sc-*`
   tokens below resolve.
   ========================================================================== */

.sc-scope {
    --sc-accent: var(--accent--color);
    --sc-ink: var(--black--color);
    --sc-muted: var(--text--color2);
    --sc-line: var(--border--color);
}

/* ==========================================================================
   1. STAGE + VIEWPORT  (desktop)
   ========================================================================== */

.sc-stage {
    position: relative;
    padding-bottom: clamp(30px, 6vh, 70px);
}

/* Soft edge fade so tiles dissolve at the viewport edges. `--sc-fade` lets a
   host on a tinted band match its own background. */
.sc-stage::before,
.sc-stage::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6vw;
    z-index: 3;
    pointer-events: none;
}

.sc-stage::before {
    right: 0;
    background: linear-gradient(to left, var(--sc-fade, #fff), rgba(255, 255, 255, 0));
}

.sc-stage::after {
    left: 0;
    background: linear-gradient(to right, var(--sc-fade, #fff), rgba(255, 255, 255, 0));
}

/* A fixed-height window onto a canvas that is larger than it in both axes.
   Panning uses a transform (see showcase.js) rather than native scrolling —
   that keeps the maths identical in RTL and LTR. */
.sc-viewport {
    overflow: hidden;
    height: min(80vh, 780px);
    /* The site header is `float-left w-100`; without clearing it this
       block formatting context would shrink to fit beside that float. */
    clear: both;
    /* Stops the browser starting a text selection or native image drag,
       either of which would cancel the pointer stream mid-drag. */
    user-select: none;
    -webkit-user-select: none;
}

.sc-canvas {
    display: flex;
    width: max-content;
    gap: clamp(16px, 2vw, 34px);
    padding: 0 clamp(18px, 4vw, 70px);
    align-items: flex-start;
    will-change: transform;
}

.sc-col {
    display: flex;
    flex-direction: column;
    gap: clamp(18px, 2.2vw, 36px);
    flex: 0 0 auto;
}

/* ==========================================================================
   2. TILES
   ========================================================================== */

.sc-tile {
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-drag: none;
}

.sc-tile figure {
    margin: 0;
    overflow: hidden;
    border-radius: 12px;
    background: var(--bg--color);
    border: 1px solid var(--sc-line);
    transition: border-color .45s ease, box-shadow .45s ease;
}

.sc-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    -webkit-user-drag: none;
    user-select: none;
    transition: transform .8s cubic-bezier(.2, .7, .3, 1);
}

.sc-cap {
    display: block;
    padding-top: 10px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .35s ease, transform .35s ease;
}

.sc-cap .t {
    display: block;
    font-family: 'Thmanyah Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(.86rem, 1.1vw, .98rem);
    color: var(--sc-ink);
    line-height: 1.4;
}

.sc-cap .s {
    display: block;
    margin-top: 3px;
    font-size: .75rem;
    color: var(--sc-muted);
    line-height: 1.5;
}

/* Hover: spotlight the target, dim the rest — the signature move. */
@media (hover: hover) and (min-width: 992px) {
    .sc-tile { transition: opacity .45s ease; }

    .sc-canvas:hover .sc-tile { opacity: .35; }

    .sc-canvas:hover .sc-tile:hover { opacity: 1; }

    .sc-tile:hover figure {
        border-color: var(--sc-accent);
        box-shadow: 0 16px 42px rgba(21, 77, 90, .20), 0 0 0 3px rgba(243, 114, 49, .16);
    }

    .sc-tile:hover img { transform: scale(1.05); }

    .sc-tile:hover .sc-cap {
        opacity: 1;
        transform: none;
    }
}

/* Touch / no-hover: captions are always readable. */
@media (hover: none), (max-width: 991px) {
    .sc-cap {
        opacity: 1;
        transform: none;
    }
}

/* Keyboard parity with the hover state. */
.sc-tile:focus-visible {
    outline: none;
    opacity: 1;
}

.sc-tile:focus-visible figure {
    border-color: var(--sc-accent);
    box-shadow: 0 0 0 3px rgba(243, 114, 49, .45);
}

.sc-tile:focus-visible .sc-cap {
    opacity: 1;
    transform: none;
}

/* Compact tiles so many read at once — a dense field — while the canvas
   still runs well past the window in both axes. */
.sc-tile figure { width: clamp(168px, 17vw, 248px); }

.sc-tile:nth-child(4n+1) figure { aspect-ratio: 4 / 5; }
.sc-tile:nth-child(4n+2) figure { aspect-ratio: 1 / 1; }
.sc-tile:nth-child(4n+3) figure { aspect-ratio: 5 / 6; }
.sc-tile:nth-child(4n+4) figure { aspect-ratio: 3 / 4; }

/* Stagger each column vertically so rows never line up. */
.sc-col:nth-child(6n+1) { padding-top: 0; }
.sc-col:nth-child(6n+2) { padding-top: clamp(38px, 6vw, 96px); }
.sc-col:nth-child(6n+3) { padding-top: clamp(12px, 2vw, 32px); }
.sc-col:nth-child(6n+4) { padding-top: clamp(52px, 8vw, 128px); }
.sc-col:nth-child(6n+5) { padding-top: clamp(22px, 3.5vw, 60px); }
.sc-col:nth-child(6n+6) { padding-top: clamp(44px, 7vw, 110px); }

@media (hover: hover) and (min-width: 992px) {
    .sc-viewport { cursor: grab; }
}

body.is-dragging,
body.is-dragging * { cursor: grabbing !important; }

body.is-dragging .sc-tile { pointer-events: none; }

/* ==========================================================================
   3. MOBILE GRID — the drag canvas collapses to a plain vertical masonry
   ========================================================================== */

@media (max-width: 991px) {
    .sc-stage::before,
    .sc-stage::after { display: none; }

    .sc-viewport {
        overflow: visible;
        height: auto;
        cursor: auto;
        user-select: auto;
        -webkit-user-select: auto;
    }

    .sc-canvas {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px 14px;
        padding: 10px 18px 20px;
        width: auto !important;
        transform: none !important;
    }

    .sc-col {
        display: contents;
        padding-top: 0 !important;
    }

    .sc-tile figure { width: 100%; }

    /* Inside the grid the tiles are the direct children, so re-derive the
       aspect rhythm from each tile's own position. */
    .sc-tile:nth-child(4n+1) figure,
    .sc-tile:nth-child(4n+2) figure,
    .sc-tile:nth-child(4n+3) figure,
    .sc-tile:nth-child(4n+4) figure { aspect-ratio: 1 / 1; }

    .sc-tile:nth-child(5n+1) figure,
    .sc-tile:nth-child(5n+4) figure { aspect-ratio: 4 / 5; }

    /* Cloned tiles exist only to make the desktop drag endless. */
    .sc-clone { display: none !important; }
}

/* Only the narrowest phones drop to one column — at 390px and up, two columns
   keep the whole set scannable without endless scrolling. */
@media (max-width: 359px) {
    .sc-canvas {
        grid-template-columns: minmax(0, 1fr);
        gap: 26px;
    }

    .sc-tile:nth-child(n) figure { aspect-ratio: 5 / 4; }
}

/* ==========================================================================
   4. HOME-PAGE STRIP — the same canvas, shorter, sitting inside a section
   ========================================================================== */

.sc-strip {
    --sc-fade: #fff;
    position: relative;
}

.sc-strip .sc-viewport { height: min(58vh, 520px); }

/* The strip is short enough that its bottom edge cuts straight through a row
   of tiles. Dissolve that edge so the field reads as continuous rather than
   cropped — desktop only, since the mobile fallback has nothing to clip. */
@media (min-width: 992px) {
    .sc-strip .sc-viewport {
        -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 96px), transparent 100%);
        mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 96px), transparent 100%);
    }
}

/* The strip lives inside `.main-container`, so the canvas needs no extra
   inset — bleeding it edge-to-edge is what makes it read as a canvas rather
   than a carousel. */
.sc-strip .sc-canvas { padding: 0 clamp(10px, 2vw, 30px); }

.sc-strip .sc-tile figure { width: clamp(150px, 14vw, 210px); }

/* Drag affordance — desktop only, since touch users simply swipe. */
.sc-strip-hint {
    display: none;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin: 0 0 18px;
    color: var(--sc-muted);
    font-size: .82rem;
    letter-spacing: .06em;
}

.sc-strip-hint i { color: var(--sc-accent); }

@media (hover: hover) and (min-width: 992px) {
    .sc-strip-hint { display: flex; }
}

.sc-strip-more {
    text-align: center;
    margin-top: clamp(18px, 3vh, 34px);
}

@media (max-width: 991px) {
    .sc-strip .sc-viewport { height: auto; }
    .sc-strip .sc-canvas { padding-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sc-clone { display: none !important; }

    .sc-tile img,
    .sc-tile figure,
    .sc-cap { transition: none !important; }
}
