/* ============================================================
   TTCC — NAVIGATION
   Top bar, slide-in menu panel and search overlay. Shared by
   index.html and works.html. Load after base.css.
   ============================================================ */

/* ============================================================
   TOP BAR
   Full width, transparent, sits above the hero slider. Its side
   padding matches the slider's inset, so their edges line up.
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  height: var(--topbar-h);
  background: transparent;
  /* Carried from the start so the bar's height never shifts when the
     solid state fades its colour in. */
  border-bottom: 1px solid transparent;
  /* Hide-on-scroll-down / reveal-on-scroll-up (class toggled by JS).
     --ease-panel is cubic-bezier(0.76, 0, 0.24, 1). */
  transform: translateY(0);
  transition:
    transform 0.55s var(--ease-panel),
    background-color 0.35s ease,
    border-color 0.35s ease;
}

/* Solid state: added by JS once the bar is revealed past the top of the
   page, so its text never has to compete with the media behind it.
   Dark pages by default; the light home page overrides below. */
.topbar.is-solid {
  background-color: #000000;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.home .topbar.is-solid {
  background-color: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

.topbar.nav-hidden {
  transform: translateY(-100%);
}

@media (prefers-reduced-motion: reduce) {
  .topbar {
    transition-duration: 0.01ms;
  }
}

/* Same gutter and same 2000px cap as the hero slider, so the brand's left
   edge and "Blog"'s right edge sit on the slider's own edges. */
.topbar__inner {
  max-width: 2000px;
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Wraps the logo only — line-height 0 so the anchor is exactly as tall
   as the image and the bar's centring stays true. */
.topbar__brand {
  display: block;
  line-height: 0;
}

.topbar__logo,
.search-panel__logo {
  display: block;
  height: 34px;
  width: auto;
}

/* Right-hand controls. Grouped so the bar stays a two-item flex row and
   the nav keeps its place; on the home page the group is empty at desktop
   width, so it is hidden outright. */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.home .topbar__actions {
  display: none;
}

.topbar__search {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: #e6e6e6;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.topbar__search:hover {
  opacity: 0.55;
}

.topbar__search svg {
  display: block;
}

/* The artwork is black on transparent. That reads on the white home page;
   on the dark pages it is inverted to white to match the bar's text. */
body:not(.home) .topbar__logo {
  filter: invert(1);
}

/* ----- Horizontal nav (desktop only) ----- */
.topnav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.topnav__link,
.topnav__search {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  color: #999999;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: color 0.3s ease;
}

/* base.css sets these to #111 for the light theme, at a specificity this
   file cannot beat unscoped — so the muted default is restated with the
   same `body.home` scope here, where it lands later in the cascade. */
body.home .topnav__link,
body.home .topnav__search {
  color: #999999;
}

/* The current page's link stays dark; hover only lifts the others. */
.topnav__link.is-active,
body.home .topnav__link.is-active {
  color: #000000;
}

.topnav__link:not(.is-active):hover,
.topnav__search:hover,
body.home .topnav__link:not(.is-active):hover,
body.home .topnav__search:hover {
  color: #000000;
}

.topnav__search {
  display: inline-flex;
  align-items: center;
}

.topnav__search svg {
  display: block;
}

/* Toggle button. Two states only: the full .topnav above 900px, the
   hamburger below it — so the button itself is hidden at desktop width
   and never shows the old "+" icon or "Menu" label. */
.menu-toggle {
  display: none;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  padding: 0;
  color: #e6e6e6;
  font: inherit;
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* The only icon the toggle ever shows. */
.menu-toggle__burger {
  display: block;
}

/* Retired with the intermediate "+ Menu" variant: the markup still
   carries these, so they are held hidden at every width. Their old
   rotate/hover rules went with the variant. */
.menu-toggle__iconwrap,
.menu-toggle__label {
  display: none;
}

/* ----- Mobile bar: logo left, hamburger right, nothing else -----
   The only nav breakpoint: above it the full .topnav, below it the
   hamburger. */
@media (max-width: 900px) {
  .topnav {
    display: none;
  }

  /* Nav is gone, so its search icon goes with it — the search overlay is
     reached from the menu panel. */
  .topbar__search {
    display: none;
  }

  .topbar__actions,
  .home .topbar__actions {
    display: flex;
  }

  .menu-toggle {
    display: inline-flex;
  }

  /* The panel covers the full width here, so the home page's black logo
     would sit on black. Invert it for as long as the panel is open —
     the same flip the toggle already does. */
  body.home.is-open .topbar__logo {
    filter: invert(1);
  }

  /* Two lines, and they cross when open — the state stays readable
     without a "Close" label. */
  .menu-toggle__burger line {
    transform-origin: 12px 9px;
    transition: transform 0.4s var(--ease-panel);
  }

  body.is-open .menu-toggle__burger line:nth-child(1) {
    transform: translateY(4px) rotate(45deg);
  }

  body.is-open .menu-toggle__burger line:nth-child(2) {
    transform: translateY(-4px) rotate(-45deg);
  }
}

@media (max-width: 700px) {
  .topbar__logo,
  .search-panel__logo {
    height: 26px;
  }
}

/* ============================================================
   SEARCH OVERLAY
   Blurred backdrop + a white panel that slides down over it.
   Open/close is driven by the `is-open` class JS puts on the
   overlay; the closed rules carry the exit timings, so the two
   directions can run on different curves.
   ============================================================ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;                 /* above the top bar (100) */
  /* Closed: inert, and only removed from the a11y tree once the exit
     animation has finished (contents 0.2s + panel 0.45s + backdrop 0.35s). */
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 1s;
}

.search-overlay.is-open {
  visibility: visible;
  pointer-events: auto;
  transition: visibility 0s;
}

/* ----- Backdrop: blurs whatever is behind it ----- */
.search-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  opacity: 0;
  /* Closing: the backdrop is last to go. */
  transition: opacity 0.35s ease 0.65s;
}

.search-overlay.is-open .search-overlay__backdrop {
  opacity: 1;
  transition: opacity 0.35s ease;
}

/* ----- Panel: slides down from above ----- */
.search-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* Was a flat 360px: the panel now grows with its results, and the list
     inside takes over the scrolling once there are too many. */
  min-height: 360px;
  max-height: 85vh;
  background: #ffffff;
  transform: translateY(-100%);
  /* Closing: waits for the contents to fade, then leaves. */
  transition: transform 0.45s var(--ease-panel) 0.2s;
  will-change: transform;
}

