/* ==========================================================================
   daitoua.quest - Strategic Intelligence Observatory
   Navy Metallic / Swiss Grid / Border-Animate
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0C1222;
    --bg-secondary: #142035;
    --border-default: #2A3A5C;
    --border-active: #8EADD4;
    --accent-cyan: #3FD4E7;
    --accent-brass: #D4A853;
    --text-primary: #E8EDF3;
    --text-secondary: #8A9BB5;
    --success: #2ECE8B;
    --alert: #F0A830;
    --text-body-light: #1B2838;
    --text-body-dark: #C8D6E5;
    --dot-color: #1A2740;
    --border-angle: 0deg;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Dot Grid Background --- */
.dot-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 800ms ease-out;
    background-image:
        radial-gradient(circle, var(--dot-color) 1px, transparent 1px),
        linear-gradient(to right, var(--dot-color) 16px, transparent 16px),
        linear-gradient(to bottom, var(--dot-color) 16px, transparent 16px);
    background-size:
        32px 32px,
        128px 128px,
        128px 128px;
    background-position:
        0 0,
        0 0,
        0 0;
    /* Only the dot pattern is visible; crosshair lines handled via separate background layer */
}

.dot-grid.visible {
    opacity: 0.02;
}

/* Crosshair overlay at every 128px intersection */
.dot-grid::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, rgba(26, 39, 64, 0.05) 0px, rgba(26, 39, 64, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(26, 39, 64, 0.05) 0px, rgba(26, 39, 64, 0.05) 1px, transparent 1px);
    background-size: 128px 128px;
    background-position: 56px 56px;
    pointer-events: none;
}

/* --- Fixed Label (Top Left) --- */
.fixed-label {
    position: fixed;
    top: 20px;
    left: 24px;
    z-index: 100;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-variant: small-caps;
}

/* --- Nav Trigger (Top Right) --- */
.nav-trigger {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 100;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    gap: 4px;
    padding: 8px;
}

.nav-trigger .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    transition: background-color 300ms ease;
}

.nav-trigger:hover .dot {
    background-color: var(--accent-cyan);
}

/* --- Overlay Nav --- */
.overlay-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 90;
    background: rgba(12, 18, 34, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 400ms ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.overlay-nav.active {
    opacity: 1;
    pointer-events: all;
}

.overlay-nav nav {
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: center;
}

.overlay-nav nav a {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(24px, 4vw, 40px);
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: color 300ms ease;
}

.overlay-nav nav a:hover {
    color: var(--accent-cyan);
}

/* --- Hero Section --- */
.hero {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hero-content {
    opacity: 0;
    animation: heroFadeIn 1s ease-out 300ms forwards;
}

.hero-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(40px, 6vw, 96px);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 16px;
}

.hero-tagline {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    color: var(--text-secondary);
    opacity: 0;
    animation: heroFadeIn 800ms ease-out 1700ms forwards;
}

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

/* --- Card Grid Wrapper --- */
.card-grid-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 48px 96px;
}

/* --- Section Divider --- */
.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-default), transparent);
    margin-bottom: 48px;
    position: relative;
    overflow: hidden;
}

.section-divider::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, #4B6A8D, transparent);
    transform: translateX(-100%);
    animation: none;
}

.section-divider.visible::after {
    animation: dividerSweep 1.2s ease-out forwards;
}

@keyframes dividerSweep {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

/* --- Card Row Layouts --- */
.card-row {
    display: grid;
    gap: 24px;
    margin-bottom: 48px;
}

.row-3col {
    grid-template-columns: repeat(3, 1fr);
}

.row-2-1 {
    grid-template-columns: 2fr 1fr;
}

.row-1-2 {
    grid-template-columns: 1fr 2fr;
}

.row-4col {
    grid-template-columns: repeat(4, 1fr);
}

.row-full {
    grid-template-columns: 1fr;
}

/* --- Card Base --- */
.card {
    position: relative;
    border-radius: 2px;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Animated Border (Conic Gradient Approach) --- */
.card-border-anim {
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 2px;
    background: var(--border-default);
    z-index: 0;
    transition: background 300ms ease;
}

.card:hover .card-border-anim {
    background: conic-gradient(
        from var(--border-angle, 0deg) at 0% 0%,
        var(--border-active) 0deg,
        var(--border-active) 90deg,
        var(--border-default) 180deg,
        var(--border-default) 360deg
    );
    animation: borderSpin 600ms linear forwards;
}

@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@keyframes borderSpin {
    from { --border-angle: 0deg; }
    to { --border-angle: 360deg; }
}

/* Fallback for browsers without @property support */
.no-at-property .card:hover .card-border-anim {
    background: var(--border-active);
    animation: none;
}

/* --- Card Inner --- */
.card-inner {
    position: relative;
    z-index: 1;
    background: var(--bg-secondary);
    border-radius: 2px;
    padding: 32px;
    height: 100%;
}

/* --- Corner Accents --- */
.corner-accent {
    position: absolute;
    width: 8px;
    height: 8px;
    z-index: 2;
}

.corner-accent.top-left {
    top: 8px;
    left: 8px;
    border-top: 1px solid rgba(63, 212, 231, 0.4);
    border-left: 1px solid rgba(63, 212, 231, 0.4);
}

.corner-accent.bottom-right {
    bottom: 8px;
    right: 8px;
    border-bottom: 1px solid rgba(63, 212, 231, 0.4);
    border-right: 1px solid rgba(63, 212, 231, 0.4);
}

/* --- Card Typography --- */
.card-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-brass);
    margin-bottom: 12px;
}

