/* Shared navigation layer for long case pages (loaded after cases.css).
   Contents index, section markers, two-level heading hierarchy, desktop rotor
   and mobile dial. Behaviour lives in js/case-nav.js.

   Markup contract, per page:
     - <nav class="case-rail"> with <a data-rail="sNN"> links
     - <nav class="case__cell case__cell--full case-index"> with the contents
     - a cell with class "case-open" and id "sNN" opens each section
     - .case-mark inside an opener, and a .case-mark--ghost in the cell paired
       to its right so the two headings share a baseline */

/* ---------- CONTENTS INDEX ---------- */
.case-index {
  border-bottom: 1px solid var(--rule-strong, rgba(15, 26, 46, .14));
  padding-bottom: clamp(20px, 3vh, 36px);
}

.case-index__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: clamp(18px, 2.5vh, 28px);
}

.case-index__label {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.85rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 400;
  color: var(--ink, #0f1a2e);
}

/* Numbered, so it reads down each column. The row count is set per page with
   --case-index-rows. */
.case-index__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(var(--case-index-rows, 2), auto);
  grid-auto-flow: column;
  column-gap: clamp(24px, 4vw, 64px);
  row-gap: 2px;
}

.case-index__item a {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--rule, rgba(15, 26, 46, .08));
  text-decoration: none;
  color: var(--ink, #0f1a2e);
  transition: background 160ms ease, padding-inline 160ms ease;
}

.case-index__item a:hover,
.case-index__item a:focus-visible {
  background: rgba(15, 26, 46, .04);
  padding-inline: 10px;
}

.case-index__n {
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--case-accent, #b4553a);
}

.case-index__t { font-size: 1.05rem; line-height: 1.25; }

.case-index__k {
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft, #2a3651);
  white-space: nowrap;
}

/* ---------- SECTION MARKER ---------- */
.case-mark {
  display: block;
  font-size: clamp(2.2rem, 4.4vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink, #0f1a2e);
  opacity: .16;
  margin-bottom: 10px;
}

.case-mark--ghost { visibility: hidden; }

/* ---------- HEADING HIERARCHY ----------
   Two levels, far apart in size. The two selectors target disjoint sets. */
.case-open h2 {
  font-size: clamp(2rem, 3.2vw, 3rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin-bottom: clamp(14px, 2vh, 20px);
}

.case__cell:not(.case-open) h2 {
  font-size: clamp(0.98rem, 0.5vw + 0.8rem, 1.15rem);
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--ink-soft, #2a3651);
  margin-bottom: 10px;
}

/* Empty title band, sized by the equaliser in js/case-nav.js. */
.case-band-ghost { display: block; }

/* ---------- DESKTOP ROTOR ---------- */
.case-rail {
  position: fixed;
  right: calc(var(--case-side-reserve, 88px) + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 27%, #000 73%, transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0%, #000 27%, #000 73%, transparent 100%);
  pointer-events: none;
}

.case-rail__track {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: auto;
  transition: transform 450ms cubic-bezier(.22, .61, .36, 1);
}

.case-rail a {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink, #0f1a2e);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .08em;
  transition: font-size 300ms ease, color 300ms ease, font-weight 300ms ease;
}

/* data-d is the distance from the selected item, written by the scroll
   handler. Two sizes only; the rotor comes from the grey ramp. */
.case-rail a[data-d="0"] {
  font-size: 12px;
  font-weight: 600;
  color: var(--case-accent, #b4553a);
}

.case-rail a[data-d="1"] { font-size: 8px; color: rgba(15, 26, 46, .62); }
.case-rail a[data-d="2"] { font-size: 8px; color: rgba(15, 26, 46, .34); }
.case-rail a[data-d="3"] { font-size: 8px; color: rgba(15, 26, 46, .18); }
.case-rail a[data-d="4"] { font-size: 8px; color: rgba(15, 26, 46, .10); }
.case-rail a[data-d="5"] { font-size: 8px; color: rgba(15, 26, 46, .06); }

.case-rail a:hover { color: var(--ink, #0f1a2e); }

/* ---------- MOBILE DIAL ---------- */
.case-dial__btn {
  display: none;
  position: fixed;
  right: clamp(10px, 3vw, 18px);
  top: 58%;
  z-index: 1900;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(15, 26, 46, .12);
  background: rgba(255, 255, 255, .62);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
          backdrop-filter: blur(14px) saturate(150%);
  color: var(--ink, #0f1a2e);
  cursor: pointer;
  place-items: center;
  box-shadow: 0 8px 22px -12px rgba(15, 26, 46, .5);
}

.case-dial__count {
  font-family: 'Galatea', 'Times New Roman', serif;
  font-size: 11px;
  letter-spacing: .06em;
}

.case-dial__btn[aria-expanded="true"] {
  background: var(--ink, #0f1a2e);
  border-color: var(--ink, #0f1a2e);
  color: #fff;
}

.case-dial {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1850;
  touch-action: none;
}

.case-dial[data-open="true"] { display: block; }

.case-dial__scrim {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
          backdrop-filter: blur(18px) saturate(140%);
}

.case-dial__arc {
  position: absolute;
  inset: 0;
  --r: 132px;
  --spin: 0deg;
}

.case-dial__arc a {
  position: absolute;
  right: clamp(32px, 10vw, 44px);
  top: 50%;
  transform-origin: 100% 50%;
  transform:
    translateY(-50%)
    rotate(calc(var(--a) + var(--spin)))
    translateX(calc(var(--r) * -1))
    rotate(calc((var(--a) + var(--spin)) * -1));
  white-space: nowrap;
  text-decoration: none;
  text-align: right;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(15, 26, 46, .62);
  padding: 17px 2px;
}

.case-dial__arc a[aria-current="true"] {
  color: var(--case-accent, #b4553a);
  font-weight: 600;
}

.case-dial__arc a[data-focus="true"] {
  font-size: 12px;
  color: var(--ink, #0f1a2e);
  font-weight: 600;
}

.case-dial__arc a[data-focus="true"][aria-current="true"] {
  color: var(--case-accent, #b4553a);
}

.case-dial__arc.is-settling a { transition: transform 260ms cubic-bezier(.22,.61,.36,1); }

.case-dial__n {
  display: inline-block;
  margin-right: 6px;
  font-size: 7px;
  color: rgba(15, 26, 46, .38);
}

@media (max-width: 820px) {
  .case-dial__btn { display: grid; }
  .case-rail { display: none; }
  .case-index__list { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; }
  .case-index__item a { grid-template-columns: 2.2rem 1fr; }
  .case-index__k { grid-column: 2; }
  .case-open h2 { font-size: 1.7rem; }
  .case__cell:not(.case-open) h2 { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .case-rail__track, .case-rail a, .case-index__item a { transition: none; }
}
