/* ============================================================
   tanso.in -- McBling Carbon Analytics Dashboard
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --soft-gray: #F0EDE8;
    --charcoal: #2A2828;
    --muted-gold: #B0A080;
    --chrome-silver: #C0B8B0;
    --blush: #D8B8B0;
    --deep-mute: #5A5048;
    --warm-white: #E8E0D8;
    --chrome-alt: #C0B0A0;

    --font-display: 'Inter', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;

    --ring-circumference: 326.73;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.7;
    font-weight: 400;
    color: var(--charcoal);
    background-color: var(--soft-gray);
    overflow-x: hidden;
    position: relative;
}

/* --- Grid-Lines Foundation Overlay --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 59px,
            rgba(192, 176, 160, 0.08) 59px,
            rgba(192, 176, 160, 0.08) 60px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 59px,
            rgba(192, 176, 160, 0.08) 59px,
            rgba(192, 176, 160, 0.08) 60px
        );
}

/* --- Sparkle Texture Mixin (applied via pseudo/child elements) --- */
.hero-sparkle-field,
.panel-sparkle-field,
.featured-sparkle-field,
.closing-sparkle-field {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle 2px at 15% 25%, rgba(200, 180, 140, 0.4), transparent 3px),
        radial-gradient(circle 1px at 45% 15%, rgba(200, 180, 140, 0.3), transparent 2px),
        radial-gradient(circle 2px at 70% 35%, rgba(200, 180, 140, 0.35), transparent 3px),
        radial-gradient(circle 1px at 25% 65%, rgba(200, 180, 140, 0.25), transparent 2px),
        radial-gradient(circle 2px at 85% 55%, rgba(200, 180, 140, 0.4), transparent 3px),
        radial-gradient(circle 1px at 55% 80%, rgba(200, 180, 140, 0.3), transparent 2px),
        radial-gradient(circle 2px at 10% 90%, rgba(200, 180, 140, 0.35), transparent 3px),
        radial-gradient(circle 1px at 90% 10%, rgba(200, 180, 140, 0.3), transparent 2px),
        radial-gradient(circle 2px at 35% 45%, rgba(200, 180, 140, 0.4), transparent 3px),
        radial-gradient(circle 1px at 60% 55%, rgba(200, 180, 140, 0.25), transparent 2px),
        radial-gradient(circle 2px at 80% 80%, rgba(200, 180, 140, 0.35), transparent 3px),
        radial-gradient(circle 1px at 5% 50%, rgba(200, 180, 140, 0.3), transparent 2px),
        radial-gradient(circle 2px at 50% 30%, rgba(200, 180, 140, 0.4), transparent 3px),
        radial-gradient(circle 1px at 75% 70%, rgba(200, 180, 140, 0.3), transparent 2px),
        radial-gradient(circle 2px at 30% 10%, rgba(200, 180, 140, 0.35), transparent 3px),
        radial-gradient(circle 1px at 95% 40%, rgba(200, 180, 140, 0.25), transparent 2px),
        radial-gradient(circle 2px at 40% 95%, rgba(200, 180, 140, 0.4), transparent 3px),
        radial-gradient(circle 1px at 20% 78%, rgba(200, 180, 140, 0.3), transparent 2px),
        radial-gradient(circle 2px at 65% 5%, rgba(200, 180, 140, 0.35), transparent 3px),
        radial-gradient(circle 1px at 48% 60%, rgba(200, 180, 140, 0.25), transparent 2px);
    animation: sparkle-shimmer 4s ease-in-out infinite alternate;
}

@keyframes sparkle-shimmer {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* --- Hero Section --- */
#hero {
    position: relative;
    z-index: 1;
    padding: 4rem 2rem 3.5rem;
    text-align: center;
    overflow: hidden;
    background: var(--soft-gray);
}

.hero-chrome-band {
    height: 4px;
    background: linear-gradient(135deg, var(--chrome-silver), var(--warm-white), var(--chrome-silver));
    position: relative;
    z-index: 2;
}

