/* Homepage clothes rail (server/views/rail.js + public/js/rail.js) */
/* --n (number of pairs) comes from the markup; the pair height is the largest that lets the whole
   rail fit the content width: n steps of .53h plus the rail ends. */
.clothes-rail { --pad: clamp(28px, 4vw, 64px); --jh: clamp(150px, calc((min(100vw - 2 * var(--gutter), 1424px) - 2 * var(--pad)) / (var(--n, 11) * .53)), 240px); --step: calc(var(--jh) * .53); background: var(--paper); overflow: hidden; }
.clothes-rail .section-head { align-items: end; }
.cr-tip { font-size: 13px; }
.cr-tip-touch { display: none; }
@media (hover: none), (max-width: 760px) { .cr-tip-mouse { display: none; } .cr-tip-touch { display: inline; } }

/* ---------- hanger (shared by the rail and the spotlight) ---------- */
/* The hanger is drawn over the top of the jeans so its clips grip the waistband. */
.cr-hanger { display: block; position: relative; z-index: 1; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, .22)); }

/* ---------- the rack ---------- */
.cr-stage { position: relative; width: fit-content; max-width: 100%; margin: 26px auto 0; padding: 14px var(--pad) 0; }
.js .cr-stage.reveal { opacity: 1; transform: none; }
.cr-rod { position: absolute; top: 14px; left: 0; right: 0; height: 5px; border-radius: 3px;
  background: linear-gradient(#fdfdfd, #c9ccd0 30%, #8b8f95 62%, #5e6268 85%, #a9adb2); box-shadow: 0 3px 5px rgba(0, 0, 0, .16); }
.cr-rod::before, .cr-rod::after { content: ''; position: absolute; top: -3.5px; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #a5a8ad 60%, #7d8086); }
.cr-rod::before { left: -6px; } .cr-rod::after { right: -6px; }
.cr-items { display: flex; list-style: none; margin: 0; padding: 0; height: calc(var(--jh) * 1.16); }
.cr-item { position: relative; flex: 0 0 var(--step); transition: translate .55s var(--ease); }
.cr-hang { --h: var(--jh); position: absolute; top: calc(2.5px - var(--jh) * .0174); left: 50%; display: flex; flex-direction: column; align-items: center;
  width: max-content; translate: -50% 0; transform-origin: 50% 0; -webkit-tap-highlight-color: transparent;
  animation: cr-sway 5.5s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -.75s);
  transition: scale .55s var(--ease), filter .4s; }
/* width .47h (narrower than the .53h step so neighbouring bars never touch); the clip jaws overlap the waistband */
.cr-hang .cr-hanger, .cr-piece-hang .cr-hanger { width: calc(var(--h) * .47); margin-bottom: calc(var(--h) * -.05); }
.cr-img { display: block; height: var(--jh); width: auto; max-width: none; user-select: none; filter: drop-shadow(0 10px 10px rgba(0, 0, 0, .12)); }
.cr-hang.is-away { visibility: hidden; }
.cr-hang:focus-visible { outline: none; }
.cr-hang:focus-visible .cr-img { outline: 2px solid var(--ink); outline-offset: 6px; }
@keyframes cr-sway { from { rotate: -1deg; } to { rotate: 1deg; } }

/* drop onto the rail when scrolled into view */
/* .cr-wait (set by rail.js) holds the pairs back until their photos have loaded */
.js .cr-stage:not(.is-in) .cr-hang, .cr-stage.cr-wait .cr-hang { opacity: 0; transform: translateY(-36px); }
.cr-stage.is-in:not(.cr-wait) .cr-hang { animation: cr-sway 5.5s ease-in-out infinite alternate, cr-drop .9s var(--ease) backwards; animation-delay: calc(var(--i) * -.75s), calc(var(--i) * 65ms); }
@keyframes cr-drop { from { opacity: 0; transform: translateY(-36px); } }

/* hover: lift the pair, nudge the neighbours aside */
@media (hover: hover) and (min-width: 761px) {
  .cr-item:hover { z-index: 3; }
  .cr-item:hover .cr-hang { scale: 1.12; animation-play-state: paused; }
  .cr-item:hover + .cr-item { translate: 22px 0; }
  .cr-item:hover + .cr-item ~ .cr-item { translate: 14px 0; }
  .cr-item:has(+ .cr-item:hover) { translate: -22px 0; }
  .cr-item:has(~ .cr-item:hover):not(:has(+ .cr-item:hover)) { translate: -14px 0; }
}

/* ---------- spotlight (fixed overlay) ---------- */
html.cr-lock { overflow: hidden; }
.cr-focus { --h: min(46vh, 500px); position: fixed; inset: 0; z-index: 70; display: grid; grid-template-rows: 1fr auto; justify-items: center;
  padding: 64px 20px 28px; background: rgba(248, 246, 242, 0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0);
  transition: background .6s, backdrop-filter .6s, -webkit-backdrop-filter .6s; }
.cr-focus[hidden] { display: none; }
.cr-focus.is-open { background: rgba(248, 246, 242, .86); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
.cr-close { position: absolute; top: 18px; right: 22px; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink); opacity: 0; transition: opacity .4s .25s; }
.cr-close .icon { width: 14px; height: 14px; }
.cr-arrow { position: absolute; top: calc(64px + var(--h) * .5); width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-2);
  display: grid; place-items: center; color: var(--ink); background: rgba(255, 255, 255, .6); opacity: 0; transition: opacity .4s .25s, background .2s; }
.cr-arrow:hover { background: #fff; }
.cr-arrow .icon { width: 16px; height: 16px; }
.cr-arrow--prev { left: clamp(12px, 4vw, 56px); } .cr-arrow--next { right: clamp(12px, 4vw, 56px); }
.cr-focus.is-open .cr-close, .cr-focus.is-open .cr-arrow { opacity: 1; }

.cr-show { align-self: end; display: grid; place-items: end center; width: 100%; }
.cr-piece { position: relative; transition: transform .42s var(--ease), opacity .3s; }
.cr-piece.is-out-left { transform: translateX(-28vw); opacity: 0; }
.cr-piece.is-out-right { transform: translateX(28vw); opacity: 0; }
.cr-piece.is-in-right { transform: translateX(28vw); opacity: 0; transition: none; }
.cr-piece.is-in-left { transform: translateX(-28vw); opacity: 0; transition: none; }
.cr-piece-hang { position: relative; display: flex; flex-direction: column; align-items: center; will-change: transform; }
.cr-p-flat { display: block; height: var(--h); width: auto; max-width: none; filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .14)); transition: opacity .3s; user-select: none; }
.cr-p-model { position: absolute; bottom: 0; left: 50%; translate: -50% 0; height: calc(var(--h) + var(--h) * .3); width: auto; max-width: none;
  border-radius: 6px; opacity: 0; transition: opacity .35s; pointer-events: none; }
