@import url(
    "https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap"
);

/* =========================================================
   Variables and reset
   ========================================================= */

:root {
    --bg: #ffffff;
    --surface: #f7f4f8;
    --text: #101010;
    --muted: #66626a;
    --line: #cbc4cf;

    --accent: #9146a5;
    --accent-dark: #6e337d;
    --accent-soft: #f3eaf6;

    --result: #315c45;
    --result-soft: #edf5f0;

    --danger: #9f3f46;
    --danger-soft: #fbecee;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;

    background:
        radial-gradient(
            circle at 84% 12%,
            rgba(145, 70, 165, 0.12),
            transparent 28%
        ),
        var(--bg);

    color: var(--text);
    font-family: "Geist", sans-serif;
}

button {
    font: inherit;
}

/* =========================================================
   Page header
   ========================================================= */

.app-page {
    width: min(1400px, calc(100% - 40px));
    margin: 0 auto;
    padding: clamp(42px, 7vw, 76px) 0 100px;
}

.app-header {
    width: min(780px, 100%);
    margin: 0 auto clamp(54px, 8vw, 90px);
    text-align: center;
}

.eyebrow {
    margin: 0 0 12px;

    color: var(--accent);

    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 20px;

    font-size: clamp(38px, 6vw, 68px);
    line-height: 1;
    letter-spacing: -0.055em;
}

.app-description {
    max-width: 700px;
    margin: 0 auto;

    color: var(--muted);
    font-size: clamp(17px, 2vw, 20px);
    line-height: 1.65;
}

.restart-button {
    margin-top: 26px;
    padding: 11px 20px;

    background: #ffffff;
    color: var(--accent);

    border: 1px solid var(--accent);
    border-radius: 7px;

    font-weight: 650;
    cursor: pointer;
}

.restart-button:hover {
    background: var(--accent-soft);
}

/* =========================================================
   Decision tree
   ========================================================= */

.decision-tree {
    width: 100%;
}

.tree-level {
    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;

    opacity: 0;
    transform: translateY(-12px);

    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
}

.tree-level.visible {
    opacity: 1;
    transform: translateY(0);
}

.tree-node {
    width: min(460px, 100%);
    min-height: 130px;
    padding: 26px 30px;

    position: relative;
    z-index: 2;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    background: #ffffff;

    border: 2px solid var(--accent);
    border-radius: 14px;

    text-align: center;
}

.tree-node-statement {
    background: var(--accent);
    color: #ffffff;
}

.tree-node-question {
    background: #ffffff;
    color: var(--text);
}

.tree-node-result {
    background: var(--result-soft);
    color: var(--result);
    border-color: var(--result);
}

.result-restart-button {
    margin-top: 22px;
    padding: 10px 18px;

    background: transparent;
    color: currentColor;

    border: 1px solid currentColor;
    border-radius: 7px;

    font-family: "Geist", sans-serif;
    font-size: 14px;
    font-weight: 650;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        color 0.2s ease;
}

.tree-node-prioritise_conversion,
.tree-node-do_not_launch {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger);
}

.tree-node-prioritise_conversion .node-type,
.tree-node-do_not_launch .node-type {
    color: var(--danger);
}

.tree-node-prioritise_conversion .result-restart-button:hover,
.tree-node-do_not_launch .result-restart-button:hover {
    background: var(--danger);
    color: #ffffff;
}

.result-restart-button:hover {
    transform: translateY(-2px);
    background: var(--result);
    color: #ffffff;
}

.node-type {
    margin-bottom: 10px;

    color: var(--accent);

    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tree-node-statement .node-type {
    color: rgba(255, 255, 255, 0.76);
}

.tree-node-result .node-type {
    color: var(--result);
}

.node-text {
    margin: 0;

    font-size: clamp(17px, 2vw, 21px);
    font-weight: 600;
    line-height: 1.45;
}

/* =========================================================
   Branches and connectors
   ========================================================= */

.tree-branches {
    width: min(1050px, 100%);
    padding-top: 62px;

    position: relative;

    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(18px, 4vw, 60px);
}

/* Vertical stem from the parent node. */
.tree-branches::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;

    width: 2px;
    height: 31px;

    background: var(--line);
    transform: translateX(-50%);
}

/* Horizontal line joining multiple options. */
.tree-branches::after {
    content: "";
    position: absolute;
    top: 30px;
    left: calc(100% / (var(--branch-count, 2) * 2));
    right: calc(100% / (var(--branch-count, 2) * 2));

    height: 2px;
    background: var(--line);
}

.tree-branch {
    min-width: 0;
    flex: 1;

    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;

    transition:
        opacity 0.25s ease,
        filter 0.25s ease;
}

.branch-connector {
    position: absolute;
    top: -32px;
    left: 50%;

    width: 2px;
    height: 33px;

    background: var(--line);
    transform: translateX(-50%);
}

.branch-button {
    min-width: 130px;
    min-height: 48px;
    padding: 11px 18px;

    position: relative;
    z-index: 2;

    background: #ffffff;
    color: var(--accent);

    border: 2px solid var(--accent);
    border-radius: 999px;

    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        color 0.2s ease;
}

.branch-button:hover:not(:disabled) {
    transform: translateY(-3px);
    background: var(--accent-soft);
}

.branch-button.selected {
    background: var(--accent);
    color: #ffffff;
}

.tree-branch.not-selected {
    opacity: 0.28;
    filter: grayscale(1);
}

.branch-button:disabled {
    cursor: default;
}

.branch-child {
    width: 100%;
    margin-top: 38px;

    position: relative;

    display: flex;
    justify-content: center;
}

/* Connector below the selected answer. */
.tree-branch.selected > .branch-child::before {
    content: "";
    position: absolute;
    top: -38px;
    left: 50%;

    width: 2px;
    height: 38px;

    background: var(--accent);
    transform: translateX(-50%);
}

.branch-child .tree-level {
    min-width: 280px;
}

/* =========================================================
   Messages
   ========================================================= */

.loading-message,
.error-message {
    width: min(600px, 100%);
    margin: 0 auto;
    padding: 20px;

    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;

    color: var(--muted);
    text-align: center;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 760px) {
    .app-page {
        width: min(100% - 24px, 680px);
        padding-top: 32px;
    }

    .app-header {
        margin-bottom: 52px;
    }

    .tree-node {
        width: min(390px, 100%);
        min-height: 112px;
        padding: 22px;
    }

    .tree-branches {
        padding-top: 52px;
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }

    .tree-branches::before {
        height: 52px;
    }

    .tree-branches::after,
    .branch-connector {
        display: none;
    }

    .tree-branch {
        width: 100%;
    }

    .branch-button {
        width: min(280px, 100%);
    }

    .tree-branch.not-selected {
        display: none;
    }

    .branch-child {
        margin-top: 34px;
    }

    .tree-branch.selected > .branch-child::before {
        top: -34px;
        height: 34px;
    }

    .branch-child .tree-level {
        min-width: 0;
        width: 100%;
    }
}