/* ============================================================================
   Vídeos Social Media & Vídeos 3D (v2) — Layout Palco + Fileira Única Rolável
   Direction 08 (Light Ceramic Console OS) & Direction 09 (Dark Ceramic Console OS)
   Consumes shared tokens from css/tokens.css
   ============================================================================ */

/* === 1. Shell Framing & Stage Container === */
.sm-frame-spacer {
  height: clamp(0px, calc((100vh - 800px) / 2), 36px);
  pointer-events: none;
}

.sm-main {
  position: relative;
  display: flow-root;
  width: 100%;
}

.sm-expand-stage {
  position: relative;
  width: 100%;
  transform-origin: center top;
}

.sm-expand-stage.is-framed {
  will-change: transform;
}

.sm-gallery-host {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 56px 20px;
}

/* === 2. Shared Card & Media Primitives === */
.sm-work-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  text-align: left;
  background: var(--surface-tray);
  border: 1.5px solid var(--border-panel);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  color: var(--ink-primary);
  box-shadow:
    inset 0 1px 0 var(--tile-hi),
    0 8px 22px var(--panel-shadow);
  transition:
    transform 220ms var(--ease-out),
    border-color 220ms var(--ease-out),
    box-shadow 220ms var(--ease-out),
    background-color 220ms var(--ease-out);
}

.sm-work-card:focus-visible {
  outline: 2px solid var(--wii-sky);
  outline-offset: 3px;
}

.sm-media-box {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--oled-bg);
}

.sm-media-box[data-ratio="16-9"] {
  aspect-ratio: 16 / 9;
}

.sm-media-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 420ms var(--ease-out);
  will-change: transform;
}

.sm-badge-float {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(14, 15, 19, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #F3F2EE;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.sm-badge-float[hidden] {
  display: none;
}

.sm-work-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 12px 14px 13px;
  min-width: 0;
}

.sm-work-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.015em;
  color: var(--ink-primary);
}

.sm-work-client {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   3. Palco Principal (.sm-v3-stage-layout & .sm-v3-stage)
   ============================================================================ */
.sm-v3-stage-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sm-v3-stage {
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: 24px;
  overflow: clip;
  background: var(--surface-tray);
  border: 2px solid var(--border-panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    var(--tray-shadow);
  transition:
    border-color 220ms var(--ease-out),
    box-shadow 220ms var(--ease-out),
    transform 160ms var(--ease-out);
}

.sm-v3-stage.is-pressed {
  transform: scale(0.997);
}

.sm-v3-stage-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: clamp(220px, 37vh, 360px);
  padding: 0;
  overflow: hidden;
  background: var(--oled-bg);
  cursor: pointer;
}

.sm-v3-stage-media:focus-visible {
  outline: 2px solid var(--wii-sky);
  outline-offset: -3px;
}

.sm-v3-stage-bg {
  position: absolute;
  inset: -28px;
  z-index: 0;
  width: calc(100% + 56px);
  height: calc(100% + 56px);
  object-fit: cover;
  filter: blur(28px) brightness(0.42) saturate(1.15);
  transform: scale(1.06);
  opacity: 0.9;
  pointer-events: none;
}

.sm-v3-stage-fg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 380ms var(--ease-out);
}

.sm-v3-stage-fg.is-cover {
  object-fit: cover;
}

.sm-v3-stage:not(.is-vertical) .sm-v3-stage-media:hover .sm-v3-stage-fg {
  transform: scale(1.015);
}

.sm-v3-stage.is-vertical .sm-v3-stage-fg {
  width: auto;
  height: calc(100% - 24px);
  max-width: 88%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.58);
}

.sm-v3-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 22px;
  background: var(--surface-tray);
  border-top: 1px solid var(--hairline);
  color: var(--ink-primary);
}

.sm-v3-stage-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sm-v3-stage-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.08rem, 1.8vw, 1.35rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

