/*
 * The title bar: the logo on the menu, the page title elsewhere, with a back button or action buttons. It stays on
 * top while the page scrolls (the frame, .chrome, is the sticky part); the status bar of the web app is covered by the
 * safe-area padding. A phone on its side gets a slimmer one. Not on the desktop and the tablet in landscape.
 */

@layer components {
  .topbar {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: calc(env(safe-area-inset-top) + var(--s-2)) var(--s-4) var(--s-2);
    background: var(--header);
    color: var(--on-header);
  }

  /* A long title (or large text) wraps onto a second line and the bar grows with it: a title is never cut off. */
  .topbar__title {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    line-height: 1.2;
    font-size: 1.0625rem;
    font-weight: 700;
  }

  /*
   * A title in the display font of the look (screens without a back button). The title of a bar is bold in every look, as the
   * design draws it (700), where the other display text (the greeting, the headings) has the weight of the look (600 in the two
   * italic ones).
   */
  .topbar__title--display {
    font-family: var(--font-display);
    font-style: var(--display-style);
    font-weight: 700;
    font-size: 1.375rem;
    letter-spacing: 0.01em;
  }

  /* With a back button the title is centred, balanced by an empty space of the width of the button. */
  .topbar__title--centered {
    text-align: center;
  }

  .topbar__spacer {
    flex: 1;
  }

  .topbar__brand {
    display: flex;
    align-items: center;
    min-height: var(--tap);
    line-height: 0;
  }

  .topbar__logo {
    display: block;
    width: auto;
    height: 40px;
  }

  .topbar__brand:active {
    opacity: 0.6;
  }

  /* A phone on its side: a slim bar, as native apps have in landscape. */
  @media (pointer: coarse) and (max-height: 500px) {
    :root {
      --topbar-h: 48px;
    }

    .topbar {
      padding-block: calc(env(safe-area-inset-top) + 2px) 2px;
    }

    .topbar__title--display {
      font-size: 1.1875rem;
    }
  }

  /* The same width as an icon button, so a centred title stays centred. */
  .topbar__balance {
    flex: none;
    width: var(--tap);
  }

  /* The band in the colour of the header behind the top half of the restaurant card: on the phone only. */
  .hero-band {
    height: 44px;
    background: var(--header);
  }

  .hero-band + .resto {
    position: relative;
    margin-top: -40px;
  }

  @media (min-width: 600px) and (min-height: 501px), (min-width: 600px) and (pointer: fine) {
    .hero-band {
      display: none;
    }

    .hero-band + .resto {
      margin-top: var(--s-3);
    }
  }
}
