/* ==========================================================================
   EXPERIMENT: centred glass navigation bar (homepage only, not published).
   Replaces the corner logo + Menu button while it's switched on. To undo:
   remove the glass-nav <nav>, this stylesheet and js/glass-nav.js from
   index.html.

   Two looks, picked by js/glass-nav.js from what's behind the bar:
   dark glass with white words over dark sections, clear glass with black
   words over light ones (.glass-nav--light).
   ========================================================================== */

/* the corner logo and Menu button step aside while the bar is on */
.site-header > .logo,
.site-header > .menu-btn { display: none; }

.glass-nav {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.glass-nav__bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border-radius: 14px;
  color: #fff;
  /* one even tint, just a touch deeper toward the bottom: no steps, so no
     band across the middle */
  background: linear-gradient(rgba(16, 16, 18, 0.52), rgba(16, 16, 18, 0.6));
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
  /* bevel: light catches the top-left rim, shade sits on the bottom-right */
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.24),
    inset -1px -1px 0 rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 12px 32px rgba(0, 0, 0, 0.28);
  transition: background 0.35s ease, box-shadow 0.35s ease, color 0.35s ease;
}

/* Chrome / Edge: real refraction. The SVG filter (built in js/glass-nav.js)
   bends the page behind the bar's rim, pulling red, green and blue slightly
   apart, so a faint rainbow runs along the edge as things scroll under it. */
.glass-refract .glass-nav__bar {
  -webkit-backdrop-filter: url(#glass-refract);
  backdrop-filter: url(#glass-refract);
}

/* a soft sheen across the bevel: bright top-left corner fading out */
.glass-nav__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.08));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Safari and Firefox can't bend the backdrop: a faint rainbow rim hints at it */
html:not(.glass-refract) .glass-nav__bar::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from 200deg, #ff6b6b, #ffd93d, #6bff95, #4dd8ff, #8b7bff, #ff6bd6, #ff6b6b);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.22;
  pointer-events: none;
}

/* the darker rectangle that slides to the current section */
.glass-nav__pill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 0;
  border-radius: 9px;
  background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.66));
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.14),
    inset -1px -1px 0 rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: background 0.35s ease, box-shadow 0.35s ease;
}
.glass-nav__pill.is-placed { opacity: 1; }

.glass-nav__link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  padding: 9px 15px;
  border-radius: 9px;
  font-family: var(--font-display);
  font-size: 0.85rem; /* ~13.6px */
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.2;
  color: inherit;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}
.glass-nav__link:not(.is-active):hover { background: rgba(255, 255, 255, 0.08); }
/* the selected word goes semibold. Each word quietly reserves the width of
   its bold version, so the words beside it don't shift when it changes. */
.glass-nav__label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.glass-nav__label::after {
  content: attr(data-label);
  font-weight: 600;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}
.glass-nav__link.is-active .glass-nav__label { font-weight: 600; }

.glass-nav__link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* the icon slides in to the left of the current section's word */
.glass-nav__icon {
  display: inline-flex;
  width: 0;
  margin-right: 0;
  opacity: 0;
  overflow: hidden;
  transition: width 0.35s var(--ease), margin-right 0.35s var(--ease), opacity 0.25s ease;
}
.glass-nav__icon svg {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.glass-nav__link.is-active .glass-nav__icon {
  width: 15px;
  margin-right: 7px;
  opacity: 1;
}

/* ---------- over light sections: clear glass, black words ---------- */
.glass-nav--light .glass-nav__bar {
  color: var(--ink);
  background: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.28));
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.95),
    inset -1px -1px 0 rgba(17, 17, 16, 0.1),
    0 0 0 1px rgba(17, 17, 16, 0.08),
    0 10px 28px rgba(17, 17, 16, 0.1);
}
.glass-nav--light .glass-nav__bar::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 45%);
}
/* a raised white chip: brighter than the glass around it, lifted by a soft
   shadow, instead of a grey fill (which read as muddy) */
.glass-nav--light .glass-nav__pill {
  /* see-through white, so what's behind the glass still shows a little */
  background: linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.5));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 0 0 1px rgba(17, 17, 16, 0.07),
    0 1px 2px rgba(17, 17, 16, 0.08),
    0 4px 14px rgba(17, 17, 16, 0.08);
}
.glass-nav--light .glass-nav__link:not(.is-active):hover { background: rgba(17, 17, 16, 0.05); }

/* ---------- Works dropdown (built by js/glass-nav.js) ---------- */
.glass-nav__caret {
  display: inline-flex;
  margin-left: 4px;
  transition: rotate 0.25s ease;
}
/* touch screens: a bigger invisible target, so the caret is easy to tap
   (with a mouse it would make the hover area spill past the Works pill) */
@media (hover: none) {
  .glass-nav__caret { margin: -8px -8px -8px -4px; padding: 8px; }
}
.glass-nav__caret svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.glass-nav.has-menu .glass-nav__caret { rotate: 180deg; }

.glass-nav__menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 260px;
  padding: 6px;
  border-radius: 14px;
  color: #fff;
  background: rgba(20, 20, 22, 0.86);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 16px 36px rgba(0, 0, 0, 0.3);
  opacity: 0;
  translate: 0 -6px;
  transition: opacity 0.2s ease, translate 0.2s ease;
}
.glass-nav__menu.is-open { opacity: 1; translate: 0 0; }
/* a bridge over the gap, so the pointer can travel from Works to the menu */
.glass-nav__menu::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}
.glass-nav__menu-link {
  display: flex;
  align-items: center;
  gap: 8px; /* the lock sits right after the project name */
  padding: 10px 12px;
  border-radius: 9px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  line-height: 1.3;
  color: inherit;
  white-space: nowrap;
}
.glass-nav__menu-link:hover { background: rgba(255, 255, 255, 0.1); }
.glass-nav__menu-link:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.glass-nav__menu-link[aria-current="page"] { font-weight: 600; background: rgba(255, 255, 255, 0.08); }
.glass-nav__lock { display: inline-flex; flex: none; }
.glass-nav__lock svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* light glass over light sections */
.glass-nav--light .glass-nav__menu {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.95),
    0 0 0 1px rgba(17, 17, 16, 0.08),
    0 16px 36px rgba(17, 17, 16, 0.14);
}
.glass-nav--light .glass-nav__menu-link:hover { background: rgba(17, 17, 16, 0.05); }
.glass-nav--light .glass-nav__menu-link[aria-current="page"] { background: rgba(17, 17, 16, 0.06); }

@media (max-width: 480px) {
  .glass-nav { top: 14px; }
  /* five words across a phone: a smaller size so they fit with a gutter */
  .glass-nav__link { padding: 8px 10px; font-size: 0.7rem; }
  .glass-nav__icon svg { width: 13px; height: 13px; }
  .glass-nav__link.is-active .glass-nav__icon { width: 13px; margin-right: 5px; }
}
/* small phones (iPhone SE / mini) */
@media (max-width: 390px) {
  .glass-nav__link { padding: 8px 6px; font-size: 0.66rem; }
  .glass-nav__caret { margin-left: -6px; }
  .glass-nav__caret svg { width: 10px; height: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .glass-nav__menu,
  .glass-nav__caret,
  .glass-nav__icon,
  .glass-nav__bar,
  .glass-nav__pill { transition: none; }
}
