/* The 8 Ball page (/8ball): the ball, its start screen, the progress while it works and the figures under an answer.
   Colours come from the portal's palette (MudBlazor variables) so the page follows the light and the dark theme. */

.eb-page {
    --eb-accent: var(--mud-palette-primary, #0c5b33);
    --eb-ink: var(--mud-palette-text-primary, #1d2329);
    --eb-muted: var(--mud-palette-text-secondary, #5f6b76);
    --eb-surface: var(--mud-palette-surface, #fff);
    --eb-line: var(--mud-palette-lines-default, rgba(0, 0, 0, .12));
    --eb-soft: color-mix(in srgb, var(--eb-accent) 7%, var(--eb-surface));
    display: flex;
    flex-direction: column;
    /* The page fits the window: only the conversation scrolls, the question box stays in view. 12px is the
       bottom padding of the portal's main content. */
    height: calc(100dvh - var(--mud-appbar-height, 64px) - 12px);
    min-height: 560px;
}

/* The bar: the small ball, the name, and which model answers. */
.eb-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 10px 20px;
    border-bottom: 1px solid var(--eb-line);
}
.eb-bar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.eb-bar-title h1 { font: 700 20px/1.2 Sora, 'Plus Jakarta Sans', sans-serif; margin: 0; color: var(--eb-ink); }
.eb-bar-sub { font-size: 12.5px; color: var(--eb-muted); }
.eb-models { display: flex; gap: 6px; flex-wrap: wrap; }
.eb-model {
    display: inline-flex; align-items: center; gap: 4px;
    border: 1px solid var(--eb-line); background: var(--eb-surface); color: var(--eb-ink);
    border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.eb-model:hover { border-color: var(--eb-accent); }
.eb-model.is-on { background: var(--eb-accent); border-color: var(--eb-accent); color: #fff; }
.eb-model:focus-visible, .eb-starter:focus-visible, .eb-brief:focus-visible, .eb-action:focus-visible, .eb-recent-item:focus-visible {
    outline: 2px solid var(--eb-accent); outline-offset: 2px;
}

.eb-chat { flex: 1; min-height: 0; display: flex; }
.eb-chat > * { flex: 1; min-width: 0; }

/* The chat panel fills what the bar leaves (its page height assumes no bar above it), and the answers use the
   whole width: they hold tables and figures. The question box stays a readable width. */
.eb-page .dac--page { height: 100%; min-height: 0; }
.eb-page .dac { --dac-thread-width: 100%; --dac-gutter: 32px; }
.eb-page .dac__composer-inner { max-width: 1100px; }

/* The start screen. */
.eb-welcome { max-width: 920px; margin: 8px auto 24px; padding: 0 16px; text-align: center; }
.eb-greeting { font: 700 28px/1.2 Sora, 'Plus Jakarta Sans', sans-serif; margin: 4px 0 6px; color: var(--eb-ink); }
.eb-lead { max-width: 640px; margin: 0 auto 18px; color: var(--eb-muted); font-size: 14.5px; line-height: 1.55; }

.eb-brief {
    display: flex; align-items: center; gap: 14px; width: 100%; max-width: 720px; margin: 0 auto 16px;
    padding: 14px 18px; text-align: left; cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--eb-accent) 35%, transparent); border-radius: 14px;
    background: linear-gradient(120deg, var(--eb-soft), var(--eb-surface));
    color: var(--eb-ink); transition: transform .15s ease, box-shadow .15s ease;
}
.eb-brief:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(12, 91, 51, .14); }
.eb-brief-icon {
    display: grid; place-items: center; width: 40px; height: 40px; flex: none;
    border-radius: 12px; background: var(--eb-accent); color: #fff;
}
.eb-brief-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.eb-brief-text strong { font-size: 15.5px; }
.eb-brief-text span { font-size: 13px; color: var(--eb-muted); }
.eb-brief-go { color: var(--eb-accent); }

.eb-starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; text-align: left; }
.eb-starter {
    display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; cursor: pointer;
    border: 1px solid var(--eb-line); border-radius: 12px; background: var(--eb-surface); color: var(--eb-ink);
    text-align: left; transition: border-color .15s ease, transform .15s ease;
}
.eb-starter:hover { border-color: var(--eb-accent); transform: translateY(-1px); }
.eb-starter-hint { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--eb-accent); }
.eb-starter-text { font-size: 13.5px; line-height: 1.4; }