.hero-chrome-band--bottom {
    margin-top: 0;
}

.hero-content {
    position: relative;
    z-index: 3;
    padding: 2.5rem 0;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 800;
    color: var(--charcoal);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--charcoal) 0%, var(--deep-mute) 50%, var(--charcoal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--deep-mute);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* --- Dashboard Grid (Section 2) --- */
#dashboard-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-panel {
    position: relative;
    background: rgba(240, 237, 232, 0.85);
    border: 1px solid var(--chrome-alt);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-panel:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(42, 40, 40, 0.08), 0 2px 8px rgba(176, 160, 128, 0.12);
}

/* Chrome header strip on panels */
.panel-chrome-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--chrome-silver), var(--warm-white), var(--chrome-silver));
    border-bottom: 1px solid rgba(192, 176, 160, 0.3);
    position: relative;
    z-index: 2;
}

.panel-label {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--charcoal);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.panel-unit {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--deep-mute);
    text-transform: lowercase;
    letter-spacing: 0.05em;
    background: rgba(176, 160, 128, 0.15);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.panel-body {
    position: relative;
    z-index: 2;
    padding: 1.5rem;
    text-align: center;
}

/* --- Progress Ring --- */
.metric-ring-container {
    position: relative;
    display: inline-block;
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
}

.progress-ring {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

.progress-ring__track {
    fill: none;
    stroke: rgba(192, 176, 160, 0.25);
    stroke-width: 8;
}

.progress-ring__fill {
    fill: none;
    stroke: var(--muted-gold);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: var(--ring-circumference);
    stroke-dashoffset: var(--ring-circumference);
    transition: stroke-dashoffset 2s ease-out;
}

.metric-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 700;
    color: var(--charcoal);
    line-height: 1;
}

.metric-description {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--deep-mute);
    line-height: 1.5;
}

/* --- Featured Panel (Section 3) --- */
#featured-panel {
    position: relative;
    z-index: 1;
    padding: 1rem 2rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.featured-card {
    position: relative;
    background: rgba(240, 237, 232, 0.9);
    border: 1px solid var(--chrome-alt);
    border-radius: 12px;
    overflow: hidden;
}

.featured-chrome-header {
    padding: 1rem 1.5rem;
}

.featured-sparkle-field {
    z-index: 1;
    background-size: 200% 200%;
    animation: sparkle-shimmer 3s ease-in-out infinite alternate, sparkle-drift 8s linear infinite;
}

@keyframes sparkle-drift {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

.featured-body {
    position: relative;
    z-index: 2;
    padding: 2rem 1.5rem;
}

/* --- Trajectory Chart --- */
.trajectory-chart {
    position: relative;
    margin-bottom: 2rem;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 180px;
    padding: 0 1rem;
    border-bottom: 2px solid rgba(192, 176, 160, 0.3);
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 80px;
}

.chart-bar {
    width: 100%;
    max-width: 40px;
    height: 0;
    position: relative;
    border-radius: 4px 4px 0 0;
    overflow: hidden;
    transition: height 1.5s ease-out;
}

.chart-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    background: linear-gradient(180deg, var(--muted-gold), var(--blush));
    border-radius: 4px 4px 0 0;
}

.chart-bar-label {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--deep-mute);
    margin-top: 0.5rem;
    letter-spacing: 0.02em;
}

.chart-trend-line {
    display: none; /* Implemented via JS canvas or kept as decorative */
}

/* --- Featured Stats --- */
.featured-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
    text-align: center;
}

.featured-stat {
    padding: 1rem;
    background: rgba(232, 224, 216, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(192, 176, 160, 0.2);
}

.featured-stat-value {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 700;
    color: var(--charcoal);
    line-height: 1.1;
}

.featured-stat-suffix {
    font-family: var(--font-display);
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: 600;
    color: var(--muted-gold);
    vertical-align: super;
}

.featured-stat-label {
    display: block;
    margin-top: 0.35rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--deep-mute);
    letter-spacing: 0.04em;
}

