/*
Theme Name: RepublikBaja
Author: Your Name
Description: TikTok-style vertical scroll theme.
*/

/* Import TikTok Sans */
/* Import TikTok Sans */
@media (max-width: 600px) {
    .tiktok-section {
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }
}

@font-face {
    font-family: 'TikTok Sans';
    src: url('fonts/TikTokSans-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'TikTok Sans';
    src: url('fonts/TikTokSans-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'TikTok Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.tiktok-container {
    height: 100vh;
    height: 100dvh;
    /* Dynamic Viewport Height for mobile */
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    background-color: #000;
}

.tiktok-container::-webkit-scrollbar {
    display: none;
}

/* Redundant removal - previous file had duplicate block */

.tiktok-section {
    height: 100vh;
    height: 100dvh;
    /* Dynamic Viewport Height for mobile */
    max-width: 600px;
    margin: 0 auto;

    /* Rounded edges for the phone look (desktop) */
    border-radius: 20px;
    overflow: hidden;

    border: 0px solid #111;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);

    scroll-snap-align: start;
    scroll-snap-stop: always;
    /* Force stop at each item */
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: white;
}

.content-overlay {
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.4) 30%, rgba(0, 0, 0, 0.95) 100%);
    padding: 80px 20px 140px;
    /* Increased bottom padding to move card up */
    width: 100%;
    box-sizing: border-box;
    z-index: 10;
}

.content-overlay p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
    max-width: 85%;
    /* Limits width so it doesn't hit the right edge */
    white-space: normal;
    /* Ensures text wraps to the next line */
    word-wrap: break-word;
    /* Breaks long strings of text if necessary */
    overflow-wrap: break-word;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.content-overlay h2 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

#stories-tray {
    position: fixed;
    top: 0px;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 600px;

    /* The Background Shadow Layer */
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0.8) 0%,
            rgba(0, 0, 0, 0.4) 60%,
            transparent 100%);

    padding: 10px 0 20px;
    /* Increased top padding for better spacing */
    z-index: 9999;
    transform: translateY(-110%);
    opacity: 0;
    transition: transform 0.2s ease-in-out, opacity 0.2s ease;

    /* Ensures the shadow follows the rounded phone corners */
    border-radius: 20px px 0 0;
}

/* Hidden state: Pushed up and transparent */
.stories-hidden {
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
    /* Crucial so users can still scroll while tray is "gone" */
}

/* Visible state */
.stories-visible {
    transform: translateY(0) !important;
    opacity: 1 !important;
}

.stories-scroll {
    display: flex;
    overflow-x: auto;
    padding: 0 15px;
    gap: 15px;
    scrollbar-width: none;
}

/* Header Banner */
#header-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
    z-index: 9999;
    padding: 15px 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;

    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), transparent 100%);

    transform: translateY(-110%);
    opacity: 0;
    transition: transform 0.2s ease-in-out, opacity 0.2s ease;
    border-radius: 20px 20px 0 0;
    pointer-events: none;
}

#header-banner img {
    height: 48px;
    max-width: 100%;
    object-fit: contain;
}

.header-banner-visible {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.header-banner-hidden {
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
}

/* Scroll Indicator */
#scroll-indicator {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    z-index: 999;
    opacity: 0.8;
    animation: bounce 2s infinite;
    pointer-events: none;
    transition: opacity 0.3s ease;
    filter: drop-shadow(0px 2px 3px rgba(0, 0, 0, 0.8));
    /* heavy shadow for visibility */
}

.scroll-hidden {
    opacity: 0 !important;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    40% {
        transform: translateX(-50%) translateY(-10px);
    }

    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

.stories-scroll::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.story-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #fe2c55;
    /* TikTok Red */
    padding: 2px;
    overflow: hidden;
    background: #000;
}

