/* The stained glass nav: the top bar of a glass museum, alone on a white page. The glass, the lead and the light on
   the floor are worked out by the script pixel by pixel, with the colours below. */
:root {
  --page: #ffffff;          /* the page */
  --ruby: #a0142c;          /* the glass of each link, as it is with no light behind it */
  --cobalt: #1d3c9c;
  --amber: #b5650a;
  --emerald: #0f7044;
  --violet: #5a2780;
  --clear: #dfe2cc;         /* the pale antique glass round the coloured tiles */
  --rondel: #bcc25e;        /* the spun disc of glass beside the name */
  --corner: #b8780f;        /* the small squares in the border of the window, on a phone */
  --lead: #45474b;          /* the lead between the pieces, where the room's light catches it */
  --lead-deep: #121315;     /* the lead in its own shade */
  --lead-shine: #c9c8c2;    /* the shine along the top of the lead */
  --solder: #8a8b88;        /* the dabs of solder where the leads meet */
  --light: #ffd9a0;         /* the warm light behind the bar */
  --letters: #ede2c8;       /* the letters, ground clear out of the coloured glass */
  --letters-lit: #fffaf0;   /* the letters with the light behind them */
  --trace: rgba(28, 12, 4, 0.7);  /* the dark painted line round the letters */
  --brand-ink: #241a14;     /* the name, painted on the pale glass */
  --cta: #24211e;           /* the button */
  --on-cta: #f4ead2;        /* the words on the button */
  --ring: #ffd66b;          /* the outline of the keyboard focus */
}

* {
  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(--letters);
  font-family: 'Cinzel Variable', 'Trajan Pro', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

/* the component sits in the middle of the page; on a real site .vitrail goes at the top, the floor light over the
   page under it (position: absolute; top: 0; left: 50%; translate: -50% 0; the floor stays as it is, under the bar) */
.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 48px 16px;
}

.vitrail {
  position: relative;
  width: min(1000px, 100%);
}

.vitrail.is-waiting {
  opacity: 0;
}

/* ---------------------------------------------------------------- the bar */
.bar {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 64px;
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(22, 18, 14, 0.16),
    0 16px 30px -20px rgba(22, 18, 14, 0.5);
}

/* the glass and the lead, drawn by the script over the whole bar, under the words */
.glass {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

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

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

/* every part of the bar sits in a lancet: the words are centred in its body, under the point of the arch */
.brand,
.link,
.end,
.toggle {
  padding-top: 12px;
}

/* ---------------------------------------------------------------- the name, painted on pale glass */
.brand {
  position: relative;
  z-index: 1;
  display: flex;
  flex: none;
  align-items: center;
  gap: 11px;
  padding-left: 19px;
  padding-right: 22px;
  color: var(--brand-ink);
  border-radius: 14px;
}

/* the place of the spun disc of glass, drawn by the script */
.brand__rondel {
  width: 26px;
  height: 26px;
  flex: none;
}

.brand__name {
  font-size: 15px;
  font-weight: 760;
  letter-spacing: 0.15em;
  line-height: 1;
  text-transform: uppercase;
  margin-right: -0.15em;
  text-shadow: 0 0.5px 0 rgba(255, 250, 235, 0.55);
}

/* ---------------------------------------------------------------- the links, one tile of glass each */
.nav {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
}

/* the window of the phone, only there */
.nav__glass {
  display: none;
}

.list {
  position: relative;
  display: flex;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  flex: 1 1 auto;
  height: 100%;
}

.item[data-glass-color='ruby'] { --tone: var(--ruby); }
.item[data-glass-color='cobalt'] { --tone: var(--cobalt); }
.item[data-glass-color='amber'] { --tone: var(--amber); }
.item[data-glass-color='emerald'] { --tone: var(--emerald); }
.item[data-glass-color='violet'] { --tone: var(--violet); }

/* each link is the whole tile; --lit, from 0 to 1, is how much light comes through it, written by the script */
.link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding-left: 16px;
  padding-right: 16px;
  color: var(--letters);
  color: color-mix(in srgb, var(--letters-lit) calc(var(--lit, 0) * 100%), var(--letters));
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.11em;
  line-height: 14px;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow:
    0 0 1px var(--trace),
    0 1px 1.5px var(--trace),
    0 0 calc(var(--lit, 0) * 13px) color-mix(in srgb, var(--tone, #fff) 55%, var(--light));
}

/* the word keeps the room of its heavier self, so the tile does not move when the page changes */
.link__word {
  display: inline-grid;
  margin-right: -0.11em;
  transition: transform 0.16s ease-out;
}

.link__word::after {
  content: attr(data-text);
  grid-area: 1 / 1;
  height: 0;
  font-weight: 760;
  visibility: hidden;
  overflow: hidden;
}

.link[aria-current='page'] {
  font-weight: 760;
}

/* the keys: a thin gold ring round the word, clear of the lead */
.link__word {
  border-radius: 5px;
  outline: 1.5px solid transparent;
  outline-offset: 6px;
}

.link:focus-visible .link__word {
  outline-color: var(--ring);
}

.link:active .link__word {
  transform: scale(0.95);
}

/* ---------------------------------------------------------------- the button, on the last piece of pale glass */
.end {
  position: relative;
  z-index: 1;
  display: flex;
  flex: none;
  align-items: center;
  padding-left: 18px;
  padding-right: 13px;
}

/* the pill of the bar: the word widens on the width axis, the pill swells with a bounce (in the script) */
.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  height: 34px;
  color: var(--on-cta);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-size: 12.5px;
  font-stretch: 100%;
  font-weight: 640;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  isolation: isolate;
  transition: font-stretch 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.16s ease-out;
}

.cta__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  background: var(--cta);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.35);
}