.sm-v3-stage-client {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.sm-v3-stage-cta {
  flex: none;
  min-height: 44px;
  padding: 9px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ============================================================================
   4. Fileira Única Rolável (.sm-v3-shelf-wrap & .sm-v3-shelf)
   ============================================================================ */
.sm-v3-shelf-wrap {
  position: relative;
  width: 100%;
}

.sm-v3-shelf-viewport {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  outline: none;
}

.sm-v3-shelf-viewport::-webkit-scrollbar {
  display: none;
}

.sm-v3-shelf-viewport.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.sm-v3-shelf-viewport.is-dragging .sm-v3-thumb {
  pointer-events: none;
}

.sm-v3-shelf {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 14px;
  padding: 4px 2px 8px;
}

.sm-v3-thumb {
  position: relative;
  display: flex;
  flex: 0 0 calc((100% - 42px) / 4);
  flex-direction: column;
  width: calc((100% - 42px) / 4);
  min-width: 0;
  padding: 6px;
  border-radius: 15px;
  background: var(--surface-tile);
  border: 2px solid var(--border-tile);
  box-shadow:
    inset 0 1px 0 var(--tile-hi),
    0 3px 0 var(--tile-ledge),
    0 8px 16px var(--panel-shadow);
  text-align: left;
  color: var(--ink-primary);
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    background-color 180ms var(--ease-out);
}

.sm-v3-thumb.is-hover-zone {
  transform: translateY(-2px);
  border-color: var(--border-tile-hover);
  box-shadow:
    inset 0 1px 0 var(--tile-hi),
    0 4px 0 var(--tile-ledge),
    0 12px 20px var(--panel-shadow);
}

.sm-v3-thumb.is-hover-zone .sm-media-img,
.sm-v3-thumb:focus-visible .sm-media-img {
  transform: scale(1.03);
}

.sm-v3-thumb:active,
.sm-v3-thumb.is-pressed {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 var(--tile-hi),
    0 1px 0 var(--tile-ledge),
    0 4px 10px var(--panel-shadow);
  transition-duration: 90ms;
}

.sm-v3-thumb.is-active {
  background: var(--surface-tray);
  border-color: var(--signal-orange);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 var(--tile-hi),
    0 2.5px 0 var(--signal-orange-ledge),
    0 8px 18px var(--panel-shadow);
}

.sm-v3-thumb.is-active.is-hover-zone {
  border-color: var(--signal-orange-border);
}

.sm-v3-thumb .sm-media-box,
.sm-v3-thumb .sm-media-box[data-ratio="16-9"] {
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  border: 1px solid var(--border-tile-inner);
}

.sm-v3-thumb .sm-badge-float {
  top: 7px;
  right: 7px;
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
}

.sm-v3-thumb .sm-work-meta {
  padding: 8px 5px 4px;
  gap: 3px;
}

.sm-v3-thumb .sm-work-title {
  font-size: 0.875rem;
  line-height: 1.24;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sm-v3-thumb .sm-work-client {
  font-size: 11.5px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Setas laterais 44×44px da fileira */
.sm-v3-rail-arrow {
  position: absolute;
  top: 50%;
  z-index: 6;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface-pill);
  border: 1.5px solid var(--border-panel);
  color: var(--ink-primary);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 20px var(--panel-shadow);
  transform: translateY(calc(-50% - 3px));
  cursor: pointer;
  transition:
    opacity 180ms var(--ease-out),
    transform 180ms var(--ease-out),
    background-color 180ms var(--ease-out),
    border-color 180ms var(--ease-out);
}

.sm-v3-rail-arrow--prev {
  left: -52px;
}

.sm-v3-rail-arrow--next {
  right: -52px;
}

.sm-v3-rail-arrow:hover:not(:disabled) {
  background: var(--surface-tray);
  border-color: var(--border-tile-hover);
  transform: translateY(calc(-50% - 4px));
}

.sm-v3-rail-arrow:active:not(:disabled) {
  transform: translateY(calc(-50% - 1px));
}

.sm-v3-rail-arrow:disabled {
  opacity: 0.32;
  cursor: default;
}

.sm-v3-rail-mobile-nav {
  display: none;
  align-items: center;
  gap: 8px;
}

.sm-v3-rail-arrow--inline {
  position: static;
  transform: none;
  box-shadow: none;
}

.sm-v3-rail-arrow--inline:hover:not(:disabled),
.sm-v3-rail-arrow--inline:active:not(:disabled) {
  transform: none;
}

/* Rodapé silencioso do trilho */
.sm-v3-rail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px;
}

.sm-v3-rail-progress {
  position: relative;
  flex: 1;
  max-width: 240px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-dock);
  border: 1px solid var(--hairline);
  overflow: hidden;
}

.sm-v3-rail-progress-thumb {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--signal-orange);
  will-change: transform, width;
}

