:root {
    --font-main: 'Inter', system-ui, Avenir, Helvetica, Arial, sans-serif;
    --bg-color: #ffffff;
    /* Clean White */
    --surface-color: #f4f4f5;
    /* Light Grey Surface */
    --surface-hover: #e4e4e7;
    --primary-color: #4f46e5;
    /* Indigo */
    --primary-hover: #4338ca;
    --text-main: #18181b;
    /* Zinc 900 */
    --text-muted: #71717a;
    /* Zinc 500 */
    --gradient-start: #4f46e5;
    --gradient-end: #ec4899;
    /* Pink/Rose */

    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 32px;
    --spacing-xl: 64px;

    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --input-bg: #ffffff;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

main:not(.home-scroll-container) {
    padding-top: 100px;
    min-height: 100vh;
}

/* Home Layout specific for Globe background */
.home-scroll-container {
    position: relative;
    /* ensure content sits over the fixed background */
    z-index: 10;
}

.home-scroll-container section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.home-scroll-container h1,
.home-scroll-container h2 {
    color: #ffffff;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
}

.home-scroll-container p {
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.98);
    /* White background like Anthropic */
    backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid #000000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

/* Scrolled state - compact header */
.app-header.scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.app-header.scrolled .navbar {
    padding: 4px var(--spacing-lg);
}

.app-header.scrolled .logo img {
    height: 60px;
}

.app-header.scrolled .site-title {
    opacity: 0;
    pointer-events: none;
}

.navbar {
    max-width: 100%;
    margin: 0;
    padding: var(--spacing-sm) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* Gothic Site Title */
.site-title {
    font-family: 'MedievalSharp', cursive;
    font-size: 2.2rem;
    color: #000000;
    text-align: center;
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
    letter-spacing: 0.1em;
    font-weight: 400;
}

.logo {
    display: flex;
    align-items: center;
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.05em;
}

.logo img {
    height: 135px;
    width: auto;
    object-fit: contain;
    transition: height 0.3s ease;
}

.nav-links {
    display: flex;
    gap: var(--spacing-lg);
    list-style: none;
    align-items: center;
}

.nav-links a {
    color: #000000;
    /* Black text on white header */
    font-weight: 500;
    transition: color 0.2s;
    text-decoration: none;
}

.nav-links a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Tagline Styling */
.tagline {
    font-family: var(--font-main);
    font-style: italic;
    font-size: 1.1rem;
    color: #000000;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 15px;
    white-space: nowrap;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tagline::before {
    content: '❝';
    font-size: 1.8rem;
    line-height: 1;
}

.tagline::after {
    content: '❞';
    font-size: 1.8rem;
    line-height: 1;
}

.app-header.scrolled .tagline {
    opacity: 0;
    pointer-events: none;
}



/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #ffffff;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) 0;
    z-index: 1001;
    transition: all 0.2s ease;
    transform: translateY(10px);
}

/* Pont invisible pour combler le vide de 15px et garder le hover actif */
.dropdown-content::before {
    content: "";
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    height: 15px;
    background: transparent;
}

.dropdown-content a {
    color: #000000;
    padding: 12px 20px;
    text-decoration: none;
    display: block;
    transition: background-color 0.2s;
}

.dropdown-content a:hover {
    background-color: var(--surface-color);
    color: #000000;
}

.dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(8px);
}

.dropdown>a::after {
    content: " ▾";
    font-size: 0.8em;
    margin-left: 4px;
}

.cta-button {
    background: #000000;
    /* Black button like Anthropic's "Try Claude" */
    color: #ffffff;
    /* White text */
    border: none;
    padding: 10px 20px;
    border-radius: 9999px;
    /* Pill shape */
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cta-button:hover {
    background: #1a1a1a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button {
    font-family: inherit;
    font-size: 1rem;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: 2px solid #000000;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(100, 108, 255, 0.4);
}

.secondary-btn {
    background: transparent;
    color: var(--text-main);
    border: 2px solid #000000;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: #000000;
    color: #ffffff;
    transform: translateY(-2px);
}

.api-controls input {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: white;
    color: black;
    font-size: 0.85rem;
    width: 180px;
    margin-right: var(--spacing-sm);
    transition: all 0.2s;
}

.api-controls input:focus {
    width: 220px;
    border-color: var(--primary-color);
    outline: none;
    background: white;
}

/* Market Data Section */
.market-data-section {
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
}

.container {
    max-width: 1400px;
    /* Increased to fit multiple cards */
    margin: 0 auto;
}

.section-subtitle {
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}

.search-container {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    margin-bottom: var(--spacing-lg);
}

#etf-search {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: 2px solid #000000;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 1rem;
    width: 300px;
    outline: none;
    font-weight: 500;
    transition: all 0.2s;
}

#etf-search:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.hidden {
    display: none !important;
}

