/*
 * The Brain, on the API domains. Håkon's two screenshots, in two states:
 *
 *   sketch.jpg  the rows, the meters, the counters, the head and the player
 *   page2.jpg   the orb, full window, with one search field over it
 *
 * Black, gold and green, which is the palette the member's own Database page on the main site
 * already uses, so the two read as one product rather than two.
 */

:root {
    /* The page is black and so are its form controls and its scrollbars. Without this an OS
       in light mode draws the audio player and the search field's own furniture pale. */
    color-scheme: dark;

    --bn-ink: #000;
    --bn-line: #222;
    --bn-edge: #333;
    --bn-face: #2b2b2b;
    --bn-face-lit: #3a3a3a;
    --bn-text: #fff;
    --bn-quiet: #9d9d9c;
    --bn-dim: #6a6a6a;
    --bn-gold: #ffd700;
    --bn-gold-lit: #ffe95c;
    --bn-green: #00e400;
    --bn-red: #ff3b30;
}

* { box-sizing: border-box; }

/* One scrollbar on this screen and it belongs to the rows, never to the window.

   Both elements, not just body: overflow on body only reaches the viewport while html is
   visible, so declaring it on one of them alone leaves which element scrolls up to the
   browser. */
html {
    height: 100%;
    overflow: hidden;
}

body.bn-body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bn-ink);
    color: var(--bn-text);
    font-family: "Open Sans", Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* Every control that is reachable from a keyboard says where it is. */
.bn-body :focus-visible {
    outline: 2px solid var(--bn-gold);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- the page */

.bn-page {
    display: flex;
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    border: 1px solid var(--bn-edge);
}

/*
 * min-height: 0 is not tidiness, it is the whole reason this column can scroll.
 *
 * A flex item defaults to min-height: auto, which refuses to shrink below its content. Once
 * the page stacks on a phone this column is an item in a COLUMN flex container, so without
 * this it keeps its full content height, the capped scroller inside it never gets a height
 * to be capped to, and the window scrolls instead of the rows. Measured at 375: the window
 * overflowed by 1951px with every box looking correct.
 */
.bn-left {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

/* ------------------------------------------------------------- the search */

.bn-search {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 10px 16px;
    border-bottom: 1px solid var(--bn-line);
}

.bn-search-input {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 575px;
    height: 44px;
    padding: 7px 10px;
    border: 1px solid #444;
    background: #111;
    color: var(--bn-text);
    font-family: inherit;
    font-size: 13px;
}

.bn-search-input::placeholder,
.bn-big-input::placeholder {
    color: var(--bn-dim);
}

/* Safari and Chrome draw their own clear button, a light glyph on a dark field. */
.bn-search-input::-webkit-search-cancel-button,
.bn-big-input::-webkit-search-cancel-button {
    filter: invert(1) opacity(0.55);
}

.bn-search-input:hover,
.bn-search-input:focus,
.bn-big-input:hover,
.bn-big-input:focus {
    border-color: var(--bn-gold);
    outline: none;
}

.bn-btn {
    flex: 0 0 auto;
    min-width: 44px;
    height: 44px;
    margin-left: 8px;
    padding: 7px 12px;
    border: 1px solid #444;
    background: #111;
    color: var(--bn-text);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}

.bn-btn:hover,
.bn-btn:focus {
    border-color: var(--bn-gold);
    color: var(--bn-gold);
}

.bn-btn[hidden] { display: none; }

/* Held down while the browser is listening, so it is obvious the mic is live. */
.bn-mic.is-listening {
    border-color: #ff4444;
    background: #3a0d0d;
    color: #ff8080;
}

.bn-count {
    flex: 0 0 auto;
    margin-left: 12px;
    color: var(--bn-quiet);
    font-size: 12px;
    white-space: nowrap;
}

/* --------------------------------------------------------------- the rows */

/*
 * The orb sits behind the rows, centered on the WINDOW rather than on this box, because the
 * box is only the left column and its middle lands at about 40% of the screen. Desktop only:
 * iOS Safari handles a fixed attachment badly, and below the breakpoint the columns stack so
 * the panel spans the screen anyway and centering on it is the same thing.
 *
 * graphics/bbbbbbbb.gif is the orb in both of his screenshots, and it is the same file the
 * member's own Database page uses on the main site. NOT graphics/mbx2.png, which is this
 * site's overlay artwork and is a collage rather than the orb.
 *
 * The wash in front of it is load bearing, not taste. Measured on the first build with the
 * orb bare: a member's name over the bright middle of it came out at 1.45:1, which is a
 * white word on a white ground, and the dates over it at 3.95:1. Two layers rather than an
 * overlaying element because the background is attached to the viewport further down, and an
 * absolutely placed child of a scrolling box only ever covers its first screenful.
 */
.bn-scroll {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.66)),
        url('/graphics/bbbbbbbb.gif');
    background-repeat: repeat, no-repeat;
    background-position: center center, center center;
    background-size: cover, contain;
    scrollbar-width: thin;
    scrollbar-color: #444 #111;
}

