/*
 * Responsible for: how the two-way switch above the Map looks: two names side by side in one pill, the chosen one filled.
 *
 * Must never: change its size when the choice changes (the Map below must never move): both sides have one width, one
 * weight and one height, and only the fill tells them apart. Values come from tokens.css only.
 */

@layer kit {
  .ia-switch {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--rule);
    border-radius: var(--r-pill);
    background: var(--sunken);
  }

  .ia-switch__side {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 7.5rem;
    height: var(--s-6);
    padding: 0 var(--s-4);
    border-radius: var(--r-pill);
    color: var(--muted);
    font-size: var(--t-sm);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }

  .ia-switch__side.is-chosen {
    background: var(--accent);
    color: var(--on-accent);
  }

  .ia-switch__side:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  @media (hover: hover) {
    .ia-switch__side:hover:not(.is-chosen) {
      background: var(--hover);
      color: var(--ink);
    }
  }

  /* On a phone the switch is as wide as the page and each side is a full finger tall. */
  @media (max-width: 600px) {
    .ia-switch {
      display: flex;
    }

    .ia-switch__side {
      flex: 1 1 0;
      min-width: 0;
      height: var(--tap);
    }
  }

  /*
   * The demo's "Shown as  Gmail | Outlook" choice. It is the same switch in a quieter dress, so that it is not taken for the
   * Map's "All mail | Your inbox": a small word before it, no filled pill, and the chosen side marked by a line under it.
   */
  .ia-look {
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    gap: var(--s-2);
    min-width: 0;
  }

  .ia-look__label {
    color: var(--muted);
    font-size: var(--t-xs);
    white-space: nowrap;
  }

  .ia-switch--quiet,
  .ia-switch--quiet .ia-switch__side {
    border-color: transparent;
    background: transparent;
  }

  .ia-switch--quiet .ia-switch__side {
    flex: 0 0 auto;
    min-width: 0;
    padding: 0 var(--s-3);
    border-radius: var(--r-sm);
    font-size: var(--t-xs);
  }

  .ia-switch--quiet .ia-switch__side.is-chosen {
    background: transparent;
    color: var(--ink);
    box-shadow: inset 0 -2px 0 var(--accent);
  }

  @media (hover: hover) {
    .ia-switch--quiet .ia-switch__side:hover:not(.is-chosen) {
      background: transparent;
      color: var(--ink);
    }
  }

  /* The quiet switch does not stretch across a phone as the Map's does. */
  @media (max-width: 600px) {
    .ia-switch--quiet {
      display: inline-flex;
    }

    .ia-switch--quiet .ia-switch__side {
      flex: 0 0 auto;
    }
  }
}
