/* arXte — "La parete" (Wall Component)
   Oval portrait miniatures hanging from a brass rail on ivory laid paper.
   Prefix: wl-
*/

.wl-root {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: clamp(24px, 3vw, 40px) 0 clamp(32px, 4vw, 56px);
  background: transparent; /* let the page's laid-paper texture show through */
  color: var(--ink);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Header & Filter Controls */
.wl-header {
  max-width: 1200px;
  margin: 0 auto clamp(28px, 4vw, 48px);
  padding: 0 clamp(20px, 4vw, 48px);
  text-align: center;
}

.wl-eyebrow {
  margin-bottom: 10px;
  display: block;
}

.wl-title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: var(--fs-h2);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  color: var(--ink);
}

.wl-subtitle {
  font-family: var(--font-text);
  font-style: italic;
  font-size: var(--fs-body);
  color: var(--ink-soft);
  max-width: 680px;
  margin: 0 auto clamp(24px, 3.5vw, 36px);
  line-height: 1.5;
}

/* Filter Bar */
.wl-filters {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 20px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.wl-filter-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  font-size: var(--fs-label);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
  transition: color 0.25s var(--ease-out);
  font-family: var(--font-ui);
}

.wl-filter-btn::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 10px;
  right: 10px;
  height: 1px;
  background-color: var(--gold);
  opacity: 0;
  transform: scaleX(0);
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}

.wl-filter-btn:hover {
  color: var(--ink);
}

.wl-filter-btn.wl-active-filter {
  color: var(--ink);
  font-weight: 600;
}

.wl-filter-btn.wl-active-filter::after {
  opacity: 1;
  transform: scaleX(1);
}

.wl-filter-btn:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.wl-filter-sep {
  color: var(--hairline-strong);
  font-size: 11px;
  user-select: none;
}

/* Gallery Horizontal Scroll Area */
.wl-stage {
  position: relative;
  width: 100%;
  margin: 0 auto;
  cursor: grab;
}

.wl-stage:active {
  cursor: grabbing;
}

.wl-scroll-track {
  overflow-x: auto;
  overflow-y: visible;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Hide default scrollbar */
  padding: 40px 0 60px;
}

.wl-scroll-track::-webkit-scrollbar {
  display: none;
}

.wl-rail-assembly {
  position: relative;
  isolation: isolate; /* rail and frames stack among themselves, not against the page */
  display: inline-flex;
  min-width: 100%;
  padding: 0 clamp(40px, 8vw, 120px);
  box-sizing: border-box;
}

/* Brass Picture Rail */
.wl-rail {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--gold-foil);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 -1px 0 rgba(100, 70, 30, 0.6) inset,
    0 3px 6px rgba(40, 30, 15, 0.25);
  z-index: 10;
  pointer-events: none;
}

.wl-rail::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(140, 105, 50, 0.4);
}

/* Hanging List */
.wl-gallery-list {
  display: flex;
  align-items: flex-start;
  gap: clamp(32px, 5vw, 64px);
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

/* Single Frame Item: hangs behind the brass rail (z-index 10) */
.wl-item {
  position: relative;
  z-index: 0;
  flex: 0 0 auto;
  width: 190px;
  /* on closing, stay above the rail and the neighbours until the frame has turned back */
  transition: opacity 0.5s var(--ease-out), z-index 0s linear 0.75s;
}

.wl-item.wl-filtered-out {
  opacity: 0.18;
  pointer-events: none;
}

/* The enlarged verso comes forward, over the rail and the neighbouring frames */
.wl-item.wl-is-open {
  z-index: 50;
  transition: opacity 0.5s var(--ease-out), z-index 0s;
}

/* Brass Nail / Rail Bracket */
.wl-nail {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff0d0 0%, #d9bf86 40%, #7d5e28 90%);
  box-shadow: 0 2px 4px rgba(30, 20, 10, 0.4);
  z-index: 15;
  pointer-events: none;
}

/* Damped Pendulum Arm */
.wl-pendulum {
  position: relative;
  display: flow-root; /* stop the frame's margin-top collapsing through: ribbons must start at the nail */
  width: 100%;
  transform-origin: 50% 0; /* Nail anchor */
  will-change: transform;
}

/* Silk Ribbon */
.wl-ribbon-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}

.wl-ribbon-line {
  stroke: rgba(120, 30, 30, 0.78); /* Deep wine-silk cord */
  stroke-width: 1.5;
  stroke-linecap: round;
}

.wl-ribbon-bow {
  fill: #8e1b1b;
}

