:root {
    --accent: #d4af37;
    --bg-dark: #0f172a;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: #f8fafc;
    overflow-x: hidden;
}

.serif {
    font-family: 'Playfair Display', serif;
}

/* ===== FIXED BACKGROUND LAYER ===== */
#bg-fixed {
    pointer-events: none;
    z-index: 0;
}

#bg-fixed .slide-container,
#bg-fixed .slide-layer,
#bg-fixed .absolute {
    pointer-events: none;
}

/* Slideshow container */
.slide-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Each slide layer â€“ GPU accelerated */
.slide-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    will-change: opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
    filter: brightness(0.6);
    transition: opacity 1.5s ease-in-out;
}

/* 3D Canvas sits above slides but below overlay */
#bg-fixed #webgl-canvas {
    z-index: 1 !important;
    pointer-events: none;
}

/* Overlay gradient (above canvas) */
#bg-fixed .z-2 {
    z-index: 2;
}

/* ===== HERO SECTION (transparent) ===== */
#home-section {
    background: transparent !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== GLASS SECTIONS ===== */
#most-read-section,
#comic-section {
    background-color: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ===== SOLID SECTIONS ===== */
#catalog-section,
#about,
#submit {
    background-color: #0f172a;
}

/* ===== STORY CARDS ===== */
.story-card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.story-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    border-color: var(--accent);
}

.story-card:active {
    transform: scale(0.95);
}

.story-card i {
    transition: transform 0.3s ease;
}

.story-card:hover i {
    transform: rotate(10deg) scale(1.2);
}

/* ===== CATEGORY PILLS ===== */
.category-pill {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.category-pill:hover,
.category-pill.active {
    background-color: var(--accent);
    color: #000;
    transform: scale(1.05);
}

/* ===== REVEAL ANIMATION ===== */
.hidden-section {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

.reveal-section {
    animation: fadeIn 0.8s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1e293b;
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ===== BACK TO TOP BUTTON ===== */
#backToTop {
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

#backToTop.show {
    opacity: 0.8;
    visibility: visible;
}

/* ===== AUTHOR MODAL ===== */
.author-modal-bg {
    animation: fadeModal 0.35s ease forwards;
}

.author-modal-box {
    animation: scaleModal 0.35s ease forwards;
}

@keyframes fadeModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleModal {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.author-modal-closing {
    animation: closeModal 0.3s ease forwards;
}

@keyframes closeModal {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

    to {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
}

.author-icon {
    transition: transform 0.4s ease;
}

.author-modal-box:hover .author-icon {
    transform: scale(1.2) rotate(10deg);
}

/* ===== BADGES ===== */
.new-story-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    color: #facc15;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.series-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.253);
    color: #facc15;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ===== MOBILE SEARCH ===== */
@media (max-width: 767px) {
    #navSearchContainer.expanded {
        display: block !important;
        flex: 1;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    #navSearchContainer.expanded input {
        width: 100%;
    }
}

/* ===== COMIC CARDS ===== */
#comic-grid .story-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    overflow: hidden;
    border-radius: 1rem;
}

#comic-grid .story-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 30px -5px rgba(212, 175, 55, 0.5);
    border-color: var(--accent);
}

#comic-grid .story-card img {
    transition: transform 0.4s ease;
}

#comic-grid .story-card:hover img {
    transform: scale(1.05);
}

/* ===== Glass navbar - pseudo-element only ===== */
#main-nav {
    z-index: 150;
    pointer-events: auto;
}

#main-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 40%);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* ===== PREMIUM COMIC CARDS (from library) ===== */
.comic-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.comic-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 30px -5px rgba(212, 175, 55, 0.5);
    border-color: var(--accent);
}

.card-image-wrapper {
    position: relative;
    height: 280px;
    overflow: hidden;
    cursor: pointer;
}

.card-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card-image-wrapper:hover .card-cover {
    transform: scale(1.08);
}

.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.9) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    display: flex;
    align-items: flex-end;
    padding: 1.5rem;
}

.card-image-wrapper:hover .card-overlay {
    opacity: 1;
}

.card-overlay-content {
    width: 100%;
}

.card-badge {
    display: inline-block;
    background: rgba(212, 175, 55, 0.8);
    color: #0f172a;
    padding: 2px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.card-title-overlay {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 4px 0 2px;
}

.card-author-overlay {
    color: #94a3b8;
    font-size: 0.85rem;
    font-style: italic;
}

.card-body {
    padding: 1.25rem 1.5rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.card-meta i {
    margin-right: 4px;
    color: var(--accent);
}

.rating-stars {
    color: #d4af37;
    display: flex;
    align-items: center;
    gap: 2px;
}

.rating-stars i {
    margin-right: 0;
}

.card-description {
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-actions {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-read {
    flex: 1;
    background: var(--accent);
    color: #0f172a;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-read:hover {
    background: #e6c84a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.btn-share {
    width: 38px;
    height: 38px;
    background: rgba(37, 211, 102, 0.15);
    border: 1px solid rgba(37, 211, 102, 0.2);
    border-radius: 50%;
    color: #25d366;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.btn-share:hover {
    background: #25d366;
    color: white;
    border-color: #25d366;
    transform: scale(1.1);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .card-image-wrapper {
        height: 160px;
    }

    .card-title-overlay {
        font-size: 0.95rem;
    }

    .card-meta {
        gap: 0.5rem;
        font-size: 0.7rem;
    }

    .card-description {
        font-size: 0.8rem;
    }

    .btn-read {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }
}

/* ===== IMPROVED NEW STORY ALERT ===== */
.new-story-alert {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 140;
    max-width: 420px;
    width: calc(100% - 40px);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(245, 158, 11, 0.05);
    animation: slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: all 0.3s ease;
}

.new-story-alert.hidden {
    display: none;
}

.new-story-alert.closing {
    animation: slideOutRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    animation: pulse 2s ease-in-out infinite;
}

.alert-message {
    flex: 1;
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.5;
    min-width: 0;
}

.alert-heading {
    color: #e2e8f0;
    margin-bottom: 4px;
}

.alert-story-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 2px;
}

.alert-story-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 6px;
    line-height: 1.4;
}

.alert-author {
    color: #94a3b8;
    font-size: 0.78rem;
}

.alert-link {
    color: #fbbf24;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
    font-weight: 600;
}

.alert-link:hover {
    color: #fcd34d;
}

.alert-label {
    color: #94a3b8;
    font-weight: 400;
}

.alert-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: #94a3b8;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.alert-close:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
    transform: rotate(90deg);
}

.alert-close:active {
    transform: scale(0.9);
}

/* ===== ANIMATIONS ===== */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(60px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateX(60px) scale(0.95);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15) rotate(-5deg);
    }
}

