/* ==========================================================================
   The finale — the closing shot.
   Deep black + dark red + crimson + cream. The furnace canvas sits behind a
   giant BIJU400X set in real type (Anton, stretched to the reference's
   ultra-tall poster proportions, wearing the extracted grunge), the man's
   canvas rides in front of the title, and the editorial captions + the quiet
   functional row hold the edges.
   ========================================================================== */

/* Two frames of one closing scene: the pinned stage holds frame 1 (the
   BIJU400X composition) while the extra scroll room drives frame 2 sliding in
   from the left over it. */
.fin {
  position: relative;
  height: 240svh;
  background: #000;
}

.fin__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: #000;
}

.fin__stage1 {
  position: absolute;
  inset: 0;
  will-change: transform;
}

#finBack,
#finMan {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#finBack { z-index: 1; }
/* man layer hidden: the figure is baked into plate.jpg */
#finMan  { z-index: 3; pointer-events: none; display: none !important; }

/* dims frame 1 as frame 2 advances over it */
.fin__dim {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Frame 2 — the supplied still, full-bleed, entering from the LEFT under
   scroll control (boot6 writes its transform). Its leading edge throws a
   soft shadow onto frame 1, and a grain veil keeps it in the film's stock.
   -------------------------------------------------------------------------- */
.fin__frame2 {
  position: absolute;
  inset: 0;
  z-index: 6;
  margin: 0;
  transform: translate3d(-104%, 0, 0);
  will-change: transform, filter;
  pointer-events: none;
  box-shadow: 42px 0 110px rgba(0, 0, 0, 0.62);
  background: #0a0203;
}
.fin__frame2 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 42%;
  display: block;
  user-select: none;
}
.fin__frame2::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../../public/tex/grain.png') repeat;
  background-size: 340px;
  opacity: 0.06;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Editorial captions — cream letterspaced, red punctuation.
   -------------------------------------------------------------------------- */

.f-cap {
  position: absolute;
  margin: 0;
  z-index: 4;
  font-family: var(--ui);
  font-size: clamp(8px, 0.72vw, 12px);
  font-weight: 400;
  line-height: 2.1;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(233, 220, 208, 0.72);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s ease calc(var(--li, 0) * 0.15s),
              transform 1.2s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--li, 0) * 0.15s);
  pointer-events: none;
}
.fin.is-caps .f-cap { opacity: 1; transform: none; }

.f-cap--tl {
  top: clamp(22px, 6vh, 58px);
  left: clamp(24px, 3.6vw, 62px);
  padding-left: 1.2em;
  border-left: 2px solid #b3271d;
}
.f-cap--quote {
  top: 38%;
  left: clamp(24px, 3.2vw, 56px);
  font-size: clamp(10px, 0.92vw, 15px);
  letter-spacing: 0.34em;
  color: rgba(240, 230, 220, 0.88);
}
.f-cap--quote::after {
  content: '';
  display: block;
  width: 2.1em;
  height: 2px;
  margin-top: 1.5em;
  background: #b3271d;
}
.f-cap--blw {
  bottom: clamp(64px, 11vh, 110px);
  left: clamp(24px, 3.6vw, 62px);
  padding-left: 1.2em;
  border-left: 2px solid #b3271d;
}
.f-cap--tr {
  top: clamp(22px, 6vh, 58px);
  right: clamp(24px, 3.6vw, 62px);
}
.f-cap--tr::after,
.f-cap--br::after {
  content: '';
  display: block;
  width: 1.8em;
  height: 2px;
  margin-top: 1.2em;
  background: #b3271d;
}
.f-cap--br {
  bottom: clamp(64px, 11vh, 110px);
  right: clamp(24px, 3.6vw, 62px);
}

/* --------------------------------------------------------------------------
   The functional row — a real footer, whispering. Sits on the bottom edge
   without breaking the frame.
   -------------------------------------------------------------------------- */

