/* =========================================
   Generic CSS Variable Theme System
   All color/styling variables use generic
   role-agnostic names. Override via JSON.
   ========================================= */
:root {
    --color-bg: #f4f7f8;
    --color-surface: #003349;
    --color-primary: #00a99d;
    --color-accent: #f39c12;
    --color-hover: #8bb38d;
    --color-text: #333;
    --transition-speed: 0.8s;
    --bg-gradient: linear-gradient(to bottom, var(--color-accent) 0%, var(--color-primary) 100%);

    /* Simple default SVG watermark — a clean hexagon */
    --svg-default: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,5 95,27.5 95,72.5 50,95 5,72.5 5,27.5' fill='black'/%3E%3C/svg%3E");

    /* Palette-swappable values (overridden per theme via JSON) */
    --theme-text: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --mask-opacity: 0.25;
    --node-bg: var(--color-surface);
    --node-text: #e2e8f0;
    --node-hover-bg: #ffffff;
    --node-hover-text: var(--color-surface);
    --hover-text: #06202a;
    --hover-bg: #ffffff;
    --hover-border: #111827;
    --hero-h1: #f8fafc;
    --hero-text: #94a3b8;
    --boundary-bg: rgba(251, 191, 36, 0.15);
    --boundary-border: #fbbf24;
    --boundary-text: #fde68a;

    /* Repeating honeycomb lattice wallpaper (SVG mask; stroke color follows text) */
    --bg-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2217.32%22%20height%3D%2230.00%22%20viewBox%3D%220%200%2017.32%2030.00%22%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%220.8%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M%200.00%2C-10.00%20L%208.66%2C-5.00%20L%208.66%2C5.00%20L%200.00%2C10.00%20L%20-8.66%2C5.00%20L%20-8.66%2C-5.00%20Z%20M%208.66%2C5.00%20L%2017.32%2C10.00%20L%2017.32%2C20.00%20L%208.66%2C25.00%20L%200.00%2C20.00%20L%200.00%2C10.00%20Z%20M%200.00%2C20.00%20L%208.66%2C25.00%20L%208.66%2C35.00%20L%200.00%2C40.00%20L%20-8.66%2C35.00%20L%20-8.66%2C25.00%20Z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
    --bg-pattern-opacity: 0.07;
    --pattern-tile-w: 150px;
    --pattern-tile-h: 260px;
}

body,
html {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    height: 100vh;
    overflow: hidden;
}

.presentation-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-behavior: smooth;
}

.scene {
    min-height: 100vh;
    width: 100vw;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 10vh 0;
}

/* Repeating honeycomb lattice wallpaper across every scene:
   hex strokes intersected with a center vignette, so the lattice
   becomes edge/corner detail and the content area stays clean.
   --pattern-offset-y is set per scene by the renderer to keep the
   tile grid continuous across scene boundaries. */
.scene::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--color-text);
    --pattern-vignette: radial-gradient(
        ellipse 90% 80% at 50% 50%,
        transparent 0%,
        transparent 45%,
        #000 100%
    );
    -webkit-mask-image: var(--bg-pattern, none), var(--pattern-vignette);
    mask-image: var(--bg-pattern, none), var(--pattern-vignette);
    -webkit-mask-size: var(--pattern-tile-w, 150px) var(--pattern-tile-h, 260px), 100% 100%;
    mask-size: var(--pattern-tile-w, 150px) var(--pattern-tile-h, 260px), 100% 100%;
    -webkit-mask-repeat: repeat, no-repeat;
    mask-repeat: repeat, no-repeat;
    -webkit-mask-position: 0 var(--pattern-offset-y, 0), 0 0;
    mask-position: 0 var(--pattern-offset-y, 0), 0 0;
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
    opacity: var(--bg-pattern-opacity, 0.06);
    pointer-events: none;
    z-index: 0;
}

/* =========================================
   SCENE BACKGROUND — dark with watermark
   ========================================= */
