/* --- CATEGORY COLOR THEMES (The Verge Style) --- */
:root {
    --cat-essay: #d35400;   /* Vibrant Orange */
    --cat-review: #2980b9;  /* Deep Blue */
    --cat-opinion: #8e44ad; /* Rich Purple */
    --cat-news: #27ae60;    /* Green */
    
    --current-cat-color: var(--maroon); /* Default fallback */
}

/* Dynamically assign the main color based on the data attribute */
.article-main[data-category="essay"] { --current-cat-color: var(--cat-essay); }
.article-main[data-category="review"] { --current-cat-color: var(--cat-review); }
.article-main[data-category="opinion"] { --current-cat-color: var(--cat-opinion); }

/* --- LAYOUT & SPACING (Wired Style) --- */
.article-container {
    max-width: 760px; /* Narrow line length for high-end readability */
    margin: 0 auto;
    padding: 160px 24px 120px; /* Safe clearing for top navbar */
}

/* --- HEADER --- */
.article-header {
    position: relative;
    z-index: 30; 
    overflow: visible !important; /* CRITICAL FIX: Stops GSAP from hiding the popover card */
}

.category-badge {
    display: inline-block;
    background-color: var(--current-cat-color);
    color: var(--light);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    margin-bottom: 1.5rem;
}

.article-title {
    font-family: "neue-haas-grotesk-display", "Agdasima", sans-serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--dark);
    margin-bottom: 1rem;
}

.article-subtitle {
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: #555;
    line-height: 1.4;
    margin-bottom: 2.5rem;
    font-weight: 400;
}

/* --- META & AUTHOR POPOVER --- */
.article-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: #888;
    border-top: 1px solid #dbd8d8;
    border-bottom: 1px solid #dbd8d8;
    padding: 1rem 0;
    margin-bottom: 3rem;
    overflow: visible !important; 
}

.meta-divider { opacity: 0.5; }

.author-wrapper {
    position: relative;
    display: inline-block;
    overflow: visible !important;
    z-index: 40;
}

.author-wrapper.active {
    z-index: 9999; 
}

.author-trigger {
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
    color: var(--dark);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
}

.plus-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--dark);
    color: var(--light);
    border-radius: 50%;
    font-size: 10px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Popover Base Card */
.author-popover {
    position: absolute;
    top: calc(100% + 14px); 
    left: 0;
    width: 320px;
    background: #ffffff;
    border: 1px solid #e2e2e2;
    border-radius: 14px;
    padding: 1.5rem 1.35rem 1.35rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.09);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10000;
    text-align: left;
}

.author-popover.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.author-wrapper.active .plus-icon {
    transform: rotate(45deg); 
}

/* Close button styling */
.close-popover {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 1.1rem;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s ease;
}

.close-popover:hover {
    color: var(--dark);
}

.popover-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.85rem;
    padding-right: 18px;
}

.author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.popover-name {
    font-family: 'Manrope', sans-serif;
    font-size: 1rem;
    color: var(--dark);
    margin-bottom: 0.15rem;
}

.popover-role {
    font-size: 0.72rem;
    color: var(--current-cat-color);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.popover-bio {
    font-family: 'Manrope', sans-serif;
    font-size: 0.84rem;
    color: #666;
    line-height: 1.5;
    margin-bottom: 1.1rem;
}

/* --- POPOVER SOCIAL ICONS --- */
.popover-socials {
    display: flex;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f0f0f0;
}

.social-icon {
    color: #888;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-flex;
}

.social-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.social-icon:hover {
    color: var(--current-cat-color);
    transform: translateY(-2px);
}

.more-articles-link {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--dark);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid var(--dark);
    transition: color 0.3s, border-color 0.3s;
}

.more-articles-link:hover {
    color: var(--current-cat-color);
    border-color: var(--current-cat-color);
}

/* --- ARTICLE BODY --- */
.article-body {
    font-family: 'Manrope', sans-serif;
    font-size: 1.15rem;
    line-height: 1.8;
    color: #222;
    position: relative;
    z-index: 5;
}

.article-body p { margin-bottom: 2rem; }

.article-body h2 {
    font-family: "neue-haas-grotesk-display", "Agdasima", sans-serif;
    font-size: 2.5rem;
    margin: 3rem 0 1.5rem;
    line-height: 1.2;
}

.has-dropcap::first-letter {
    float: left;
    font-family: 'Playfair Display', serif;
    font-size: 5.5rem;
    line-height: 0.8;
    padding-top: 0.2rem;
    padding-right: 0.8rem;
    padding-left: 0.1rem;
    color: var(--current-cat-color);
    font-weight: 700;
}

.article-body blockquote {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    line-height: 1.4;
    font-style: italic;
    color: var(--current-cat-color);
    margin: 3rem 0;
    padding-left: 2rem;
    border-left: 4px solid var(--current-cat-color);
}

/* --- OPTIONAL IMAGES --- */
.article-cover-photo { width: 100%; margin: 0 0 3.5rem 0; }
.article-cover-photo img { width: 100%; height: auto; object-fit: cover; }
.article-inline-photo { width: 100%; margin: 3rem 0; }
.article-inline-photo img { width: 100%; height: auto; }

.article-cover-photo figcaption,
.article-inline-photo figcaption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.75rem;
    text-align: right;
    letter-spacing: 0.03em;
}

/* --- HIGH-END "RELATED READS" GRID (MAKES THE LAYOUT POP) --- */
.related-articles-section {
    margin-top: 6rem;
    padding-top: 3rem;
    border-top: 1px solid #dbd8d8;
    overflow: visible;
}

.related-section-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888;
    margin-bottom: 2rem;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.related-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    padding: 1.5rem;
    border-radius: 8px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border-color 0.3s ease;
}

.related-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.related-badge {
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Map categories inside cards to custom tokens */
.related-card[data-related-cat="review"] .related-badge { color: var(--cat-review); }
.related-card[data-related-cat="opinion"] .related-badge { color: var(--cat-opinion); }
.related-card[data-related-cat="news"] .related-badge { color: var(--cat-news); }

.related-time { color: #aaa; }

.related-card-title {
    font-family: 'Manrope', sans-serif;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--dark);
    font-weight: 600;
    margin-bottom: 1.5rem;
    flex-grow: 1; /* Pushes date to the very bottom uniformly */
    transition: color 0.25s ease;
}

.related-card-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: #999;
}

/* Premium Card Hover State Transitions */
.related-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.06);
    border-color: var(--dark);
}

.related-card[data-related-cat="review"]:hover { border-color: var(--cat-review); }
.related-card[data-related-cat="opinion"]:hover { border-color: var(--cat-opinion); }
.related-card[data-related-cat="news"]:hover { border-color: var(--cat-news); }

.related-card:hover .related-card-title {
    color: var(--dark);
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 900px) {
    .related-grid { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 768px) {
    .article-container { padding: 120px 6% 80px; }
    .author-popover { width: 290px; left: 0; max-width: calc(100vw - 48px); } 
    .has-dropcap::first-letter { font-size: 4.5rem; }
    .article-body blockquote { font-size: 1.4rem; padding-left: 1rem; }
}