.cr-piece.is-model .cr-p-model { opacity: 1; }
.cr-piece.is-model .cr-p-flat, .cr-piece.is-model .cr-hanger { opacity: 0; }
.cr-piece-hang .cr-hanger { transition: opacity .3s; }
.cr-piece.is-swapping .cr-p-flat, .cr-piece.is-swapping .cr-p-model { opacity: 0; }

/* colour swing tags */
/* placed from the centre so they clear both the flat pair and the wider on-model photo */
.cr-tags { position: absolute; top: calc(var(--h) * .06); left: calc(50% + var(--h) * .46); display: flex; gap: 10px; }
.cr-tag { position: relative; display: flex; flex-direction: column; align-items: center; transform-origin: 50% 0; opacity: 0; translate: 0 -14px;
  transition: opacity .4s, translate .5s var(--ease); transition-delay: calc(.35s + var(--k) * 80ms); }
.cr-tags.is-in .cr-tag { opacity: 1; translate: 0 0; }
.cr-tag-string { width: 1px; height: calc(34px + var(--k) * 14px); background: #8a8a8a; }
.cr-tag-card { position: relative; display: grid; justify-items: center; gap: 6px; width: 38px; padding: 12px 0 10px; border-radius: 3px;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .14); transition: box-shadow .25s, transform .25s; }
.cr-tag-hole { position: absolute; top: 4px; width: 5px; height: 5px; border-radius: 50%; background: #F6F4F0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.cr-tag-swatch { width: 24px; height: 24px; border-radius: 2px; background: #ccc center/cover; }
.cr-tag-name { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 8.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); max-height: 84px; overflow: hidden; }
.cr-tag:hover .cr-tag-card { transform: translateY(2px); }
.cr-tag.is-on .cr-tag-card { box-shadow: 0 0 0 1.5px var(--ink), 0 4px 10px rgba(0, 0, 0, .18); }
.cr-tag.is-swing { animation: cr-swing .9s var(--ease); }
@keyframes cr-swing { 0% { rotate: 0deg; } 25% { rotate: 9deg; } 50% { rotate: -6deg; } 75% { rotate: 3deg; } 100% { rotate: 0deg; } }