.scene-dark {
    background-color: var(--color-scene-dark, #141414);
    position: relative;
    overflow: hidden;
}

.scene-dark::before {
    content: "";
    position: absolute;
    top: 50%;
    left: var(--mask-left, auto);
    right: var(--mask-right, auto);
    transform: translateY(-50%);
    width: 52vmin;
    height: 52vmin;
    max-width: 600px;
    background: var(--bg-gradient);

    -webkit-mask-image: var(--mask-url, var(--svg-default));
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;

    opacity: var(--mask-opacity, 0.25);
    pointer-events: none;
    z-index: 1;
}

/* Blinking terminal-prompt cursor on the watermark.
   Same proven blink pattern as the hero terminal: base opacity 0,
   ::after content glyph, term-blink keyframes, active-scene gated. */
.watermark-cursor {
    position: absolute;
    top: 50%;
    left: var(--mask-left, auto);
    right: var(--mask-right, auto);
    transform: translateY(-50%);
    width: 52vmin;
    max-width: 600px;
    height: 52vmin;
    pointer-events: none;
    z-index: 1;
    /* Match the watermark's dimming so the cursor reads as part of it */
    opacity: var(--mask-opacity, 0.25);
}

.watermark-cursor::after {
    content: "_";
    position: absolute;
    left: 68%;
    top: 72%;
    color: var(--color-accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: min(9vmin, 105px);
    font-weight: 700;
    line-height: 1;
    opacity: 0;
}

.scene.is-active .watermark-cursor::after {
    animation: term-blink 1s infinite;
}

.scene-dark .scene-content {
    position: relative;
    z-index: 10;
}

/* =========================================
   SCENE BACKGROUND — light with watermark
   ========================================= */
.scene-light {
    background-color: var(--color-bg);
    position: relative;
    overflow: hidden;
}

.scene-light::before {
    content: "";
    position: absolute;
    top: 50%;
    left: var(--mask-left, auto);
    right: var(--mask-right, auto);
    transform: translateY(-50%);
    width: 60vmin;
    height: 60vmin;
    max-width: 700px;
    background: var(--bg-gradient);

    --mask-scanlines: repeating-linear-gradient(
        to bottom,
        black 0, black 2px,
        transparent 2px, transparent 4px
    );
    -webkit-mask-image: var(--mask-url, var(--svg-default)), var(--mask-scanlines);
    -webkit-mask-size: contain, 100% 100%;
    -webkit-mask-repeat: no-repeat, repeat;
    -webkit-mask-composite: source-in;
    mask-composite: intersect;

    opacity: 0.35;
    pointer-events: none;
    z-index: 1;
}

.scene-light .scene-content {
    position: relative;
    z-index: 10;
}

/* =========================================
   LOGO
   ========================================= */
.company-logo {
    position: fixed;
    top: 2rem;
    right: 0;
    width: 80px;
    height: 80px;
    object-fit: contain;
    z-index: 100;
}

/* =========================================
   LAYOUT SYSTEM
   ========================================= */
.scene-content {
    display: flex;
    width: 90%;
    max-width: 1400px;
    gap: 4rem;
    z-index: 10;
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--transition-speed) ease-out;
    box-sizing: border-box;
    padding: 3rem;
    border-radius: 24px;
    background: var(--color-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.scene.is-active .scene-content {
    opacity: 1;
    transform: translateY(0);
}

.col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.col-highlight { flex: 0.8; }

.col-text {
    flex: 1.2;
    font-size: 1.1rem;
    line-height: 1.6;
}

.col-media {
    flex: 0.8;
    align-items: center;
    gap: 2rem;
}

.layout-reversed .col-media   { order: 1; }
.layout-reversed .col-text    { order: 2; }
.layout-reversed .col-highlight {
    order: 3;
    text-align: right;
}

.layout-image-only .col-highlight { display: none; }
.layout-image-only .col-text      { flex: 1; }
.layout-image-only .col-media     { flex: 1; }

/* Hide the media column when a scene has no bubbles or image */
.col-media { display: none; }
.col-media:has(.bubble),
.col-media:has(.large-image) { display: flex; }

/* =========================================
   COMPONENTS
   ========================================= */
h1.huge-highlight {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 0;
    color: var(--color-accent);
}

.bubble {
    width: 150px;
    height: 150px;
    box-sizing: border-box;
    background-color: var(--color-surface);
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.bubble:hover {
    transform: scale(1.05);
    background-color: var(--hover-bg, #ffffff);
    border-color: var(--hover-border, #111827);
    color: var(--hover-text, #06202a);
}

.bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.large-image {
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.keyword {
    font-weight: bold;
    color: var(--color-accent);
    border-bottom: 2px dashed var(--color-accent);
    position: relative;
    padding: 0 4px;
}

.line-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

/* =========================================
   MODALS
   ========================================= */
dialog {
    border: none;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: left;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.close-modal {
    margin-top: 1.5rem;
    padding: 0.5rem 1rem;
    background: #e2e8f0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.modal-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1.5rem auto;
    display: block;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    border: 3px solid var(--color-accent);
}

/* =========================================
   HERO
   ========================================= */
.hero {
    color: var(--color-hover);
    flex-direction: column;
}

.hero h1 {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.theme-dark.hero {
    color: var(--hero-text, #94a3b8);
}

.theme-dark.hero h1 {
    color: var(--hero-h1, #f8fafc);
}

.hero-status {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-accent);
    opacity: 0.9;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #34d399;
    animation: status-pulse 2.4s ease-out infinite;
}

@keyframes status-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
    70%  { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* =========================================
   THEME TOGGLE
   ========================================= */
.theme-toggle {
    position: fixed;
    top: 1.1rem;
    right: 1.1rem;
    z-index: 100;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(15, 23, 42, 0.72);
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: border-color 0.2s, color 0.2s, transform 0.2s;
}

.theme-toggle:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
}

@media (max-width: 900px) {
    .theme-toggle {
        top: 0.8rem;
        right: 0.8rem;
        padding: 0.4rem 0.7rem;
    }
}

/* =========================================
   HERO TERMINAL
   ========================================= */
.hero-terminal {
    margin-top: 2.2rem;
    width: min(560px, 92vw);
    background: rgba(8, 12, 18, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 20px 45px -20px rgba(0, 0, 0, 0.65);
    text-align: left;
    overflow: hidden;
}

.term-title {
    padding: 0.6rem 1rem;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.term-body {
    padding: 0.9rem 1rem 1.1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre;
    color: #cbd5e1;
    min-height: 7.5em;
    display: flex;
    flex-direction: column;
}

.term-line { min-height: 1.55em; }

.term-prompt { color: var(--color-accent); font-weight: 700; }

.term-out { color: #94a3b8; }

.term-cursor {
    margin-left: 2px;
    color: var(--color-accent);
    animation: term-blink 1s infinite;
}

@keyframes term-blink {
    0%, 40%  { opacity: 0; }
    50%, 90% { opacity: 1; }
    100%     { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .term-cursor::after,
    .status-dot,
    .watermark-cursor::after {
        animation: none;
    }
}

/* =========================================
   TREE DIAGRAM
   ========================================= */
.tree {
    display: flex;
    justify-content: center;
    width: 100%;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    display: flex;
    justify-content: center;
    padding-left: 0;
}

.tree li {
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 10px 0 10px;
}

.tree-node {
    display: inline-block;
    box-sizing: border-box;
    padding: 15px 25px;
    background-color: #cbd5e1;
    color: var(--color-text);
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    border: 2px solid var(--color-accent);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    cursor: pointer;
}

.tree-node:hover {
    transform: translateY(-3px);
    background-color: var(--hover-bg, #ffffff);
    border-color: var(--hover-border, #111827);
    color: var(--hover-text, #06202a);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Connector lines */
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid var(--color-accent);
    width: 50%;
    height: 20px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid var(--color-accent);
}

.tree li:only-child::after,
.tree li:only-child::before { display: none; }
.tree li:only-child { padding-top: 0; }
.tree li:first-child::before,
.tree li:last-child::after { border: 0 none; }
.tree li:last-child::before {
    border-right: 2px solid var(--color-accent);
    border-radius: 0 5px 0 0;
}
.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}
.tree ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(50% - 1px);
    border-left: 2px solid var(--color-accent);
    width: 0;
    height: 20px;
}

/* =========================================
   PIPELINE FLOW
   ========================================= */
.layout-wide .scene-content.flex-column {
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.pipeline-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 2rem;
}

.pipeline-flow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    position: relative;
    padding: 40px 0;
}

.pipeline-flow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-accent);
    z-index: 1;
    transform: translateY(-50%);
}

.flow-step {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.flow-node {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    background: #cbd5e1;
    color: var(--color-surface);
    font-weight: bold;
    border-radius: 12px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    text-align: center;
    min-width: 140px;
    border: 2px solid var(--color-accent);
    position: relative;
}

.flow-node:hover {
    transform: translateY(-5px);
    background: var(--node-hover-bg, #ffffff);
    border-color: var(--hover-border, #111827);
    color: var(--node-hover-text, #111827);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Security boundary step: amber dashed ring */
.flow-node.boundary {
    background: rgba(251, 191, 36);
    border: 2px dashed #fbbf24;
    color: #fde68a;
}

.flow-node.boundary:hover {
    background: rgba(251, 191, 36);
    border-color: #fbbf24;
    color: #fde68a;
}

.flow-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-primary);
    font-weight: bold;
}

.flow-node::after {
    content: '▶';
    position: absolute;
    right: -25px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-accent);
    font-size: 12px;
    pointer-events: none;
}

.flow-step:last-child .flow-node::after {
    display: none;
}

@media (max-width: 900px) {
    .pipeline-flow {
        flex-direction: column;
        gap: 3rem;
    }
    .pipeline-flow::before {
        width: 2px;
        height: 100%;
        left: 50%;
        top: 0;
        transform: translateX(-50%);
    }
    .flow-node::after {
        content: '▼';
        right: auto;
        bottom: -30px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* =========================================
   MOBILE FIRST
   ========================================= */
@media (max-width: 900px) {
    .scene {
        padding: 6vh 0;
    }

    .scene-content {
        flex-direction: column;
        gap: 2rem;
        padding: 1.5rem;
        width: 92%;
    }

    .col,
    .col-highlight,
    .col-text,
    .col-media {
        flex: none;
        width: 100%;
    }

    .layout-reversed .col-media { order: 0; }
    .layout-reversed .col-text  { order: 1; }
    .layout-reversed .col-highlight { order: 2; text-align: left; }

    h1.huge-highlight {
        font-size: 2.4rem;
    }

    .hero h1 {
        font-size: 2.6rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .bubble {
        width: 120px;
        height: 120px;
    }

    .term-body {
        font-size: 0.75rem;
        min-height: 6.5em;
    }

    .flow-node {
        min-width: 0;
        width: 100%;
    }

    .flow-step {
        width: 100%;
    }

    .tree ul {
        flex-direction: column;
        align-items: center;
    }

    .tree li::before,
    .tree li::after,
    .tree ul::before {
        display: none;
    }

    .tree li {
        padding: 6px 0;
    }

    .scene-tracker {
        gap: 0.5rem;
        padding: 0.6rem 1rem;
    }

    .tracker-dot {
        width: 10px;
        height: 10px;
    }

    .tracker-dot::after {
        display: none;
    }
}

/* =========================================
   DARK THEME UTILITIES
   ========================================= */
.theme-dark {
    color: var(--theme-text, #ffffff);
}

.theme-dark .huge-highlight {
    color: var(--color-accent);
}

.theme-dark h2 {
    color: var(--theme-text, #ffffff);
}

.theme-dark .keyword {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.theme-dark .scene-content {
    background: var(--card-bg, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--card-border, rgba(255, 255, 255, 0.1));
    color: var(--theme-text, #ffffff);
}

.theme-dark .flow-node {
    background: var(--node-bg, var(--color-surface));
    color: var(--node-text, #e2e8f0);
}

.theme-dark .flow-node:hover {
    background: var(--node-hover-bg, #ffffff);
    color: var(--node-hover-text, var(--color-surface));
}

/* Security boundary step: amber dashed ring, palette-aware */
.theme-dark .flow-node.boundary,
.theme-dark .flow-node.boundary:hover {
    background: var(--boundary-bg, rgba(251, 191, 36, 0.15));
    border: 2px dashed var(--boundary-border, #fbbf24);
    color: var(--boundary-text, #fde68a);
}

.theme-dark .tree-node {
    background: var(--node-bg, var(--color-surface));
    color: var(--node-text, #e2e8f0);
}

/* =========================================
   TRACKER
   ========================================= */
.scene-tracker {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    max-width: min(90vw, 760px);
    background: rgba(255, 255, 255, 0.7);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.tracker-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #cbd5e1;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.tracker-dot:hover { background: #94a3b8; }

.tracker-dot.is-active {
    background: var(--color-accent);
    transform: scale(1.4);
}

.tracker-dot::after {
    content: attr(data-title);
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #1e293b;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.tracker-dot:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