/* Oval Frame Wrapper & 3D Perspective */
.wl-frame-anchor {
  position: relative;
  z-index: 3; /* above the ribbons: the enlarged verso must not be crossed by the cords */
  width: 180px;
  height: 230px;
  margin: 0 auto;
  perspective: 1200px;
}

.wl-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.2, 0.85, 0.32, 1.2), scale 0.75s var(--ease-out);
  border-radius: 50%;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 12px 28px -6px rgba(40, 25, 10, 0.4),
    0 3px 8px rgba(40, 25, 10, 0.15);
  cursor: pointer;
}

/* The recto is the frame's <button>: its ring traces the oval */
.wl-front:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

.wl-item.wl-is-open .wl-flipper {
  transform: rotateY(180deg) scale(1.42);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 36px 64px -14px rgba(30, 18, 5, 0.6),
    0 8px 18px rgba(30, 18, 5, 0.25);
  cursor: default;
}

/* Faces (Recto & Verso) */
.wl-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-sizing: border-box;
  overflow: hidden;
}

/* RECTO: Gilded Frame & Portrait (a <button>: native box reset) */
.wl-front {
  display: block;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-color: #1a1612;
  border: 7px solid #a8834a;
  box-shadow:
    0 0 0 1px #5e461b inset,
    0 0 0 3px #d9bf86 inset,
    0 0 0 5px #1c1710 inset,
    0 0 0 1px #d9bf86,
    0 0 0 3px #735322;
}

.wl-portrait-img {
  position: absolute; /* fill the button's box in every engine */
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
  filter: contrast(1.04) brightness(0.98);
  transition: transform 0.6s var(--ease-out), filter 0.4s var(--ease-out);
}

.wl-flipper:hover .wl-portrait-img {
  transform: scale(1.03);
  filter: contrast(1.08) brightness(1.02);
}

/* Glass Sheen Reflection */
.wl-glass-sheen {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.24) 0%,
    rgba(255, 255, 255, 0.05) 36%,
    transparent 55%,
    rgba(217, 191, 134, 0.12) 100%
  );
  pointer-events: none;
  mix-blend-mode: soft-light;
}

/* Engraved Brass Plaque Under Frame */
.wl-plaque {
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 130px;
  max-width: 165px;
  padding: 4px 10px;
  background: linear-gradient(180deg, #dfc894 0%, #b89758 50%, #9a7a3e 100%);
  border: 1px solid #7a5f2e;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 2px 4px rgba(35, 25, 10, 0.35);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
}

.wl-item.wl-is-open .wl-plaque {
  opacity: 0;
}

.wl-plaque-name {
  font-size: 0.72rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.14em;
  color: #241d13;
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-ui);
}

.wl-plaque-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 1px;
  font-family: var(--font-text);
  font-size: 0.65rem;
  font-style: italic;
  color: #3b2c15;
}

/* Tiny Lit Candle SVG Flame */
.wl-candle-flame {
  display: inline-block;
  width: 7px;
  height: 12px;
  transform-origin: 50% 90%;
}
/* the candles flicker only while the wall is on screen and the tab is visible (wall.js toggles the class) */
.wl-root.wl-is-visible .wl-candle-flame {
  animation: wl-flame-flicker 2.4s infinite ease-in-out;
}

@keyframes wl-flame-flicker {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.95; }
  25% { transform: scale(1.08, 0.95) rotate(-2deg); opacity: 1; }
  50% { transform: scale(0.94, 1.05) rotate(3deg); opacity: 0.88; }
  75% { transform: scale(1.04, 1) rotate(-1deg); opacity: 0.98; }
}

/* VERSO: Aged Paper & Handwritten Dossier
   Every size inside is in em of this font-size, so a smaller frame scales the whole note at once */
.wl-back {
  font-size: 1rem;
  transform: rotateY(180deg);
  background:
    radial-gradient(ellipse at 50% 50%, var(--paper-2) 45%, #e1d6c2 78%, #cbbda3 100%);
  border: 7px solid #94723a;
  box-shadow:
    0 0 0 1px #5e461b inset,
    0 0 0 3px #d9bf86 inset,
    0 0 0 1px #d9bf86,
    0 0 0 3px #735322;
  padding: 1.125em 0.875em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink);
  overflow: hidden;
}

/* Faint Foxing Spots on Verso */
.wl-back::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 25%, rgba(130, 95, 45, 0.12) 0, transparent 8px),
    radial-gradient(circle at 82% 70%, rgba(130, 95, 45, 0.1) 0, transparent 12px),
    radial-gradient(circle at 75% 20%, rgba(130, 95, 45, 0.08) 0, transparent 6px);
  pointer-events: none;
}