.search-overlay.is-open .search-panel {
  transform: translateY(0);
  transition: transform 0.6s var(--ease-panel);
}

/* Same gutter and cap as the top bar, so the logo lands where the
   bar's own logo sits. */
.search-panel__inner {
  max-width: 2000px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  flex-direction: column;
  /* Contents come in after the panel is on its way down, and are the
     first thing to leave on the way out. */
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.search-overlay.is-open .search-panel__inner {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.5s ease-out 0.18s,
    transform 0.5s ease-out 0.18s;
}

/* ----- Top row: mirrors the top bar ----- */
.search-panel__top {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-close {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  color: #111111;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.search-close:hover {
  opacity: 0.55;
}

.search-close svg {
  display: block;
}

/* ----- Field row, then the results under it ----- */
.search-panel__body {
  flex: 1 1 auto;
  min-height: 0;              /* lets the results scroll instead of spilling */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ----- Results -----
   Hidden outright until there is a query, so an empty field leaves the
   panel exactly as it was. */
.search-results {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 32px;
  padding-bottom: 32px;
  overflow-y: auto;
}

.search-results[hidden] {
  display: none;
}

.search-group + .search-group {
  margin-top: 28px;
}

.search-group__label {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: #8a8a8a;
}

.search-result {
  display: block;
  padding: 12px 0;
  border-radius: 0;
  color: #111111;
  transition: opacity 0.2s ease;
}

.search-result:hover {
  opacity: 0.55;
}

.search-result__title {
  display: block;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}

.search-result__meta {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: #8a8a8a;
}

.search-results__empty {
  font-size: 15px;
  font-weight: 400;
  color: #8a8a8a;
}

.search-field {
  width: 100%;
  display: flex;
  /* Centred, not baseline: an image's baseline is its bottom edge, which
     would hang the mascot above the line rather than on it. */
  align-items: center;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #d8d8d8;
}

.search-field__input {
  flex: 1 1 auto;
  min-width: 0;                 /* lets it shrink inside the flex row */
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 42px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: #111111;
  outline: none;
  /* Strip the UA's search-field chrome */
  -webkit-appearance: none;
  appearance: none;
}

.search-field__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

/* Set smaller than the typed text, which stays at the input's own size. */
.search-field__input::placeholder {
  font-size: 26px;
  color: #b8b8b8;
  opacity: 1;                   /* Firefox dims placeholders by default */
}

/* The mascot is the submit control — the button stays for the click
   target and keyboard access, the image carries the label. */
.search-field__submit {
  flex: 0 0 auto;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  line-height: 0;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.search-field__submit:hover {
  opacity: 0.7;
}

.search-field__mascot {
  display: block;
  height: 60px;
  width: auto;
  transform-origin: bottom center;
}

/* ----- Typing hop -----
   One-shot, added by JS as `is-hopping` on the first keystroke. Three
   hops of decreasing height (12/9/6px), each ~200ms up (ease-out) and
   ~200ms down (ease-in), with a 90ms squash on every landing. Vertical
   only — no rotation, and the pupil is part of the same image so it
   never moves independently. Total 1300ms.

   Percentages below are that 1300ms timeline:
     0     start          600   land 1 + squash
     200   apex 1 (-12)   690   squash out
     400   land 1         800   apex 2 (-9)  -> written as 61.5%
   ...expressed exactly as ms/1300 so the keyframes stay readable. */
@keyframes search-mascot-hop {
  0%     { transform: translateY(0)     scaleY(1); }

  /* hop 1: up 12, down, land */
  15.4%  { transform: translateY(-12px) scaleY(1); }    /* 200ms  apex */
  30.8%  { transform: translateY(0)     scaleY(1); }    /* 400ms  land */
  33.8%  { transform: translateY(0)     scaleY(0.92); } /* 440ms  squash */
  37.7%  { transform: translateY(0)     scaleY(1); }    /* 490ms  recovered */

  /* hop 2: up 9 */
  53.1%  { transform: translateY(-9px)  scaleY(1); }    /* 690ms  apex */
  68.5%  { transform: translateY(0)     scaleY(1); }    /* 890ms  land */
  71.5%  { transform: translateY(0)     scaleY(0.92); } /* 930ms  squash */
  75.4%  { transform: translateY(0)     scaleY(1); }    /* 980ms  recovered */

  /* hop 3: up 6 */
  83.1%  { transform: translateY(-6px)  scaleY(1); }    /* 1080ms apex */
  90.8%  { transform: translateY(0)     scaleY(1); }    /* 1180ms land */
  93.8%  { transform: translateY(0)     scaleY(0.92); } /* 1220ms squash */
  100%   { transform: translateY(0)     scaleY(1); }    /* 1300ms at rest */
}

.search-field__mascot.is-hopping {
  /* ease-out rising, ease-in falling: alternating per segment isn't
     expressible in one timing function, so the shape is carried by the
     keyframe spacing and this curve smooths between them. */
  animation: search-mascot-hop 1300ms ease-in-out;
}

@media (max-width: 900px) {
  .search-panel {
    min-height: 260px;
  }

  .search-field__input {
    font-size: 24px;
  }

  .search-field__input::placeholder {
    font-size: 17px;
  }

  .search-field__mascot {
    height: 42px;
  }
}

/* Reduced motion: it appears and disappears, nothing travels */
@media (prefers-reduced-motion: reduce) {
  .search-overlay,
  .search-overlay__backdrop,
  .search-panel,
  .search-panel__inner {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .search-panel {
    transform: translateY(0);
  }

  .search-overlay:not(.is-open) .search-panel {
    transform: translateY(-100%);
  }

  /* JS also skips it, but belt-and-braces if the class ever lands. */
  .search-field__mascot.is-hopping {
    animation: none !important;
  }
}


/* ============================================================
   SLIDE-IN MENU PANEL
   ============================================================ */
.menu-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 50vw;
  height: 100vh;
  /* Short screens: the meta block at the foot would otherwise sit below
     the fold with no way to reach it. The panel scrolls itself; the body
     stays locked behind it. */
  max-height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 90;                  /* just below the top bar */
  background: var(--panel-bg);
  transform: translateX(100%);  /* closed */
  transition: transform 0.9s var(--ease-panel);
  will-change: transform;
}

body.is-open .menu-panel {
  transform: translateX(0);     /* open */
}

@media (max-width: 900px) {
  .menu-panel {
    width: 100vw;
  }
}

/* Anchored rather than centred: the links start a set distance below the
   top bar and the meta block is pushed to the foot of the panel. */
.menu-panel__inner {
  /* min-height, not height: with the panel scrolling, a fixed 100% would
     leave taller content hanging outside its box in some engines. This
     still fills the panel, so the meta block keeps its margin-top: auto
     footing when there is room to spare. */
  min-height: 100%;
  padding: calc(var(--topbar-h) + 64px) 40px 64px 80px;
  display: flex;
  flex-direction: column;
}

/* ----- Nav links ----- */
.menu-nav {
  list-style: none;
}

.menu-nav__link {
  display: inline-block;
  /* The search item is a <button>; these keep it identical to the anchors
     around it. */
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-size: clamp(40px, 4.5vw, 72px);
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -0.02em;
  /* Staggered reveal start state (closed = quick fade back out) */
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}

/* Search sits on the same baseline as the labels, with its glyph inline
   ahead of the word. */
.menu-nav__link--search {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.menu-nav__glyph {
  display: block;
  width: 0.5em;
  height: 0.5em;
}

/* Hover: dim to 0.5 (scoped to open so it beats the reveal rule) */
body.is-open .menu-nav__link:hover {
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

/* ----- Contact / socials block ----- */
.menu-meta {
  margin-top: auto;             /* sits at the foot of the panel */
  padding-top: 80px;            /* but never crowds the links above it */
  display: flex;
  flex-direction: column;
  gap: 28px;
  /* Fades in last (closed = quick fade back out) */
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}

.menu-meta__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-meta__label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.menu-meta__value {
  font-size: 14px;
  color: var(--fg);
  transition: opacity 0.3s ease;
}

.menu-meta__value:hover {
  opacity: 0.5;
}

/* Socials: three glyphs on one line, sized to the meta text. */
.menu-meta__icons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}

.menu-meta__icon {
  display: inline-flex;
  color: var(--fg);
  transition: opacity 0.2s ease;
}

.menu-meta__icon:hover {
  opacity: 0.5;
}

.menu-meta__icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

/* ============================================================
   STAGGERED REVEAL (open state)
   Links animate in Home -> Contact with 80ms steps.
   Meta block comes last, after the 5 links.
   ============================================================ */
/* Open: use the slower reveal easing + staggered delays */
body.is-open .menu-nav__link,
body.is-open .menu-meta {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.7s var(--ease-reveal),
    transform 0.7s var(--ease-reveal);
}

body.is-open .menu-nav li:nth-child(1) .menu-nav__link { transition-delay: 0.30s; } /* Search */
body.is-open .menu-nav li:nth-child(2) .menu-nav__link { transition-delay: 0.38s; } /* Works */
body.is-open .menu-nav li:nth-child(3) .menu-nav__link { transition-delay: 0.46s; } /* About */
body.is-open .menu-nav li:nth-child(4) .menu-nav__link { transition-delay: 0.54s; } /* Contact */
body.is-open .menu-nav li:nth-child(5) .menu-nav__link { transition-delay: 0.62s; } /* Blog */

/* Meta block fades in after the last link */
body.is-open .menu-meta { transition-delay: 0.74s; }

