﻿/* ============================================================================================
   Blow demo - the styles of the live samples.

   The site's chrome, tokens and shared surfaces live in app.css (the site kit every Utilities demo
   shares); this file only draws what is Blow's own - the frame a flow runs in, the toolbar over it,
   the examples gallery, the landing page's live flow - and it ties the library's own theme to the
   site's: the canvas follows the light/dark toggle, and its selection colours are the bit brand.
   Each page keeps the styles of its own nodes and panels next to its markup, written against the
   library's --bit-blow-* properties, so they follow the colour mode with the canvas.
   ============================================================================================ */

/* ---------- The library's theme, tinted with the bit brand ----------

   One accent paints the selection, the selection box, focus rings, resize controls and the line
   drawn while connecting. :root in front of the class makes these outrank bit-blow.css, which
   declares the same properties on .bit-blow and is linked after this file; the dark mode copies
   --bit-blow-dark-accent over the three, so it is tinted through that. */
:root .bit-blow {
    --bit-blow-node-selected: #1276C6;
    --bit-blow-edge-selected: #1276C6;
    --bit-blow-connection-stroke: #1276C6;
    --bit-blow-dark-accent: #4FA3F4;
}

/* ---------- Every flow follows the site's theme ----------

   Under the dark site theme a flow takes the library's own dark palette - the very rule
   ColorMode="Dark" applies with .bit-blow-dark, copied here because the pages leave ColorMode at its
   default rather than each wiring it to the theme toggle. A canvas that picks its colour mode itself
   (the Color Mode example, the Theming page) carries .own-color-mode and is left alone, so the mode
   chosen there is the one on screen. */
:root[bit-theme="dark"] .bit-blow:not(.own-color-mode) {
    --bit-blow-bg: var(--bit-blow-dark-bg);
    --bit-blow-node-bg: var(--bit-blow-dark-node-bg);
    --bit-blow-node-border: var(--bit-blow-dark-node-border);
    --bit-blow-node-color: var(--bit-blow-dark-node-color);
    --bit-blow-node-selected: var(--bit-blow-dark-accent);
    --bit-blow-edge-stroke: var(--bit-blow-dark-edge-stroke);
    --bit-blow-edge-selected: var(--bit-blow-dark-accent);
    --bit-blow-connection-stroke: var(--bit-blow-dark-accent);
    --bit-blow-handle-bg: var(--bit-blow-dark-handle-bg);
    --bit-blow-node-input-border: var(--bit-blow-dark-node-input-border);
    --bit-blow-node-output-border: var(--bit-blow-dark-node-output-border);
    --bit-blow-surface: var(--bit-blow-dark-surface);
    --bit-blow-surface-hover: var(--bit-blow-dark-surface-hover);
    --bit-blow-surface-muted: var(--bit-blow-dark-surface-muted);
    --bit-blow-surface-muted-hover: var(--bit-blow-dark-surface-muted-hover);
    --bit-blow-surface-translucent: var(--bit-blow-dark-surface-translucent);
    --bit-blow-border: var(--bit-blow-dark-border);
    --bit-blow-border-subtle: var(--bit-blow-dark-border-subtle);
    --bit-blow-text: var(--bit-blow-dark-text);
    --bit-blow-text-muted: var(--bit-blow-dark-text-muted);
    --bit-blow-shadow: var(--bit-blow-dark-shadow);
    --bit-blow-group-bg: var(--bit-blow-dark-group-bg);
    --bit-blow-group-border: var(--bit-blow-dark-group-border);
    --bit-blow-background-pattern: var(--bit-blow-dark-background-pattern);
    --bit-blow-minimap-node: var(--bit-blow-dark-minimap-node);
    --bit-blow-minimap-mask: var(--bit-blow-dark-minimap-mask);
    color: var(--bit-blow-node-color);
    color-scheme: dark;
}

/* ---------- The frame a flow runs in ----------

   The kit's live-sample surface, with the canvas edge to edge inside it rather than on a padded
   stage: a flow is the whole sample. The toolbar over it is the kit's demo bar, flush with the
   frame. */
.blow-demo {
    padding: 0;
    overflow: hidden;
}

.blow-demo > .bb-demo-bar {
    margin: 0;
    padding: .5rem .875rem;
    border-radius: 0;
}

/* A canvas fills its container, so the container is what has the height: as much of the window as
   the header and the page's title block leave, so the whole flow - the controls and the minimap at
   its bottom included - is on screen without scrolling; within bounds that keep a flow usable on a
   phone and stop it towering over a reader on a tall monitor. The "View code" toggle is under the
   frame, so it takes none of that height. */
