/* ==========================================================================
   Little Stars Corner — immersive card → section expand
   ========================================================================== */

.tools {
  overflow: hidden;
  overflow-anchor: none;
}

.tools.is-tools-open:not(.is-tools-opening):not(.is-tools-closing) {
  overflow: visible;
}

.tools .tool-card {
  padding: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Kill hover lift while a tool is open so cards don't jump under the panel */
.tools.is-tools-open .tool-card:hover,
.tools.is-tools-opening .tool-card:hover,
.tools.is-tools-closing .tool-card:hover {
  transform: none;
  box-shadow: none;
}

.tools .tool-card-hit {
  position: relative;
  min-height: 240px;
}

.tools-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 32px;
  width: 100%;
  opacity: 1;
  filter: none;
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1), filter 0.55s ease;
}

/*
 * Stage leaves the flow while open. Keep it in the content box (not the
 * padding edge) so cards never shift vs idle — inherit shell padding and
 * size to content (no bottom:0 stretch / vertical centering in a tall shell).
 */
.tools.is-tools-open .tools-stage,
.tools.is-tools-opening .tools-stage,
.tools.is-tools-measuring .tools-stage {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: auto;
  height: fit-content;
  max-height: none;
  margin: 0;
  padding: inherit;
  box-sizing: border-box;
  z-index: 1;
  overflow-anchor: none;
}

.tool-card-hit {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 20px 20px 80px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  border-radius: inherit;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.tool-card-hit:focus-visible {
  outline: 2px solid var(--plum-700);
  outline-offset: 3px;
}

.tool-card-hit.is-pressed {
  transform: scale(0.985);
}

.tool-card .tool-card-title {
  display: block;
}

.tool-card .tool-card-arrow {
  pointer-events: none;
}

.tools.is-tools-open:not(.is-tools-closing) .tools-stage,
.tools.is-tools-opening .tools-stage {
  opacity: 0;
  filter: blur(1px);
  pointer-events: none;
}

.tools.is-tools-open:not(.is-tools-closing) .tool-card.is-sibling-fade,
.tools.is-tools-opening .tool-card.is-sibling-fade {
  opacity: 0;
}

.tools.is-tools-open:not(.is-tools-closing) .tool-card.is-active-card,
.tools.is-tools-opening .tool-card.is-active-card {
  opacity: 0;
}

/* Closing: bring cards/intro back in the idle layout under the shrinking panel */
.tools.is-tools-closing .tools-stage {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  width: 100% !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  opacity: 1;
  filter: none;
  pointer-events: none;
}

.tools.is-tools-closing .tool-card {
  opacity: 1;
  transform: none;
}

.tools.is-tools-closing .tools-expand-panel {
  overflow: hidden;
}

.tools-expand {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  border-radius: inherit;
  overflow: hidden;
}

/* During close, JS pins expand to a measured box; keep it above the restored cards */
.tools.is-tools-closing .tools-expand {
  position: absolute;
  inset: auto;
  overflow: hidden;
  pointer-events: none;
}

/* Pre-measure final tool height before FLIP (invisible, in-flow) */
.tools.is-tools-measuring .tools-stage {
  opacity: 0;
  pointer-events: none;
}

.tools.is-tools-measuring .tools-expand {
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  overflow: visible;
  visibility: hidden;
}

.tools.is-tools-measuring .tools-expand-panel {
  flex: none;
  min-height: auto;
  height: auto;
  overflow: visible;
}

/* Grow with tool content — drives .tools height (page scrolls, panel does not) */
.tools.is-tools-open:not(.is-tools-opening):not(.is-tools-closing):not(.is-tools-measuring) .tools-expand {
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  overflow: visible;
}

.tools-expand[hidden] {
  display: none !important;
}

.tools-expand-panel {
  --tools-expand-accent: var(--pink-tint);
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--tools-expand-accent) 72%, white) 0%, var(--white) 48%, var(--peach-bg) 100%);
  box-shadow: 0 18px 40px rgba(34, 6, 28, 0.1);
}

.tools-expand-panel.is-flipping {
  will-change: transform;
  backface-visibility: hidden;
}

.tools.is-tools-open:not(.is-tools-opening):not(.is-tools-closing):not(.is-tools-measuring) .tools-expand-panel {
  flex: none;
  min-height: auto;
  height: auto;
  overflow: visible;
}

.tools-expand-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 10px;
  opacity: 0;
  transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.tools-expand-panel.is-content-ready .tools-expand-header {
  opacity: 1;
}

/* While closing, drop header/body instantly (JS also toggles classes) */
.tools.is-tools-closing .tools-expand-header,
.tools.is-tools-closing .tools-expand-body {
  transition: none;
  opacity: 0;
}

.tools-expand-heading {
  min-width: 0;
}

.tools-expand-source {
  margin: 0 0 4px;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--grey-500);
}

.tools-expand-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  letter-spacing: normal;
}

.tools-expand-close {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 999px;
  background: var(--navy-dark);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px rgba(8, 33, 71, 0.22);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.tools-expand-close:hover,
.tools-expand-close:focus-visible {
  transform: scale(1.05);
  background: var(--plum-700);
  outline: none;
}

.tools-expand-close:focus-visible {
  box-shadow: 0 0 0 3px rgba(165, 60, 145, 0.35), 0 10px 22px rgba(8, 33, 71, 0.22);
}

.tools-expand-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  padding: 8px 14px 18px;
  opacity: 0;
  transition: opacity 0.36s cubic-bezier(0.22, 1, 0.36, 1) 0.04s;
}

.tools.is-tools-open:not(.is-tools-opening):not(.is-tools-closing):not(.is-tools-measuring) .tools-expand-body {
  flex: none;
  min-height: auto;
  overflow: visible;
}

.tools-expand-body.is-revealed {
  opacity: 1;
}

/* While FLIP is running, height/inset come from JS (match final padded box) */
.tools.is-tools-opening .tools-expand {
  inset: auto;
  overflow: hidden;
}

@media (min-width: 768px) {
  .tools .tool-card-hit {
    padding: 34px 34px 90px;
    min-height: 240px;
  }

  .tools.is-tools-open,
  .tools.is-tools-opening {
    min-height: 560px;
  }

  .tools-expand-header {
    padding: 22px 24px 12px;
  }

  .tools-expand-body {
    padding: 10px 24px 24px;
  }

  .tools-expand-close {
    width: 46px;
    height: 46px;
  }
}

/* Restore desktop intro | grid row now that both live inside .tools-stage */
@media (min-width: 1200px) {
  .tools-stage {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 36px;
  }
}

@media (max-width: 767.98px) {
  .tools.is-tools-open,
  .tools.is-tools-opening {
    min-height: 70vh;
  }

  .tool-card-hit {
    padding: 20px 20px 80px;
  }

  .tools-expand-close {
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tools-stage,
  .tools-expand-header,
  .tools-expand-body,
  .tool-card,
  .tools-expand-close {
    transition: none !important;
    animation: none !important;
  }

}
