/* The Long Arc, reading tools (assets/js/longarc-tools.js): the brass year
   scrubber, "Compare two moments" (facing pages) and the Listen button. */

/* ------------------------------------------------------- Year scrubber */

.la { --brass-hi: #F6E3A8; --brass: #D4AE5C; --brass-lo: #8C6A26; --brass-ink: #3A2A0C; }
.la.has-scrub .la-main { padding-bottom: 140px; }
.la-scrub {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 40;
  width: min(880px, calc(100vw - 32px)); transform: translate(-50%, calc(100% + 30px));
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease; opacity: 0; pointer-events: none;
}
.la-scrub.is-on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.la-scrub-plate {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 8px 18px 10px 12px; border-radius: 14px; color: var(--brass-ink);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 1px, rgba(0, 0, 0, 0.035) 1px 3px),
    linear-gradient(180deg, var(--brass-hi) 0%, var(--brass) 38%, #B88E3F 72%, var(--brass-lo) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 252, 235, 0.9), inset 0 -2px 0 rgba(70, 48, 10, 0.45), 0 0 0 1px rgba(70, 48, 10, 0.55),
    0 18px 40px -16px rgba(20, 10, 40, 0.65), 0 4px 10px -4px rgba(20, 10, 40, 0.4);
}
/* screws */
.la-scrub-plate::before, .la-scrub-plate::after {
  content: ""; position: absolute; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFF3C9, #8C6A26 70%); box-shadow: inset 0 0 0 1px rgba(60, 40, 8, 0.5);
}
.la-scrub-plate::before { left: 5px; }
.la-scrub-plate::after { right: 5px; }

/* The odometer: four wheels that roll to the year. */
.la-odo {
  display: inline-flex; gap: 2px; padding: 4px 5px; margin-left: 6px; border-radius: 6px; background: #1A1209;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 250, 225, 0.7);
  font-family: var(--font-serif); font-size: 1.85rem; font-weight: 600; line-height: 1; font-variant-numeric: lining-nums tabular-nums;
}
.la-odo-wheel {
  position: relative; display: block; width: 0.72em; height: 1.1em; overflow: hidden; border-radius: 2px;
  background: linear-gradient(180deg, #CFC4AE 0%, #FBF6EA 22%, #FFFDF7 50%, #FBF6EA 78%, #CFC4AE 100%);
}
.la-odo-wheel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.28)); pointer-events: none; }
.la-odo-strip { display: flex; flex-direction: column; transform: translateY(calc(var(--d, 0) * -1.1em)); transition: transform 0.42s cubic-bezier(0.3, 1.35, 0.5, 1); color: #24180A; }
.la-odo-strip span { display: block; height: 1.1em; line-height: 1.1em; text-align: center; }

.la-scrub-track { position: relative; height: 40px; }
.la-scrub-rule {
  position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px;
  background: linear-gradient(180deg, #5A4113, #A27C33); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 245, 210, 0.7);
}
.la-scrub-rule::before { /* the travelled part, inlaid in plum */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); border-radius: 3px; background: linear-gradient(180deg, #4A2F73, #6E42A6);
}
.la-scrub-rule i { /* engraved: a year with stories */
  position: absolute; left: var(--x); top: -9px; width: 1px; height: 6px; background: rgba(58, 42, 12, 0.7); transform: translateX(-0.5px);
}
.la-scrub-rule i.is-key { top: -13px; height: 10px; width: 2px; background: #2A1B45; }
.la-scrub-rule b { /* an era begins */
  position: absolute; left: var(--x); bottom: -10px; width: 5px; height: 5px; background: rgba(58, 42, 12, 0.75); transform: translateX(-50%) rotate(45deg);
}
.la-scrub-input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: transparent; cursor: grab;
  -webkit-appearance: none; appearance: none; touch-action: none;
}
.la-scrub-input:active { cursor: grabbing; }
.la-scrub-input::-webkit-slider-runnable-track { height: 40px; background: transparent; }
.la-scrub-input::-moz-range-track { height: 40px; background: transparent; }
.la-scrub-input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 34px; margin-top: 3px; border-radius: 5px; border: 1px solid #4A3408;
  background: linear-gradient(90deg, #8C6A26, #F6E3A8 35%, #D4AE5C 60%, #8C6A26); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45), inset 0 1px 0 #FFF7D6;
}
.la-scrub-input::-moz-range-thumb {
  width: 22px; height: 34px; border-radius: 5px; border: 1px solid #4A3408;
  background: linear-gradient(90deg, #8C6A26, #F6E3A8 35%, #D4AE5C 60%, #8C6A26); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
}
.la-scrub-input:focus-visible { outline: 2px solid #2A1B45; outline-offset: 4px; border-radius: 6px; }
.la-scrub-mid { position: relative; min-width: 0; padding-bottom: 12px; }
.la-scrub-ends {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between;
  font: 700 0.6rem/1 var(--font); letter-spacing: 0.16em; color: rgba(58, 42, 12, 0.8); pointer-events: none;
}
.la-scrub-rule i.is-off { opacity: 0.12; }

/* The era plate: an engraved name over the track, following the page. */
.la-scrub-era { display: flex; align-items: baseline; gap: 0.6rem; margin: 0 0 1px; min-width: 0; white-space: nowrap; line-height: 1.2; position: relative; z-index: 1; }
.la-scrub-era-name {
  overflow: hidden; text-overflow: ellipsis; font: italic 600 0.98rem/1.2 var(--font-serif); color: #2A1B45;
  text-shadow: 0 1px 0 rgba(255, 246, 214, 0.75);
}
.la-scrub-era-years { flex: none; font: 700 0.6rem/1 var(--font); letter-spacing: 0.16em; color: rgba(58, 42, 12, 0.85); font-variant-numeric: tabular-nums; }

/* The "Eras" drawer: a brass button; the list opens above the dock. */
.la-scrub-eras { position: relative; }
.la-scrub-eras > summary {
  list-style: none; display: inline-flex; align-items: center; gap: 0.45rem; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  font: 700 0.66rem/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: #F7EBC4;
  background: linear-gradient(180deg, #3B2A5E, #2A1B45); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 0 rgba(255, 250, 225, 0.6), 0 0 0 1px rgba(40, 24, 6, 0.6);
}
.la-scrub-eras > summary::-webkit-details-marker { display: none; }
.la-scrub-eras > summary:focus-visible { outline: 2px solid #2A1B45; outline-offset: 3px; }
.la-scrub-eras-ico { width: 12px; height: 10px; background: linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat, linear-gradient(currentColor, currentColor) 0 50% / 70% 2px no-repeat, linear-gradient(currentColor, currentColor) 0 100% / 85% 2px no-repeat; }
.la-scrub-menu {
  position: absolute; right: -8px; bottom: calc(100% + 18px); width: min(340px, calc(100vw - 32px)); max-height: min(60vh, 460px); overflow-y: auto;
  padding: 8px; border-radius: 12px; background: #FBF7EC; color: #2A1B45;
  box-shadow: 0 0 0 1px rgba(70, 48, 10, 0.35), 0 24px 50px -18px rgba(20, 10, 40, 0.6);
}
.la-scrub-menu ol { list-style: none; margin: 0; padding: 0; }
.la-scrub-menu a {
  display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; align-items: baseline; gap: 0.6rem; padding: 8px 10px; border-radius: 8px;
  color: inherit; text-decoration: none; font-family: var(--font-serif); font-size: 1rem;
}
.la-scrub-menu a:hover, .la-scrub-menu a:focus-visible { background: #EFE6CF; outline: none; }
.la-scrub-menu a.is-current { background: #2A1B45; color: #FBF2D6; }
.la-scrub-menu a.is-past .la-scrub-menu-t { color: #6F6780; }
.la-scrub-menu-y { font: 700 0.7rem/1 var(--font); letter-spacing: 0.1em; color: #8C6A26; font-variant-numeric: tabular-nums; }
.la-scrub-menu a.is-current .la-scrub-menu-y { color: #E8C878; }
.la-scrub-menu-n { font: 600 0.7rem/1 var(--font); color: #8B8398; font-variant-numeric: tabular-nums; }
.la-scrub-menu a.is-current .la-scrub-menu-n { color: #CBBEE0; }

@media (max-width: 640px) {
  .la-scrub-plate { gap: 8px; padding: 7px 10px 8px 8px; }
  .la-odo { font-size: 1.3rem; margin-left: 4px; }
  .la-scrub-era-name { font-size: 0.86rem; }
  .la-scrub-era-years { display: none; }
  .la-scrub-eras > summary { padding: 8px 9px; }
  .la-scrub-eras > summary > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .la-scrub-menu { right: -10px; bottom: calc(100% + 14px); }
}

/* ------------------------------------------------------------- Listen */

.la-read-bar { max-width: 1040px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.la-read-bar .la-read-crumbs { margin: 0; max-width: none; }
.la-listen {
  display: inline-flex; align-items: center; gap: 0.5em; min-height: 36px; padding: 0.4em 0.95em; border-radius: 999px; cursor: pointer;
  font: 600 0.84rem/1 var(--font); color: #2A1B45; background: #fff; border: 1px solid #C9B8DE; transition: background 0.15s ease, border-color 0.15s ease;
}
.la-listen:hover { border-color: #6E42A6; }
.la-listen:focus-visible, .lc-listen:focus-visible { outline: 2px solid #6E42A6; outline-offset: 2px; }
.la-listen.is-speaking, .lc-listen.is-speaking { background: #2A1B45; border-color: #2A1B45; color: #fff; }
[data-la-listen].is-speaking .la-listen-wave, [data-la-listen].is-speaking svg path + path { animation: la-wave 1.1s ease-in-out infinite; }
.bk-btn.is-speaking { border-color: #D4AE5C; color: #F6E3A8; }
@keyframes la-wave { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.is-read-aloud { background: linear-gradient(transparent 8%, rgba(212, 174, 92, 0.22) 8%, rgba(212, 174, 92, 0.22) 92%, transparent 92%); box-shadow: -10px 0 0 rgba(212, 174, 92, 0.22), 10px 0 0 rgba(212, 174, 92, 0.22); }

/* -------------------------------------------------- Compare two moments */

.lc {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; overflow: hidden;
  display: none; grid-template-rows: auto auto minmax(0, 1fr); color: #EFE8DA;
  background: radial-gradient(ellipse at 50% 42%, #2E2048 0%, #120B20 78%);
}
.lc[open] { display: grid; }
.lc::backdrop { background: rgba(10, 6, 20, 0.7); }
.lc-top { display: flex; align-items: center; gap: 1rem; padding: max(10px, env(safe-area-inset-top)) 18px 4px; }
.lc-title { margin: 0; font-family: var(--font-serif); font-size: 1.35rem; font-weight: 560; color: #fff; }
.lc-gap { flex: 1; margin: 0; font: 600 0.72rem/1.3 var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: #E2C98A; }
.lc-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 40px; padding: 0.4em 0.9em; border-radius: 999px;
  font: 600 0.88rem/1 var(--font); color: #F3EDE2; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.22); cursor: pointer;
}
.lc-btn:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.45); }
.lc-btn:focus-visible, .lc-select:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lc-close { font-size: 1.4rem; padding: 0; }
.lc-go { background: #D4AE5C; border-color: #D4AE5C; color: #241A08; }
.lc-go:hover { background: #F0D493; border-color: #F0D493; }
.lc-pick { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 6px 18px 12px; }
.lc-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lc-field-label { font: 600 0.66rem/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: #B9A6D6; }
.lc-select {
  width: 100%; min-height: 40px; padding: 0 0.7em; border-radius: 8px; font: 500 0.9rem var(--font); color: #2A1B45;
  background: #F8F5EE; border: 1px solid rgba(255, 255, 255, 0.3); text-overflow: ellipsis;
}
.lc-stage { min-height: 0; padding: 0 18px 18px; display: flex; justify-content: center; perspective: 2400px; }
.lc-spread {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr); width: min(1360px, 100%); height: 100%;
  transform-style: preserve-3d; transition: opacity 0.25s ease;
}
.lc-spread.is-loading { opacity: 0.45; }
.lc-gutter { background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.05) 45%, rgba(0, 0, 0, 0.05) 55%, rgba(0, 0, 0, 0.35)); }
.lc-page {
  display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--paper, #FBFAF7); color: var(--ink, #1C1C19);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}
.lc-page--left { border-radius: 4px 0 0 4px; box-shadow: inset -30px 0 30px -30px rgba(0, 0, 0, 0.45), 0 30px 60px -30px rgba(0, 0, 0, 0.8); transform-origin: 100% 50%; }
.lc-page--right { border-radius: 0 4px 4px 0; box-shadow: inset 30px 0 30px -30px rgba(0, 0, 0, 0.45), 0 30px 60px -30px rgba(0, 0, 0, 0.8); transform-origin: 0 50%; }
.lc-spread.is-opening .lc-page--left { animation: lc-open-left 0.75s cubic-bezier(0.45, 0.05, 0.3, 1) both; }
.lc-spread.is-opening .lc-page--right { animation: lc-open-right 0.75s cubic-bezier(0.45, 0.05, 0.3, 1) 0.08s both; }
@keyframes lc-open-left { from { transform: rotateY(80deg); filter: brightness(0.55); } to { transform: none; filter: none; } }
@keyframes lc-open-right { from { transform: rotateY(-80deg); filter: brightness(0.55); } to { transform: none; filter: none; } }
.lc-run {
  display: flex; align-items: center; gap: 0.8rem; margin: 0 26px; padding: 12px 0 6px; border-bottom: 4px double var(--rule, #2A1B45);
  font-family: var(--font-serif); font-size: 0.86rem; font-variant-caps: all-small-caps; letter-spacing: 0.1em; color: var(--muted, #5D5B54);
}
.lc-run > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-listen {
  display: inline-flex; align-items: center; gap: 0.4em; min-height: 32px; padding: 0.3em 0.75em; border-radius: 999px; cursor: pointer;
  font: 600 0.74rem/1 var(--font); font-variant-caps: normal; letter-spacing: 0; color: var(--ink-2, #2A1B45); background: transparent; border: 1px solid currentColor;
}
.lc-open { font: 600 0.74rem/1 var(--font); font-variant-caps: normal; letter-spacing: 0; color: var(--acc-ink, #5A3689); white-space: nowrap; }
.lc-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 26px 30px; scrollbar-width: thin; }
.lc-body:focus-visible { outline: 2px solid #6E42A6; outline-offset: -4px; }
.lc-body .bk-headline { font-size: clamp(1.6rem, 2.6vw, 2.4rem); }
.lc-body .bk-facts--flow, .lc-body .bk-photo--flow { display: none; }
.lc-body .bk-photo--cover { margin: 0 0 1rem; }
.lc-body .bk-photo--cover img { width: 100%; height: auto; }
.lc-fail { font-style: italic; color: var(--muted, #5D5B54); }

@media (max-width: 760px) {
  .lc { overflow-y: auto; display: none; }
  .lc[open] { display: block; }
  .lc-top { position: sticky; top: 0; z-index: 2; background: #1C1230; padding-bottom: 8px; }
  .lc-gap { display: none; }
  .lc-pick { grid-template-columns: minmax(0, 1fr) auto; }
  .lc-pick .lc-field:nth-child(3) { grid-column: 1; }
  .lc-swap { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
  .lc-go { grid-column: 1 / -1; }
  .lc-stage { padding: 0 10px 24px; perspective: none; }
  .lc-spread { display: block; height: auto; }
  .lc-gutter { height: 10px; background: none; }
  .lc-page, .lc-page--left, .lc-page--right { border-radius: 4px; box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.8); }
  .lc-run { margin: 0 16px; }
  .lc-body { overflow: visible; padding: 14px 16px 22px; }
  .lc-spread.is-opening .lc-page--left, .lc-spread.is-opening .lc-page--right { animation-name: lc-rise; }
  @keyframes lc-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
}

@media (prefers-reduced-motion: reduce) {
  .la-scrub, .la-odo-strip { transition: none; }
  .lc-spread.is-opening .lc-page--left, .lc-spread.is-opening .lc-page--right, [data-la-listen].is-speaking svg path + path { animation: none; }
}
@media print { .la-scrub, .la-listen, .lc { display: none !important; } }