/* details under the piece */
.cr-info { width: min(440px, 100%); margin-top: 18px; text-align: center; opacity: 0; transform: translateY(14px); transition: opacity .4s .3s, transform .5s .3s var(--ease); }
.cr-focus.is-open .cr-info { opacity: 1; transform: none; }
.cr-info.is-changing { opacity: 0; transition-delay: 0s; }
.cr-form { display: grid; justify-items: center; gap: 10px; }
.cr-name { font: 600 15px/1.2 var(--f-body); letter-spacing: .08em; text-transform: uppercase; }
.cr-price { font-size: 13px; margin-top: -4px; }
.cr-price s { color: var(--stone); }
.cr-meta { color: var(--stone); }
.cr-views { display: inline-flex; padding: 3px; border: 1px solid var(--line-2); border-radius: 999px; }
.cr-views button { padding: 5px 14px; border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--stone); transition: background .25s, color .25s; }
.cr-views button.is-on { background: var(--ink); color: #fff; }
.cr-sizes { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.cr-size { position: relative; cursor: pointer; }
.cr-size input { position: absolute; opacity: 0; pointer-events: none; }
.cr-size span { display: grid; place-items: center; width: 38px; height: 32px; border: 1px solid var(--line-2); border-radius: 4px; font-size: 12px; transition: .2s; }
.cr-size:hover span { border-color: var(--ink); }
.cr-size input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.cr-size input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.cr-size.is-out span { color: var(--taupe); text-decoration: line-through; cursor: not-allowed; }
.cr-sizes.shake { animation: shake .45s; }
.cr-msg:empty { display: none; }
.cr-add { width: min(300px, 100%); height: 42px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; opacity: .35; transition: opacity .3s, background .2s; }
.cr-form.has-size .cr-add { opacity: 1; }
.cr-add:hover { background: var(--ink-2); }
.cr-add.is-loading { opacity: .6; }
.cr-add:disabled { opacity: .25; cursor: not-allowed; }
.cr-more { font-size: 11px; color: var(--stone); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .clothes-rail { --jh: 230px; }
  .cr-stage { width: auto; padding: 14px 0 0; }
  .cr-rod { left: -20px; right: -20px; }
  .cr-items { overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scrollbar-width: none; padding: 0 24px; }
  .cr-items::-webkit-scrollbar { display: none; }
  .cr-item { flex: 0 0 calc(var(--jh) * .5); scroll-snap-align: center; }
  .cr-focus { --h: 40vh; padding: 56px 14px 20px; }
  /* beside the product name, clear of the swing tags */
  .cr-arrow { width: 36px; height: 36px; top: auto; bottom: 190px; }
  .cr-tags { gap: 4px; left: calc(50% + var(--h) * .3); }
  .cr-tag-card { width: 26px; padding: 10px 0 8px; }
  .cr-tag-swatch { width: 16px; height: 16px; }
  .cr-tag-name { font-size: 7.5px; max-height: 70px; }
  .cr-p-model { height: calc(var(--h) * .9); }
}
@media (prefers-reduced-motion: reduce) {
  .cr-hang, .cr-stage.is-in:not(.cr-wait) .cr-hang { animation: none; }
  .js .cr-stage:not(.is-in) .cr-hang { opacity: 1; transform: none; }
  .cr-focus, .cr-info, .cr-tag, .cr-piece { transition-duration: .01s; transition-delay: 0s; }
}