.card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(18px, 2vw, 28px);
    letter-spacing: -0.03em;
    line-height: 1.25;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.card-body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-body-dark);
    margin-bottom: 16px;
}

/* --- Sparkline --- */
.sparkline-container {
    margin-top: 12px;
}

.sparkline {
    width: 80px;
    height: 24px;
    display: block;
}

.sparkline-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease-out;
}

.card.visible .sparkline-path {
    stroke-dashoffset: 0;
}

/* --- Radial Ring --- */
.radial-ring-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 16px auto 0;
}

.radial-ring-container.small-ring {
    width: 80px;
    height: 80px;
    margin: 12px 0 0;
}

.small-ring .radial-ring {
    width: 80px;
    height: 80px;
}

.small-ring .ring-value {
    font-size: 18px;
}

.radial-ring {
    width: 120px;
    height: 120px;
}

.ring-fg {
    transition: stroke-dashoffset 1.2s ease-out;
}

.ring-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 32px;
    color: var(--text-primary);
}

/* --- Metric Card --- */
.card-metric .card-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 32px;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.metric-trend {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 0.02em;
    margin-top: 8px;
}

.metric-trend.positive {
    color: var(--success);
}

.metric-trend.alert {
    color: var(--alert);
}

.metric-trend.neutral {
    color: var(--text-secondary);
}

/* --- Area Chart --- */
.area-chart-container {
    margin-top: 16px;
    width: 100%;
    height: 120px;
    overflow: hidden;
}

.area-chart {
    width: 100%;
    height: 100%;
}

.area-path {
    opacity: 0;
    transition: opacity 1s ease-out;
}

.card.visible .area-path {
    opacity: 1;
}

.area-path.area-cyan {
    fill: rgba(63, 212, 231, 0.15);
}

.area-path.area-brass {
    fill: rgba(212, 168, 83, 0.12);
}

.area-path.area-teal {
    fill: rgba(46, 206, 139, 0.10);
}

/* --- Conclusion Card --- */
.card-conclusion .card-inner {
    padding: 80px 48px;
    text-align: center;
}

.conclusion-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 24px;
    line-height: 1.5;
    color: var(--text-primary);
    max-width: 800px;
    margin: 0 auto;
    letter-spacing: -0.01em;
}

/* --- Featured Card Variant (Brass border) --- */
.card.featured .card-border-anim {
    background: var(--accent-brass);
}

/* --- Responsive: Tablet --- */
@media (max-width: 1199px) {
    .card-grid-wrapper {
        padding: 0 32px 72px;
    }

    .card-row {
        gap: 20px;
    }

    .row-3col {
        grid-template-columns: repeat(2, 1fr);
    }

    .row-4col {
        grid-template-columns: repeat(2, 1fr);
    }

    .row-2-1,
    .row-1-2 {
        grid-template-columns: 1fr;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 767px) {
    .card-grid-wrapper {
        padding: 0 16px 48px;
    }

    .card-row {
        gap: 16px;
        margin-bottom: 32px;
    }

    .row-3col,
    .row-4col,
    .row-2-1,
    .row-1-2 {
        grid-template-columns: 1fr;
    }

    .card-inner {
        padding: 24px;
    }

    .card-conclusion .card-inner {
        padding: 48px 24px;
    }

    .conclusion-text {
        font-size: 20px;
    }

    .metric-value {
        font-size: 28px;
    }

    .fixed-label {
        font-size: 11px;
        top: 16px;
        left: 16px;
    }

    .nav-trigger {
        top: 16px;
        right: 16px;
    }
}
