/* ==========================================================================
   Voyamore — Carousel / Cat-nav / Catbar
   Three editorial UI primitives sharing one stylesheet + one JS bundle.
   All class-based; the same CSS applies whether the markup came from the
   shortcodes or was written directly in Oxygen.

   Native CSS nesting throughout. Tokens come from voyamore-core.css.
   ========================================================================== */

/* ==========================================================================
   .vym-cz-section — horizontal-scroll carousel
   ========================================================================== */

.vym-cz-section {
  position: relative;

  /* ---- Section header (eyebrow + h2 + blurb + arrows) ---- */
  & .vym-cz-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 30px;
    flex-wrap: wrap;

    & .vym-cz-head__main {
      min-width: 0;
      flex: 1 1 320px;
    }

    & .vym-cz-eyebrow {
      display: block;
      font-family: var(--font);
      font-size: 12px;
      font-weight: 600;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      color: var(--vym-muted);
      margin-bottom: 8px;
    }

    & .vym-cz-head__title {
      font-family: var(--vym-font-display);
      font-weight: 500;
      font-size: clamp(28px, 3.6vw, 42px);
      line-height: 1.08;
      letter-spacing: -0.01em;
      color: var(--vym-text);
      margin: 0;

      & em {
        font-style: italic;
        color: var(--vym-accent);
        font-weight: 500;
      }
    }

    & .vym-cz-blurb {
      color: var(--vym-muted);
      font-size: 15px;
      line-height: 1.55;
      margin: 10px 0 0;
      max-width: 460px;
    }
  }

  /* ---- Arrow controls ---- */
  & .vym-cz-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }

  & .vym-cz-arrow {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--vym-border);
    background: var(--vym-glass);
    color: var(--vym-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition:
      background 0.25s var(--vym-ease),
      color 0.25s var(--vym-ease),
      border-color 0.25s var(--vym-ease),
      transform 0.25s var(--vym-ease),
      opacity 0.25s var(--vym-ease);

    & svg {
      width: 18px;
      height: 18px;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    &:hover {
      background: var(--vym-accent);
      color: var(--vym-pill-fg);
      border-color: var(--vym-accent);
      transform: translateY(-2px);
    }

    &:focus-visible {
      outline: 2px solid var(--vym-accent);
      outline-offset: 2px;
    }

    &:disabled {
      opacity: 0.35;
      cursor: default;
      transform: none;
      background: var(--vym-glass);
      color: var(--vym-text);
      border-color: var(--vym-border);
    }
  }

  /* ---- The scrolling track ---- */
  & .vym-cz-track {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0 22px;
    scrollbar-width: none;
    scroll-snap-type: x proximity;

    /* Soft fade on both edges so cards bleed out of view nicely. */
    mask-image: linear-gradient(90deg, transparent 0, #000 2.5%, #000 97.5%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 2.5%, #000 97.5%, transparent 100%);

    &::-webkit-scrollbar { display: none; }

    /* While dragging: disable smooth scroll so the cursor stays in sync. */
    &.is-grabbing {
      scroll-behavior: auto;
      cursor: grabbing;
    }

    /* Any direct child becomes a snap target with the configured width.
       The editor's card markup (whatever it is) gets sized + snapped
       automatically — no per-card class required. */
    & > * {
      scroll-snap-align: start;
      flex: 0 0 var(--cw, 320px);
      min-width: 0;
    }

    /* On a surface-bg section, flip the cards to the page background
       so they stand out from the surface. The editor opts in by passing
       on_surface="1" to the shortcode (or adding the modifier class). */
    &.vym-cz-track--on-surface > * {
      background: var(--vym-bg, transparent);
    }
  }
}

/* Responsive: header stacks above arrows on narrower screens. */
@media (max-width: 720px) {
  .vym-cz-section .vym-cz-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }
  .vym-cz-section .vym-cz-controls { align-self: flex-end; }
}

/* ==========================================================================
   Grid view — [voyamore_cz_section view="grid"]

   Same markup, same cards; the track becomes a wrapped grid instead of a
   scroll-snap row. Everything that only makes sense while scrolling — the
   edge fade, snap points, drag cursor, horizontal overflow — is switched
   off so the section reads as a normal archive block.
   ========================================================================== */

.vym-cz-section--grid {
  & .vym-cz-track {
    display: grid;
    grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
    gap: 24px;

    overflow: visible;
    scroll-snap-type: none;
    padding: 0;
    mask-image: none;
    -webkit-mask-image: none;

    /* Cards stretch to their grid cell rather than a fixed --cw. */
    & > * {
      flex: initial;
      width: auto;
      scroll-snap-align: none;
    }
  }

  /* Nothing to scroll, so no drag affordance. */
  & .vym-cz-track.is-grabbing { cursor: default; }
}

