/* =============================================
   assets/css/style.css
   Modern Arabic News App - Premium UI v3
   ============================================= */

/* --- 1. Google Font: Cairo (Arabic optimized, font-display:swap) --- */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap&font-display=swap');

/* --- 2. Design Tokens --- */
:root {
    --font-arabic: 'Cairo', system-ui, sans-serif;

    /* Colors */
    --clr-bg: #f5f7fa;
    --clr-surface: #ffffff;
    --clr-text: #0f172a;
    --clr-muted: #64748b;
    --clr-border: rgba(226, 232, 240, 0.8);
    --clr-primary: #2563eb;
    --clr-primary-hover: #1d4ed8;
    --clr-accent: #f43f5e;
    --clr-overlay-gradient: linear-gradient(to top, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.3) 60%, transparent 100%);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);

    /* Border Radius */
    --radius-sm: 0.75rem;
    --radius-md: 1.25rem;
    --radius-lg: 1.75rem;
    --radius-xl: 2rem;

    /* Timing */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --dur-fast: 0.15s;
    --dur-med: 0.3s;
    --dur-slow: 0.5s;

    /* Bottom Nav Height */
    --bottom-nav-h: 68px;
}

/* --- 3. Base Reset & RTL --- */
html {
    scroll-behavior: smooth;
    direction: rtl;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-arabic);
    background-color: var(--clr-bg);
    color: var(--clr-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    /* bottom nav space on mobile */
    padding-bottom: var(--bottom-nav-h);
}

@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }
}

h1,
h2,
h3,
h4,
h5,
h6,
.font-heading {
    font-family: var(--font-arabic);
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* --- 4. Page Transition (View Transitions API) --- */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.3s;
    animation-timing-function: var(--ease-out-expo);
}

::view-transition-old(root) {
    animation-name: slide-out;
}

::view-transition-new(root) {
    animation-name: slide-in;
}

@keyframes slide-out {
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.99);
    }
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.99);
    }
}

/* --- 5. Animations --- */
.fade-in {
    animation: fadeIn var(--dur-med) var(--ease-out-expo) both;
}

.fade-up {
    animation: fadeUp var(--dur-med) var(--ease-out-expo) both;
}

.fade-up-delay-1 {
    animation-delay: 0.08s;
}

.fade-up-delay-2 {
    animation-delay: 0.16s;
}

.fade-up-delay-3 {
    animation-delay: 0.24s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(16px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.94);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse for live badges */
@keyframes livePulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Shimmer for skeleton */
@keyframes shimmer {
    0% {
        background-position: -400px 0;
    }

    100% {
        background-position: 400px 0;
    }
}

/* Floating animation for hero badge */
@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* --- 6. Scroll-triggered Reveal (used with IntersectionObserver) --- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.55s var(--ease-out-expo), transform 0.55s var(--ease-out-expo);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal.delay-1 {
    transition-delay: 0.05s;
}

.reveal.delay-2 {
    transition-delay: 0.1s;
}

.reveal.delay-3 {
    transition-delay: 0.15s;
}

.reveal.delay-4 {
    transition-delay: 0.2s;
}

.reveal.delay-5 {
    transition-delay: 0.25s;
}

/* --- 7. Tap/Click Micro-interaction --- */
.scale-tap {
    transition: transform var(--dur-fast) var(--ease-bounce), box-shadow var(--dur-fast);
    cursor: pointer;
}

.scale-tap:active {
    transform: scale(0.96);
}

/* --- 8. Cards --- */
.news-card {
    background: var(--clr-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--clr-border);
    overflow: hidden;
    transition: transform var(--dur-med) var(--ease-out-expo),
        box-shadow var(--dur-med) var(--ease-out-expo);
    will-change: transform;
}

.news-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.news-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

.news-card img {
    transition: transform var(--dur-slow) var(--ease-out-expo);
}

.news-card:hover img {
    transform: scale(1.05);
}

/* --- 9. Category Badge --- */
.cat-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--clr-primary);
    color: white;
    line-height: 1;
}

/* --- 10. Skeleton Loading --- */
.skeleton {
    background: linear-gradient(90deg, #e8ecf0 25%, #f3f5f8 50%, #e8ecf0 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* --- 11. Horizontal Scroll (Trending) --- */
.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.875rem;
    padding-bottom: 4px;
    /* allow shadow to show */
}

.horizontal-scroll::-webkit-scrollbar {
    display: none;
}

.horizontal-scroll-item {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* --- 12. Custom Scrollbar (Desktop) --- */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 5px;
        height: 5px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 10px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
}

/* --- 13. Line Clamp Utilities --- */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 1;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 3;
}

/* --- 14. Bottom Navigation (Mobile App Feel) --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid rgba(226, 232, 240, 0.7);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.06);
    z-index: 50;
    /* safe area for iPhone notch */
    padding-bottom: env(safe-area-inset-bottom);
    /* Slide up animation on page load */
    animation: slideUp 0.4s var(--ease-out-expo) both;
    animation-delay: 0.2s;
    transform: translateY(100%);
}

