/* 
 * Contextual Ads Protocol (CAP) - Clean Modern Aesthetic
 * Theme: Professional, Human-Centric, Trustworthy
 */

:root {
    /* Base Colors - Slate/Zinc Palette */
    --bg-page: #ffffff;
    --bg-surface: #f8fafc;
    --bg-surface-hover: #f1f5f9;
    --bg-card: #ffffff;

    /* Borders */
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Typography Colors */
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --text-on-brand: #ffffff;

    /* Brand Colors */
    --brand-primary: #4f46e5;
    /* Indigo 600 */
    --brand-hover: #4338ca;
    /* Indigo 700 */
    --brand-light: #e0e7ff;
    /* Indigo 100 */
    --brand-subtle: #eef2ff;
    /* Indigo 50 */

    /* Functional Colors */
    --success: #10b981;
    /* Emerald 500 */
    --success-bg: #ecfdf5;
    /* Emerald 50 */
    --warning: #f59e0b;
    /* Amber 500 */
    --warning-bg: #fffbeb;
    /* Amber 50 */
    --danger: #ef4444;
    /* Red 500 */
    --danger-bg: #fef2f2;
    /* Red 50 */

    /* Code Syntax Highlighting (Light Theme) */
    --code-bg: #f8fafc;
    --code-key: #7c3aed;
    /* Violet 600 */
    --code-string: #059669;
    /* Emerald 600 */
    --code-number: #d97706;
    /* Amber 600 */
    --code-comment: #94a3b8;
    /* Slate 400 */

    /* Dimensions & Effects */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Fonts */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Layout */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo span {
    color: var(--brand-primary);
}

.nav-links {
    display: flex;
    gap: 32px;
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--brand-primary);
}

/* Hero Section */
.hero {
    padding: 80px 0 60px;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 3rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 40px;
}

/* Tabs */
.demo-tabs {
    display: inline-flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 40px;
    background: var(--bg-surface);
    padding: 6px;
    border-radius: 99px;
    border: 1px solid var(--border-subtle);
    box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
}

.demo-tab {
    padding: 10px 20px;
    border-radius: 99px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
}

.demo-tab:hover {
    color: var(--text-primary);
}

.demo-tab.active {
    background: white;
    color: var(--brand-primary);
    box-shadow: var(--shadow-sm);
}

/* Panels */
.demo-panel {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.demo-panel.active {
    display: block;
}

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

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

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.1);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.1);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--brand-primary);
    color: white;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ===== DEMO COMPONENTS ===== */

/* Network Waterfall */
.waterfall-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.waterfall-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.waterfall-panel.traditional {
    border-top: 3px solid var(--danger);
}

.waterfall-panel.cap {
    border-top: 3px solid var(--success);
}

.waterfall-header {
    padding: 16px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.waterfall-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.waterfall-body {
    padding: 16px;
    min-height: 300px;
}

.waterfall-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.8rem;
}

.waterfall-row:last-child {
    border-bottom: none;
}

