/* ============================================
   Kijeba Media - Custom Stylesheet
   ============================================ */

/* === Base & Reset === */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Selection Color === */
::selection {
    background-color: rgba(220, 38, 38, 0.2);
    color: #991b1b;
}

.dark ::selection {
    background-color: rgba(220, 38, 38, 0.3);
    color: #fecaca;
}

/* === Custom Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Firefox */
html {
    scrollbar-width: thin;
    scrollbar-color: #9ca3af transparent;
}

.dark {
    scrollbar-color: #4b5563 transparent;
}

/* === Focus Visible Ring === */
*:focus-visible {
    outline: 2px solid #DC2626;
    outline-offset: 2px;
    border-radius: 4px;
}

/* === Breaking News Ticker === */
@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.animate-ticker-scroll {
    animation: ticker-scroll 30s linear infinite;
}

.breaking-ticker:hover .animate-ticker-scroll {
    animation-play-state: paused;
}

.ticker-wrap {
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

/* === Digital Archivist: Glass & Gradient rule === */
.glass {
    background: rgba(249, 249, 252, 0.8) !important; /* surface color at 80% */
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

.dark .glass {
    background: rgba(27, 27, 31, 0.8) !important; /* dark surface color at 80% */
}

/* === Ambient card lift — no harsh shadows === */
.card-ambient {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-ambient:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px -4px rgba(0, 17, 58, 0.08);
}

.dark .card-ambient:hover {
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.4);
}

/* === Article / Prose Typography === */
.article-content {
    font-size: 1.0625rem;
    line-height: 1.8;
    color: #1f2937;
}

.dark .article-content {
    color: #d1d5db;
}

.article-content p {
    margin-bottom: 1.5rem;
}

.article-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: #111827;
    line-height: 1.3;
}

.dark .article-content h2 {
    color: #f3f4f6;
}

.article-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: #1f2937;
    line-height: 1.4;
}

.dark .article-content h3 {
    color: #e5e7eb;
}

.article-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.article-content ul {
    list-style-type: disc;
}

.article-content ol {
    list-style-type: decimal;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.article-content blockquote {
    border-left: 4px solid #00113a; /* using primary */
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    background-color: #f3f3f6; /* surface_container_low */
    font-style: italic;
    color: #00113a;
    border-radius: 0 0.75rem 0.75rem 0;
    font-family: 'Inter', system-ui, sans-serif;
}

.dark .article-content blockquote {
    background-color: #1a1f2e;
    color: #e0e4ec;
    border-left-color: #4a6fa5;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 1rem;
    margin: 2rem 0;
}

.article-content a {
    color: #00113a;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: #00113a40;
    transition: text-decoration-color 0.2s;
}

.article-content a:hover {
    text-decoration-color: #00113a;
}

.article-content pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.875rem;
}

.article-content code {
    background: #f3f4f6;
    color: #DC2626;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.dark .article-content code {
    background: #1f2937;
    color: #fca5a5;
}

.article-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.article-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, #00113a10, transparent);
    margin: 3rem 0;
}

.dark .article-content hr {
    background: linear-gradient(to right, transparent, #ffffff10, transparent);
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
}

.article-content th,
.article-content td {
    padding: 0.875rem 1.25rem;
    border: none; /* No-line rule */
    text-align: left;
}

.article-content tr:nth-child(even) {
    background-color: #f3f3f6; /* surface_container_low */
}

.dark .article-content tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

.article-content th {
    background: #e2e2e5; /* surface_container_highest */
    font-weight: 700;
    font-family: 'Inter', system-ui, sans-serif;
    color: #00113a;
}

.dark .article-content th {
    background: #2a2a2e;
    color: #f0f2f8;
}

/* === WhatsApp Float Pulse === */
@keyframes whatsapp-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

.whatsapp-float {
    animation: whatsapp-pulse 2s infinite;
}

.whatsapp-float:hover {
    animation: none;
    transform: scale(1.1);
}

/* === Mobile Menu Slide Animation === */
.mobile-menu-drawer {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-drawer.open {
    transform: translateX(0) !important;
}

.mobile-menu-backdrop {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-backdrop.open {
    opacity: 1;
}

/* === Skeleton Loading Placeholders === */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

.dark .skeleton {
    background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 200% 100%;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    margin-bottom: 0.75rem;
    width: 80%;
}

.skeleton-image {
    height: 200px;
    margin-bottom: 1rem;
}

/* === Image Lazy Load Fade In === */
img[data-src] {
    opacity: 0;
    transition: opacity 0.4s ease;
}

img.loaded {
    opacity: 1;
}

/* === Gradient Overlays for Hero Images === */
.gradient-overlay {
    position: relative;
    overflow: hidden;
}

.gradient-overlay::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    pointer-events: none;
}

.gradient-overlay-full::after {
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.3) 50%, transparent 100%);
}

/* === Line Clamp Utilities === */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    overflow: hidden;
}

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

.line-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

/* === Responsive Image Containers === */
.img-container {
    position: relative;
    overflow: hidden;
    border-radius: 0.75rem;
}

.img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.img-container-16-9 {
    aspect-ratio: 16 / 9;
}

.img-container-4-3 {
    aspect-ratio: 4 / 3;
}

.img-container-1-1 {
    aspect-ratio: 1 / 1;
}