.fin__bar {
  position: absolute;
  z-index: 7;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end; /* changed from center to flex-end so the social links align with the bottom */
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(20px, 3.6vw, 62px) 16px;
  font-family: var(--ui);
  font-size: clamp(8px, 0.66vw, 11px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(216, 186, 174, 0.5);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1.2s var(--ease-out) 1s, transform 1.2s var(--ease-out) 1s;
}

.fin__nav-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fin__nav-list a {
  display: inline-block;
  font-size: clamp(10px, 1vw, 14px);
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-decoration: none;
  color: rgba(233, 220, 208, 0.9);
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.fin__nav-list a:hover,
.fin__nav-list a:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: translateX(8px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.fin__nav-list a:active {
  transform: translateX(4px) scale(0.96);
  transition: all 0.1s;
}
.fin.is-bar .fin__bar { opacity: 1; transform: none; }

.fin__bar a {
  color: rgba(233, 220, 208, 0.7);
  text-decoration: none;
  transition: color 0.35s ease, text-shadow 0.35s ease;
}
.fin__bar a:hover,
.fin__bar a:focus-visible {
  color: #f4ecdd;
  text-shadow: 0 0 14px rgba(220, 60, 40, 0.55);
  outline: none;
}
.fin__soc {
  display: flex;
  gap: 2.4em;
}
.fin__c { font-size: inherit; letter-spacing: 0.24em; }

/* --------------------------------------------------------------------------
   Premium Back to Top Control
   -------------------------------------------------------------------------- */
.fin__actions-wrap {
  position: absolute;
  z-index: 10;
  bottom: clamp(70px, 12vh, 100px);
  right: clamp(24px, 3.6vw, 62px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s var(--ease-out) 0.5s, transform 0.7s var(--ease-out) 0.5s;
}

.fin.is-bar .fin__actions-wrap {
  opacity: 1;
  transform: translateY(0);
}

.fin__btt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  outline: none;
}

.fin__quick-actions {
  display: flex;
  gap: 12px;
}

.fin__quick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #E8E2DC;
  text-decoration: none;
  transition: border-color 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease, color 0.4s ease;
}

.fin__quick-btn:hover,
.fin__quick-btn:focus-visible {
  border-color: rgba(216, 177, 131, 0.4);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(216, 177, 131, 0.15);
  color: #D8B183;
}

.fin__btt-ring {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.4);
  transition: border-color 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease;
}

.fin__btt-ring svg {
  position: absolute;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.btt-ring-bg {
  fill: none;
  stroke: transparent;
  stroke-width: 2;
}

.btt-ring-progress {
  fill: none;
  stroke: #D8B183;
  stroke-width: 2;
  stroke-dasharray: 301.59; /* 2 * pi * 48 */
  stroke-dashoffset: 301.59;
  transition: stroke-dashoffset 0.1s linear;
}

.fin__btt-circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #E8E2DC;
  pointer-events: none;
}

.btt-arrow {
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.4s ease;
}

.fin__btt-label {
  font-family: var(--ui);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.25em;
  color: rgba(232, 226, 220, 0.5);
  text-transform: uppercase;
  transition: color 0.4s ease;
}

/* Hover State */
.fin__btt:hover .fin__btt-ring,
.fin__btt:focus-visible .fin__btt-ring {
  border-color: rgba(216, 177, 131, 0.4);
  transform: scale(1.04);
  box-shadow: 0 0 20px rgba(216, 177, 131, 0.15);
}

.fin__btt:hover .btt-arrow,
.fin__btt:focus-visible .btt-arrow {
  transform: translateY(-4px);
  color: #D8B183;
}

.fin__btt:hover .fin__btt-label,
.fin__btt:focus-visible .fin__btt-label {
  color: rgba(216, 177, 131, 0.9);
}

/* Click Animation */
.fin__btt:active .fin__btt-ring {
  transform: scale(0.96);
  transition: transform 0.1s;
}
.fin__btt:active .btt-arrow {
  transform: translateY(-8px);
  transition: transform 0.1s;
}

/* --------------------------------------------------------------------------
   Portrait + fallbacks
   -------------------------------------------------------------------------- */

.fin.is-portrait .f-cap--tr,
.fin.is-portrait .f-cap--tl,
.fin.is-portrait .f-cap--blw { display: none; }
.fin.is-portrait .f-cap--quote { top: auto; bottom: 24vh; }
.fin.is-portrait .fin__bar {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 20px;
}
.fin.is-portrait .fin__soc,
.fin.is-portrait .fin__c {
  align-self: center;
}

/* Mobile Back-to-Top adjustments */
@media (max-width: 760px) {
  .fin__bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 20px;
  }
  .fin__soc,
  .fin__c {
    align-self: center;
  }
  .fin__actions-wrap {
    top: auto;
    bottom: 150px; /* Above the stacked footer text on mobile */
    right: 20px;
  }
  .fin__btt {
    gap: 8px;
  }
  .fin__btt-ring, .fin__btt-circle {
    width: 48px;
    height: 48px;
  }
  .fin__btt-label {
    font-size: 8px;
    letter-spacing: 0.2em;
  }
}

.fin.is-fallback #finBack,
.fin.is-fallback #finMan { display: none; }
.fin.is-fallback {
  background: #000 url('../../public/fin/plate.jpg') center / cover no-repeat;
}
.fin.is-set .f-cap,
.fin.is-set .fin__bar { opacity: 1; transform: none; filter: none; }

@media (prefers-reduced-motion: reduce) {
  .f-cap, .fin__bar, .fin__btt, .fin__actions-wrap, .fin__btt-ring, .btt-arrow, .fin__btt-label, .fin__quick-btn {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    transform: none !important;
  }
}
