/* The swallows nav: the top bar of a wetland nature reserve, alone on a white page, with a pair of swallows drawn on
   a canvas over it. The swallows' colours are read by the script from here. */
:root {
  --page: #ffffff;          /* the page */
  --bar: #eaf1f4;           /* the bar, the pale sky of a morning over the reeds */
  --edge: rgba(22, 42, 60, 0.1);  /* the bar's edge */
  --ink: #142030;           /* the name, the current link and the one pointed at */
  --muted: #61707d;         /* the other links */
  --reed: #234332;          /* the button and the reeds of the mark */
  --reed-lit: #2c5441;      /* the button pointed at */
  --on-reed: #f1f5ef;       /* the words on the button */
  --ring: #2b6a8e;          /* the outline of the keyboard focus */
  --swallow: #172336;       /* the swallows' backs, heads and wings */
  --swallow-far: #34465f;   /* the far wing, a little paler */
  --belly: #f3ecdf;         /* their pale breasts */
  --throat: #8d3d29;        /* the rust under the beak */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Albert Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the bar alone in the middle, with air above it for the swallows' flights */
.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 96px 16px 48px;
}

/* ---------------------------------------------------------------- the bar */
.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(880px, 100%);
  height: 62px;
  padding: 0 11px 0 18px;
  border-radius: 20px;
  background: var(--bar);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    0 1px 2px rgba(20, 38, 56, 0.06),
    0 18px 40px -26px rgba(20, 40, 60, 0.42);
}

a,
button {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

a:focus,
button:focus {
  outline: none;
}

/* ---------------------------------------------------------------- the name */
.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 8px 0 2px;
  border-radius: 12px;
}

.brand__mark {
  width: 28px;
  height: 28px;
  flex: none;
  fill: none;
  stroke: var(--reed);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.brand__head {
  fill: var(--reed);
  stroke: none;
}

.brand__name {
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

/* ---------------------------------------------------------------- the links */
.nav {
  display: flex;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.nav__list {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__link {
  position: relative;
  display: block;
  height: 42px;
  padding: 0 13px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 520;
  letter-spacing: -0.005em;
  line-height: 42px;
  white-space: nowrap;
  transition: color 0.25s ease, background-color 0.2s ease;
}

/* pressed: a shade of the bar under the link (the letters stay put: the swallows stand on them) */
.nav__link:active {
  background: rgba(22, 42, 60, 0.06);
  transition-duration: 0.05s;
}

.nav__link[aria-current='page'],
.nav__link:focus-visible {
  color: var(--ink);
}

@media (hover: hover) {
  .nav__link:hover {
    color: var(--ink);
  }
}

/* the letters, one box each, so a letter can dip under a swallow that lands on it; the box of no size at the end of
   a word sits on its baseline */
.word,
.ch,
.probe {
  display: inline-block;
}

.probe {
  width: 0;
  height: 0;
}

/* the word for screen readers, once the visible one is split into letters */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the button */
.cta {
  display: flex;
  flex: none;
  align-items: center;
  height: 42px;
  padding: 0 19px;
  border-radius: 999px;
  background: var(--reed);
  color: var(--on-reed);
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 2px rgba(16, 34, 24, 0.18);
  transition: background-color 0.2s ease, transform 0.16s ease-out;
}

.cta__short {
  display: none;
}

@media (hover: hover) {
  .cta:hover {
    background: var(--reed-lit);
  }
}

.cta:active {
  transform: scale(0.97);
}

/* ---------------------------------------------------------------- the phone's menu button */
/* a plain word with its two lines, so the swallows have the word to themselves */
.menu {
  display: none;
  flex: none;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.16s ease-out;
}

.menu:active {
  background: rgba(22, 42, 60, 0.07);
  transform: scale(0.97);
}

.menu__icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  overflow: visible;
}

/* the two lines cross when the links are open */
.menu__line {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.36s cubic-bezier(0.23, 1, 0.32, 1);
}

.bar.is-open .menu__line--a {
  transform: translateY(2.5px) rotate(45deg);
}

.bar.is-open .menu__line--b {
  transform: translateY(-2.5px) rotate(-45deg);
}

/* the two words stacked in one place: Menu, and Close when the links are open */
.menu__words {
  display: grid;
}

.menu__word {
  grid-area: 1 / 1;
  justify-self: center;
  transition: opacity 0.2s ease, transform 0.32s cubic-bezier(0.23, 1, 0.32, 1);
}

.menu__word--close {
  opacity: 0;
  transform: translateY(7px);
}

.bar.is-open .menu__word:not(.menu__word--close) {
  opacity: 0;
  transform: translateY(-7px);
}

.bar.is-open .menu__word--close {
  opacity: 1;
  transform: none;
}

/* ---------------------------------------------------------------- the keys */
.brand:focus-visible,
.nav__link:focus-visible,
.cta:focus-visible,
.menu:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- the swallows */
.sky {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  pointer-events: none;
}

/* ---------------------------------------------------------------- narrow screens: the links fold into a menu */
@media (max-width: 820px) {
  .bar {
    gap: 8px;
    height: 58px;
    padding: 0 8px 0 13px;
    border-radius: 18px;
  }

  .brand__name {
    font-size: 18px;
  }

  /* the button, then the menu at the far right (in the page's order the menu comes first, with its links) */
  .cta {
    order: 1;
    margin-left: auto;
    height: 40px;
    padding: 0 17px;
  }

  .cta__long {
    display: none;
  }

  .cta__short {
    display: inline;
  }

  .menu {
    order: 2;
    display: flex;
    height: 40px;
  }

  /* the links drop down under the bar, in a panel of the same paper */
  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 2;
    display: block;
    padding: 8px;
    border-radius: 18px;
    background: var(--bar);
    box-shadow:
      inset 0 0 0 1px var(--edge),
      0 1px 2px rgba(20, 38, 56, 0.06),
      0 22px 44px -26px rgba(20, 40, 60, 0.48);
    visibility: hidden;
    opacity: 0;
    clip-path: inset(0 0 100% 0 round 18px);
    transition: clip-path 0.3s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease, visibility 0s linear 0.3s;
  }

  .bar.is-open .nav {
    visibility: visible;
    opacity: 1;
    clip-path: inset(0 0 0 0 round 18px);
    transition: clip-path 0.36s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.16s ease, visibility 0s;
  }

  .nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  .nav__link {
    height: 56px;
    padding: 0 16px;
    font-size: 21px;
    line-height: 56px;
  }
}

/* la casella bassa dell'anteprima sul telefono: la barra in alto, con l'aria giusta sopra per i voli delle rondini,
   e le righe del menu più basse, così il menu aperto e le rondini stanno tutti nella casella */
@media (max-width: 820px) and (max-height: 520px) {
  .stage {
    align-items: start;
    padding: 78px 16px 12px;
  }

  .nav__link {
    height: 42px;
    font-size: 19px;
    line-height: 42px;
  }
}

/* with less motion: no presses that shrink, and the panel only fades */
@media (prefers-reduced-motion: reduce) {
  .cta:active,
  .menu:active {
    transform: none;
  }

  .menu__word,
  .menu__word--close,
  .bar.is-open .menu__word:not(.menu__word--close) {
    transform: none;
  }

  .menu__line {
    transition: none;
  }

  .nav,
  .bar.is-open .nav {
    clip-path: none;
  }
}
