/* =========================================================
   GLOBAL STYLES & CSS VARIABLES
   (matches the portfolio root stylesheet)
========================================================= */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
    --glow-color: rgba(56, 189, 248, 0.5);
    --glow-hover: rgba(56, 189, 248, 0.8);
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent: #0284c7;
    --accent-hover: #0369a1;
    --card-bg: rgba(0, 0, 0, 0.03);
    --card-border: rgba(0, 0, 0, 0.1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --glow-color: rgba(2, 132, 199, 0.3);
    --glow-hover: rgba(2, 132, 199, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: clip;
    -webkit-tap-highlight-color: transparent;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* Screen-reader-only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================
   CUSTOM SCROLLBAR
========================================================= */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* =========================================================
   SCROLL PROGRESS
========================================================= */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--accent);
    z-index: 2000;
    transition: width 0.1s linear;
}

/* =========================================================
   SKIP LINK
========================================================= */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--bg-primary);
    padding: 0.8rem 1.5rem;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    transition: top 0.3s;
}
.skip-link:focus {
    top: 0;
}

/* =========================================================
   PRELOADER
========================================================= */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--card-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   HEADER / NAV
========================================================= */
header {
    position: sticky;
    top: 0;
    background-color: var(--bg-primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: background-color 0.3s;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

nav h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 1.2rem;
    align-items: center;
}

.nav-links a {
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: color 0.3s;
}
.theme-toggle:hover {
    color: var(--accent);
}

a:focus-visible,
button:focus-visible,
.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* =========================================================
   SECTIONS GENERAL
========================================================= */
section {
    padding: 4rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    scroll-margin-top: 80px;
}

.small-title {
    font-size: 0.9rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

section h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    position: relative;
}

section h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--accent);
    margin-top: 0.5rem;
    border-radius: 2px;
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================================
   HERO
========================================================= */
.stories-hero {
    min-height: 70vh;
    display: flex;
    align-items: center;
    padding: 3rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.stories-hero-content {
    max-width: 800px;
}

.stories-hero h1 {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1.1;
    margin: 0.5rem 0 1.5rem;
}

.stories-hero p:not(.small-title) {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 650px;
    margin-bottom: 2rem;
}

/* =========================================================
   PRIMARY BUTTON
========================================================= */
.primary-button {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.5rem;
    border: 2px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-weight: 500;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
}

.primary-button:hover {
    background: var(--accent);
    color: var(--bg-primary);
    box-shadow: 0 0 20px var(--glow-hover);
}

/* =========================================================
   CATEGORIES
========================================================= */
.categories-section {
    padding-top: 2rem;
}

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.5rem;
}

.category {
    padding: 0.6rem 1rem;
    border: 1px solid var(--card-border);
    border-radius: 30px;
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
}

.category:hover,
.category.active {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--glow-color);
}

/* =========================================================
   SECTION HEADING
========================================================= */
.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 1.5rem;
}

/* =========================================================
   FEATURED STORY
========================================================= */
.featured-story {
    position: relative;
    overflow: hidden;
    padding: 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    transition: var(--transition);
}

.featured-story:hover {
    border-color: var(--accent);
    box-shadow: 0 0 25px var(--glow-hover);
    transform: translateY(-3px);
}

.featured-number {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
}

.featured-content {
    max-width: 800px;
}

.story-category {
    display: inline-block;
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.featured-content h3 {
    font-size: 2.2rem;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.featured-content p {
    color: var(--text-secondary);
    max-width: 700px;
    margin-bottom: 1.5rem;
}

/* =========================================================
   STORY META
========================================================= */
.story-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
}

.story-meta i {
    color: var(--accent);
    margin-right: 0.3rem;
}

/* =========================================================
   READ STORY LINK
========================================================= */
.read-story {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
    font-weight: 500;
    transition: var(--transition);
}

.read-story:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* =========================================================
   STORIES GRID / CARDS
========================================================= */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.story-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 280px;
    padding: 1.75rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 15px;
    transition: var(--transition);
}

.story-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 0 25px var(--glow-hover);
}

.story-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.story-date {
    color: var(--text-secondary);
    font-size: 0.75rem;
    opacity: 0.7;
}

.story-card h3 {
    font-size: 1.3rem;
    line-height: 1.3;
    margin-bottom: 0.9rem;
}

.story-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.story-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.story-footer i {
    color: var(--accent);
}

.story-footer a {
    color: var(--accent);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: var(--transition);
}

.story-footer a:hover {
    text-decoration: underline;
}