@media (hover: hover) {
  .cta:hover {
    font-stretch: 118%;
  }
}

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

.brand:focus-visible,
.cta:focus-visible,
.toggle:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -4px;
}

.cta:focus-visible {
  outline-offset: 3px;
  border-radius: 999px;
}

/* ---------------------------------------------------------------- the menu button, only on a phone */
/* it stands on a tile of the colour of the page you are on, with the light behind it */
.toggle {
  position: relative;
  z-index: 1;
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 124px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--letters);
  color: color-mix(in srgb, var(--letters-lit) calc(var(--lit, 0) * 100%), var(--letters));
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow:
    0 0 1px var(--trace),
    0 1px 1.5px var(--trace),
    0 0 calc(var(--lit, 0) * 12px) var(--light);
  cursor: pointer;
}

.toggle__label {
  display: inline-block;
  min-width: 46px;
  text-align: right;
  margin-right: -0.12em;
  transition: transform 0.16s ease-out;
}

.toggle__icon {
  width: 18px;
  height: 18px;
  overflow: visible;
  filter: drop-shadow(0 0 1px var(--trace));
}

.toggle__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.toggle:active .toggle__label {
  transform: scale(0.95);
}

/* ---------------------------------------------------------------- the light on the floor */
.floor {
  display: block;
  width: 100%;
  height: 120px;
  pointer-events: none;
}

.floor--panel {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
}

/* ---------------------------------------------------------------- narrower screens: the button goes */
@media (max-width: 980px) {
  .end {
    display: none;
  }

  .link {
    padding-left: 13px;
    padding-right: 13px;
  }
}

/* ---------------------------------------------------------------- the phone: the links open in a window of their own */
@media (max-width: 760px) {
  .bar {
    height: 60px;
    border-radius: 15px;
  }

  .brand {
    flex: 1;
    min-width: 0;
    padding-left: 17px;
  }

  .toggle {
    display: flex;
  }

  .floor {
    height: 104px;
  }

  .floor--panel {
    display: block;
    height: 120px;
  }

  /* the window hangs under the bar: one row of glass for each link, in a border of pale glass */
  .nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 3;
    flex: none;
    height: 270px;
    border-radius: 15px;
    box-shadow:
      0 1px 2px rgba(22, 18, 14, 0.16),
      0 22px 36px -22px rgba(22, 18, 14, 0.55);
    clip-path: inset(0 0 100% 0 round 15px);
    visibility: hidden;
  }

  .bar.is-open .nav {
    clip-path: inset(0 0 0 0 round 15px);
    visibility: visible;
  }

  .nav__glass {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    pointer-events: none;
  }

  .list {
    flex-direction: column;
    padding: 5px 0;
    touch-action: none;
  }

  .item {
    flex: none;
    height: 52px;
  }

  .link {
    justify-content: flex-start;
    padding: 0 20px 0 36px;
    font-size: 14px;
    letter-spacing: 0.13em;
  }

  .link__word {
    margin-right: -0.13em;
  }
}

/* la casella bassa dell'anteprima sul telefono: la barra in alto e le righe di vetro della finestra più basse,
   così la finestra aperta e la sua luce sul pavimento stanno nella casella */
@media (max-width: 760px) and (max-height: 520px) {
  .stage {
    align-items: start;
    padding: 14px 16px;
  }

  .nav {
    height: 230px;
  }

  .item {
    height: 44px;
  }

  .floor--panel {
    height: 80px;
  }
}

/* with less motion: no presses that shrink, and the button keeps its width */
@media (prefers-reduced-motion: reduce) {
  .cta {
    font-stretch: 100%;
  }

  @media (hover: hover) {
    .cta:hover {
      font-stretch: 100%;
    }
  }

  .cta:active,
  .link:active .link__word,
  .toggle:active .toggle__label {
    transform: none;
  }
}
