/* ===== Homepage: one URL in, a broadcast out =====
   home.html only, loaded after sbl.css. */

/* ----- the page's fonts -----
   The two files sbl.css names, under names of their own here so that this
   page alone gets font-display: swap. Its text then never waits for a font
   file: until one is in, it shows in the nearest face the device has, a bold
   Helvetica or Arial for the titles (SBLTitle is a bold Neue Haas Grotesk),
   and the swap is hard to see. home.html preloads the titles' file. */
@font-face {
    font-family: 'SBLTitle Swap';
    src: url('../fonts/NeueHaasGroteskText-Bold.woff2') format('woff2'),
         url('../fonts/NeueHaasGroteskText-Bold.otf') format('opentype');
    font-display: swap;
}

@font-face {
    font-family: 'SBLBody Swap';
    src: url('../fonts/PublicSans-Regular.woff2') format('woff2'),
         url('../fonts/PublicSans-Regular.otf') format('opentype');
    font-display: swap;
}

@font-face {
    font-family: 'SBLTitle Fallback';
    src: local('Helvetica Neue Bold'), local('HelveticaNeue-Bold'),
         local('Arial Bold'), local('Arial-BoldMT');
}

body { font-family: 'SBLBody Swap', system-ui, -apple-system, 'Segoe UI', sans-serif; }

.sb-tagline,
.contact-btn { font-family: 'SBLTitle Swap', 'SBLTitle Fallback', sans-serif; }

.sb-tagline {
    font-size: var(--tag-fs);
    line-height: 0.95;
    user-select: none;
}

/* The tagline's last words stay together, so it never ends on "link" alone:
   where it wraps, it wraps before them. */
.sb-tagline .sb-keep { white-space: nowrap; }

/* The tagline's type, and the tagline's height, which the frames need to know
   (--rest). home.js sets --tag-h to what it measures, since the height
   depends on where the words wrap (two lines in a wide short window, three
   otherwise); this is the most it takes: its 16px of top padding and three
   lines. */
.sb-home {
    --tag-fs: min(4.6vw, 7.6vh);
    --tag-h: calc(16px + 2.85 * var(--tag-fs));
}

/* ----- camera -> URL -> broadcast -----
   One group: the field, the two frames, and a wire from each frame to the
   field. From 768px up the field sits over the two frames and the wire goes
   through it end to end: up out of the camera frame, round into the field's
   left end, out of its right end, round and down into the broadcast frame.
   A phone stacks it in the order it reads (camera, field, broadcast) with a
   straight wire between each. */
.sb-flow {
    --wire: 46px; /* stacked: the run of wire between a frame and the field */
    /* how far in from its frame's outer side a wire meets the frame. Stacked,
       that is also where it meets the field: under the start of the protocol
       name and the same distance from the far end (the field's border and
       padding, then 1.5 of its characters, .sb-url-text). */
    --wire-inset: 38px;
    /* a wire's box (see .sb-wire) */
    --wire-w: 28px;
    --wire-h: calc(var(--wire) + 4px);
    display: grid;
    grid-template-columns: min(100%, 440px);
    grid-template-areas: "cam" "url" "live";
    justify-content: center;
    row-gap: var(--wire);
    padding: 1rem 1rem 0;
}

/* a frame and the wire that leaves or enters it */
.sb-stage {
    position: relative;
    min-width: 0;
}

.sb-stage-in { grid-area: cam; }
.sb-stage-out { grid-area: live; }

@media (min-width: 768px) {
    .sb-flow {
        --drop: clamp(22px, calc(4.4vh - 9.7px), 30px); /* between the field and the frames */
        /* A frame's height; everything else in the group is sized from it.
           As tall as the rest of the page leaves (--rest), so the contact
           line ends just above the footer, but never wider than fits two
           abreast. The rest of the page: the tagline (--tag-h), the tabs
           (--tabs-h: their type grows with the window's width), the contact
           line (--under-tabs), the drop, and 83px of spacing and footer. The
           field's height follows the frames' (--field-h) between its 52px
           and its 92px, hence the three terms of --fit-h. */
        --tabs-h: calc(12px + 1.2 * clamp(12px, 1vw, 15px));
        --rest: calc(100vh - var(--tag-h) - var(--tabs-h) - var(--under-tabs) - var(--drop) - 83px);
        --fit-h: min(calc(var(--rest) - 52px), max(calc(var(--rest) / 1.253), calc(var(--rest) - 92px)));
        --feed-h: min(calc(28.1vw - 22px), max(180px, var(--fit-h)));
        --gap: 1.5rem;
        --field-h: clamp(52px, calc(var(--feed-h) * 0.253), 92px);
        --wire-inset: clamp(26px, calc(var(--feed-h) * 0.11), 36px);
        --wire-run: clamp(44px, calc(var(--feed-h) * 0.165), 58px); /* from there in to the field's end */
        --wire-w: calc(var(--wire-run) + 16px);
        --wire-h: calc(var(--field-h) / 2 + var(--drop) + 16px);
        grid-template-columns: repeat(2, calc(var(--feed-h) * 16 / 9));
        grid-template-areas: "url url" "cam live";
        column-gap: var(--gap);
        row-gap: var(--drop);
        padding: 1.1rem 1.5rem 0;
    }
}

