/* dsn.css - DSN status page; light and dark themes (auto, or forced with
   data-theme="light" / "dark" on <html>, see the theme button). */

/* A card that changes flashes, then keeps a contrasting outline that fades. */
:root {
    --card-flash:        300ms;     /* duration of the flash */
    --card-outline-fade: 5000ms;    /* duration of the outline fading out */
}

/* The width of the page (as LightningMonitor's, centred): just that of the longest line of
   cards, the 6 antennas of MDSCC with the name of the complex at their left; the header, the
   tables and the map or globe below are as wide. Narrower windows: the whole width. */
:root {
    --card-w:     168px;            /* an antenna card */
    --card-gap:   6px;
    --site-w:     78px;             /* the name of a complex, left of its cards */
    --site-gap:   8px;
    --site-cards: 6;                /* cards on the longest line (MDSCC) */
    --page-w:     calc(var(--site-w) + var(--site-gap) + var(--site-cards) * var(--card-w)
                       + (var(--site-cards) - 1) * var(--card-gap));
    --gutter:     16px;             /* left and right of the page */
}

:root {
    --bg:       #f4f6f8;
    --panel:    #ffffff;
    --text:     #1d2329;
    --muted:    #66717d;
    --line:     #d5dbe1;
    --grey:     #858d96;
    --green:    #1f9d4b;
    --red:      #d1313d;
    --warn:     #b26b00;
    --shadow:   0 1px 2px rgba(0, 0, 0, .08);
    --hover:    rgba(0, 0, 0, .035);
    --change:   #0b6bcb;            /* outline of a card that changed */
    --flash:    rgba(11, 107, 203, .28);
    --map-coast:  #6b7a90;          /* globe (as LightningMonitor): coasts, borders, */
    --map-border: #9b6fb0;
    --map-sphere: #1971c2;          /* the sphere, tinted */
    --osm-coast:  #6b7a90;          /* local maps of the complexes (OpenStreetMap): */
    --osm-border: #9b6fb0;          /* discreet, as LightningMonitor's */
    --osm-road:   #c9853f;
    --osm-road2:  #dbb894;
    --osm-water:  #74a9d8;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:     #0f1317;
        --panel:  #182027;
        --text:   #e3e8ed;
        --muted:  #8b97a3;
        --line:   #2b3640;
        --grey:   #7d8790;
        --green:  #2fbf63;
        --red:    #f0505b;
        --warn:   #e09a2b;
        --shadow: none;
        --hover:  rgba(255, 255, 255, .04);
        --change: #6cb6ff;
        --flash:  rgba(108, 182, 255, .28);
        --map-coast:  #8c99ad;
        --map-border: #b48cc8;
        --map-sphere: #4dabf7;
        --osm-coast:  #8c99ad;
        --osm-border: #b48cc8;
        --osm-road:   #b9824a;
        --osm-road2:  #7d6a55;
        --osm-water:  #3f78a8;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg:     #0f1317;
    --panel:  #182027;
    --text:   #e3e8ed;
    --muted:  #8b97a3;
    --line:   #2b3640;
    --grey:   #7d8790;
    --green:  #2fbf63;
    --red:    #f0505b;
    --warn:   #e09a2b;
    --shadow: none;
    --hover:  rgba(255, 255, 255, .04);
    --change: #6cb6ff;
    --flash:  rgba(108, 182, 255, .28);
    --map-coast:  #8c99ad;
    --map-border: #b48cc8;
    --map-sphere: #4dabf7;
    --osm-coast:  #8c99ad;
    --osm-border: #b48cc8;
    --osm-road:   #b9824a;
    --osm-road2:  #7d6a55;
    --osm-water:  #3f78a8;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* -- header ---------------------------------------------------------------- */

header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    /* the bar across the window, its content as wide as the page */
    padding: 8px max(var(--gutter), calc((100% - var(--page-w)) / 2));
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

h1 { margin: 0; font-size: 16px; font-weight: 600; }


.info { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }

.link::before {
    content: "";
    display: inline-block;
    width: 8px; height: 8px;
    margin-right: 5px;
    border-radius: 50%;
    background: var(--grey);
}
.link.live::before    { background: var(--green); }
.link.polling::before { background: var(--warn); }
.link.error::before   { background: var(--red); }

.updated.stale { color: var(--warn); font-weight: 600; }

button {
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
}

/* header buttons, as LightningMonitor's: link of the view, map, globe (the one shown green), theme;
   emoji only, as big
   as the title, ringed under the pointer */
.ctl { display: flex; gap: 6px; }
.btn {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    padding: 1px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
}
.ctl .btn:hover { box-shadow: inset 0 0 0 1px var(--text); }
.btn.on         { border-color: var(--green); color: var(--green); }
.btn[hidden]    { display: none; }

/* -- one line per site ------------------------------------------------------- */

main {
    max-width: calc(var(--page-w) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 10px var(--gutter);
    display: flex; flex-direction: column; gap: 10px;
}

.site { display: flex; align-items: stretch; gap: var(--site-gap); }

.site-name {
    flex: 0 0 var(--site-w);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.site-name b     { font-size: 16px; letter-spacing: .03em; }
.site-name small { color: var(--muted); }

.cards { display: flex; flex-wrap: wrap; gap: var(--card-gap); flex: 1; min-width: 0; }

.empty { color: var(--muted); padding: 20px 0; }

/* -- one card per antenna ------------------------------------------------------ */

.card {
    width: var(--card-w);
    display: flex;
    flex-direction: column;
    padding: 5px 7px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: var(--shadow);
    outline: 2px solid transparent;
    outline-offset: -1px;
}
.card.down { opacity: .55; }

/* Set by dsn.js on a card whose content changed (not at page load), on the
   fields of the card that changed, and on the cells of the antennas table. */
.card.changed {
    animation: card-flash var(--card-flash) ease-out,
               card-outline var(--card-outline-fade) ease-in forwards;
}
.card .changed {
    outline: 2px solid transparent;
    outline-offset: 1px;
    border-radius: 3px;
    animation: card-outline var(--card-outline-fade) ease-in forwards;
}
.grid td.changed {
    outline: 2px solid transparent;
    outline-offset: -2px;
    animation: card-flash var(--card-flash) ease-out,
               card-outline var(--card-outline-fade) ease-in forwards;
}
@keyframes card-flash   { from { background-color: var(--flash); } to { background-color: var(--panel); } }
@keyframes card-outline { from { outline-color: var(--change); } to { outline-color: transparent; } }

@media (prefers-reduced-motion: reduce) {
    .card.changed, .grid td.changed { animation: card-outline var(--card-outline-fade) ease-in forwards; }
}

.card .top { display: flex; justify-content: space-between; align-items: baseline; }
.card .name { font-size: 14px; font-weight: 600; }
.card .type { color: var(--muted); font-size: 11px; }

/* OFF | DL | UL, then az | el | wind: three equal columns, full width */
.blocks, .pos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.blocks { margin: 4px 0 3px; }
.blocks .blk { min-width: 0; cursor: default; }

.blk {
    display: inline-block;
    min-width: 30px;
    padding: 0 3px;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 600;
    line-height: 13px;
    text-align: center;
    opacity: .5;
}
.blk.on     { opacity: 1; color: #fff; }
.blk.off.on { background: var(--grey);  border-color: var(--grey); }
.blk.dl.on  { background: var(--green); border-color: var(--green); }
.blk.ul.on  { background: var(--red);   border-color: var(--red); }

.pos {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
}
.pos .key { color: var(--muted); }

/* the spacecraft, centred at the bottom of the card */
.card .sc {
    margin-top: auto;
    padding-top: 4px;
    min-height: 21px;
    font-weight: 600;
    text-align: center;
    overflow-wrap: anywhere;
}
.card .sc.none { color: var(--muted); font-weight: 400; }

/* -- views: links, tables (?status, ?missions) ---------------------------------- */

nav { display: flex; gap: 10px; font-size: 12px; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--text); text-decoration: underline; }
nav a.here { color: var(--text); font-weight: 600; }


.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: var(--shadow);
    align-self: flex-start;
}

table.grid {
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.grid th {
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-align: left;
}
.grid td { padding: 3px 10px; }
.grid tr.group td { border-top: 1px solid var(--line); }
.grid tbody tr:first-child td { border-top: 0; }
.grid tr.dim td { color: var(--muted); }
.grid tbody tr:hover td { background: var(--hover); }
.grid .num { text-align: right; }
.grid td.merged { vertical-align: middle; }
.grid tr.site-start td { border-top: 2px solid var(--line); }
.grid td.site-cell { font-weight: 600; border-right: 1px solid var(--line); }

footer { max-width: calc(var(--page-w) + 2 * var(--gutter)); margin: 0 auto;
         padding: 0 var(--gutter) 12px; color: var(--muted); font-size: 12px; min-height: 16px; }

/* -- copyright and logo, as LightningMonitor's -------------------------------------- */

/* room under the page for the copyright line, so that the end of the page can be read */
body { padding-bottom: 24px; }

/* one small line of text floating at the bottom of the window, over the page (no bar, no room
   taken: the page scrolls under it, and clicks go through it); the halo, of the page's colour,
   keeps it legible over what it covers */
.copyright {
    position:       fixed;
    inset:          auto 0 7px;
    margin:         0;
    z-index:        20;
    font-size:      11px;
    line-height:    1.3;
    text-align:     center;
    text-shadow:    0 0 3px var(--bg), 0 0 3px var(--bg), 0 0 3px var(--bg);
    pointer-events: none;
}

/* SIGORYX logo floating in the bottom right corner, faint until pointed at */
.logo     { position: fixed; right: 16px; bottom: 16px; width: 96px; height: 96px; z-index: 5;
            line-height: 0; opacity: .35; transition: opacity .2s ease; }
.logo:hover, .logo:focus-visible { opacity: 1; }
.logo img { width: 96px; height: 96px; object-fit: contain; display: block; }
@media (max-width: 600px) {           /* phones: smaller, closer to the corner */
    .logo, .logo img { width: 64px; height: 64px; }
    .logo            { right: 6px; bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) { .logo { transition: none; } }

/* -- map in perspective, globe (dsn_globe.js), as LightningMonitor's maps ----------- */

/* while one is shown, a click on a card or a complex zooms it there */
body.globe-on .card, body.globe-on .site-name { cursor: pointer; }

/* as wide as the page (the cards of MDSCC), centred; the whole width of a narrower window */
.globe-sec { max-width: calc(var(--page-w) + 2 * var(--gutter)); margin: 0 auto;
             padding: 0 var(--gutter) 16px; container-type: inline-size; }
.globe-sec[hidden] { display: none; }
.globe-sec h2 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.globe-info { margin-left: 10px; font-size: 12px; font-weight: 400; }

/* round, so as high as the window leaves room for under the section's title (the whole globe
   on screen when scrolled to it), but never higher than it is wide (100cqw: the width of its
   section, as wide as the page) */
.wmap {
    position: relative;
    min-height: min(220px, 100cqw);
    height: min(calc(100vh  - 48px), 100cqw);
    height: min(calc(100dvh - 48px), 100cqw);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: var(--panel);
}
/* the world, the antennas (WebGL), the labels: the top one takes the pointer */
.wmap canvas      { position: absolute; inset: 0; width: 100%; height: 100%; display: block;
                    pointer-events: none; }
#globe-lbl        { pointer-events: auto; cursor: grab; touch-action: none;
                    user-select: none; -webkit-user-select: none; }
#globe-lbl.drag   { cursor: grabbing; }

/* the map in perspective: 3:2, as wide as the section (the page); its labels' canvas takes the
   pointer for the orbit controls */
.wmap.map         { height: auto; min-height: 0; aspect-ratio: 3 / 2; }
.wmap[hidden]     { display: none; }
#map-lbl          { pointer-events: auto; cursor: grab; touch-action: none;
                    user-select: none; -webkit-user-select: none; }
#map-lbl:active   { cursor: grabbing; }
/* the compass of the map, top left: turned with the view (its N to the north); a click puts
   the north up */
.compass {
    position: absolute; left: 8px; top: 8px; z-index: 2;
    width: 40px; height: 40px; padding: 0;
    border: 1px solid var(--line); border-radius: 50%;
    background: color-mix(in srgb, var(--panel) 80%, transparent);
    cursor: pointer;
}
.compass:hover  { box-shadow: inset 0 0 0 1px var(--text); }
.compass svg    { display: block; width: 100%; height: 100%; transition: transform .1s linear; }
.compass .c-ring  { fill: none; stroke: var(--muted); stroke-width: 1; }
.compass .c-north { fill: var(--red); }
.compass .c-south { fill: var(--muted); }
.compass .c-n     { fill: var(--text); font: 600 8px system-ui, sans-serif; text-anchor: middle;
                    dominant-baseline: hanging; }
@media (prefers-reduced-motion: reduce) { .compass svg { transition: none; } }
/* the map or globe has the keys (a click on it, Tab): outlined only when reached with Tab */
.wmap:focus         { outline: none; }
.wmap:focus-visible { outline: 2px solid var(--change); outline-offset: 2px; }
/* the hints of the title: those of the view shown */
.globe-sec[data-mode="map"] .hint-globe, .globe-sec:not([data-mode="map"]) .hint-map { display: none; }

@media (max-width: 520px) {
    .site { flex-direction: column; gap: 4px; }
    .site-name { flex-direction: row; gap: 6px; align-items: baseline; flex-basis: auto; }
    .card { width: calc(50% - 3px); }
}