.story-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.story-item span {
    color: white;
    font-size: 11px;
    margin-top: 5px;
    font-family: 'TikTok Sans', sans-serif;
    text-align: center;

    /* Constraint width to match circle */
    max-width: 74px;
    width: 100%;

    /* 2-line Ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    line-height: 1.2;
}

/* Story Viewer Overlay */
#story-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    height: 100dvh;
    /* Fit mobile viewport dynamically */
    background: #000;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Initially hidden/unclickable */
    border-radius: 0;
    /* Optional: Reset radius or match phone if desired */
}

@media (min-width: 601px) {
    #story-overlay {
        border-radius: 20px;
        /* Match the phone curves on desktop */
        height: 100vh;
        /* Start: Match .tiktok-section shadow */
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    }
}

#story-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.story-header {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10001;
    /* Above tap areas */
}

.story-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.story-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#story-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Ensure whole image is visible */
}

.story-caption {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 20px;
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.4) 30%, rgba(0, 0, 0, 0.95) 100%);
    font-family: 'TikTok Sans', sans-serif;
    font-weight: bold;
    pointer-events: none;
    box-sizing: border-box;
    /* Include padding in width calculation to ensure perfect centering */
}

/* Progress Bars */
.story-progress-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 10001;
}

.story-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.5);
    /* Brighter for visibility */
    border-radius: 2px;
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    /* Hardware acceleration for mobile */
    transform: translateZ(0);
    will-change: width;
}

/* Tap Areas */
.story-tap-area {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 10000;
}

.story-tap-area.left {
    left: 0;
    width: 30%;
}

.story-tap-area.right {
    right: 0;
    width: 30%;
}

/* Rich Post Card UI */
.content-overlay {
    padding: 0 20px 20px 20px !important;
    background: transparent !important;
    /* Remove gradient */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0;
    /* Removing gap to attach body and footer */
}

/* Card Header: Logo + Name */
.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-left: 4px;
}

/* ... logo styling ... */

/* ... card body styling ... */

.card-desc p {
    margin: 0;
    font-size: 14px;
    /* Slightly larger */
    line-height: 1.4;
    color: #fff;
    /* Pure white on dark bg */
    text-shadow: none;
    /* No shadow needed on dark plate */

    word-break: break-word;
    overflow-wrap: anywhere;

    max-width: 100% !important;
}

/* Old card-logo removed */

/* Let's try a safer approach that works on the IMG tag directly without complex masking if possible, 
   or just accept that we need a wrapper. 
   
   Actually, I can't wrap the IMG tag easily without editing PHP. 
   I CAN just give it a solid border first to fix "no border" issue?
   User said "icon is complety red" -> the placeholder is red bg with red border.
   
   Let's update the placeholder first.
*/
.card-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
    /* Prevent squashing */
    object-fit: cover;
}

.card-logo-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    position: relative;
    box-sizing: border-box;
    flex-shrink: 0;
    /* Prevent squashing */
}

.card-logo-placeholder::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: #555;
    /* Dark gray inner for placeholder */
    border-radius: 50%;
    z-index: 1;
}

.card-site-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.card-site-slogan {
    font-size: 14px;
    font-weight: 700;
    color: #eee;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Card Body: Thumb + Desc */
.card-body {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    /* Align items to the top */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;

    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 15px;
    border-radius: 12px 12px 0 0;
    /* Top rounded */
}

.card-thumb-container {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-post-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-desc {
    flex: 1;
    min-width: 0;
    /* Critical for flex shrinking */
}

.card-post-title {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);

    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-desc p {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: #eee;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);

    word-break: break-word;
    overflow-wrap: anywhere;

    max-width: 100% !important;
    /* Override old rule */
}

/* Footer: CTA */
.card-footer {
    width: 100%;
    margin-top: 0;
}

.card-cta-button {
    display: flex;
    justify-content: space-between;
    /* Text left, arrow right */
    align-items: center;
    width: 100%;
    box-sizing: border-box;

    background-color: #fff;
    color: #000;
    padding: 15px 20px;
    border-radius: 0 0 12px 12px;
    /* Bottom rounded */
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    transition: background-color 0.2s;
}

.card-cta-button:active {
    background-color: #f0f0f0;
}

@media (min-width: 601px) {
    .content-overlay {
        padding-bottom: 40px !important;
    }
}