/* --- Closing Panel (Section 4) --- */
#closing-panel {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 3rem 2rem;
    margin-top: 2rem;
    overflow: hidden;
}

.closing-chrome-band {
    height: 4px;
    background: linear-gradient(135deg, var(--chrome-silver), var(--warm-white), var(--chrome-silver));
    position: relative;
    z-index: 2;
}

.closing-chrome-band--bottom {
    margin-top: 0;
}

.closing-content {
    position: relative;
    z-index: 3;
    padding: 2rem 0;
}

.closing-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--charcoal);
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.closing-tagline {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    color: var(--deep-mute);
    letter-spacing: 0.1em;
}

.closing-sparkle-field {
    animation: sparkle-shimmer 5s ease-in-out infinite alternate;
    opacity: 0.5;
}

/* --- Progress Ring Animation Keyframes --- */
@keyframes ring-fill {
    from {
        stroke-dashoffset: var(--ring-circumference);
    }
    to {
        stroke-dashoffset: var(--ring-target-offset);
    }
}

/* --- Sparkle Burst Animation (on panels) --- */
@keyframes sparkle-burst {
    0% {
        box-shadow:
            inset 0 0 0 rgba(176, 160, 128, 0),
            0 0 0 rgba(176, 160, 128, 0);
    }
    50% {
        box-shadow:
            inset 0 0 20px rgba(176, 160, 128, 0.1),
            0 0 15px rgba(176, 160, 128, 0.05);
    }
    100% {
        box-shadow:
            inset 0 0 0 rgba(176, 160, 128, 0),
            0 0 0 rgba(176, 160, 128, 0);
    }
}

.dashboard-panel.is-visible {
    animation: sparkle-burst 1.5s ease-out forwards;
}

/* --- Panel Enter Animations --- */
@keyframes panel-enter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-panel {
    opacity: 0;
}

.dashboard-panel.is-visible {
    animation: panel-enter 0.6s ease-out forwards, sparkle-burst 1.5s ease-out 0.3s forwards;
}

.dashboard-panel:nth-child(1).is-visible { animation-delay: 0s, 0.3s; }
.dashboard-panel:nth-child(2).is-visible { animation-delay: 0.1s, 0.4s; }
.dashboard-panel:nth-child(3).is-visible { animation-delay: 0.2s, 0.5s; }
.dashboard-panel:nth-child(4).is-visible { animation-delay: 0.3s, 0.6s; }
.dashboard-panel:nth-child(5).is-visible { animation-delay: 0.4s, 0.7s; }
.dashboard-panel:nth-child(6).is-visible { animation-delay: 0.5s, 0.8s; }

/* --- Featured Card Enter --- */
@keyframes featured-enter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.featured-card {
    opacity: 0;
}

.featured-card.is-visible {
    animation: featured-enter 0.8s ease-out forwards;
}

/* --- Closing Fade --- */
@keyframes closing-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#closing-panel {
    opacity: 0;
}

#closing-panel.is-visible {
    animation: closing-fade 1s ease-out forwards;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #dashboard-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }

    #featured-panel {
        padding: 1rem;
    }

    .featured-stats {
        grid-template-columns: 1fr;
    }

    .chart-bars {
        height: 140px;
    }

    #hero {
        padding: 2.5rem 1rem 2rem;
    }

    .hero-title {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    .metric-value {
        font-size: 1.5rem;
    }

    .featured-stat-value {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .chart-bar-label {
        font-size: 0.6rem;
    }

    .chart-bar {
        max-width: 28px;
    }

    .panel-chrome-header {
        padding: 0.6rem 1rem;
    }

    .panel-label {
        font-size: 0.75rem;
    }
}

/* --- Bling Accent on Gold Elements --- */
.progress-ring__fill {
    filter: drop-shadow(0 0 3px rgba(176, 160, 128, 0.3));
}

.chart-bar-fill {
    box-shadow: inset 0 0 8px rgba(176, 160, 128, 0.2);
}

/* --- Selection Color --- */
::selection {
    background: var(--blush);
    color: var(--charcoal);
}
