/*
 * ============================================================================
 *  THE LANGUAGE BUTTON
 * ============================================================================
 *
 *  The button that opens the list of languages.
 *
 *  It sits in the top-left corner on a phone (the top-right corner is
 *  where the app switcher and the install button live) and next to the
 *  switcher on a wide screen. It never covers the work: on a phone it
 *  shrinks to the globe alone.
 *
 * ============================================================================
 */

.tsite-lang {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 2147483004;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.tsite-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(16, 16, 24, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: rgba(255, 255, 255, 0.88);
  font: 600 13px/1 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.16s, background 0.16s;
}

.tsite-lang-btn:hover {
  transform: translateY(-1px);
  background: rgba(28, 28, 40, 0.92);
}

.tsite-lang-btn:active {
  transform: scale(0.97);
}

.tsite-lang-btn:focus-visible {
  outline: 2px solid #7c6cff;
  outline-offset: 2px;
}

.tsite-lang-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 250px;
  max-height: min(70vh, 460px);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(14, 14, 22, 0.97);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  animation: tsite-lang-rise 0.16s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.tsite-lang-panel[hidden] {
  display: none;
}

@keyframes tsite-lang-rise {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.tsite-lang-list {
  display: grid;
  gap: 1px;
  padding: 6px;
}

.tsite-lang-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s;
}

.tsite-lang-row:hover {
  background: rgba(255, 255, 255, 0.07);
}

.tsite-lang-row:focus-visible {
  outline: 2px solid #7c6cff;
  outline-offset: -2px;
}

.tsite-lang-row.is-current {
  background: rgba(124, 108, 255, 0.18);
  color: #fff;
}

.tsite-lang-native {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.tsite-lang-english {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* On a phone the button is the globe alone, so it takes as little room
   as possible. */
@media (max-width: 520px) {
  .tsite-lang {
    top: 10px;
    left: 10px;
  }
  .tsite-lang-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
  }
  .tsite-lang-name {
    display: none;
  }
  .tsite-lang-panel {
    width: min(280px, calc(100vw - 20px));
  }
}

/* On a wide screen the button sits next to the app switcher, so the two
   never fight for the same corner. */
@media (min-width: 900px) {
  .tsite-lang {
    left: auto;
    right: 76px;
    bottom: 18px;
    top: auto;
  }
  .tsite-lang-panel {
    left: auto;
    right: 0;
    top: auto;
    bottom: calc(100% + 8px);
  }
}

/* ------------------------------------------------------------- in a header */

/*
 * The button lives in the header of the page, not in the corner of the
 * window, so it is a part of the bar and not a layer over it.
 */

/*
 * The box the buttons of the site live in.
 *
 * It is a row, so the two buttons sit side by side and the box is only as
 * tall as one button.
 *
 * The box stands at the LEFT-hand end of the bar. The right-hand end is
 * where the app keeps its own buttons (Save, Export, the account), and the
 * buttons of the site used to sit on top of them, so a click reached the
 * ad or the app's button instead of the one that was pressed.
 *
 * The box has to be a row whatever the header around it is: a header that
 * is a grid would otherwise make a new cell for it, and the header would
 * grow a row that was not there before.
 */
.tsite-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  width: auto;
  height: auto;
  min-width: 0;
  margin-left: 0;
  margin-right: auto;
  padding: 0;
  grid-column: auto;
  grid-row: auto;
  order: -1;
  /*
   * The box is one row and never wraps: the button that leads back to the
   * landing page, the button of the language and the button of the
   * switcher always stay on one line, whatever the width of the window.
   */
  flex-wrap: nowrap;
  /*
   * The buttons are above the parts of the app that stretch across the
   * bar (a brand that runs the whole width, for example), so a click
   * always reaches the button and not the link underneath it.
   */
  position: relative;
  z-index: 900;
}

.tsite-tools:empty {
  display: none;
}

/*
 * The box is always one row. It is never a column, even in a bar that
 * stands on its side: the three buttons are small, and a row keeps them
 * together and keeps them from breaking the bar of the app.
 */

/* In a grid header the box is put in the first cell of the row, so it does
   not push the header down and it stands at the left-hand end. */
.tsite-tools.tsite-tools-grid {
  grid-column: 1 / 2;
  grid-row: 1;
}

/* When the box is the only thing in a header of its own, it stands at the
   left-hand end of the bar. */
.tsite-tools.tsite-tools-alone {
  margin-left: 0;
  margin-right: auto;
  padding-left: 8px;
}

/*
 * The box has no header to live in yet (an app that draws its header a
 * moment after the page has loaded).
 *
 * It sits at the top-left corner of the window until the header is there,
 * so the visitor can always reach the buttons.
 */
body > .tsite-tools.tsite-tools-alone {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 2147483000;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
}

/*
 * A screen of an app that has no header of its own (the start screen of
 * the video studio). The box sits in the corner of the app, above the
 * page, so it is always within reach.
 */
.tsite-tools.tsite-tools-in-app {
  position: fixed;
  top: 10px;
  z-index: 900;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
}

/*
 * A header with no group of its own at the left.
 *
 * The box is pinned to the left-hand end of the bar, over the app's own
 * buttons. The first part of the bar is given the room the box takes, so
 * the app's own buttons move out of the way instead of being covered.
 */
.tsite-tools.tsite-tools-pinned {
  position: absolute;
  top: 50%;
  left: 8px;
  right: auto;
  transform: translateY(-50%);
  margin-left: 0;
  margin-right: 0;
  z-index: 6;
}

/*
 * A short bar (the header of the video studio on a phone) gets a row of
 * the tools instead of a column, so the box never stands taller than the
 * bar it lives in.
 */
.tsite-tools.tsite-tools-pinned.tsite-tools-row {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin-top: 0;
}

header.tsite-bar-pinned,
.tsite-bar-pinned {
  position: relative;
  /* The room the pinned box takes. The app's own buttons move out of the
     way instead of being covered by it. */
  padding-left: 84px !important;
}

/* On a phone the box is smaller, so less room is needed. */
@media (max-width: 900px) {
  header.tsite-bar-pinned,
  .tsite-bar-pinned {
    padding-left: 80px !important;
  }
}

.tsite-lang.tsite-tool {
  position: relative;
  inset: auto;
  z-index: auto;
  display: inline-flex;
  align-items: center;
}

.tsite-lang.tsite-tool .tsite-lang-btn {
  height: 32px;
  width: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 9px;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: none;
  color: inherit;
  font: 600 12.5px/1 inherit;
}

/* In an app the button is the globe alone: the header of an app has no
   room for the name of the language, and the name is in the list anyway. */
.tsite-lang.tsite-tool .tsite-lang-name {
  display: none;
}

.tsite-lang.tsite-tool .tsite-lang-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: none;
}

