/* =============================================================================
   TILES.CSS — Index Tile Component (Market Pulse / Landing Page)
   AI Supply Chain Dashboard
   Created: 2025-02-27

   PURPOSE: The animated index tiles (SPY, QQQ, DIA etc.) with MA stack ladder
   and trend score are exclusive to index.html. Extracted here to keep index.html
   lean for the Vite migration.

   COMPONENTS:
   - .index-tile          Clickable market tile card
   - .change-badge        % change pill (top-right)
   - .price-text          Large price display
   - .stack-row           MA stack ladder row
   - .ext-bar             Extended hours strip
   - .vol-tag             Volume ratio badge
   - .cat-section         Category group wrapper
   - .guide-wrapper       Score guide tooltip
   - .modal-overlay       TradingView chart modal
   - .dash-btn            "View full dashboard" CTA button

   USAGE: @import './tiles.css'; in index.html ONLY.
   Also imports: base.css, scores.css (for score-N classes on trend-badge).

   REVERT: Copy all rules below back into index.html's <style> tag.
   ============================================================================= */

/* =============================================================================
   INDEX TILE — main card
   ============================================================================= */
.index-tile {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Top accent line — colour set by --accent local var */
.index-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.index-tile:hover {
    transform: translateY(-4px);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.index-tile:hover::before { opacity: 1; }

/* State variants */
.index-tile.gain    { --accent: var(--gain); }
.index-tile.gain:hover {
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px var(--gain-glow);
}
.index-tile.loss    { --accent: var(--loss); }
.index-tile.loss:hover {
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px var(--loss-glow);
}
.index-tile.loading { --accent: var(--acc); }

/* =============================================================================
   LOADING SKELETON — shimmer animation on tiles before data loads
   ============================================================================= */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

.shimmer {
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.04) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.tile-animate {
    opacity: 0;
    animation: fadeSlideUp 0.6s cubic-bezier(0.4,0,0.2,1) forwards;
}

/* =============================================================================
   BADGES & PRICE DISPLAY
   ============================================================================= */
.change-badge {
    font-family: var(--font-data);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 8px;
}

.change-badge.gain { color: var(--gain); background: var(--gain-dim); }
.change-badge.loss { color: var(--loss); background: var(--loss-dim); }

.price-text {
    font-family: var(--font-data);
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: -0.02em;
}

/* =============================================================================
   MA STACK LADDER (v5)
   Vertical ranking of Price / 10EMA / 20EMA / 50SMA / 200SMA / VWAP
   ============================================================================= */
.stack-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--font-data);
    font-size: 10px;
    font-weight: 600;
}

.stack-row.price-row {
    padding: 5px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 11px;
}

.stack-row.price-row.bull {
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.25);
    color: var(--gain);
}

.stack-row.price-row.bear {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.25);
    color: var(--loss);
}

.stack-row.vwap-row {
    border: 1px dashed rgba(161,161,170,0.15);
    opacity: 0.6;
}

.stack-connector {
    width: 1px;
    height: 4px;
    background: rgba(255,255,255,0.06);
    margin: 0 auto;
}

/* =============================================================================
   EXTENDED HOURS BAR (pre-market / after-hours strip below price)
   ============================================================================= */
.ext-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    margin-top: 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 8px;
    font-family: var(--font-data);
    font-size: 10px;
    font-weight: 600;
}

.ext-icon  { font-size: 12px; line-height: 1; }
.ext-label { color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; font-size: 8px; font-weight: 700; }
.ext-price { color: var(--text-base); }
.ext-change.gain { color: var(--gain); }
.ext-change.loss { color: var(--loss); }
.ext-time  { color: #3f3f46; font-size: 8px; margin-left: auto; }

/* =============================================================================
   VOLUME TAG (top-left of tile)
   ============================================================================= */
.vol-tag {
    font-family: var(--font-data);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 5px;
    letter-spacing: 0.05em;
}

/* =============================================================================
   CATEGORY SECTION — groups of tiles (Major Indices, Macro, etc.)
   ============================================================================= */
.cat-section  { margin-bottom: 48px; }

.cat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.cat-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    font-family: var(--font-data);
}

.cat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-family: var(--font-data);
}

.cat-desc {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-data);
}

/* =============================================================================
   SCORE GUIDE TOOLTIP (hover-reveal on "Score Guide" button in header)
   ============================================================================= */
.guide-wrapper {
    position: relative;
    display: inline-block;
}

.guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-data);
    font-size: 9px;
    font-weight: 700;
    color: var(--text-dim);
    background: rgba(255,255,255,0.03);
    border: 1px solid #262626;
    border-radius: 8px;
    padding: 5px 10px;
    cursor: default;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.guide-btn:hover {
    color: var(--text-base);
    border-color: #3f3f46;
    background: rgba(255,255,255,0.05);
}

.guide-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    width: 400px;
    background: var(--card);
    border: 1px solid #262626;
    border-radius: 12px;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    z-index: 50;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    pointer-events: none;
}

.guide-wrapper:hover .guide-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Caret arrow */
.guide-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: var(--card);
    border-right: 1px solid #262626;
    border-bottom: 1px solid #262626;
    transform: rotate(45deg);
}

.guide-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-family: var(--font-data);
    font-size: 9px;
}

.guide-row:last-child { border-bottom: none; }
.guide-score { font-weight: 800; min-width: 32px; }
.guide-label { font-weight: 700; min-width: 100px; }
.guide-desc  { color: var(--text-dim); font-weight: 400; text-align: right; }

/* =============================================================================
   CHART MODAL (TradingView embed)
   ============================================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(12px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--card-raised);
    border: 1px solid #1a1a2e;
    width: 95%;
    max-width: 900px;
    border-radius: 20px;
    padding: 28px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

#tv_chart_container {
    width: 100%;
    height: 450px;
    background: #000;
    border-radius: 10px;
    margin-top: 16px;
    border: 1px solid #1a1a2e;
}

/* =============================================================================
   CTA BUTTON — "View Full Supply Chain Dashboard"
   ============================================================================= */
.dash-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 40px;
    background: linear-gradient(135deg, var(--card), #141420);
    border: 1px solid #262640;
    border-radius: 14px;
    color: #fff;
    font-family: var(--font-data);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.dash-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59,130,246,0.08), transparent);
    transition: left 0.6s ease;
}

.dash-btn:hover {
    border-color: rgba(59,130,246,0.4);
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(59,130,246,0.1);
}

.dash-btn:hover::before { left: 100%; }

/* =============================================================================
   ANIMATION UTILITIES
   ============================================================================= */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.fade-in    { animation: fadeUp 0.4s ease forwards; }
.fade-in-d1 { animation: fadeUp 0.4s 0.05s ease both; }
.fade-in-d2 { animation: fadeUp 0.4s 0.10s ease both; }
.fade-in-d3 { animation: fadeUp 0.4s 0.15s ease both; }

/* =============================================================================
   TOOLTIP UTILITY (generic hover tooltip)
   ============================================================================= */
.tip { position: relative; }

.tip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #0e0e14;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 8px;
    color: var(--text-base);
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
}

.tip:hover .tip-content { display: block; }
