/* =============================================================================
   AdStar landing — control.css
   "After the ad is created, you stay in control"
   Full-bleed row of 6 expandable panels (Modify active by default).
   Desktop: hover expands a panel. Tablet/Mobile: all expanded, h-scroll.
   ========================================================================== */

.control {
  /* Clip the full-bleed (1920px) glow horizontally, but let it bleed
     vertically: in Figma the glow overflows the section's bottom by ~110px and
     spills over the top of the pricing section, which is what visually connects
     the two. overflow-x:clip + overflow-y:visible is a valid pair that does
     NOT force the y axis to auto (unlike overflow:hidden), so no scrollbar. */
  overflow-x: clip;
  overflow-y: visible;
}

.control__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 60px;
}

/* ---- Heading ------------------------------------------------------------- */
.control__head {
  max-width: 760px;
}
.control__title {
  display: inline;
  white-space: nowrap; /* one line on desktop, like Figma */
}
.control__title-accent {
  background: linear-gradient(90deg, var(--brand-500) 0%, var(--brand-900) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Content (panels + studio note) -------------------------------------- */
.control__content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

/* ---- Panels row ---------------------------------------------------------- */
.control__panels {
  display: flex;
  gap: 18px;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: var(--content-max);
}

/* A single panel (collapsed by default; .is-active expands) */
.control__panel {
  position: relative;
  height: 500px;
  flex: 0 0 100px;
  width: 100px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0c0c0c;
  transition: flex-basis var(--dur-slow) var(--ease-out),
              width var(--dur-slow) var(--ease-out);
  /* inset highlight per Figma */
  box-shadow: inset 1px 1px 1px 0 rgba(255, 255, 255, 0.1);
}
.control__panel.is-active {
  flex: 0 0 432px;
  width: 432px;
}

/* The whole panel is the toggle control */
.control__panel-btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  text-align: left;
  border-radius: inherit;
  cursor: pointer;
}
.control__panel.is-active .control__panel-btn {
  cursor: default;
}
.control__panel-btn:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: -2px;
}

/* Gradient glow background (harvested images) */
.control__panel-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.control__panel-bg--modify    { background-image: url("../images/control/company-financials.png"); background-position: left top; }
.control__panel-bg--variation { background-image: url("../images/control/analyst-estimates.png"); }
.control__panel-bg--resize    { background-image: url("../images/control/analyst-estimates1.png"); }
.control__panel-bg--translate { background-image: url("../images/control/analyst-estimates2.png"); }
.control__panel-bg--endcard   { background-image: url("../images/control/analyst-estimates3.png"); }
.control__panel-bg--captions  { background-image: url("../images/control/analyst-estimates4.png"); }

/* Rotated vertical label */
.control__panel-label {
  position: absolute;
  top: 34px;
  left: 35px;
  transform-origin: left top;
  transform: rotate(90deg);
  white-space: nowrap;
  font-size: var(--fs-xl);
  line-height: 30px;
  font-weight: 600;
  color: var(--white);
  pointer-events: none;
}

/* Bottom icon — rendered as a mask so the page controls the color: bright-grey
   while collapsed, greenish once the panel is active. (The source SVGs use a
   hard-coded stroke that can't be reached through an <img>, so we recolor via
   background-color + mask-image instead.) */
.control__panel-icon {
  position: absolute;
  left: 39px;
  bottom: 40px;
  width: 20px;
  height: 20px;
  pointer-events: none;
  background-color: var(--gray-200);   /* bright-grey default */
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transition: background-color var(--dur) var(--ease-out);
}
.control__panel-icon img { display: none; } /* shape comes from the mask */

.control__panel.is-active .control__panel-icon {
  background-color: var(--brand-500);  /* greenish when active */
}

/* Per-panel mask shapes (mirrors each panel's <img src>) */
.control__panel[data-panel="modify"]    .control__panel-icon { -webkit-mask-image: url("../images/control/icon.svg");   mask-image: url("../images/control/icon.svg"); }
.control__panel[data-panel="variation"] .control__panel-icon { -webkit-mask-image: url("../images/control/icon1.svg");  mask-image: url("../images/control/icon1.svg"); }
.control__panel[data-panel="resize"]    .control__panel-icon { -webkit-mask-image: url("../images/control/icon2.svg");  mask-image: url("../images/control/icon2.svg"); }
.control__panel[data-panel="translate"] .control__panel-icon { -webkit-mask-image: url("../images/control/icon3.svg");  mask-image: url("../images/control/icon3.svg"); }
.control__panel[data-panel="endcard"]   .control__panel-icon { -webkit-mask-image: url("../images/control/icon4.svg");  mask-image: url("../images/control/icon4.svg"); }
.control__panel[data-panel="captions"]  .control__panel-icon { -webkit-mask-image: url("../images/control/vector.svg"); mask-image: url("../images/control/vector.svg"); }