.error-message {
    color: #ff4d4d;
    margin-top: var(--spacing-md);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    /* Cards start at 200px (-20%) to allow more per row */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
    justify-items: center;
}

/* Results Card */
.result-card {
    background: linear-gradient(145deg, var(--surface-color), var(--surface-hover));
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    border: 2px solid #000000;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.4s ease-out;
    position: relative;
    font-size: 0.9rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}



.chart-container {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Valuation Indicator */
.valuation-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: var(--spacing-md);
    font-size: 0.85rem;
    font-weight: 600;
}

.valuation-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.valuation-text {
    color: var(--text-main);
}

/* Valuation Colors */
.valuation-indicator[data-valuation="very-overvalued"] {
    background: rgba(239, 68, 68, 0.15);
}

.valuation-indicator[data-valuation="very-overvalued"] .valuation-dot {
    background: #ef4444;
    /* Red */
}

.valuation-indicator[data-valuation="overvalued"] {
    background: rgba(249, 115, 22, 0.15);
}

.valuation-indicator[data-valuation="overvalued"] .valuation-dot {
    background: #f97316;
    /* Orange */
}

.valuation-indicator[data-valuation="slightly-overvalued"] {
    background: rgba(234, 179, 8, 0.15);
}

.valuation-indicator[data-valuation="slightly-overvalued"] .valuation-dot {
    background: #eab308;
    /* Yellow */
}

.valuation-indicator[data-valuation="fair"] {
    background: rgba(34, 197, 94, 0.15);
}

.valuation-indicator[data-valuation="fair"] .valuation-dot {
    background: #16a34a;
    /* Dark Green */
}

.valuation-indicator[data-valuation="undervalued"] {
    background: rgba(59, 130, 246, 0.15);
}

.valuation-indicator[data-valuation="undervalued"] .valuation-dot {
    background: #3b82f6;
    /* Light Blue */
}

.valuation-indicator[data-valuation="neutral"] {
    background: rgba(0, 0, 0, 0.05);
}

.valuation-indicator[data-valuation="neutral"] .valuation-dot {
    background: #9ca3af;
    /* Gray */
}

.dashboard-controls {
    margin-bottom: var(--spacing-lg);
    display: flex;
    justify-content: flex-end;
}

.remove-card-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

.remove-card-btn:hover {
    color: #ff4d4d;
}

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

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ticker-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
}

.etf-name {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-right: auto;
    margin-left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-body {
    display: flex;
    justify-content: space-around;
}

/* Percentile Stats Grid */
.stats-grid {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
}

@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        align-items: center;
    }

    #etf-search {
        width: 100%;
    }

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

/* --- Scroll Reveal Animations --- */
.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

.scroll-reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Delay for staggered children */
.features-grid > .scroll-reveal:nth-child(2) {
    transition-delay: 0.2s;
}
.features-grid > .scroll-reveal:nth-child(3) {
    transition-delay: 0.4s;
}

