/* ===========================================================================
   The nav shelf — me.yodamad.fr

   The menu that used to run down the left side, laid out as one band under
   the header. Four decisions carry it:

   1. The band stays dark in both schemes. The header and footer already do
      (--scene-deep / --scene-well), so the shelf reads as the bottom step of
      one piece of brand chrome rather than as a light strip bolted under it.
      It sits on --scene: one step up from the header, so the two never merge.
   2. Marigold does exactly one job here — marking where you are, as a solid
      stamp behind the label. Hover and focus lift the label onto a faint
      chalk wash instead, so the stage light is never spent on a state the
      mouse creates.
   3. Hairlines between items, so the band reads as a measured row of sections
      rather than words floating in a strip.
   4. The pictograms from nav.md get their own slot at a size that matches the
      type, instead of setting their own and dragging the baseline with them.

   Markup lives in overrides/main.html (`block tabs`).
   =========================================================================== */

.shelf {
  position: relative;
  z-index: 2;
  background: var(--scene);
  /* A hairline of light along the top edge separates the band from the
     header's darker well without a second border doing it. */
  box-shadow: inset 0 1px 0 rgba(234, 242, 232, 0.07);
  border-bottom: 1px solid rgba(234, 242, 232, 0.14);
}

/* .md-grid puts the row in the content column; this padding plus the stamp's
   own 0.5rem lands the first label on the same left edge as a page's H1. */
.shelf__inner {
  padding: 0 0.45rem;
}

/* The row wraps rather than scrolls. A horizontal scroller would need
   `overflow` on this element, and that clips the panels hanging below it —
   and it hides menu items behind a gesture. Wrapped, every section stays
   visible at every width. */