@keyframes slideUp {
    to {
        transform: translateY(0);
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: 16px;
    transition: all 0.2s var(--ease-out-expo);
    position: relative;
    cursor: pointer;
}

.bottom-nav-item.active .nav-icon {
    color: var(--clr-primary);
    transform: scale(1.1);
}

.bottom-nav-item.active .nav-label {
    color: var(--clr-primary);
    font-weight: 800;
}

.bottom-nav-item:active {
    transform: scale(0.88);
    background: rgba(37, 99, 235, 0.06);
}

.nav-icon {
    width: 26px;
    height: 26px;
    color: #94a3b8;
    transition: color 0.2s, transform 0.2s var(--ease-bounce);
}

.nav-label {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    transition: color 0.2s;
    line-height: 1;
}

/* Active nav indicator dot */
.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--clr-primary);
    animation: scaleIn 0.25s var(--ease-bounce) both;
}

/* --- 15. Header --- */
.site-header {
    background: rgba(255, 255, 255, 0.90);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    transition: transform var(--dur-med) var(--ease-out-expo),
        background var(--dur-fast),
        box-shadow var(--dur-fast);
}

.site-header.scrolled {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
}

.site-header.hidden-header {
    transform: translateY(-100%);
}

/* --- 16. Live Badge --- */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--clr-accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(244, 63, 94, 0.4);
    animation: float 3s ease-in-out infinite;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    animation: livePulse 1.4s ease-in-out infinite;
}

/* --- 17. Section Headers --- */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--clr-text);
    letter-spacing: -0.02em;
    line-height: 1;
}

.section-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(to left, transparent, var(--clr-border));
    border-radius: 1px;
}

.section-accent {
    width: 4px;
    height: 20px;
    background: var(--clr-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

/* --- 18. Post Content (Article Reading) --- */
.post-content {
    font-size: 1.1rem;
    line-height: 2;
    color: #1e293b;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: #0f172a;
    position: relative;
    padding-right: 1rem;
}

.post-content h2::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--clr-primary);
    border-radius: 2px;
}

.post-content h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: #0f172a;
}

.post-content img {
    border-radius: var(--radius-md);
    margin: 1.75rem 0;
    width: 100%;
    height: auto;
    box-shadow: var(--shadow-md);
}

.post-content a {
    color: var(--clr-primary);
    text-decoration: underline;
    text-underline-offset: 4px;
    font-weight: 600;
}

.post-content ul {
    list-style-type: disc;
    padding-right: 1.5rem;
    margin-bottom: 1.5rem;
    color: #334155;
    row-gap: 0.5rem;
}

.post-content ul li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.post-content blockquote {
    border-right: 4px solid var(--clr-primary);
    background: linear-gradient(to left, rgba(37, 99, 235, 0.05), transparent);
    padding: 1.25rem 1.5rem 1.25rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: #334155;
    font-size: 1.05rem;
}

/* --- 19. Search Input --- */
.search-input {
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: 999px;
    font-family: var(--font-arabic);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--clr-primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* --- 20. Trending Number Badge --- */
.trending-num {
    font-size: 2.5rem;
    font-weight: 900;
    color: rgba(37, 99, 235, 0.08);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
}

/* --- 21. Pull-to-refresh visual hint (CSS only) --- */
.ptr-hint {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top 0.3s;
    z-index: 100;
}

/* --- 22. Glassmorphism Overlay --- */
.glass {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.glass-dark {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- 23. Image Ratio Containers --- */
.aspect-news-hero {
    aspect-ratio: 16/9;
}

.aspect-news-card {
    aspect-ratio: 4/3;
}

.aspect-news-wide {
    aspect-ratio: 21/9;
}

.aspect-thumbnail {
    aspect-ratio: 1/1;
}

/* --- 24. Progress Bar (Reading indicator) --- */
#reading-progress {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(to left, var(--clr-primary), #60a5fa);
    transform-origin: right;
    transform: scaleX(0);
    z-index: 9999;
    transition: transform 0.1s linear;
    border-radius: 0 0 2px 2px;
}

/* --- 25. Toast Notification --- */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.6rem 1.25rem;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.3s var(--ease-out-expo);
    white-space: nowrap;
    z-index: 200;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 768px) {
    .toast {
        bottom: 24px;
    }
}

/* --- 26. Ripple Effect --- */
.ripple-container {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: rippleAnim 0.5s linear;
    pointer-events: none;
}

@keyframes rippleAnim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* --- 27. Tag Cloud Styles --- */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.3rem 0.8rem;
    background: white;
    border: 1.5px solid var(--clr-border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--clr-muted);
    transition: all var(--dur-fast) var(--ease-out-expo);
    cursor: pointer;
}

.tag-chip:hover {
    background: var(--clr-primary);
    color: white;
    border-color: var(--clr-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* --- 28. Sidebar Widgets --- */
.widget {
    background: var(--clr-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--clr-border);
    overflow: hidden;
}

.widget-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--clr-border);
    font-weight: 900;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- 29. Post Meta Row --- */
.post-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--clr-muted);
    font-weight: 600;
    flex-wrap: wrap;
}

.post-meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

/* --- 30. Mobile Performance Touch targets --- */
@media (max-width: 767px) {

    /* Ensure minimum touch target sizes */
    a,
    button,
    [role="button"] {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Disable hover states on mobile (performance) */
    .news-card:hover {
        transform: none;
        box-shadow: var(--shadow-card);
    }

    .news-card:hover img {
        transform: none;
    }
}