/* Reddgifs Shorts — portrait 9:16 grid (/shorts/) + reusable home rail.
   Loaded on the /shorts/ index and the homepage (rail only). Scoped entirely
   under .rg-shorts-* so it can't leak into the landscape grids. */

:root {
    --rg-shorts-accent: #ff2e4d;
    --rg-shorts-card-bg: #101012;
    --rg-shorts-radius: 10px;
    --rg-shorts-gap: 10px;
}

/* ---------- Portrait card (shared: grid + rail) ---------- */

.rg-shorts-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    min-width: 0;               /* let titles ellipsize instead of stretching the track */
}
.rg-shorts-card__thumb {
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: var(--rg-shorts-radius);
    overflow: hidden;
    background: var(--rg-shorts-card-bg);
}
.rg-shorts-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;          /* portrait posters fill the 9:16 box cleanly */
    display: block;
    transition: transform .25s ease;
}
.rg-shorts-card:hover .rg-shorts-card__img { transform: scale(1.04); }
.rg-shorts-card__img--empty {
    background: linear-gradient(135deg, #1a1a1e, #232327);
}

/* Center play affordance — subtle at rest, brighter on hover */
.rg-shorts-card__play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    background: rgba(0, 0, 0, .38);
    border-radius: 50%;
    opacity: .82;
    transition: opacity .2s ease, background .2s ease;
    pointer-events: none;
}
.rg-shorts-card:hover .rg-shorts-card__play {
    opacity: 1;
    background: var(--rg-shorts-accent);
}
.rg-shorts-card__play svg { margin-left: 2px; }   /* optical centering of the triangle */

.rg-shorts-card__dur {
    position: absolute;
    right: 6px; bottom: 6px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    background: rgba(0, 0, 0, .72);
    border-radius: 4px;
}
.rg-shorts-card__title {
    margin: 7px 2px 0;
    font-size: 12.5px;
    line-height: 1.3;
    color: #e8e8ea;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rg-shorts-card__meta {
    margin: 3px 2px 0;
    font-size: 11px;
    color: #8b8b90;
}
.rg-shorts-card__meta .icon-eye { font-size: 11px; opacity: .8; }

/* ---------- /shorts/ grid ---------- */

.rg-shorts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px var(--rg-shorts-gap);
    padding: 4px 8px 8px;
}
@media (min-width: 480px)  { .rg-shorts-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 768px)  { .rg-shorts-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1024px) { .rg-shorts-grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 1280px) { .rg-shorts-grid { grid-template-columns: repeat(7, 1fr); } }
@media (min-width: 1600px) { .rg-shorts-grid { grid-template-columns: repeat(8, 1fr); } }

.rg-shorts-head-icon { color: var(--rg-shorts-accent); vertical-align: -3px; margin-right: 4px; }

/* ---------- Home rail ---------- */

.rg-shorts-rail {
    margin: 10px 0 6px;
    padding: 0 8px;
}
.rg-shorts-rail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 2px 8px;
}
.rg-shorts-rail__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #f2f2f4;
    text-transform: none;
}
.rg-shorts-rail__title-icon { color: var(--rg-shorts-accent); display: inline-flex; }
.rg-shorts-rail__seeall {
    font-size: 13px;
    font-weight: 600;
    color: var(--rg-shorts-accent);
    text-decoration: none;
    white-space: nowrap;
}
.rg-shorts-rail__seeall:hover { text-decoration: underline; }

/* The single line: horizontal scroller with snap. Same element is one desktop
   row and a swipeable mobile strip — only the card width changes per breakpoint. */
.rg-shorts-rail__track {
    display: flex;
    gap: var(--rg-shorts-gap);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    /* Own horizontal gestures so the rail keeps scrolling on touch instead of
       handing the gesture back to the page after the first swipe. Without pan-x,
       the theme's global touch handling / vertical scroll intercepts subsequent
       drags and the rail "freezes" mid-strip. */
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    padding: 2px 2px 10px;
    scrollbar-width: thin;
    scrollbar-color: #3a3a40 transparent;
}
.rg-shorts-rail__track::-webkit-scrollbar { height: 7px; }
.rg-shorts-rail__track::-webkit-scrollbar-thumb { background: #3a3a40; border-radius: 4px; }
.rg-shorts-rail__track::-webkit-scrollbar-track { background: transparent; }

.rg-shorts-rail__track .rg-shorts-card {
    flex: 0 0 auto;
    width: 150px;
    scroll-snap-align: start;
}
/* Mobile: cards sized so ~2.5 peek, signaling "swipe for more". */
@media (max-width: 600px) {
    .rg-shorts-rail__track .rg-shorts-card { width: 40vw; max-width: 168px; }
}
@media (min-width: 1280px) {
    .rg-shorts-rail__track .rg-shorts-card { width: 165px; }
}