.shelf__track {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf__item {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0;
}

/* Dividers only once the row is wide enough that it does not wrap; on a phone
   a wrapped row would show them in the wrong places. */
@media screen and (min-width: 48em) {
  .shelf__item + .shelf__item {
    border-left: 1px solid rgba(234, 242, 232, 0.1);
  }
}

.shelf__link {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.3rem;
  text-decoration: none;
  color: rgba(234, 242, 232, 0.74);
}

.shelf__stamp {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.3rem 0.5rem;
  transition: background-color 130ms, color 130ms;
}

.shelf__text {
  font-variation-settings: "wdth" 88;
  font-weight: 620;
  font-size: 0.78rem;
  line-height: 1.2;
  letter-spacing: 0.012em;
  white-space: nowrap;
}

/* The pictogram sits a hair above the label's baseline and a hair under its
   size, so the words — not the emoji — set the rhythm of the row. */
.shelf__pic {
  flex: 0 0 auto;
  font-size: 0.72rem;
  line-height: 1;
  translate: 0 -0.04em;
}

.shelf__link:hover,
.shelf__link:focus-visible {
  color: var(--chalk);
}

.shelf__link:hover .shelf__stamp,
.shelf__link:focus-visible .shelf__stamp {
  background: rgba(234, 242, 232, 0.09);
}

/* The hover wash alone is too quiet to track a caret by. Keyboard focus gets
   a marigold ring on the stamp — the same shape the current page is marked
   with, so "where I am" and "where I'm about to go" share one vocabulary. */
.shelf__link:focus-visible,
.shelf__caret:focus-visible,
.shelf__sublink:focus-visible {
  outline: none;
}

.shelf__link:focus-visible .shelf__stamp,
.shelf__caret:focus-visible,
.shelf__sublink:focus-visible {
  outline: 2px solid var(--marigold);
  outline-offset: -2px;
}

/* The current item's stamp is already marigold, so its ring inverts. */
.shelf__link--here:focus-visible .shelf__stamp {
  outline-color: var(--scene);
}

/* Where you are. A stamp of marigold, nothing else. --scene on --marigold is
   8.3:1. */
.shelf__link--here {
  color: var(--scene);
}

.shelf__link--here .shelf__stamp,
.shelf__link--here:hover .shelf__stamp,
.shelf__link--here:focus-visible .shelf__stamp {
  background: var(--marigold);
  color: var(--scene);
}

/* --- Sections with sub-pages -------------------------------------------- */

.shelf__item--group {
  position: relative;
}

/* A hair of negative margin pulls the caret against its label, so the pair
   reads as one target rather than two. */
.shelf__caret {
  display: flex;
  align-items: center;
  margin-left: -0.42rem;
  padding: 0.3rem 0.38rem;
  background: none;
  border: none;
  color: rgba(234, 242, 232, 0.5);
  cursor: pointer;
}

.shelf__caret svg {
  width: 0.52rem;
  height: 0.52rem;
  transition: rotate 140ms;
}

.shelf__caret:hover,
.shelf__caret:focus-visible {
  color: var(--chalk);
}

.shelf__item--group:hover .shelf__caret svg,
.shelf__item--group:focus-within .shelf__caret svg,
.shelf__caret[aria-expanded="true"] svg {
  rotate: 180deg;
}

/* The panel. Hairline rows, like the gig list — not a card with a shadow. */
.shelf__panel {
  position: absolute;
  top: 100%;
  left: 0.3rem;
  z-index: 3;
  min-width: 11.5rem;
  max-width: min(18rem, calc(100vw - 2rem));
  padding: 0.3rem 0;
  background: var(--scene-deep);
  border: 1px solid rgba(234, 242, 232, 0.16);
  border-top: none;
  opacity: 0;
  visibility: hidden;
  translate: 0 -0.25rem;
  transition: opacity 140ms, translate 140ms, visibility 140ms;
}

/* Hover for the mouse, :focus-within for the keyboard, [data-open] for touch
   (set by js/nav.js on the caret). `visibility` keeps the closed panel out of
   both the tab order and the accessibility tree. */
.shelf__item--group:hover .shelf__panel,
.shelf__item--group:focus-within .shelf__panel,
.shelf__item--group[data-open] .shelf__panel {
  opacity: 1;
  visibility: visible;
  translate: 0 0;
}

/* --- The phone menu ------------------------------------------------------
   Ten sections in a wrapped row take four ragged lines on a 390px screen and
   push the page itself below the fold. Under 45em the band becomes one row
   naming the current section, which opens the whole menu as a vertical list.

   Three things change with it, all for the same reason — a finger has no
   hover and no second target to spare:
   - the carets go, and every section's sub-pages are listed inline, indented,
     already open. One tap reaches any page, instead of tap-caret-then-tap.
   - the panels stop being absolutely positioned and flow in the list.
   - the toggle is what collapses the list, and js/nav.js is what grants it
     that power (`data-nav-collapsible`). With JS off nothing hides, so the
     full menu is still on the page.

   Only the toggle's own rules live here; the under-45em block sits at the
   foot of the file, after the panel and sub-link rules it has to override.
   ========================================================================= */

.shelf__toggle {
  display: none;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.62rem 0.8rem;
  background: none;
  border: none;
  color: var(--chalk);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.shelf__toggle .shelf__text {
  font-variation-settings: "wdth" 88;
  font-weight: 620;
  font-size: 0.8rem;
  letter-spacing: 0.012em;
}

.shelf__toggle-label {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  min-width: 0;
}

.shelf__toggle-icon {
  flex: 0 0 auto;
  width: 0.6rem;
  height: 0.6rem;
  margin-left: auto;
  color: rgba(234, 242, 232, 0.6);
  transition: rotate 140ms;
}

.shelf__toggle[aria-expanded="true"] .shelf__toggle-icon {
  rotate: 180deg;
}

.shelf__toggle:focus-visible {
  outline: 2px solid var(--marigold);
  outline-offset: -2px;
}


.shelf__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf__row {
  margin: 0;
  border-top: 1px solid rgba(234, 242, 232, 0.09);
}

.shelf__row:first-child {
  border-top: none;
}

.shelf__sublink {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.44rem 0.8rem;
  text-decoration: none;
  color: rgba(234, 242, 232, 0.78);
  transition: color 120ms, background-color 120ms;
}

.shelf__sublink .shelf__text {
  font-variation-settings: "wdth" 94;
  font-weight: 500;
  font-size: 0.74rem;
  line-height: 1.3;
  white-space: normal;
}

.shelf__sublink:hover,
.shelf__sublink:focus-visible {
  color: var(--chalk);
  background: rgba(234, 242, 232, 0.07);
}

.shelf__sublink[aria-current] {
  color: var(--marigold);
}

/* Third level (Side projects → GitHub / GitLab): indented, no extra rules. */
.shelf__row .shelf__list .shelf__sublink {
  padding-left: 1.6rem;
  color: rgba(234, 242, 232, 0.58);
}

.shelf__row .shelf__list .shelf__text {
  font-size: 0.68rem;
}

.shelf__row .shelf__list .shelf__row {
  border-top: none;
}

/* --- Replacing the sidebar ----------------------------------------------
   The shelf is the menu now, so the left sidebar and the drawer button it
   opens both go. The right-hand table of contents is untouched. */

.md-sidebar--primary,
.md-header__button[for="__drawer"] {
  display: none;
}

@media screen and (max-width: 76.1875em) {
  /* Material reserves the drawer's gutter on small screens via the content
     wrapper; without a drawer the content takes the full column. */
  .md-content {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shelf__panel,
  .shelf__caret svg,
  .shelf__stamp,
  .shelf__sublink {
    transition: none;
  }
}

@media screen and (max-width: 44.9375em) {
  .shelf__inner {
    padding: 0;
  }

  .shelf[data-nav-collapsible] .shelf__toggle {
    display: flex;
  }

  .shelf[data-nav-collapsible] .shelf__track {
    display: none;
  }

  .shelf[data-nav-collapsible][data-nav-open] .shelf__track {
    display: block;
    max-height: 70vh;
    overflow-y: auto;
    border-top: 1px solid rgba(234, 242, 232, 0.14);
    overscroll-behavior: contain;
  }

  /* One section per line, hairline-separated, like the gig list. */
  .shelf__item,
  .shelf__item--group {
    display: block;
    position: static;
    width: 100%;
  }

  .shelf__item + .shelf__item {
    border-top: 1px solid rgba(234, 242, 232, 0.09);
  }

  .shelf__link {
    padding: 0;
  }

  /* A full-width row, so the marigold stamp marks the line you are on and the
     tap target is the whole width rather than the width of the words. */
  .shelf__stamp {
    padding: 0.62rem 0.8rem;
  }

  .shelf__caret {
    display: none;
  }

  .shelf__panel {
    position: static;
    min-width: 0;
    max-width: none;
    padding: 0;
    border: none;
    opacity: 1;
    visibility: visible;
    translate: none;
    transition: none;
  }

  .shelf__sublink {
    padding: 0.5rem 0.8rem 0.5rem 1.9rem;
  }

  .shelf__row .shelf__list .shelf__sublink {
    padding-left: 2.9rem;
  }
}