/* The list of languages opens downwards from the button. */
.tsite-lang.tsite-tool .tsite-lang-panel {
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  bottom: auto;
}

/*
 * The list of languages is placed against the window by the script that
 * owns it, so it is never cut off by the header of an app.
 */
.tsite-lang-panel {
  z-index: 2147483005;
}

/*
 * The list while it is open.
 *
 * It stands on its own in the body of the page, against the window. The
 * styles of an app may put a height on anything that stands in the body,
 * so the size of the list is set here and kept.
 */
.tsite-lang-panel--free {
  position: fixed !important;
  top: auto;
  bottom: auto;
  left: auto;
  right: auto;
  width: 250px !important;
  height: auto !important;
  max-height: min(70vh, 460px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  z-index: 2147483005 !important;
}

@media (max-width: 520px) {
  .tsite-lang-panel--free {
    width: min(280px, calc(100vw - 20px)) !important;
  }
}

/* On a phone the button is the globe alone, so it takes as little room
   as possible. */
@media (max-width: 520px) {
  .tsite-lang.tsite-tool .tsite-lang-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }
  .tsite-lang.tsite-tool .tsite-lang-name {
    display: none;
  }
  .tsite-lang.tsite-tool .tsite-lang-panel {
    width: min(280px, calc(100vw - 20px));
  }
}