/* === Form Input Focus Styles === */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
textarea,
select {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    border-color: rgba(0, 17, 58, 0.4); /* primary with 40% opacity */
    box-shadow: 0 0 0 4px rgba(0, 17, 58, 0.05);
    outline: none;
}

/* === Button: Secondary Glow on Hover === */
.btn-editorial {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-editorial:hover {
    box-shadow: 0 0 20px -2px rgba(188, 0, 10, 0.15); /* subtle 10-15% secondary glow */
    transform: translateY(-1px);
}

/* === Status Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-draft {
    background-color: #fef3c7;
    color: #92400e;
}

.dark .badge-draft {
    background-color: rgba(254, 243, 199, 0.15);
    color: #fbbf24;
}

.badge-published {
    background-color: #d1fae5;
    color: #065f46;
}

.dark .badge-published {
    background-color: rgba(209, 250, 229, 0.15);
    color: #34d399;
}

.badge-archived {
    background-color: #f3f4f6;
    color: #6b7280;
}

.dark .badge-archived {
    background-color: rgba(243, 244, 246, 0.1);
    color: #9ca3af;
}

/* === Category Color Badges === */
.cat-siasa       { background-color: #dbeafe; color: #1e40af; }
.cat-uchumi      { background-color: #d1fae5; color: #065f46; }
.cat-michezo     { background-color: #fef3c7; color: #92400e; }
.cat-afya        { background-color: #fce7f3; color: #9d174d; }
.cat-utalii      { background-color: #e0e7ff; color: #3730a3; }
.cat-diplomasia  { background-color: #ede9fe; color: #5b21b6; }
.cat-kimataifa   { background-color: #ccfbf1; color: #115e59; }
.cat-teknolojia  { background-color: #fef9c3; color: #854d0e; }
.cat-burudani    { background-color: #ffe4e6; color: #9f1239; }
.cat-elimu       { background-color: #f0fdf4; color: #166534; }

.dark .cat-siasa       { background-color: rgba(219, 234, 254, 0.15); color: #93c5fd; }
.dark .cat-uchumi      { background-color: rgba(209, 250, 229, 0.15); color: #6ee7b7; }
.dark .cat-michezo     { background-color: rgba(254, 243, 199, 0.15); color: #fcd34d; }
.dark .cat-afya        { background-color: rgba(252, 231, 243, 0.15); color: #f9a8d4; }
.dark .cat-utalii      { background-color: rgba(224, 231, 255, 0.15); color: #a5b4fc; }
.dark .cat-diplomasia  { background-color: rgba(237, 233, 254, 0.15); color: #c4b5fd; }
.dark .cat-kimataifa   { background-color: rgba(204, 251, 241, 0.15); color: #5eead4; }
.dark .cat-teknolojia  { background-color: rgba(254, 249, 195, 0.15); color: #fde047; }
.dark .cat-burudani    { background-color: rgba(255, 228, 230, 0.15); color: #fda4af; }
.dark .cat-elimu       { background-color: rgba(240, 253, 244, 0.15); color: #86efac; }

/* === Reading Progress Bar === */
#reading-progress {
    transition: width 0.15s ease-out;
}

/* === Back to Top Button === */
#back-to-top {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

#back-to-top.visible {
    display: flex !important;
    opacity: 1;
    transform: translateY(0);
}

/* === Placeholder Image (broken image fallback) === */
.img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #DC2626 0%, #7f1d1d 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

/* === Share Button Tooltip === */
.share-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.5rem;
    background: #1f2937;
    color: #fff;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.share-tooltip.show {
    opacity: 1;
}

/* === Like Button Heart Animation === */
@keyframes heart-beat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.2); }
    50% { transform: scale(0.95); }
    75% { transform: scale(1.1); }
}

.heart-animate {
    animation: heart-beat 0.4s ease;
}

/* === Like Loading State === */
.like-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* === Toast Notification (Global) === */
@keyframes toast-slide-up {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

.toast-msg {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    background: #00113a;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Inter', system-ui, sans-serif;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.25);
}

.toast-msg.show {
    opacity: 1;
    animation: toast-slide-up 0.3s ease;
}

.dark .toast-msg {
    background: #f9f9fc;
    color: #00113a;
}

/* === New Comment Entrance Animation === */
@keyframes comment-slide-in {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comment-new {
    animation: comment-slide-in 0.4s ease;
}

/* === Button Loading Spinner === */
@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

.btn-loading::after {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
    vertical-align: middle;
}

/* === Share Button Hover Effects === */
.share-btn {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.2);
}

.share-btn:active {
    transform: translateY(0);
}

/* === Telegram Brand Color === */
.bg-telegram { background-color: #0088cc; }
.bg-telegram:hover { background-color: #0077b5; }

/* === Responsive Utilities === */
@media (max-width: 640px) {
    .article-content {
        font-size: 1rem;
        line-height: 1.75;
    }

    .article-content h2 {
        font-size: 1.25rem;
    }

    .article-content h3 {
        font-size: 1.125rem;
    }

    .article-content blockquote {
        padding: 0.75rem 1rem;
    }
}

/* === Print Styles === */
@media print {
    header, footer, .whatsapp-float, #back-to-top, .breaking-ticker, #reading-progress {
        display: none !important;
    }

    body {
        color: #000;
        background: #fff;
    }

    .article-content a {
        color: #000;
        text-decoration: underline;
    }

    .article-content a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}