/* ----- the URL field -----
   Its border is not its own: that is transparent and only keeps the width
   (--edge), and the dashes of .sb-rim are drawn along it (--rim wide, flush
   with its outer edge). */
.sb-url {
    --edge: 4px;
    --rim: 5px;
    grid-area: url;
    justify-self: center;
    position: relative; /* over the ends of the wires */
    z-index: 1;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    height: 52px;
    padding: 0 1.25rem;
    border: var(--edge) solid transparent;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
    font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    white-space: nowrap;
    container-type: inline-size;
}

@media (min-width: 768px) {
    /* short of the group's width by the wires that come round into its ends */
    .sb-url {
        width: calc(100% - 2 * (var(--wire-inset) + var(--wire-run)));
        height: var(--field-h);
    }
}

/* The code runs on past the field and dissolves before its edge: the address
   is plainly longer than what is shown, with no hard cut. */
.sb-url-text {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    /* Sized from the field's width (cqw), whatever that is: everything up to
       the code (streambox://streamboxlabs.com/, 30 characters of 0.6em) has to
       sit inside the 72% that is not fading. */
    font-size: clamp(12px, 3.8cqw, 40px);
    -webkit-mask-image: linear-gradient(to right, #000 72%, transparent 99%);
    mask-image: linear-gradient(to right, #000 72%, transparent 99%);
}

/* the parts keep their width: the row is longer than the field on purpose */
.sb-url-text > * { flex: none; }

/* The protocol name alone turns over; "://" and the address stay put and slide
   to its width. One line tall, so only the name in the URL is ever in view. */
.sb-proto {
    display: inline-block;
    height: 1.3em;
    line-height: 1.3;
    overflow: hidden;
    width: 3ch;
    transition: width 0.45s cubic-bezier(0.65, 0, 0.2, 1);
}

.sb-proto-roll {
    display: flex;
    flex-direction: column;
    transition: transform 0.45s cubic-bezier(0.65, 0, 0.2, 1);
}

.sb-proto-roll > span { height: 1.3em; }

.sb-proto.snap,
.sb-proto.snap .sb-proto-roll { transition: none; }

/* The field's border: dashes from the middle of its left end to the middle
   of its right end both ways round, over the top and under the bottom. Each
   way round is the top half of a rounded rectangle twice as tall as the half
   of the field it is in (.sb-rim > div cuts the rest off), and the lower one
   is the upper one flipped, so the two always match where they meet. A
   rectangle's outline starts at its top left corner and runs clockwise;
   turned half round it starts at the bottom right, in the half that is cut
   off, and what shows is one unbroken run up the left end, along the top
   and down the right end. The halves overlap by a pixel, so no line shows
   between them where the field's height is not a whole number. */
.sb-rim {
    position: absolute;
    inset: calc(0px - var(--edge));
    pointer-events: none;
}

.sb-rim > div {
    position: absolute;
    inset: 0 0 calc(50% - 0.5px);
    overflow: hidden;
}

.sb-rim > div + div {
    inset: calc(50% - 0.5px) 0 0;
    transform: scaleY(-1);
}

.sb-rim svg {
    position: absolute;
    left: calc(var(--rim) / 2);
    top: calc(var(--rim) / 2);
    width: calc(100% - var(--rim));
    height: calc(200% - var(--rim));
    overflow: visible;
    fill: none;
    stroke: #1d1d1f;
    stroke-width: var(--rim);
    transform: rotate(180deg);
}

/* ----- the wires -----
   Each is an SVG with no viewBox (its units are pixels) holding a rounded
   rectangle twice its size, of which only the top right corner is in the box:
   a line in from the left at y = 14, a 16px bend, a line down at 14px from the
   right. So the bend keeps its shape and the line its weight whatever the
   box's size, and the dashes run the whole way. The left end is tucked 2px
   under the field's border and the bottom end 2px under the frame's. The
   camera's wire is the same drawing mirrored.
   A wire ends in a solid arrowhead, 20px long and 26px across with its tip on
   the edge of what it points at, and under the head is a white gap as wide
   as the line and a little more: the line stops at the head's base and no
   dash shows beside its tip. */
.sb-wire {
    position: absolute;
    width: var(--wire-w);
    height: var(--wire-h);
    fill: none;
    stroke: #1d1d1f;
    stroke-width: 8;
    stroke-linejoin: round;
    pointer-events: none;
}

.sb-wire-head {
    fill: #1d1d1f;
    stroke-width: 2;
}

.sb-wire-gap {
    stroke: #fff;
    stroke-width: 12;
}

.sb-stage-in .sb-wire {
    left: calc(var(--wire-inset) - 14px);
    top: calc(100% - 2px);
    transform: scaleX(-1);
}

.sb-stage-out .sb-wire {
    right: calc(var(--wire-inset) - 14px);
    bottom: calc(100% - 2px);
}

/* stacked: the bend and the line to the field are pushed off the top of the
   box, which leaves a straight wire down, with the arrowhead at its foot */
.sb-wire-line { transform: translate(-14px, -40px); }
.sb-wire-head-side { display: none; }

@media (min-width: 768px) {
    .sb-stage-in .sb-wire {
        top: auto;
        bottom: calc(100% - 2px);
    }

    .sb-wire-line { transform: translate(-14px, 0); }

    /* the camera's wire ends at the field, not at its frame */
    .sb-stage-in .sb-wire-head-side { display: inline; }
    .sb-stage-in .sb-wire-head-down { display: none; }
}

/* ----- the flow: camera, through the URL, to the broadcast -----
   The wires and the field's border are dashes that never stand still: a
   dash and a gap (20px) every half second, out of the camera frame, both
   ways round the field, and into the broadcast frame. */
.sb-wire-line,
.sb-rim rect {
    stroke-dasharray: 12 8;
    animation: sb-march 0.5s linear infinite;
}

@keyframes sb-march {
    from { stroke-dashoffset: 20; }
    to { stroke-dashoffset: 0; }
}

@media (min-width: 768px) {
    /* the camera's wire is drawn mirrored, so its dashes run backwards */
    .sb-stage-in .sb-wire-line { animation-direction: reverse; }
}

/* ----- the frames -----
   Always 16:9, whatever the clip's shape. A frame is a container: what is
   drawn over its clips (.sb-tally) is sized in its width. */
.sb-feed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 4px solid #1d1d1f;
    border-radius: 4px;
    background: #000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    container-type: inline-size;
    -webkit-user-select: none;
    user-select: none;
}

.sb-feed video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

/* a panorama is shown whole, between black bars */
.sb-feed video.wide { object-fit: contain; }

/* Until a clip's poster is in, its frame is not black: it shows the poster as
   16 pixels blown up through a blur (--blur, on each video in home.html)
   under three dots that light in turn. Both are backgrounds of the video
   itself, so the poster, and then the clip, cover them, and home.js takes
   them away (.seen) once the poster has loaded. A panorama's has the
   panorama's shape, between the same black bars. */
.sb-feed {
    --dots: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 12' width='44' height='12' fill='%23fff' stroke='%23000' stroke-opacity='.3'%3E%3Ccircle cx='6' cy='6' r='4.5' opacity='.35'%3E%3Canimate attributeName='opacity' values='.35;1;.35;.35' keyTimes='0;.2;.4;1' dur='1.2s' begin='0s' repeatCount='indefinite'/%3E%3C/circle%3E%3Ccircle cx='22' cy='6' r='4.5' opacity='.35'%3E%3Canimate attributeName='opacity' values='.35;1;.35;.35' keyTimes='0;.2;.4;1' dur='1.2s' begin='.2s' repeatCount='indefinite'/%3E%3C/circle%3E%3Ccircle cx='38' cy='6' r='4.5' opacity='.35'%3E%3Canimate attributeName='opacity' values='.35;1;.35;.35' keyTimes='0;.2;.4;1' dur='1.2s' begin='.4s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
}

.sb-feed video.on:not(.seen) {
    background:
        var(--dots) center / clamp(30px, 7cqw, 46px) no-repeat,
        var(--blur, none) center / cover no-repeat;
}

.sb-feed video.wide.on:not(.seen) { background-size: clamp(30px, 7cqw, 46px), contain; }

.sb-tally {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.sb-feed video.on,
.sb-tally.on { opacity: 1; }

/* platform tennis, multi-match: four courts in, and which one is on air */
.sb-tally {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.sb-tally > div {
    position: relative;
    box-shadow: inset 0 0 0 0.25cqw #1d1d1f;
    transition: box-shadow 0.15s ease;
}

.sb-tally > div.air { box-shadow: inset 0 0 0 0.9cqw #db2e2e; }

.sb-tally span {
    position: absolute;
    left: 1.6cqw;
    top: 1.6cqw;
    padding: 0.5cqw 1.1cqw;
    border-radius: 0.8cqw;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font: 800 1.9cqw -apple-system, sans-serif;
    letter-spacing: 0.12em;
}

.sb-tally > div.air span { background: #db2e2e; }

/* ----- under the frames: the sport picker, the contact line -----
   Two centred rows: the sports close under the frames they belong to, then
   the contact line. Whatever height is left over sits below the contact line,
   above the footer. */
.sb-home {
    --cta-fs: clamp(19px, 1.7vw, 26px);
    --cta-gap: clamp(0.8rem, 2vh, 1.25rem); /* sports to contact line */
    /* the room the contact line needs under the sports, with 1.5rem to spare
       above the footer: what the frames have to leave (--rest) */
    --under-tabs: calc(var(--cta-gap) + 1.15 * var(--cta-fs) + 1.5rem);
}

.sb-sports {
    --sport-pad: 0.375rem; /* above a name, and from it down to the foot of its bar */
    display: flex;
    justify-content: center;
    padding: 0.7rem 1rem 0;
}

/* A sport is its name and nothing round it: grey, black for the one on show,
   with a thin line between it and the one before. The "+ more" after the
   last of them looks like a sport that isn't picked and is otherwise inert: a
   span the script doesn't count, with no pointer, no hover and nothing to
   focus. */
.sb-sport-btn,
.sb-sport-more {
    position: relative;
    font-family: 'SBLTitle Swap', 'SBLTitle Fallback', sans-serif;
    font-size: clamp(12px, 1vw, 15px);
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
    color: #6c757d;
    background: none;
    border: 0;
    padding: var(--sport-pad) 1.1rem;
}

.sb-sport-btn {
    cursor: pointer;
    transition: color 0.15s ease;
}

.sb-sport-more {
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
}

.sb-sport-btn:hover,
.sb-sport-btn.active { color: #000; }

/* the line between two neighbours: as tall as the letters, no taller */
.sb-sports > * + *::before {
    content: "";
    position: absolute;
    left: 0;
    top: calc(var(--sport-pad) + 0.1em);
    height: 1em;
    border-left: 1px solid #d4d4d4;
}

/* The bar under the name of the sport on show, as wide as the name: how far
   through its clip it is (--done, 0 to 1, from home.js). Picking a sport
   starts it over. */
.sb-sport-name {
    position: relative;
    display: inline-block;
}

.sb-sport-prog {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(0px - var(--sport-pad));
    height: 2px;
    border-radius: 1px;
    overflow: hidden;
}

.sb-sport-btn.active .sb-sport-prog { background: rgba(0, 0, 0, 0.12); }

.sb-sport-prog::after {
    content: "";
    position: absolute;
    inset: 0;
    background: #000;
    transform: scaleX(var(--done, 0));
    transform-origin: left;
}

/* The contact line: the tagline's type and black, a good deal smaller */
.sb-cta {
    margin: var(--cta-gap) 0 0;
    padding: 0 1rem 1.25rem;
    font-family: 'SBLTitle Swap', 'SBLTitle Fallback', sans-serif;
    font-size: var(--cta-fs);
    line-height: 1.15;
    text-align: center;
}

@media (max-width: 679.98px) {
    /* too narrow for the seven in a row (624px of names at the smallest
       type): a row of three and a row of four, each centred. The row breaks
       at an empty full-width item put after the third, so a line only ever
       stands between two names (the row gap falls either side of that item,
       hence half of the 0.3rem it comes to). */
    .sb-sports {
        flex-wrap: wrap;
        row-gap: 0.15rem;
    }

    .sb-sports::after {
        content: "";
        flex-basis: 100%;
        order: 1;
    }

    .sb-sports > :nth-child(n + 4) { order: 2; }

    .sb-sports > :nth-child(4)::before { content: none; }

    .sb-sport-btn,
    .sb-sport-more { padding: var(--sport-pad) 0.9rem; }
}

@media (max-width: 374.98px) {
    /* the row of four is 324px wide as it stands: on the narrowest phones
       the names stand closer, and it is 280px */
    .sb-sport-btn,
    .sb-sport-more { padding: var(--sport-pad) 0.55rem; }
}

@media (min-width: 768px) {
    .sb-sports { padding-left: 1.5rem; padding-right: 1.5rem; }

    .sb-cta { padding: 0 1.5rem; }
}

@media (max-width: 575.98px) {
    .sb-flow { --wire-inset: 26px; }

    .sb-url {
        --edge: 3px;
        --rim: 4px;
        height: 46px;
        padding: 0 0.75rem;
        border-radius: 10px;
    }

    /* the dashes' corners follow the field's */
    .sb-rim rect { rx: 8px; }
}

/* ----- the footer's small print -----
   Two lines at the left of the bar, level with the middle of its buttons:
   the copyright, and "Terms of Use · Privacy Policy" under it. CSS only, so
   the markup stays the site's shared _legal_footer.html (© · Terms · Privacy,
   one line on the other pages): the links go after an empty full-width item
   that breaks the row (order), and the dot between them and the copyright is
   hidden.
   The type is 12px and shrinks only where the bar's left part is too narrow
   for the longer line at 12px (the copyright, 14.1 times its type size), so
   it is always two lines, never three: the small print is a container and
   its pieces are sized in its width (cqi), the dots' spacing in em to match.
   On a phone, where the bar is a column, it is the last row, centred like
   the buttons over it. */
footer:not(.legal) .legal-footer {
    container-type: inline-size;
    gap: 0;
}

footer:not(.legal) .legal-footer > * { font-size: min(0.75rem, 6.8cqi); }
footer:not(.legal) .legal-footer > [aria-hidden] { margin: 0 0.5em; }
footer:not(.legal) .legal-footer > :nth-child(2) { display: none; }
footer:not(.legal) .legal-footer > :nth-child(n + 3) { order: 2; }

footer:not(.legal) .legal-footer::after {
    content: "";
    flex-basis: 100%;
    order: 1;
}

@media (max-width: 480px) {
    /* A phone: the two buttons side by side, each half the bar, and the small
       print under them, whole on one line. The bar wraps upwards, so the
       small print, first in the markup, is its bottom row once it takes a
       whole row. (!important: over Bootstrap's .gap-3 and the widths the
       buttons carry in their style attributes.) */
    footer:not(.legal) .navbar { padding-bottom: calc(var(--bs-navbar-padding-y, 0.5rem) / 2); }

    footer:not(.legal) .container-fluid { gap: 0.3rem 0.5rem !important; }

    footer:not(.legal) .container-fluid > a,
    footer:not(.legal) .container-fluid > div {
        flex: 0 0 calc(50% - 0.25rem) !important;
        min-width: 0 !important;
    }

    footer:not(.legal) .container-fluid > div > a { width: 100% !important; }

    footer:not(.legal) .container-fluid > .legal-footer {
        flex: 0 0 100%;
        flex-wrap: nowrap;
        justify-content: center;
        white-space: nowrap;
    }

    /* the line is 29 times its type size long: 12px where that fits, less
       on a narrower phone */
    footer:not(.legal) .legal-footer > * { font-size: min(0.75rem, 3.4cqi); }
    footer:not(.legal) .legal-footer > :nth-child(2) { display: inline; }
    footer:not(.legal) .legal-footer > :nth-child(n + 3) { order: 0; }
    footer:not(.legal) .legal-footer::after { content: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sb-proto,
    .sb-proto-roll,
    .sb-feed video,
    .sb-tally { transition: none; }

    .sb-wire-line,
    .sb-rim rect { animation: none; }

    /* the blurred miniature without its dots */
    .sb-feed { --dots: none; }
}