/* The note is centred where the oval is widest: the action row must sit fully inside the frame */
.wl-verso-content {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25em;
}

.wl-verso-name {
  font-family: var(--font-hand);
  font-size: 1.15em; /* the longest names ("James Whitmore") must clear the oval near its top */
  line-height: 1.05;
  color: var(--ink);
  margin: 0;
}

.wl-verso-meta {
  font-family: var(--font-text);
  font-size: 0.62em;
  font-style: italic;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--ink-soft);
  margin: 0.2em 0 0;
}

/* Miniatures Row */
.wl-verso-gallery {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375em;
  margin: 0.125em 0;
}

.wl-mini-art {
  width: 1.875em;
  height: 1.875em;
  border-radius: 2px;
  border: 1px solid rgba(140, 110, 60, 0.6);
  box-shadow: 0 1px 3px rgba(30, 20, 10, 0.25);
  overflow: hidden;
  background: #111;
  position: relative;
}

.wl-mini-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Wants & Reputation */
.wl-verso-wants {
  font-family: var(--font-text);
  font-size: 0.66em;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--ink);
  margin: 0;
}

.wl-verso-wants strong {
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-family: var(--font-ui);
}

.wl-verso-rep {
  font-family: var(--font-text);
  font-size: 0.66em;
  line-height: 1.25;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink-soft);
  margin: 0;
}

.wl-verso-rep .wl-star {
  color: var(--gold-text, #7a5c2a); /* 4.5:1 on the verso paper; --gold is for decoration only */
}

/* Actions Row */
.wl-verso-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 0.625em;
  position: relative;
  z-index: 5;
}

.wl-action-btn {
  background: none;
  border: none;
  padding: 0.4em 0.2em; /* ≥24px tall once the open frame is enlarged */
  font-size: 0.6em;
  line-height: 1.2;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.12em;
  color: var(--ink);
  cursor: pointer;
  position: relative;
  transition: color 0.2s var(--ease-out);
  font-family: var(--font-ui);
}

.wl-action-btn::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 0.2em;
  right: 0.2em;
  height: 1px;
  background-color: var(--ink);
  opacity: 0.5;
  transition: opacity 0.2s var(--ease-out);
}

.wl-action-btn:hover {
  color: var(--wax);
}

.wl-action-btn:hover::after {
  background-color: var(--wax);
  opacity: 1;
}

.wl-action-btn:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.wl-self-note {
  flex: 0 0 100%; /* own line: "Voltare" stays centred, inside the oval */
  font-family: var(--font-text);
  font-style: italic;
  font-size: 0.66em;
  line-height: 1.25;
  color: var(--ink-soft);
  margin: 0;
}

/* Hint & Instruction Footer */
.wl-footer {
  text-align: center;
  margin-top: clamp(24px, 4vw, 40px);
  padding: 0 20px;
}

.wl-hint {
  font-family: var(--font-text);
  font-style: italic;
  font-size: var(--fs-small);
  color: var(--ink-soft); /* --ink-faint is 2.5:1 on paper: too faint for running text */
  letter-spacing: 0.02em;
}

/* Responsive Rules */
@media (max-width: 768px) {
  .wl-item {
    width: 150px;
  }

  .wl-frame-anchor {
    width: 140px;
    height: 180px;
  }

  .wl-front {
    border-width: 5px;
  }

  /* The verso note shrinks with the frame (140/180) and the open frame enlarges more,
     so it reads at the same size as on desktop */
  .wl-back {
    border-width: 5px;
    font-size: 0.78rem;
  }

  .wl-item.wl-is-open .wl-flipper {
    transform: rotateY(180deg) scale(1.8);
  }

  /* room for the enlarged oval under the longest ribbons */
  .wl-scroll-track {
    padding-bottom: 84px;
  }

  .wl-plaque {
    min-width: 105px;
    bottom: -28px;
    padding: 3px 6px;
  }

  .wl-plaque-name {
    font-size: 0.65rem;
  }
}

/* Reduced Motion Mode */
@media (prefers-reduced-motion: reduce) {
  .wl-pendulum {
    transform: none !important;
    transition: none !important;
  }

  .wl-candle-flame {
    animation: none;
  }

  .wl-flipper {
    transition: none !important;
  }

  /* the frame turns back instantly: no need to keep it forward while it closes */
  .wl-item {
    transition-delay: 0s;
  }
}
