/* CSS Gradient Generator: styles for this tool only. Shared styles live in /tools/shared/tools.css. */

html,
body {
  overflow-x: clip;
}
body {
  font-variant-numeric: tabular-nums;
}
/* The page shell (workspace, stage, right panel) comes from /tools/shared/css/pdf.css */
.gg-scroll {
  flex: 1;
  padding: var(--space-4);
}
.gg-main {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding-bottom: var(--space-8);
  display: grid;
  gap: var(--space-4);
}

/* Right panel: the preset list scrolls, the CSS code is pinned in the footer */
.panel-body.gg-presets-body {
  padding: 0 var(--space-6);
  gap: 0;
}
.gg-preset-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.gg-preset-list li[hidden] {
  display: none;
}
.gg-preset {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: calc(100% + 2 * var(--space-2));
  margin: 0 calc(-1 * var(--space-2));
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: color var(--duration, 0.2s);
}
.gg-preset:hover {
  background: var(--color-field);
  color: var(--color-ink);
}
.gg-preset:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 0;
}
/* Color filter under the Presets title */
.panel-head .dropdown {
  display: block;
  margin-top: var(--space-4); /* the dropdown replaces its slot, so the space is set on the dropdown itself */
}
.gg-preset-swatch {
  flex: none;
  width: 4.5rem;
  height: 1.5rem;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-md);
}
.panel-foot.gg-code {
  gap: var(--space-4);
  border-top: 0.5px solid var(--color-border);
}
.gg-code .field-label {
  padding: 0;
  font-weight: var(--weight-regular);
}
.gg-code .gg-line {
  display: grid;
  gap: var(--space-1);
}
.gg-line-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}
.gg-code .gg-copy {
  width: auto;
  min-width: 0;
}

.gg-preview {
  height: 16rem;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-2xl);
}

.gg-card {
  min-width: 0;
  padding: var(--space-6);
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-2xl);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}
.gg-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: var(--space-3) var(--space-6);
  min-width: 0;
}
/* Match the height of the segmented control beside it, so the slider is centred on the same line */
.gg-controls .slider {
  min-height: 2.5rem;
}
.gg-controls [hidden] {
  display: none;
}
.gg-controls .dropdown {
  display: block;
}

/* Color stops */
.gg-stops {
  min-width: 0;
}
.gg-stops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.gg-stops-title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-regular);
  color: var(--color-ink);
}
.gg-stops-actions {
  display: flex;
  gap: var(--space-2);
}
.gg-stops-actions .icon,
.gg-stop-btns .icon {
  width: 16px;
  height: 16px;
}
.gg-stop-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-xl);
}
.gg-stop-list > li + li {
  border-top: 0.5px solid var(--color-border);
}
.gg-stop {
  display: grid;
  /* The slider starts where the right-hand column of the settings above starts (so it lines up with the Angle slider)
     and ends before the remove button: half the row, minus the row padding and the gap, minus the button column */
  grid-template-columns: auto 9.5rem 5.5rem minmax(0, 1fr) minmax(0, calc(50% - 2 * var(--space-3) - 2.5rem)) 2.5rem;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
}
/* The slider sits on the right, just before the remove button */
.gg-stop .slider {
  grid-column: 5;
}
.gg-stop-btns {
  justify-content: center;
}
.gg-stop-grip {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 2.5rem;
  color: var(--color-muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.gg-stop-grip:hover {
  color: var(--color-ink);
}
.gg-stop-grip .icon {
  width: 16px;
  height: 16px;
}
.gg-stop.drag-ghost {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
}
.gg-stop-btns {
  display: flex;
  gap: 2px;
}

.gg-line .field input {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.gg-copy {
  flex: none;
  width: 7.5rem;
  justify-content: center;
}
.gg-copy .icon {
  width: 16px;
  height: 16px;
}

.gg-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-align: left;
  cursor: default;
  pointer-events: none;
}
.gg-toggle .icon {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--duration, 0.2s);
}

@media (max-width: 860px) {
  .gg-toggle {
    cursor: pointer;
    pointer-events: auto;
  }
  .gg-toggle .icon {
    display: block;
  }
  .gg-toggle[aria-expanded="true"] .icon {
    transform: rotate(180deg);
  }
  .gg-toggle:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }
  /* Collapsed: only the title row shows above the code */
  .panel.gg-collapsed .panel-head .dropdown,
  .panel.gg-collapsed .gg-presets-body {
    display: none;
  }
  .panel.gg-collapsed .panel-head {
    padding-bottom: 0.75rem;
  }
  /* Expanded: a shorter list */
  .panel-body.gg-presets-body {
    max-height: 22vh;
    padding: 0 var(--space-4);
  }
  /* Each code line takes the full width of the footer */
  .gg-code .gg-line {
    flex: 1 1 100%;
  }
  .panel-foot.gg-code {
    gap: var(--space-3);
  }
}

@media (max-width: 760px) {
  .gg-card {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    padding: var(--space-4);
  }
  .gg-preview {
    height: 11rem;
  }
  .gg-controls {
    grid-template-columns: minmax(0, 1fr);
  }
  .gg-stop {
    grid-template-columns: auto minmax(0, 1fr) 5.5rem auto;
  }
  .gg-stop .slider {
    grid-column: 2 / -1;
    grid-row: 2;
    margin-top: var(--space-3);
  }
}

