/* ── 30년 장부 — 레일 위의 파일철 (연도 카드가 대각선으로 멀어지는 서류철) ──
   index.html 의 #ledger-rail 에만 적용. 기존 .ledger 목록은 <details> 안 폴백으로 유지. */
.rail {
  position: relative;
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) + 4px);
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(240,168,58,.10), transparent 60%),
    linear-gradient(180deg, #0d0d11 0%, #0a0a0c 55%, #111116 100%);
  overflow: hidden;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.rail:focus-visible { box-shadow: 0 0 0 2px rgba(240,168,58,.55); }
.rail-stage {
  position: relative;
  height: 500px;
  perspective: 1100px;
  perspective-origin: 62% 38%;
  overflow: hidden;
}
/* 바닥 레일 두 줄 — 복도 원근 */
.rail-stage::before,
.rail-stage::after {
  content: "";
  position: absolute;
  left: -10%; right: -10%; bottom: 0;
  height: 62%;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(255,255,255,.06), transparent 45%),
    repeating-linear-gradient(to top, rgba(255,255,255,.035) 0 1px, transparent 1px 46px);
  transform: perspective(700px) rotateX(62deg);
  transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent 85%);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent 85%);
}
.rail-stage::after {
  background:
    linear-gradient(90deg, transparent 31%, rgba(240,168,58,.55) 31.3%, rgba(240,168,58,.55) 31.6%, transparent 32%),
    linear-gradient(90deg, transparent 67.9%, rgba(240,168,58,.55) 68.2%, rgba(240,168,58,.55) 68.5%, transparent 69%);
  opacity: .55;
}
.rail-glow {
  position: absolute; inset: auto 0 0 0; height: 40%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(240,168,58,.14), transparent 70%);
  pointer-events: none;
}
/* 카드 */
.rail-card {
  position: absolute;
  left: 50%; top: 50%;
  width: min(420px, 72vw);
  aspect-ratio: 1.55 / 1;
  margin: -120px 0 0 -210px;
  transform-style: preserve-3d;
  transform: translate3d(var(--x, 0px), var(--y, 0px), var(--z, 0px)) rotateY(var(--ry, 0deg));
  opacity: var(--o, 1);
  transition: transform .55s cubic-bezier(.22,.61,.36,1), opacity .45s ease, filter .45s ease;
  filter: saturate(var(--sat, 1)) brightness(var(--br, 1));
  will-change: transform, opacity;
  text-decoration: none;
  color: var(--fg);
  border-radius: 14px;
  background: linear-gradient(165deg, #23232a, #141418);
  border: 1px solid rgba(255,255,255,.09);
  box-shadow:
    0 30px 60px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.06);
  padding: 26px 28px 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  pointer-events: var(--pe, auto);
}
@media (max-width: 700px) {
  .rail-card { width: min(300px, 80vw); margin: -96px 0 0 -150px; padding: 18px 18px 14px; }
  .rail-stage { height: 400px; perspective-origin: 60% 40%; }
}
/* 폴더 탭 — 연도 */
.rail-card::before {
  content: attr(data-year);
  position: absolute;
  top: -15px; left: 18px;
  padding: 3px 12px 3px;
  font-size: 12px; letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
  background: #1d1d23;
  border: 1px solid rgba(255,255,255,.1);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
}
.rail-card.is-active { border-color: rgba(240,168,58,.55); box-shadow: 0 34px 70px rgba(0,0,0,.6), var(--glow-warm), inset 0 1px 0 rgba(255,255,255,.08); }
.rail-card.is-active::before { color: var(--warm); background: #26211a; border-color: rgba(240,168,58,.5); }
.rail-card.peak::before { color: #ffd27a; }
.rail-card.now::before { color: var(--cool); }
.rail-card.low::before { color: var(--fg-3); }
.rail-card .rc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rail-card .rc-year { font-size: 13px; letter-spacing: .12em; color: var(--fg-3); }
.rail-card .rc-tag { font-size: 12px; color: var(--fg-3); }
.rail-card .rc-num {
  align-self: center;
  display: flex; align-items: baseline; gap: 8px;
  font-size: clamp(54px, 9vw, 92px); font-weight: 800; line-height: 1; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.rail-card .rc-num small { font-size: 18px; font-weight: 600; color: var(--fg-2); letter-spacing: 0; }
.rail-card.peak .rc-num { color: #ffd9a0; }
.rail-card.now .rc-num { color: #bfe9ff; }
.rail-card .rc-note { font-size: 13px; color: var(--fg-2); display: flex; justify-content: space-between; gap: 10px; }
.rail-card .rc-note .go { color: var(--warm); white-space: nowrap; opacity: 0; transform: translateX(-4px); transition: .25s; }
.rail-card.is-active:hover .rc-note .go { opacity: 1; transform: none; }
/* 뒤로 물러난 카드는 숫자를 줄이고 탭만 또렷하게 */
.rail-card.is-back .rc-num { opacity: .78; }
.rail-card.is-back .rc-note { opacity: .5; }
/* 조작 줄 */
.rail-bar {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: rgba(18,18,22,.7);
}
.rail-btn {
  width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--fg-2);
  font-size: 16px; cursor: pointer; line-height: 1;
}
.rail-btn:hover { border-color: var(--warm); color: var(--warm); }
.rail-ticks {
  display: flex; gap: 2px; justify-content: space-between; padding-top: 16px;
}
.rail-tick {
  flex: 1 1 0; min-width: 0; height: 26px; border: 0; background: none; cursor: pointer;
  padding: 0; position: relative; color: transparent; font-size: 0; overflow: visible;
}
.rail-tick::before {
  content: ""; position: absolute; left: 50%; bottom: 4px; width: 2px; height: var(--h, 8px);
  margin-left: -1px; border-radius: 2px; background: rgba(255,255,255,.22);
  transition: background .2s, height .2s;
}
.rail-tick:hover::before { background: var(--fg-2); }
.rail-tick.on::before { background: var(--warm); height: 18px; }
.rail-tick.on::after, .rail-tick:hover::after {
  content: attr(data-year); position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--fg-2); letter-spacing: .05em; white-space: nowrap;
}
.rail-tick.on::after { color: var(--warm); }
.rail-hint { font-size: 12px; color: var(--fg-3); white-space: nowrap; }
@media (max-width: 700px) { .rail-hint { display: none; } .rail-bar { grid-template-columns: auto minmax(0,1fr) auto; } }
.rail-fallback { margin-top: 14px; }
.rail-fallback summary { cursor: pointer; color: var(--fg-3); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .rail-card { transition: none; } }

/* 연도별 대표 사진: 카드 오른쪽 빈칸에 은은하게 (사진이 없는 해는 비워 둔다) */
.rail-card > :not(.rc-photo) { position: relative; z-index: 1; }
.rail-card .rc-photo {
  position: absolute;
  top: 14px; right: 14px; bottom: 14px;
  width: 44%;
  height: calc(100% - 28px);
  object-fit: cover;
  border-radius: 10px;
  opacity: 0;
  filter: grayscale(.35) contrast(1.05);
  -webkit-mask-image: linear-gradient(to left, #000 45%, transparent 100%);
          mask-image: linear-gradient(to left, #000 45%, transparent 100%);
  transition: opacity .6s ease, filter .4s ease;
  pointer-events: none;
  z-index: 0;
}
.rail-card .rc-photo.is-loaded { opacity: .2; }
.rail-card.is-active .rc-photo.is-loaded { opacity: .28; }
.rail-card.is-active:hover .rc-photo.is-loaded { opacity: .45; filter: grayscale(0) contrast(1.05); }
.rail-card.is-back .rc-photo.is-loaded { opacity: .14; }
@media (max-width: 700px) {
  .rail-card .rc-photo { width: 42%; top: 10px; right: 10px; bottom: 10px; height: calc(100% - 20px); }
}
@media (prefers-reduced-motion: reduce) { .rail-card .rc-photo { transition: none; } }