.eb-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; margin: 18px 0 0; font-size: 13px; }
.eb-links a { display: inline-flex; align-items: center; gap: 5px; color: var(--eb-accent); text-decoration: none; }
.eb-links a:hover { text-decoration: underline; }
.eb-recent { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; }
.eb-recent-label { font-size: 12px; color: var(--eb-muted); margin-right: 4px; }
.eb-recent-item {
    border: 1px dashed var(--eb-line); border-radius: 999px; background: none; color: var(--eb-ink);
    padding: 4px 12px; font-size: 12.5px; cursor: pointer; max-width: 360px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eb-recent-item:hover { border-color: var(--eb-accent); }

/* The ball. */
.eb-orb { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; }
.eb-orb-svg { width: 168px; height: 168px; overflow: visible; }
.eb-orb.is-small .eb-orb-svg { width: 40px; height: 40px; }
.eb-orb.is-small .eb-orbit, .eb-orb.is-small .eb-orb-glow { display: none; }
.eb-eight { font: 800 36px/1 Sora, 'Plus Jakarta Sans', sans-serif; fill: #111; }
.eb-face-window { opacity: 0; }
.eb-orb.is-thinking .eb-face-eight { opacity: 0; transition: opacity .35s ease; }
.eb-orb.is-thinking .eb-face-window { opacity: 1; transition: opacity .35s ease .2s; }
.eb-link { stroke: var(--eb-accent, #0c5b33); stroke-width: 1.4; stroke-dasharray: 3 7; opacity: .35; }
.eb-node { fill: var(--eb-surface, #fff); stroke: var(--eb-accent, #0c5b33); stroke-width: 2.5; }
.eb-orbit { transform-origin: 120px 120px; }
.eb-orb.is-idle .eb-ball { animation: eb-float 5s ease-in-out infinite; transform-origin: 120px 120px; }
.eb-orb.is-idle .eb-orbit { animation: eb-spin 40s linear infinite; }
.eb-orb.is-thinking .eb-ball { animation: eb-shake .9s ease-in-out 2, eb-float 2.4s ease-in-out .9s infinite; transform-origin: 120px 120px; }
.eb-orb.is-thinking .eb-orbit { animation: eb-spin 9s linear infinite; }
.eb-orb.is-thinking .eb-link { opacity: .9; animation: eb-pulse 1.1s linear infinite; }
.eb-orb.is-thinking .eb-node { animation: eb-node 1.6s ease-in-out infinite; }
.eb-orb.is-thinking .eb-node:nth-of-type(2) { animation-delay: .4s; }
.eb-orb.is-thinking .eb-node:nth-of-type(3) { animation-delay: .8s; }
.eb-orb.is-thinking .eb-node:nth-of-type(4) { animation-delay: 1.2s; }
.eb-orb.is-thinking .eb-triangle { animation: eb-rise 2.6s ease-in-out infinite; transform-origin: 120px 120px; }

.eb-orb-stage { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 38px; }
.eb-orb-stage-text { font-weight: 700; font-size: 14px; color: var(--eb-ink, #1d2329); animation: eb-fade .4s ease; }
.eb-orb-stage-detail { font-size: 12px; color: var(--eb-muted, #5f6b76); max-width: 420px; text-align: center; }

.eb-progress { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 8px; }
.eb-answering { font-size: 12.5px; color: var(--eb-muted); }

@keyframes eb-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes eb-spin { to { transform: rotate(360deg); } }
@keyframes eb-shake {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    20% { transform: translate(-6px, 2px) rotate(-6deg); }
    40% { transform: translate(6px, -2px) rotate(5deg); }
    60% { transform: translate(-4px, 1px) rotate(-3deg); }
    80% { transform: translate(3px, -1px) rotate(2deg); }
}
@keyframes eb-pulse { to { stroke-dashoffset: -20; } }
@keyframes eb-node { 0%, 100% { fill: var(--eb-surface, #fff); } 50% { fill: var(--eb-accent, #0c5b33); } }
@keyframes eb-rise { 0%, 100% { transform: translateY(2px) scale(.96); opacity: .85; } 50% { transform: translateY(-2px) scale(1.04); opacity: 1; } }
@keyframes eb-fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* While it works: the ball, the steps, what it is doing now and a scene of the step. */
.eb-think {
    display: flex; align-items: center; gap: 24px; width: 100%; max-width: 860px; padding: 16px 22px;
    border: 1px solid color-mix(in srgb, var(--eb-accent, #0c5b33) 25%, transparent); border-radius: 16px;
    background: linear-gradient(120deg, color-mix(in srgb, var(--eb-accent, #0c5b33) 6%, var(--eb-surface, #fff)), var(--eb-surface, #fff));
    animation: eb-fade .35s ease;
}
.eb-think-ball .eb-orb-svg { width: 116px; height: 116px; }
.eb-think-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.eb-think-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--eb-muted, #5f6b76); }
.eb-think-head strong { color: var(--eb-ink, #1d2329); }
.eb-think-time { font-variant-numeric: tabular-nums; }

.eb-think-steps { display: flex; flex-wrap: wrap; gap: 6px 4px; margin: 0; padding: 0; list-style: none; }
.eb-think-step { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--eb-muted, #5f6b76); }
.eb-think-step + .eb-think-step::before {
    content: ""; width: 18px; height: 2px; margin-right: 4px; border-radius: 2px; background: var(--eb-line, rgba(0,0,0,.12));
}
.eb-think-step.is-done + .eb-think-step::before { background: var(--eb-accent, #0c5b33); }
.eb-think-dot {
    display: grid; place-items: center; width: 18px; height: 18px; flex: none; border-radius: 50%;
    border: 2px solid var(--eb-line, rgba(0,0,0,.12)); color: #fff;
}
.eb-think-dot .mud-icon-root { font-size: 13px; }
.eb-think-step.is-done .eb-think-dot { background: var(--eb-accent, #0c5b33); border-color: var(--eb-accent, #0c5b33); }
.eb-think-step.is-now { color: var(--eb-ink, #1d2329); font-weight: 700; }
.eb-think-step.is-now .eb-think-dot { border-color: var(--eb-accent, #0c5b33); animation: eb-ring 1.4s ease-out infinite; }

.eb-think-now { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.eb-scene { width: 96px; height: 64px; flex: none; overflow: visible; }
.eb-think-lines { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.eb-think-line { font: 700 15px/1.35 Sora, 'Plus Jakarta Sans', sans-serif; color: var(--eb-ink, #1d2329); animation: eb-fade .45s ease; }
.eb-think-hint { font-size: 12.5px; color: var(--eb-muted, #5f6b76); }

/* The scenes. */
.eb-scene * { transform-box: fill-box; }
.eb-s-db path, .eb-s-db ellipse { fill: color-mix(in srgb, var(--eb-accent, #0c5b33) 14%, var(--eb-surface, #fff)); stroke: var(--eb-accent, #0c5b33); stroke-width: 1.6; }
.eb-s-db .eb-s-db-ring { fill: none; }
.eb-s-sheet { fill: var(--eb-surface, #fff); stroke: var(--eb-line, rgba(0,0,0,.2)); stroke-width: 1.4; }
.eb-s-path { fill: none; stroke: var(--eb-accent, #0c5b33); stroke-width: 1.6; stroke-dasharray: 3 5; animation: eb-pulse 1s linear infinite; opacity: .5; }
.eb-s-path-b { animation-direction: reverse; }
.eb-s-pick { fill: var(--eb-accent, #0c5b33); animation: eb-pick 2.4s ease-in-out infinite; }
.eb-s-row { fill: var(--eb-line, rgba(0,0,0,.12)); animation: eb-row 1.75s ease-in-out infinite; }
.eb-s-lens circle { fill: color-mix(in srgb, var(--eb-accent, #0c5b33) 12%, transparent); stroke: var(--eb-accent, #0c5b33); stroke-width: 2.5; }
.eb-s-lens line { stroke: var(--eb-accent, #0c5b33); stroke-width: 4; stroke-linecap: round; }
.eb-s-lens { animation: eb-lens 3.2s ease-in-out infinite; }
.eb-s-flow { fill: var(--eb-accent, #0c5b33); animation: eb-flow 1.2s linear infinite; opacity: 0; }
.eb-s-bar { fill: var(--eb-accent, #0c5b33); transform-origin: bottom; animation: eb-bar 1.3s ease-in-out infinite alternate; }
.eb-s-bar:nth-of-type(odd) { fill: color-mix(in srgb, var(--eb-accent, #0c5b33) 55%, #fff); }
.eb-s-type { fill: color-mix(in srgb, var(--eb-accent, #0c5b33) 45%, #fff); transform-origin: left; animation: eb-type 2.25s ease-in-out infinite; }
.eb-s-pen path { fill: var(--eb-ink, #1d2329); }
.eb-s-pen { animation: eb-pen 2.25s ease-in-out infinite; }

@keyframes eb-ring {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--eb-accent, #0c5b33) 45%, transparent); }
    100% { box-shadow: 0 0 0 7px transparent; }
}
@keyframes eb-pick { 0%, 100% { transform: translate(-34px, -26px); } 50% { transform: translate(34px, -26px); } }
@keyframes eb-row { 0%, 100% { fill: var(--eb-line, rgba(0,0,0,.12)); } 40% { fill: color-mix(in srgb, var(--eb-accent, #0c5b33) 55%, #fff); } }
@keyframes eb-lens {
    0% { transform: translate(24px, 22px); } 25% { transform: translate(64px, 32px); }
    50% { transform: translate(30px, 52px); } 75% { transform: translate(70px, 60px); } 100% { transform: translate(24px, 22px); }
}
@keyframes eb-flow { 0% { transform: translateX(0); opacity: 0; } 20% { opacity: 1; } 80% { opacity: 1; } 100% { transform: translateX(30px); opacity: 0; } }
@keyframes eb-bar { from { transform: scaleY(.25); } to { transform: scaleY(1); } }
@keyframes eb-type { 0% { transform: scaleX(0); } 45%, 85% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: .4; } }
@keyframes eb-pen { 0% { transform: translate(28px, 22px); } 45% { transform: translate(80px, 22px); } 50% { transform: translate(28px, 44px); } 95% { transform: translate(80px, 66px); } 100% { transform: translate(28px, 22px); } }

@media (max-width: 700px) {
    .eb-think { flex-direction: column; align-items: stretch; }
    .eb-think-ball { align-self: center; }
}

@media (prefers-reduced-motion: reduce) {
    .eb-orb *, .eb-brief, .eb-starter, .eb-think, .eb-think *, .eb-scene * { animation: none !important; transition: none !important; }
}

/* Under an answer: the figures and the export. */
.eb-answer-extras { margin: 2px 0 14px 44px; display: flex; flex-direction: column; gap: 8px; align-self: stretch; width: calc(100% - 44px); }
.eb-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.eb-figures.is-empty { display: none; }
.eb-figure {
    margin: 0; padding: 12px 14px; border: 1px solid var(--eb-line, rgba(0,0,0,.12)); border-radius: 12px;
    background: var(--eb-surface, #fff);
}
.eb-figure figcaption { font-size: 12.5px; font-weight: 600; color: var(--eb-muted, #5f6b76); margin-bottom: 8px; }
.eb-figure .eb-chart { height: 240px; }
.eb-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.eb-kpi .mr-kpi-value { font-size: 24px; }
.eb-kpi-change { font-size: 12px; color: var(--eb-muted, #5f6b76); margin-top: 2px; }
.eb-action.is-on { border-color: var(--eb-accent, #0c5b33); color: var(--eb-accent, #0c5b33); }
.eb-answer-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.eb-action {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; cursor: pointer;
    border: 1px solid var(--eb-line, rgba(0,0,0,.12)); border-radius: 999px;
    background: var(--eb-surface, #fff); color: var(--eb-ink, #1d2329); font-size: 12.5px;
}
.eb-action:hover { border-color: var(--eb-accent, #0c5b33); }
.eb-web-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--eb-muted, #5f6b76); }

@media (max-width: 700px) {
    .eb-bar { padding: 8px 12px; }
    .eb-bar-sub { display: none; }
    .eb-greeting { font-size: 22px; }
    .eb-answer-extras { margin-left: 0; }
    .eb-figures { grid-template-columns: 1fr; }
}