.sm-v3-rail-meta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.sm-v3-rail-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.sm-v3-rail-counter {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   5. Responsive Breakpoints (1024px, 860px, 640px / 390px Mobile)
   ============================================================================ */
@media (max-width: 1024px) {
  .sm-gallery-host {
    padding: 16px 24px 32px;
  }

  .sm-v3-rail-arrow--prev {
    left: 6px;
  }

  .sm-v3-rail-arrow--next {
    right: 6px;
  }
}

@media (max-width: 860px) {
  .sm-frame-spacer {
    height: 0;
  }

  .sm-v3-thumb {
    flex: 0 0 calc((100% - 14px) / 2.35);
    width: calc((100% - 14px) / 2.35);
  }
}

@media (max-width: 640px) {
  .sm-gallery-host {
    padding: 12px 16px 32px;
  }

  .sm-v3-stage-layout {
    gap: 12px;
  }

  .sm-v3-stage {
    border-radius: 20px;
  }

  .sm-v3-stage-media {
    height: 224px;
  }

  .sm-v3-stage.is-vertical .sm-v3-stage-media {
    height: 276px;
  }

  .sm-v3-stage.is-vertical .sm-v3-stage-fg {
    width: 144px;
    height: auto;
    max-height: calc(100% - 20px);
    aspect-ratio: 9 / 16;
    border-radius: 10px;
  }

  .sm-v3-stage-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px 14px;
  }

  .sm-v3-stage-cta {
    width: 100%;
    justify-content: center;
  }

  .sm-v3-shelf-viewport {
    scroll-snap-type: x proximity;
  }

  .sm-v3-shelf {
    gap: 12px;
  }

  .sm-v3-thumb {
    flex: 0 0 68vw;
    width: 68vw;
    max-width: 260px;
    padding: 5px;
    border-radius: 14px;
    scroll-snap-align: start;
  }

  .sm-v3-shelf-wrap > .sm-v3-rail-arrow {
    display: none;
  }

  .sm-v3-rail-footer {
    flex-wrap: wrap;
    gap: 10px;
  }

  .sm-v3-rail-progress {
    flex: 1 1 100%;
    max-width: none;
    order: 2;
  }

  .sm-v3-rail-meta {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    order: 1;
  }

  .sm-v3-rail-hint {
    font-size: 10.5px;
  }

  .sm-v3-rail-mobile-nav {
    display: inline-flex;
  }
}

/* === 6. Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  .sm-frame-spacer {
    height: 0;
  }

  .sm-work-card,
  .sm-media-img,
  .sm-v3-stage,
  .sm-v3-stage-bg,
  .sm-v3-stage-fg,
  .sm-v3-thumb,
  .sm-v3-rail-arrow {
    transition: none !important;
    animation: none !important;
  }

  .sm-v3-thumb.is-hover-zone,
  .sm-v3-thumb.is-hover-zone .sm-media-img,
  .sm-v3-thumb.is-active {
    transform: none !important;
  }
}
