/*
 * Testogram desktop app — the page around Flutter (BITE WA5).
 *
 *   #tg-titlebar  the installed app's own top bar. Only in Window Controls
 *                 Overlay (Chrome and Edge, Windows and Mac): it fills the
 *                 title-bar area the browser hands the page, the window drags
 *                 by it, and the OS window buttons sit over its right end —
 *                 never over Flutter, which is laid out BELOW the bar.
 *   #tg-app       Flutter's host element (flutter_bootstrap.js). Full window;
 *                 below the bar while the overlay is on.
 *   #tg-loader    the loading screen: the app splash's look (white crowned T
 *                 on deep sapphire, a gold line sweeping a dim track) until
 *                 Flutter's first frame.
 *
 * Colours are the brand's (docs/desktop/TESTOGRAM_DESIGN_GUIDE_FOR_DESKTOP.md):
 * deep sapphire #124799, gold #F59E0B, page #FAFAFA. Light only.
 */

:root {
  color-scheme: light;
  --tg-deep-sapphire: #124799;
  --tg-gold: #F59E0B;
  --tg-page: #FAFAFA;
  /* 0 outside the overlay, so the app fills the window. */
  --tg-bar-height: 0px;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--tg-page);
}

/* ── The top bar ─────────────────────────────────────────────────────────── */

#tg-titlebar {
  display: none;
}

@media (display-mode: window-controls-overlay) {
  :root {
    --tg-bar-height: env(titlebar-area-height, 33px);
  }

  #tg-titlebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    /* Full width: the ground behind the OS buttons is the bar's colour too. */
    width: 100%;
    height: var(--tg-bar-height);
    background: var(--tg-deep-sapphire);
    /* The whole bar moves the window… */
    app-region: drag;
    -webkit-app-region: drag;
    user-select: none;
    -webkit-user-select: none;
    z-index: 3;
  }

  /* …and its content stays inside the area the OS buttons leave free. */
  .tg-titlebar-content {
    position: absolute;
    top: env(titlebar-area-y, 0px);
    left: env(titlebar-area-x, 0px);
    width: env(titlebar-area-width, 100%);
    height: env(titlebar-area-height, 33px);
    display: flex;
    align-items: center;
    padding: 0 12px;
    box-sizing: border-box;
    overflow: hidden;
  }

  .tg-titlebar-lockup {
    display: block;
    height: 18px;
    width: auto;
    pointer-events: none;
  }
}

/* ── Flutter ─────────────────────────────────────────────────────────────── */

#tg-app {
  position: fixed;
  top: var(--tg-bar-height);
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
}

/* ── The loading screen ──────────────────────────────────────────────────── */

#tg-loader {
  position: fixed;
  top: var(--tg-bar-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--tg-deep-sapphire);
  transition: opacity 200ms ease-out;
}

#tg-loader.tg-loader-done {
  opacity: 0;
  pointer-events: none;
}

.tg-loader-mark {
  width: 185px;
  height: 185px;
}

.tg-loader-track {
  position: relative;
  width: 140px;
  height: 4px;
  margin-top: 28px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.tg-loader-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--tg-gold);
  animation: tg-sweep 1.6s ease-in-out infinite;
}

@keyframes tg-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
  .tg-loader-bar {
    animation: none;
    width: 100%;
  }
}

.tg-noscript {
  position: fixed;
  top: 40%;
  left: 0;
  right: 0;
  margin: 0;
  z-index: 4;
  text-align: center;
  color: #FFFFFF;
  font: 16px/1.5 system-ui, sans-serif;
}