.demo-canvas {
    position: relative;
    height: clamp(24rem, calc(100vh - 21.75rem), 46rem);
}

/* On a phone a minimap's fixed size is a third of the canvas or more, and it sits on the very nodes it maps. The
   samples leave it out there, except those about the minimap itself, which mark it demo-minimap-keep. */
@media (max-width: 600px) {
    .demo-canvas .bit-blow-minimap:not(.demo-minimap-keep) {
        display: none;
    }
}

/* The footer under a sample's canvas: an event log, say, which as a panel over the canvas would grow over the nodes.
   A fixed height, so the page does not jump as lines come in. */
.example-footer {
    height: 7.5rem;
    overflow: auto;
    padding: .5rem .875rem;
    font-size: var(--fl-font-size-200);
    color: var(--bb-text);
    background: var(--bb-surface-sunken);
    border-top: 1px solid var(--bb-border);
}

/* The toolbar's controls: labels hold their control and its value on one line, and the row wraps
   on a narrow screen rather than pushing the page sideways. */
.example-toolbar {
    gap: .5rem 1rem;
    font-size: var(--fl-font-size-200);
    color: var(--bb-text);
}

.example-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    min-width: 0;
}

.example-toolbar input[type="range"] {
    max-width: 10rem;
}

/* ---------- The reading guide under a sample: "Try it" and "How it works", side by side where there is room. ---------- */

.demo-notes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 1rem 2rem;
    margin-top: 1.5rem;
}

.demo-notes__title {
    margin: 0 0 .5rem;
    font-size: var(--fl-font-size-400);
    font-weight: var(--fl-weight-semibold);
    color: var(--bb-text);
}

.demo-notes__list {
    margin: 0;
    padding-inline-start: 1.25rem;
    font-size: var(--fl-font-size-300);
    line-height: 1.6;
    color: var(--bb-text-muted);
}

.demo-notes__list > li + li {
    margin-top: .375rem;
}

.demo-notes__list strong,
.demo-notes__list code {
    color: var(--bb-text);
}

/* ---------- The "View code" toggle: the kit's secondary button, with the caret and the code glyph in it. ---------- */

.demo-code__caret {
    font-size: .8em;
    color: var(--bb-text-soft);
}

.demo-code__glyph {
    font-family: var(--bb-mono);
    color: var(--bb-primary);
}

/* ---------- Code: SyntaxHighlighter's tokens on the kit's code surface ----------

   The highlighter tells more kinds apart than the kit's four (keyword, string, comment, parameter),
   so the extra ones get colours of their own here, light and dark, picked to hold their contrast on
   --bb-code-bg in both themes. */
:root {
    --demo-code-type: #8250DF;
    --demo-code-fn: #795E26;
    --demo-code-number: #CF222E;
    --demo-code-razor: #A21CAF;
}

:root[bit-theme="dark"] {
    --demo-code-type: #D2A8FF;
    --demo-code-fn: #DCDCAA;
    --demo-code-number: #FF7B72;
    --demo-code-razor: #F0ABFC;
}

.bb-code .tok-com { color: var(--bb-code-comment); font-style: italic; }
.bb-code .tok-pun { color: var(--bb-code-comment); }
.bb-code .tok-tag,
.bb-code .tok-key { color: var(--bb-code-keyword); }
.bb-code .tok-str { color: var(--bb-code-string); }
.bb-code .tok-attr { color: var(--bb-code-param); }
.bb-code .tok-type { color: var(--demo-code-type); }
.bb-code .tok-fn { color: var(--demo-code-fn); }
.bb-code .tok-num { color: var(--demo-code-number); }
.bb-code .tok-raz { color: var(--demo-code-razor); }

/* ---------- The examples gallery ---------- */

.example-card {
    gap: .25rem;
}

.example-card__title {
    color: var(--bb-text);
    font-weight: var(--fl-weight-semibold);
}

.example-card__summary {
    font-size: var(--fl-font-size-200);
    line-height: 1.5;
}

/* ---------- The landing page's hero: the live flow under its markup, inside the window frame. ---------- */

.home-hero-flow {
    position: relative;
    height: 300px;
    border-top: 1px solid var(--bb-border);
}

/* A walkthrough step shown in two languages - markup, then C# - as two blocks in the one grid cell. */
.home-code-stack {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-width: 0;
}