/* ===== RESPONSIVE FOR ALERT ===== */
@media (max-width: 640px) {
    .new-story-alert {
        top: 80px;
        right: 12px;
        width: calc(100% - 24px);
        padding: 14px 16px;
        border-radius: 14px;
    }

    .alert-content {
        gap: 10px;
    }

    .alert-icon {
        font-size: 1.2rem;
    }

    .alert-message {
        font-size: 0.82rem;
    }

    .alert-close {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

@media (min-width: 768px) {
    .new-story-alert {
        right: 30px;
        width: 440px;
        padding: 18px 22px;
    }
}

/* Add to your style/index.css or appropriate stylesheet */

/* Image preview grid styling */
#imagePreviewGrid {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 0.75rem;
    min-height: 70px;
    transition: border-color 0.3s ease;
}

#imagePreviewGrid:has(img) {
    border-color: rgba(212, 175, 55, 0.3);
    border-style: solid;
}

#imagePreviewGrid .group {
    transition: transform 0.2s ease;
}

#imagePreviewGrid .group:hover {
    transform: scale(1.02);
}

/* Upload button hover state */
#cloudinaryUploadBtn {
    transition: all 0.3s ease;
}

#cloudinaryUploadBtn:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: rgba(212, 175, 55, 0.6);
    transform: translateY(-1px);
}

/* Modal scroll styling */
#submitModal .max-h-\[90vh\] {
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

#submitModal .max-h-\[90vh\]::-webkit-scrollbar {
    width: 4px;
}

#submitModal .max-h-\[90vh\]::-webkit-scrollbar-track {
    background: transparent;
}

#submitModal .max-h-\[90vh\]::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

#submitModal .max-h-\[90vh\]::-webkit-scrollbar-thumb:hover {
    background: #d4af37;
}

/* Toast for upload status */
#uploadStatus {
    transition: all 0.3s ease;
    padding: 2px 8px;
    border-radius: 4px;
}

/* ===== CLOUDINARY WIDGET OVERRIDES (optional) ===== */
.cloudinary-upload-widget {
    --cloudinary-palette-window: #0f172a !important;
    --cloudinary-palette-window-border: #d4af37 !important;
    --cloudinary-palette-tab-icon: #d4af37 !important;
    --cloudinary-palette-menu-icons: #d4af37 !important;
    --cloudinary-palette-text-dark: #ffffff !important;
    --cloudinary-palette-text-light: #94a3b8 !important;
    --cloudinary-palette-link: #d4af37 !important;
    --cloudinary-palette-action: #d4af37 !important;
    --cloudinary-palette-inactive-tab-icon: #475569 !important;
    --cloudinary-palette-error: #ef4444 !important;
    --cloudinary-palette-in-progress: #d4af37 !important;
    --cloudinary-palette-complete: #22c55e !important;
    --cloudinary-palette-source-bg: #1e293b !important;
}

/* Fix for Cloudinary widget z-index */
.cloudinary-upload-widget-iframe {
    z-index: 9999 !important;
}

/* Responsive tweaks */
@media (max-width: 640px) {
    #imagePreviewGrid {
        grid-template-columns: repeat(2, 1fr);
        min-height: 60px;
    }

    #cloudinaryUploadBtn {
        font-size: 0.8rem;
        padding: 0.4rem 1rem;
    }
}

@media (max-width: 400px) {
    #imagePreviewGrid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

/* ===== PREVIEW GRID â€“ safe sizing ===== */
#imagePreviewGrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    min-height: 70px;
}

#imagePreviewGrid .aspect-square {
    aspect-ratio: 1 / 1;
}

#imagePreviewGrid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.5rem;
}

/* Make remove button more visible */
#imagePreviewGrid .group .absolute {
    z-index: 5;
}

/* Mobile: 2 columns */
@media (max-width: 480px) {
    #imagePreviewGrid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Fix for Cloudinary widget iframe â€“ it's already high z-index, we just close it */

/* Eye icon inside password fields */
#loginModal .relative button,
#signupModal .relative button {
    background: transparent;
    border: none;
    padding: 0 8px;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 5;
}

#loginModal .relative button:hover,
#signupModal .relative button:hover {
    color: #d4af37; /* gold on hover */
}