/* =========================================================
   SHARE SECTION
========================================================= */
.share-section {
    padding-top: 3rem;
    padding-bottom: 6rem;
}

.share-box {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    transition: var(--transition);
}

.share-box:hover {
    border-color: var(--accent);
    box-shadow: 0 0 25px var(--glow-hover);
}

.share-icon {
    width: 70px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 1.5rem;
    border: 1px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    font-size: 1.7rem;
    box-shadow: 0 0 20px var(--glow-color);
}

.share-box h2 {
    margin-bottom: 1rem;
    display: inline-block;
}

.share-box h2::after {
    margin: 0.5rem auto 0;
}

.share-box > p:not(.small-title) {
    max-width: 650px;
    margin: 0 auto 1.75rem;
    color: var(--text-secondary);
}

.share-box small {
    display: block;
    margin-top: 1.2rem;
    color: var(--text-secondary);
    opacity: 0.6;
    font-size: 0.8rem;
}

/* =========================================================
   FOOTER
========================================================= */
footer {
    text-align: center;
    padding: 2rem;
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    margin-top: 2rem;
}

/* =========================================================
   BACK TO TOP
========================================================= */
#back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px);
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease,
        visibility 0.3s ease,
        background-color 0.3s ease;
    z-index: 1100;
}
#back-to-top.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
#back-to-top:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 0 20px var(--glow-hover);
}

/* =========================================================
   WHATSAPP FLOAT
========================================================= */
.whatsapp-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    z-index: 1150;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.whatsapp-float:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(37, 211, 102, 0.6);
}

/* =========================================================
   MOBILE BOTTOM NAV
========================================================= */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 28px);
    max-width: 520px;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 8px 6px;
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.bottom-nav a,
.bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    min-height: 44px;
    color: var(--text-secondary);
    font-size: 0.64rem;
    font-weight: 500;
    text-decoration: none;
    background: none;
    border: none;
    outline: none;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.25s ease, transform 0.25s ease;
}

.bottom-nav a i,
.bottom-nav button i {
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.25s ease, color 0.25s ease;
}

.bottom-nav a:hover,
.bottom-nav button:hover {
    color: var(--accent);
    transform: translateY(-2px);
}

.bottom-nav a.active,
.bottom-nav button.active {
    color: var(--accent);
    font-weight: 600;
}

/* =========================================================
   MORE MENU
========================================================= */
.mobile-more-menu {
    display: none;
    position: fixed;
    z-index: 2000;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.45) transparent;
}

.mobile-more-menu.open {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.mobile-more-menu::-webkit-scrollbar { width: 5px; }
.mobile-more-menu::-webkit-scrollbar-track { background: transparent; margin: 10px 0; }
.mobile-more-menu::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.45);
    border-radius: 10px;
}
.mobile-more-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.7);
}