/* ---- Active pane content (Modify preview + caption) ---------------------- */
.control__pane {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  /* Fixed at the EXPANDED panel width and anchored to the left edge. The panel
     (overflow:hidden) clips it as it grows/shrinks, so the preview image + text
     are revealed/cut rather than resized — no per-frame reflow. */
  width: 432px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
}
.control__panel.is-active .control__pane {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0.12s;
}
.control__pane[hidden] { display: none; }

/* Editor preview screenshot, anchored near the top */
.control__preview {
  position: absolute;
  top: 36px;
  left: 80px;
  right: 16px;
  height: 312px;
}
.control__preview-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top right;
}

/* Caption under the preview */
.control__pane-caption {
  position: absolute;
  left: 41px;
  right: 41px;
  bottom: 81px;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  color: var(--gray-200);
}

/* ---- STUDIO note --------------------------------------------------------- */
.control__studio {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 504px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.control__studio-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #303800 0%, var(--gray-800) 100%);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: 700;
  color: var(--brand-700);
}
.control__studio-text {
  flex: 1 1 0;
  min-width: 0;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  color: var(--gray-200);
}

/* ---- Bottom wavy green glow ---------------------------------------------- */
.control__glow {
  position: absolute;
  left: 50%;
  bottom: -110px;
  width: 1920px;
  max-width: none;
  height: 400px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 0;
}
.control__glow img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
}

/* =============================================================================
   Responsive
   ========================================================================== */

/* Tablet & mobile: all panels expanded; horizontal swipe scroll. */
@media (max-width: 1024px) {
  .control__inner { gap: 48px; }
  .control__title { white-space: normal; }

  .control__panels {
    justify-content: flex-start;
    flex-wrap: nowrap;
    max-width: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    /* break out of the container gutters for a fuller-bleed scroller */
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    scrollbar-width: none;
    cursor: grab;
  }
  .control__panels::-webkit-scrollbar { display: none; }
  .control__panels.is-dragging { cursor: grabbing; }

  /* When JS drag-to-scroll is active it owns horizontal panning: disable native
     scroll + snap, and let vertical (page) scrolling pass through via pan-y. */
  .control__panels.is-draggable {
    overflow-x: hidden;
    scroll-snap-type: none;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
  }

  /* The whole panel reads as grabbable while the row scrolls on tablet. */
  .control__panel-btn,
  .control__panel.is-active .control__panel-btn { cursor: grab; }
  .control__panels.is-dragging .control__panel-btn { cursor: grabbing; }
  .control__panel img { -webkit-user-drag: none; user-select: none; }

  /* Every panel is open and a fixed comfortable width while scrolling */
  .control__panel,
  .control__panel.is-active {
    flex: 0 0 320px;
    width: 320px;
    height: 460px;
    scroll-snap-align: start;
    transition: none;
  }

  /* Show the pane caption on all panels (each panel open) */
  .control__pane,
  .control__panel.is-active .control__pane {
    opacity: 1;
    pointer-events: auto;
    transition: none;
    width: 320px; /* match the fixed panel width at this breakpoint */
  }
  .control__panel .control__pane[hidden] { display: block; }

  /* Modify preview stays anchored; others rely on label + caption */
  .control__panel[data-panel="modify"] .control__preview {
    top: 30px;
    left: 70px;
    height: 280px;
  }
}

@media (max-width: 767px) {
  .control__inner { gap: 40px; }
  .control__content { gap: 32px; }

  .control__panels {
    margin-inline: calc(-1 * var(--gutter-mobile));
    padding-inline: var(--gutter-mobile);
    gap: 14px;
  }
  .control__panel,
  .control__panel.is-active {
    flex: 0 0 280px;
    width: 280px;
    height: 420px;
  }
  .control__pane { width: 280px; } /* match the fixed panel width */

  .control__panel[data-panel="modify"] .control__preview {
    top: 26px;
    left: 60px;
    height: 240px;
  }
  .control__pane-caption {
    bottom: 64px;
    left: 36px;
    right: 36px;
  }

  .control__studio { gap: 14px; padding: 12px; }
  .control__glow { bottom: -80px; height: 300px; }
}

/* Reduced motion: no width morph, no fade delays */
@media (prefers-reduced-motion: reduce) {
  .control__panel,
  .control__pane { transition: none !important; }
}