@media (max-width: 980px) {
  .vym-cz-section--grid .vym-cz-track {
    grid-template-columns: repeat(min(var(--cols, 3), 2), minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .vym-cz-section--grid .vym-cz-track {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   .vym-cz-card — default card rendered by [voyamore_cz_section]'s auto-query.
   Editors who supply their own inner markup never see these styles.
   ========================================================================== */

.vym-cz-card {
  display: flex;
  flex-direction: column;
  background: var(--vym-surface);
  border: 1px solid var(--vym-border);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  font-family: var(--vym-font-ui);
  transition:
    transform 0.35s var(--vym-ease),
    border-color 0.35s var(--vym-ease),
    box-shadow 0.35s var(--vym-ease);

  &:hover {
    transform: translateY(-5px);
    border-color: rgba(15, 175, 203, 0.3);
    box-shadow: 0 26px 52px -30px rgba(15, 175, 203, 0.22);
  }

  & .vym-cz-card__media {
    height: 192px;
    flex: 0 0 auto;
    background-size: cover;
    background-position: center;
    position: relative;
    transition: transform 0.7s var(--vym-ease);

    &::after {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.38) 100%);
    }
  }
  &:hover .vym-cz-card__media { transform: scale(1.04); }

  /* No featured image → soft brand gradient instead of a blank box. */
  & .vym-cz-card__media--placeholder {
    background-image: linear-gradient(140deg, rgba(15,175,203,0.16), rgba(194,138,44,0.14));
  }

  & .vym-cz-card__body {
    padding: 20px 22px 22px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
  }

  & .vym-cz-card__meta {
    font-family: var(--font);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--vym-muted);
  }

  & .vym-cz-card__title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.32;
    letter-spacing: -0.005em;
    margin: 0;
    color: var(--vym-text);
  }

  & .vym-cz-card__excerpt {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--vym-muted);
    margin: 0;
  }

  & .vym-cz-card__cta {
    margin-top: auto;
    padding-top: 12px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--vym-accent);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: gap 0.25s var(--vym-ease);
  }
  &:hover .vym-cz-card__cta { gap: 10px; }
}

/* On a surface-background section, flip cards to the page bg so they
   still read as cards. Mirrors the --on-surface track modifier. */
.vym-cz-track--on-surface .vym-cz-card {
  background: var(--vym-bg);
}

/* ==========================================================================
   .vym-cat-nav — hero category grid
   ========================================================================== */

.vym-cat-nav {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;

  & .vym-cat-nav__card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 20px 18px 18px;
    background: var(--vym-surface);
    border: 1px solid var(--vym-border);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    font-family: var(--vym-font-ui);
    transition:
      transform 0.3s var(--vym-ease),
      border-color 0.3s var(--vym-ease),
      box-shadow 0.3s var(--vym-ease);

    &:hover {
      transform: translateY(-6px);
      border-color: rgba(15, 175, 203, 0.3);
      box-shadow: 0 28px 56px -30px rgba(15, 175, 203, 0.28);
    }

    /* Animated accent bar along the bottom on hover. */
    &::after {
      content: "";
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      height: 3px;
      background: var(--vym-accent);
      transform: scaleX(0);
      transform-origin: left;
      transition: transform 0.35s var(--vym-ease);
    }
    &:hover::after { transform: scaleX(1); }

    & .vym-cat-nav__icon {
      width: 46px;
      height: 46px;
      border-radius: 12px;
      background: rgba(15, 175, 203, 0.10);
      border: 1px solid rgba(15, 175, 203, 0.22);
      color: var(--vym-accent);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 18px;
      transition:
        background 0.3s var(--vym-ease),
        color 0.3s var(--vym-ease);

      & svg {
        width: 23px;
        height: 23px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.6;
        stroke-linecap: round;
        stroke-linejoin: round;
      }
    }
    &:hover .vym-cat-nav__icon {
      background: var(--vym-accent);
      color: var(--vym-pill-fg);
    }

    & .vym-cat-nav__title {
      font-size: 15px;
      font-weight: 600;
      letter-spacing: -0.005em;
      line-height: 1.25;
      margin: 0 0 4px;
      color: var(--vym-text);
    }

    & .vym-cat-nav__count {
      font-size: 12px;
      color: var(--vym-muted);
      font-weight: 500;
    }

    & .vym-cat-nav__arrow {
      margin-top: 14px;
      font-size: 18px;
      color: var(--vym-accent);
      opacity: 0;
      transform: translateX(-6px);
      transition:
        opacity 0.3s var(--vym-ease),
        transform 0.3s var(--vym-ease);
    }
    &:hover .vym-cat-nav__arrow {
      opacity: 1;
      transform: translateX(0);
    }
  }
}

@media (max-width: 1100px) {
  .vym-cat-nav { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .vym-cat-nav { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 460px) {
  .vym-cat-nav { grid-template-columns: 1fr; }
}

/* ==========================================================================
   .vym-catbar — sticky scroll-spy bar
   Visible only after the user scrolls past the hero; JS toggles is-visible.
   ========================================================================== */

/* Pinned, not sticky.
   `position: sticky` only works if the bar's own parent is tall enough to
   scroll within, and it breaks outright under any ancestor with
   overflow/transform/filter. Page builders wrap shortcode output in a
   shrink-to-fit div, so sticky reliably fails there. The JS also portals
   this element to <body> on init, which removes the last failure mode
   (fixed positioning resolving against a transformed ancestor).

   Offset is settable per instance via the `top` shortcode attribute,
   or globally: .vym-catbar { --vym-catbar-top: 80px; } */
.vym-catbar {
  position: fixed;
  top: var(--vym-catbar-top, 65px);
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--vym-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--vym-border);
  border-bottom: 1px solid var(--vym-border);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition:
    opacity 0.35s var(--vym-ease),
    transform 0.35s var(--vym-ease);

  &.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  & .vym-catbar__inner {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 10px 32px;
    max-width: 1240px;
    margin: 0 auto;

    &::-webkit-scrollbar { display: none; }
  }

  & .vym-catbar__item {
    flex: 0 0 auto;
    font-family: var(--font);
    font-size: 11.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--vym-muted);
    padding: 7px 13px;
    border-radius: 999px;
    white-space: nowrap;
    text-decoration: none;
    transition:
      color 0.2s var(--vym-ease),
      background 0.2s var(--vym-ease);

    &:hover { color: var(--vym-text); }

    &.is-active {
      color: var(--vym-pill-fg);
      background: var(--vym-accent);
    }
  }
}

@media (max-width: 720px) {
  .vym-catbar { top: var(--vym-catbar-top-mobile, 59px); }
  .vym-catbar .vym-catbar__inner { padding: 10px 22px; }
}