/* --- Minimalist Black & White Theme Elements --- */
.bw-card {
    background: rgba(10, 10, 10, 0.45); /* Darker, neutral glass */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.bw-card:hover {
    background: rgba(20, 20, 20, 0.55);
    border-color: rgba(255, 255, 255, 0.25);
}

.bw-btn {
    background-color: #ffffff;
    color: #000000;
    border: 2px solid #ffffff;
}

.bw-btn:hover {
    background-color: transparent;
    color: #ffffff;
    border-color: #ffffff;
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.15);
}

.bw-link {
    color: #a1a1aa; /* Zinc 400 */
    transition: color 0.3s ease;
}

.bw-link:hover {
    color: #ffffff;
    text-decoration: none;
}

/* --- Glassmorphism Sections (Home Page) --- */

.glass-section {
    position: relative;
    width: 100%;
    /* Add subtle gradient to differentiate sections while keeping them transparent */
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.4));
}

.glass-card {
    background: rgba(30, 30, 35, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    color: #ffffff;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(40, 40, 45, 0.55);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    width: 100%;
}

.feature-card {
    padding: var(--spacing-lg);
    text-align: center;
}

.feature-card h3 {
    margin-bottom: var(--spacing-sm);
    font-size: 1.3rem;
    color: #fff;
}

.feature-card p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    line-height: 1.6;
}

.text-center {
    text-align: center;
}

/* Historical Chart Section */
.historical-chart-section {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: linear-gradient(145deg, var(--surface-color), var(--surface-hover));
    border-radius: var(--radius-lg);
    border: 2px solid #000000;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.5s ease-out;
}

.historical-chart-section h3 {
    margin-bottom: var(--spacing-sm);
    font-size: 1.5rem;
}

#historical-chart-container {
    margin-top: var(--spacing-lg);
    min-height: 400px;
}

/* Disabled search state */
.search-container.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.search-container.disabled #search-btn {
    background-color: #9ca3af;
    cursor: not-allowed;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* News Section */
.news-section {
    padding: var(--spacing-xl) var(--spacing-md);
    max-width: 1200px;
    margin: 0 auto;
}

.news-header {
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--spacing-lg);
}

.news-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.news-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--gradient-start), var(--gradient-end));
    opacity: 0;
    transition: opacity 0.3s;
}

.news-card:hover {
    transform: translateY(-8px);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.news-card:hover::before {
    opacity: 1;
}

.news-source {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary-color);
}

.news-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-main);
}

.news-summary {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.news-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.news-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.read-more {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 4px;
}

.read-more:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.last-updated-tag {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: var(--spacing-sm);
}

@media (max-width: 480px) {
    .news-grid {
        grid-template-columns: 1fr;
    }
}

/* Footer Styles */
.app-footer {
    background: #000000;
    color: #ffffff;
    padding: var(--spacing-xl) 0 var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: var(--spacing-xl);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-xl);
}

.footer-col h4 {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.footer-col p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-links {
    list-style: none;
    padding: 0;
}

.footer-links li {
    margin-bottom: var(--spacing-sm);
}

.footer-links a {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    transition: color 0.2s;
    text-decoration: none;
}

.footer-links a:hover {
    color: #ffffff;
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.newsletter-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    padding: 12px;
    color: #ffffff;
    font-size: 0.9rem;
}

.newsletter-input:focus {
    outline: none;
    border-color: #ffffff;
}

.newsletter-btn {
    background: #ffffff;
    color: #000000;
    border: none;
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.newsletter-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

.footer-bottom {
    max-width: 1200px;
    margin: var(--spacing-xl) auto 0;
    padding: var(--spacing-lg) var(--spacing-lg) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
}

.footer-bottom-links {
    display: flex;
    gap: var(--spacing-lg);
}

.footer-bottom-links a {
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
}

.footer-bottom-links a:hover {
    color: #ffffff;
}

@media (max-width: 992px) {
    .footer-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .footer-container {
        grid-template-columns: 1fr;
    }

    .footer-bottom {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }
}