.waterfall-domain {
    width: 140px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.waterfall-bar-container {
    flex: 1;
    height: 20px;
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.waterfall-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    padding-left: 8px;
    font-size: 0.7rem;
    color: white;
    font-weight: 500;
}

.waterfall-bar.tracker {
    background: linear-gradient(90deg, var(--danger), #f87171);
}

.waterfall-bar.content {
    background: linear-gradient(90deg, var(--success), #34d399);
}

.waterfall-bar.fcs {
    background: linear-gradient(90deg, var(--brand-primary), #818cf8);
}

.waterfall-time {
    width: 50px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.waterfall-stats {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
}

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.danger {
    color: var(--danger);
}

.stat-value.success {
    color: var(--success);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Data Flow */
.data-flow-demo {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.flow-diagram {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 40px 0;
}

.flow-node {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid var(--border-subtle);
    position: relative;
    z-index: 2;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.flow-node.active {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px var(--brand-light);
    transform: scale(1.05);
}

.flow-node i {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.flow-node span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.flow-path {
    position: absolute;
    top: 50%;
    height: 2px;
    background: var(--border-subtle);
    z-index: 1;
}

.flow-path.path-1 {
    left: 100px;
    width: calc(25% - 50px);
}

.flow-path.path-2 {
    left: calc(25% + 50px);
    width: calc(25% - 50px);
}

.flow-path.path-3 {
    left: calc(50% + 50px);
    width: calc(25% - 50px);
}

.flow-path.path-4 {
    left: calc(75% + 50px);
    width: calc(25% - 100px);
}

.third-party-block {
    position: absolute;
    top: -20px;
    right: 20%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.blocked-tracker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--danger);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.blocked-tracker.visible {
    opacity: 1;
    transform: translateX(0);
}

.header-stream {
    background: #0f172a;
    border-radius: var(--radius-md);
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    height: 200px;
    overflow-y: auto;
    margin-top: 16px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.header-line {
    padding: 4px 0;
    opacity: 0;
    animation: streamIn 0.3s forwards;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes streamIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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

.header-line .timestamp {
    color: #64748b;
}

.header-line .direction {
    color: #f59e0b;
}

.header-line .key {
    color: #a78bfa;
}

.header-line .value {
    color: #34d399;
}

/* Trust Chain */
.trust-chain {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 48px 24px;
    position: relative;
}

.chain-connection {
    position: absolute;
    top: 50%;
    height: 3px;
    background: var(--border-subtle);
    z-index: 0;
    transition: background 0.5s;
}

.chain-connection.verified {
    background: linear-gradient(90deg, var(--success), var(--brand-primary));
}

.chain-connection.c1 {
    left: 80px;
    width: calc(25% - 60px);
}

.chain-connection.c2 {
    left: calc(25% + 20px);
    width: calc(25% - 40px);
}

.chain-connection.c3 {
    left: calc(50% + 20px);
    width: calc(25% - 40px);
}

.chain-connection.c4 {
    left: calc(75% + 20px);
    width: calc(25% - 100px);
}

.chain-node {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    transition: all 0.5s;
    box-shadow: var(--shadow-sm);
}

.chain-node.verified {
    border-color: var(--success);
    background: var(--success-bg);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.chain-node i {
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: color 0.5s;
}

.chain-node.verified i {
    color: var(--success);
}

.chain-node span {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 6px;
    color: var(--text-primary);
}

.chain-node .check-mark {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chain-node.verified .check-mark {
    opacity: 1;
    transform: scale(1);
}

/* Signature Reveal */
.signature-reveal {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-top: 24px;
    border: 1px solid var(--border-subtle);
}

.signature-reveal h4 {
    font-size: 0.9rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.signature-parts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.sig-part {
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    opacity: 0.4;
    transition: all 0.5s;
}

.sig-part.revealed {
    opacity: 1;
    border-color: var(--brand-primary);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.1);
    transform: translateY(-2px);
}

.sig-part .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sig-part .value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    word-break: break-all;
}

/* Intent Matcher */
.intent-viz {
    display: grid;
    grid-template-columns: 1fr 100px 1fr;
    gap: 24px;
    align-items: start;
}

.intent-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.match-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 80px;
}

.match-arrow i {
    font-size: 2rem;
    color: var(--brand-primary);
    animation: arrowPulse 2s infinite;
}

@keyframes arrowPulse {

    0%,
    100% {
        opacity: 0.5;
        transform: translateX(0);
    }

    50% {
        opacity: 1;
        transform: translateX(5px);
    }
}

.match-score-display {
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--success-bg);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.intent-option {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.2s;
}

.intent-option:last-child {
    border-bottom: none;
}

.intent-option:hover {
    background: var(--bg-surface-hover);
}

.intent-option.selected {
    background: var(--brand-subtle);
    border-left: 3px solid var(--brand-primary);
}

.intent-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.intent-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ad-result {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    transition: all 0.3s;
    opacity: 0;
    transform: translateX(20px);
}

.ad-result.visible {
    opacity: 1;
    transform: translateX(0);
}

.ad-result:last-child {
    border-bottom: none;
}

.ad-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.ad-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ad-score {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-bar {
    width: 60px;
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width 0.5s;
}

/* Footer */
footer {
    margin-top: 80px;
    padding: 40px 0;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--brand-primary);
}

/* Responsive */
@media (max-width: 900px) {

    .waterfall-comparison,
    .intent-viz,
    .signature-parts {
        grid-template-columns: 1fr;
    }

    .trust-chain {
        flex-direction: column;
        gap: 40px;
    }

    .chain-connection {
        display: none;
    }

    .match-arrow {
        padding-top: 0;
        margin: 24px 0;
    }

    .match-arrow i {
        transform: rotate(90deg);
    }
}
/* FCS Header Display */
.fcs-inline-header {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 16px;
    margin: 20px 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.header-line {
    display: flex;
    padding: 4px 0;
}

.header-key {
    color: #94a3b8;
    min-width: 160px;
}

.header-value {
    color: #60a5fa;
}

.attestation-log {
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    padding: 16px;
    margin: 16px 0;
    border-radius: 4px;
}

.attestation-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    font-size: 14px;
    color: #166534;
}

.attestation-entry i {
    color: #22c55e;
}

/* Session Continuity / Memory Timeline */
.memory-timeline {
    max-width: 700px;
    margin: 0 auto 40px;
}

.memory-event {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    position: relative;
}

.memory-timestamp {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #6b7280;
    background: #f9fafb;
    padding: 4px 8px;
    border-radius: 4px;
}

.memory-content {
    padding-right: 100px;
}

.memory-intent {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.memory-intent i {
    margin-right: 8px;
    color: #6366f1;
}

.memory-ad {
    color: #059669;
    font-size: 14px;
    margin-bottom: 8px;
}

.memory-meta {
    font-size: 12px;
    color: #6b7280;
    font-family: 'JetBrains Mono', monospace;
}

.memory-connection {
    width: 2px;
    height: 30px;
    background: linear-gradient(to bottom, #e5e7eb, #6366f1, #e5e7eb);
    margin: 0 auto;
}

.memory-insights {
    background: #f9fafb;
    border-radius: 12px;
    padding: 24px;
    margin-top: 40px;
}

.memory-insights h4 {
    color: #1f2937;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.insight-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.insight-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.insight-value {
    font-size: 28px;
    font-weight: 700;
    color: #6366f1;
    margin-bottom: 4px;
}

.insight-desc {
    font-size: 11px;
    color: #9ca3af;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .memory-content {
        padding-right: 0;
    }
    
    .memory-timestamp {
        position: static;
        display: inline-block;
        margin-bottom: 12px;
    }
    
    .insight-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