/* DESKTOP */
@media (min-width: 769px) {
    .mobile-more-menu {
        top: 72px;
        right: 70px;
        width: 300px;
        border-radius: 16px;
        padding: 14px;
        transform: translateY(-8px);
    }

    .mobile-more-menu.open { transform: translateY(0); }

    .more-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 4px;
    }

    .more-menu-header h2 {
        margin: 0;
        color: var(--text-primary);
        font-size: 1.45rem;
        font-weight: 700;
    }

    .more-close {
        width: 34px;
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: transparent;
        color: var(--text-primary);
        font-size: 1.7rem;
        cursor: pointer;
        border-radius: 50%;
    }
    .more-close:hover {
        background: var(--card-border);
        color: var(--accent);
    }

    .more-drag-handle {
        width: 45px;
        height: 5px;
        margin: 4px auto 8px;
        background: var(--text-secondary);
        border-radius: 10px;
        opacity: 0.6;
    }

    .more-menu-item {
        display: flex;
        align-items: center;
        gap: 11px;
        padding: 9px 5px;
        color: var(--text-primary);
        text-decoration: none;
        border-bottom: 1px solid var(--card-border);
        transition: background 0.2s ease, transform 0.2s ease;
    }
    .more-menu-item:last-child { border-bottom: none; }
    .more-menu-item:hover {
        background: rgba(255, 255, 255, 0.04);
        transform: translateX(3px);
    }

    .more-menu-item .more-icon {
        width: 44px;
        height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 1.2rem;
        border: 1px solid var(--card-border);
    }

    .about-icon { color: #38bdf8; background: rgba(56, 189, 248, 0.12); }
    .skills-icon { color: #34d399; background: rgba(52, 211, 153, 0.12); }
    .projects-icon { color: #a78bfa; background: rgba(167, 139, 250, 0.12); }
    .github-icon { color: #f1f5f9; background: rgba(148, 163, 184, 0.15); }
    .contact-icon { color: #f472b6; background: rgba(244, 114, 182, 0.12); }
    .services-icon { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
    .theme-icon { color: #a78bfa; background: rgba(167, 139, 250, 0.12); }

    .more-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
    }
    .more-text strong {
        color: var(--text-primary);
        font-size: 0.95rem;
    }
    .more-text span {
        color: var(--text-secondary);
        font-size: 0.75rem;
    }

    .more-arrow {
        color: var(--text-secondary);
        font-size: 1rem;
        transition: transform 0.2s ease, color 0.2s ease;
    }
    .more-menu-item:hover .more-arrow {
        color: var(--accent);
        transform: translateX(3px);
    }
}

/* MOBILE */
@media (max-width: 768px) {
    header { display: none; }

    .mobile-more-menu {
        left: 12px;
        right: 12px;
        bottom: 76px;
        width: auto;
        max-height: calc(100vh - 150px);
        border-radius: 20px;
        padding: 10px 10px;
        overflow-y: auto;
        transform: translateY(20px);
    }
    .mobile-more-menu.open { transform: translateY(0); }

    .more-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 5px;
    }
    .more-menu-header h2 {
        margin: 0;
        color: var(--text-primary);
        font-size: 1.35rem;
        font-weight: 700;
    }

    .more-close {
        width: 34px;
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: transparent;
        color: var(--text-primary);
        font-size: 1.6rem;
        cursor: pointer;
        border-radius: 50%;
    }

    .more-drag-handle {
        width: 42px;
        height: 5px;
        margin: 3px auto 6px;
        background: var(--text-secondary);
        border-radius: 10px;
        opacity: 0.55;
    }

    .more-menu-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 7px 5px;
        color: var(--text-primary);
        text-decoration: none;
        border-bottom: 1px solid var(--card-border);
    }
    .more-menu-item:last-child { border-bottom: none; }

    .more-menu-item .more-icon {
        width: 42px;
        height: 42px;
        min-width: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 1.15rem;
        border: 1px solid var(--card-border);
    }

    .about-icon { color: #38bdf8; background: rgba(56, 189, 248, 0.12); }
    .skills-icon { color: #34d399; background: rgba(52, 211, 153, 0.12); }
    .projects-icon { color: #a78bfa; background: rgba(167, 139, 250, 0.12); }
    .github-icon { color: #f1f5f9; background: rgba(148, 163, 184, 0.15); }
    .contact-icon { color: #f472b6; background: rgba(244, 114, 182, 0.12); }
    .services-icon { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
    .theme-icon { color: #a78bfa; background: rgba(167, 139, 250, 0.12); }

    .more-text {
        display: flex;
        flex-direction: column;
        gap: 1px;
        flex: 1;
    }
    .more-text strong {
        color: var(--text-primary);
        font-size: 0.9rem;
        font-weight: 700;
    }
    .more-text span {
        color: var(--text-secondary);
        font-size: 0.7rem;
    }
    .more-arrow {
        color: var(--text-secondary);
        font-size: 0.95rem;
    }

    .bottom-nav { display: flex; }

    .whatsapp-float {
        bottom: 88px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }

    #back-to-top {
        right: auto;
        left: 16px;
        bottom: 88px;
    }
}

.mobile-theme-item { display: none; }
@media (max-width: 768px) {
    .mobile-theme-item { display: flex; }
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 900px) {
    .stories-grid { grid-template-columns: repeat(2, 1fr); }
    .nav-links { gap: 0.9rem; }
}

@media (max-width: 768px) {
    section {
        padding: 3rem 1rem;
        scroll-margin-top: 100px;
    }

    .stories-hero {
        min-height: 60vh;
        padding: 2rem 1rem;
        text-align: center;
        justify-content: center;
    }

    .stories-hero h1 { font-size: 3rem; }
    .stories-hero p:not(.small-title) { font-size: 1rem; }

    .stories-grid { grid-template-columns: 1fr; }

    .featured-story { padding: 1.75rem; }
    .featured-content h3 { font-size: 1.7rem; }

    .story-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .categories { justify-content: center; }
    .section-heading { align-items: start; }
}

@media (max-width: 480px) {
    .stories-hero h1 { font-size: 2.4rem; }
    .featured-content h3 { font-size: 1.5rem; }
    .featured-story { padding: 1.5rem; }
    .category { font-size: 0.75rem; padding: 0.5rem 0.8rem; }
    .share-box { padding: 2.5rem 1.25rem; }
}