@media (min-width: 1200px) {
    .bn-scroll {
        background-attachment: fixed, fixed;
        background-size: cover, auto 55vh;
    }
}

/* The browser default is a pale bar, which on a black page reads as a rendering fault. */
.bn-scroll::-webkit-scrollbar { width: 12px; }
.bn-scroll::-webkit-scrollbar-track { background: #111; }
.bn-scroll::-webkit-scrollbar-thumb {
    background: #444;
    border: 3px solid #111;
    border-radius: 6px;
}
.bn-scroll::-webkit-scrollbar-thumb:hover { background: #666; }

.bn-rows { padding: 8px 0 16px 0; }

.bn-row {
    display: flex;
    align-items: flex-start;
    padding: 14px 16px;
}

.bn-row-label {
    flex: 0 0 130px;
    padding-top: 34px;
    color: var(--bn-text);
    font-size: 14px;
    white-space: nowrap;
}

.bn-tiles {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
}

/* ------------------------------------------------------------- the tiles */

.bn-tile {
    display: block;
    width: 88px;
    margin: 0 22px 14px 0;
    padding: 0;
    border: 1px solid transparent;
    background: none;
    color: inherit;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
}

.bn-tile:hover,
.bn-tile:focus-visible {
    border-color: var(--bn-gold);
}

.bn-note {
    display: block;
    height: 88px;
    line-height: 88px;
    background: var(--bn-face);
    color: var(--bn-gold);
    font-size: 34px;
}

.bn-tile:hover .bn-note {
    background: var(--bn-face-lit);
    color: var(--bn-gold-lit);
}

.bn-tile.is-playing {
    border-color: var(--bn-gold);
}

.bn-tile.is-playing .bn-note {
    background: var(--bn-face-lit);
    color: var(--bn-gold-lit);
    box-shadow: inset 0 0 0 2px var(--bn-gold);
}

/* The greeting is the one recording a member publishes about themselves rather than to
   somebody else, so it carries the green tone the main site already uses for the other half
   of its own page. Same two colors, so nobody has to learn a third. */
.bn-row[data-row]:first-child .bn-note { color: var(--bn-green); }
.bn-row[data-row]:first-child .bn-tile:hover .bn-note { color: #63ff63; }
.bn-row[data-row]:first-child .bn-tile.is-playing .bn-note {
    color: #63ff63;
    box-shadow: inset 0 0 0 2px var(--bn-green);
}

.bn-date {
    display: block;
    margin-top: 6px;
    color: var(--bn-text);
    font-size: 13px;
}

.bn-who {
    display: block;
    margin-top: 2px;
    color: var(--bn-quiet);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* What the clip says. Shown only while a search is running, so the page keeps the look his
   sketch has and a hit then shows why it matched. */
.bn-said {
    display: none;
    margin-top: 4px;
    max-height: 3.9em;
    overflow: hidden;
    color: var(--bn-quiet);
    font-size: 12px;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

.bn-page.is-searching .bn-said { display: block; }
.bn-page.is-searching .bn-tile { width: 150px; }
.bn-page.is-searching .bn-empty { display: none; }

.bn-tile.is-hidden,
.bn-row.is-hidden { display: none; }

.bn-empty {
    display: block;
    padding-top: 34px;
    color: var(--bn-dim);
    font-size: 13px;
}

.bn-noresults {
    display: none;
    padding: 24px 16px;
    color: var(--bn-dim);
    font-size: 13px;
}

.bn-page.is-searching .bn-noresults.is-shown { display: block; }

/* ------------------------------------------------- the meters and counters */

.bn-meters {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 10px 16px;
    border-top: 1px solid var(--bn-line);
    border-bottom: 1px solid var(--bn-line);
}

.bn-meter {
    display: flex;
    align-items: center;
    min-width: 0;
}

.bn-meter-knowledge { flex: 0 0 auto; }

.bn-meter-sector {
    flex: 1 1 auto;
    margin-left: 22px;
}

.bn-meter-label {
    flex: 0 0 auto;
    margin-right: 12px;
    color: var(--bn-text);
    font-size: 13px;
    white-space: nowrap;
}

.bn-bar {
    display: block;
    position: relative;
    width: 230px;
    height: 26px;
    background: #8f8f8f;
}

.bn-bar-fill {
    display: block;
    height: 100%;
    background: #e814e8;
}

.bn-spectrum {
    display: block;
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    height: 26px;
    background: linear-gradient(to right,
        #00d5ff 0%, #0055ff 14%, #5b2fc9 26%, #a020f0 38%, #e814e8 50%,
        #ff2a6d 62%, #ff0000 74%, #ff7f00 86%, #ffdd00 100%);
}

/* Outlined, because at a sector of 0 half of it hangs off the left end of the spectrum. */
.bn-spectrum-marker {
    display: block;
    position: absolute;
    top: -7px;
    bottom: -7px;
    width: 12px;
    margin-left: -6px;
    background: #fff;
    border: 1px solid #444;
}

.bn-scores {
    flex: 0 0 auto;
    padding: 18px 16px;
}

.bn-score {
    display: flex;
    align-items: baseline;
    margin-bottom: 14px;
}

.bn-score:last-child { margin-bottom: 0; }

.bn-score-label {
    flex: 0 0 130px;
    color: var(--bn-gold);
    font-size: 14px;
    white-space: nowrap;
}

.bn-score-value {
    color: var(--bn-text);
    font-size: 30px;
    line-height: 1.1;
}

/* ------------------------------------------------- the head and the player */

.bn-right {
    display: flex;
    flex-direction: column;
    flex: 0 0 22%;
    min-width: 0;
    min-height: 0;
    padding: 10px 14px 10px 14px;
    border-left: 1px solid var(--bn-line);
}

.bn-speaker {
    flex: 0 0 auto;
    padding-bottom: 6px;
    color: var(--bn-text);
    font-size: 22px;
    line-height: 1;
}

/*
 * Top anchored, with the player immediately under it, which is how his sketch has them.
 *
 * It must NOT take the column's slack. Stretched, the picture keeps its own aspect ratio
 * inside a taller box and the extra becomes a band of nothing between the head and the
 * words under it: measured at 1440 the gap was about 110px of black, which reads as
 * something that failed to load rather than as room. Shrinking is still allowed, so a short
 * window squeezes the picture rather than the player.
 */
.bn-head {
    flex: 0 1 auto;
    display: block;
    width: 100%;
    min-height: 0;
    max-height: 56vh;
    object-fit: contain;
    object-position: top center;
}

.bn-player {
    flex: 0 0 auto;
    padding-top: 12px;
}

.bn-player-label {
    display: block;
    margin-bottom: 6px;
    color: var(--bn-quiet);
    font-size: 12px;
}

.bn-audio {
    width: 100%;
    max-width: 100%;
}

/* ------------------------------------------------------------ the online list */

/* Lifted from tpl/header.php unchanged, so this page and the rest of the site agree. */
#onlineall {
    position: fixed;
    bottom: 0;
    right: 20px;
    margin-bottom: 40px;
    z-index: 2147483100;
    /* It is anchored to the bottom and it grows upward, so a busy evening would otherwise
       run the first names off the top of the window with no way to reach them. */
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

.logged-in { color: var(--bn-gold); }
.logged-in.is-recent { color: var(--bn-red); }

#onlineall a,
#onlineall a:link,
#onlineall a:visited { color: #fff; text-decoration: none; }

#onlineall a:hover,
#onlineall a:focus { color: #fff; text-decoration: underline; }

/* Bootstrap's own responsive helpers are not loaded on this page, so the two classes the
   online list carries are declared here rather than the markup being changed. */
@media (max-width: 1199px) {
    .hidden-xs.hidden-sm.hidden-md { display: none !important; }
}

/* ------------------------------------------------------------------ the way back */

/* .bn-btn carries the box, the height and the hover; this only places it and keeps an
   anchor looking like the button beside it. */
.bn-back {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    color: var(--bn-quiet);
    font-size: 13px;
    text-decoration: none;
}

.bn-back:hover,
.bn-back:focus { text-decoration: none; }

.bn-back .fa { margin-right: 6px; }

/* ------------------------------------------------------------ page2: the big screen */

/*
 * Hidden by CSS off the .js class the head sets before first paint, so it is never briefly
 * visible on a cold load, and the hidden attribute keeps it out of reach for a visitor with
 * no script at all, who gets the small field as a plain filter instead.
 */
.bn-big {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 2147483000;
    background: var(--bn-ink);
    overflow: hidden;
}

.bn-big.is-open { display: block; }

.bn-big-orb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: auto;
    height: 70vh;
    max-width: 92vw;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* The field lands on the brightest part of the orb, which is where he drew it, so the orb
   is dimmed under it rather than the field being given a plate of its own. */
.bn-big::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.bn-big-close,
.bn-big-field,
.bn-big-results { z-index: 1; }

.bn-big-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #444;
    background: rgba(0, 0, 0, 0.6);
    color: var(--bn-quiet);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.bn-big-close:hover,
.bn-big-close:focus {
    border-color: var(--bn-gold);
    color: var(--bn-gold);
}

/* The field sits on the orb's own center line, which is where he drew it. */
.bn-big-field {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    width: 640px;
    max-width: 92vw;
    transform: translate(-50%, -50%);
}

.bn-big-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 46px;
    padding: 8px 12px;
    border: 1px solid #444;
    background: rgba(17, 17, 17, 0.92);
    color: var(--bn-text);
    font-family: inherit;
    font-size: 16px;
}

.bn-big-mic {
    background: rgba(17, 17, 17, 0.92);
    height: 46px;
}

/*
 * The results, under the field.
 *
 * Absolutely placed and capped rather than in the flow, so the field never moves off the
 * orb's center line as hits arrive: the one thing on this screen that must not jump is the
 * thing somebody is typing into.
 */
.bn-big-results {
    position: absolute;
    top: calc(50% + 46px);
    left: 50%;
    width: 640px;
    max-width: 92vw;
    max-height: calc(50% - 80px);
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateX(-50%);
    scrollbar-width: thin;
    scrollbar-color: #444 #111;
}

.bn-big-results::-webkit-scrollbar { width: 10px; }
.bn-big-results::-webkit-scrollbar-track { background: #111; }
.bn-big-results::-webkit-scrollbar-thumb { background: #444; border: 2px solid #111; }

.bn-hit {
    display: block;
    width: 100%;
    margin-top: -1px;
    padding: 10px 12px;
    position: relative;
    border: 1px solid #333;
    background: rgba(10, 10, 10, 0.92);
    color: var(--bn-text);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.bn-hit:hover,
.bn-hit:focus-visible,
.bn-hit.is-playing {
    z-index: 1;
    border-color: var(--bn-gold);
}

.bn-hit .fa {
    margin-right: 8px;
    color: var(--bn-gold);
}

.bn-hit-who {
    color: var(--bn-text);
    white-space: nowrap;
}

.bn-hit-meta {
    float: right;
    color: var(--bn-quiet);
    font-size: 12px;
    white-space: nowrap;
}

.bn-hit-said {
    display: block;
    margin-top: 4px;
    /* An exact multiple of the line box, or the clip lands through the middle of a third
       line and reads as a rendering fault rather than as a cut. */
    max-height: 2.6em;
    overflow: hidden;
    color: var(--bn-quiet);
    font-size: 12px;
    line-height: 1.3;
    word-break: break-word;
}

.bn-big-none {
    padding: 14px 12px;
    border: 1px solid #333;
    background: rgba(10, 10, 10, 0.92);
    color: var(--bn-dim);
    font-size: 13px;
}

/* ------------------------------------------------------------------- tooltip */

/*
 * Anchored to <body> and fixed, so nothing on the page can clip it, and it is one element
 * reused rather than a pseudo-element per control.
 */
.bn-tip {
    position: fixed;
    z-index: 2147483600;
    display: none;
    max-width: 320px;
    padding: 6px 9px;
    border: 1px solid #444;
    background: #0d0d0d;
    color: #fff;
    font-size: 12px;
    line-height: 1.35;
    pointer-events: none;
    word-break: break-word;
}

.bn-tip.is-shown { display: block; }

/* ------------------------------------------------------------------- narrow */

@media (max-width: 1199px) {
    .bn-page { flex-direction: column; }

    /* The head is a decoration and on a narrow screen it would push the recordings
       themselves off the first screenful. The player is not, so it stays. */
    .bn-right {
        flex: 0 0 auto;
        border-left: 0;
        border-top: 1px solid var(--bn-line);
    }
    .bn-head,
    .bn-speaker { display: none; }
}

@media (max-width: 767px) {
    .bn-search { flex-wrap: wrap; }
    .bn-count { margin: 8px 0 0 0; }

    .bn-row,
    .bn-score { display: block; }

    .bn-row-label {
        padding-top: 0;
        margin-bottom: 8px;
    }

    .bn-empty { padding-top: 0; }

    .bn-tile { margin-right: 14px; }

    .bn-meters { display: block; }

    .bn-meter-sector {
        margin-left: 0;
        margin-top: 14px;
    }

    .bn-meter-label { flex: 0 0 90px; }

    .bn-bar {
        width: auto;
        flex: 1 1 auto;
    }

    .bn-score-label {
        display: block;
        margin-bottom: 4px;
    }

    .bn-score-value { font-size: 26px; }

    /* The orb behind a phone sized field is noise rather than atmosphere. */
    .bn-big-orb { height: 46vh; }
    .bn-big-field { width: 92vw; }
    .bn-big-results { width: 92vw; }
}
