/* ==========================================================================
   The Barber Castle — slats and precision details
   The vertical brass partition is the shop's defining architectural feature, so
   it becomes the site's structural motif: page transitions, section reveals and
   the scroll rail all reuse it.
   ========================================================================== */

/* --- Slat overlay ---------------------------------------------------------- */

.slats {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--dur) var(--ease-out),
    visibility var(--dur);
}

.slats.is-closing {
  opacity: 1;
  visibility: visible;
}

.slats__field {
  display: flex;
  height: 100%;
  width: 100%;
}

.slats i {
  flex: 1 1 0;
  background: #0a0c0b;
  box-shadow: inset -1px 0 0 rgba(201, 165, 111, 0.22);
  transform: scaleY(0);
  transform-origin: bottom;
  will-change: transform;
}

.slats.is-closing i {
  transform: scaleY(1);
  transition: transform var(--slat-ms, 380ms) var(--ease-out);
  transition-delay: calc(var(--i, 0) * var(--slat-gap, 26ms));
}

.slats.is-closing i:nth-child(odd) {
  background: #0d1412;
}

.slats.is-closing i:nth-child(1) { --i: 0; }
.slats.is-closing i:nth-child(2) { --i: 1; }
.slats.is-closing i:nth-child(3) { --i: 2; }
.slats.is-closing i:nth-child(4) { --i: 3; }
.slats.is-closing i:nth-child(5) { --i: 4; }
.slats.is-closing i:nth-child(6) { --i: 5; }
.slats.is-closing i:nth-child(7) { --i: 6; }
.slats.is-closing i:nth-child(8) { --i: 7; }
.slats.is-closing i:nth-child(9) { --i: 8; }
.slats.is-closing i:nth-child(10) { --i: 9; }
.slats.is-closing i:nth-child(11) { --i: 10; }
.slats.is-closing i:nth-child(12) { --i: 11; }
.slats.is-closing i:nth-child(13) { --i: 12; }
.slats.is-closing i:nth-child(14) { --i: 13; }

/* Narrower screens get fewer, quicker slats so the wait stays under half a second. */
@media (max-width: 700px) {
  .slats i:nth-child(n + 9) {
    display: none;
  }
  .slats {
    --slat-ms: 280ms;
    --slat-gap: 18ms;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slats {
    display: none;
  }
}

/* --- Scroll rail ------------------------------------------------------------ */

.rail {
  position: fixed;
  /* The scroll rail sits at the inline end. It is paired with .rail__label,
     which is pinned outside it on the same side, so the two have to flip
     together or the label ends up over the rail. */
  inset-inline-end: clamp(0.75rem, 1.6vw, 1.5rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  width: 22px;
  height: min(38vh, 320px);
  display: none;
  pointer-events: none;
}

.rail__track {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: var(--bc-line);
}

.rail__fill {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  transform: translateX(-50%);
  background: var(--bc-brass);
  height: 100%;
  transform-origin: top;
  /* Progress is expressed as a `scaleY()` written by the scroll handler. The
     standalone `scale` property composes multiplicatively with `transform` and
     this `scale: 1 0` was annihilating it, so the fill measured 0px tall at
     every scroll position even when JS reported progress 1. */
  will-change: transform;
}

.rail__tick {
  position: absolute;
  left: 50%;
  width: 7px;
  height: 1px;
  transform: translateX(-50%);
  background: var(--bc-line-2);
}

.rail__label {
  position: absolute;
  inset-inline-end: 100%;
  top: 0;
  margin-inline-end: 0.5rem;
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  color: var(--bc-ink-3);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity var(--dur) var(--ease-out);
}

.rail:hover .rail__label,
.rail:focus-visible .rail__label {
  opacity: 1;
}

@media (min-width: 1280px) {
  .rail {
    display: block;
  }
}

/* --- Trim-line hover on menu rows -------------------------------------------- */

.menu__row {
  position: relative;
}

.menu__row::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--bc-brass);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 520ms var(--ease-out);
}

.menu__row:hover::after,
.menu__row:focus-within::after {
  transform: scaleX(1);
}

.menu__row:hover .menu__name {
  color: var(--bc-brass-soft);
}

@media (prefers-reduced-motion: reduce) {
  .menu__row::after {
    transition: none;
  }
}

/* --- Slat section reveal ------------------------------------------------------ */

.slat-reveal {
  position: relative;
}

.slat-reveal__curtain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  display: flex;
}

.slat-reveal__curtain i {
  flex: 1 1 0;
  background: #060807;
  transform-origin: top;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .slat-reveal__curtain {
    display: none;
  }
}

/* --- Brass corner on featured cards -------------------------------------------- */

.brass-corner {
  position: relative;
}

.brass-corner::before {
  content: "";
  position: absolute;
  top: -1px;
  inset-inline-end: -1px;
  width: 26px;
  height: 26px;
  border-top: 1px solid var(--bc-brass);
  border-inline-end: 1px solid var(--bc-brass);
  opacity: 0.75;
  pointer-events: none;
}
/* --- Slat reveal curtain behaviour ------------------------------------------- */

.slat-reveal__curtain i {
  transform: scaleY(1);
  transition: transform 720ms var(--ease-out);
  transition-delay: calc(var(--slat-cascade, 0ms) + var(--i, 0) * 55ms);
}

.slat-reveal.is-open .slat-reveal__curtain i {
  transform: scaleY(0);
}

/* --- The mark closes the page as it opened it ------------------------------- */

.closing {
  position: relative;
  overflow: hidden;
}

/* The mark itself, in the official artwork, as a struck-brass watermark. */
.closing__crest {
  position: absolute;
  left: 50%;
  bottom: -26%;
  width: min(64vw, 700px);
  aspect-ratio: 590 / 768;
  transform: translateX(-50%);
  opacity: 0.11;
  /* Lit metal rather than a flat tint, so the watermark catches the eye as the
     page scrolls past it instead of reading as a grey smudge. */
  background: var(--bc-brass-edge) center/contain no-repeat;
  -webkit-mask: var(--closing-mask) center/contain no-repeat;
  mask: var(--closing-mask) center/contain no-repeat;
  pointer-events: none;
}

:root {
  --closing-mask: url("/assets/img/crest-mask.svg");
}

/* ==========================================================================
   Arabic / RTL

   The rail and its label are logical above and need nothing here. Two things do:
   the menu row's hover trim and the brass corner, both of which are drawn from
   the left/top-right and would otherwise sit on the wrong corner.

   The rail's own `left: 50%` + `translateX(-50%)` centring is a centre
   calculation and is deliberately untouched — it is measured against a 22px
   fixed box, so it is the same number in both directions. main.js sets the
   fill's height from a scroll fraction, which is direction-agnostic too.
   ========================================================================== */

[dir="rtl"] .menu__row::after {
  transform-origin: right center;
}
