/*!
 * 123PhotoTool — CSS Gradient Generator (gradient.php, assets/js/gradient.js).
 *
 * Panel: type, angle and the eight directions, shape, the colour stops (a
 * row each), presets, the CSS, and the image to save. Stage: the gradient in
 * the shape of the image size, the stops on a bar under it, and a photo to
 * take colours from.
 */

.gr-field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.gr-add { display: inline-flex; align-items: center; gap: 6px; }
.gr-add svg { width: 14px; height: 14px; flex: none; }

/* ── Angle: the slider, then the eight directions ──────────────────────── */
.gr-angle-range { --track: linear-gradient(90deg, var(--pt-line, #e3e7ee), var(--pt-line, #e3e7ee)); }
.gr-dirs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.gr-dir {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  color: var(--pt-muted, #6c757d);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gr-dir svg { width: 18px; height: 18px; transform: rotate(var(--a, 0deg)); }
.gr-dir:hover { color: var(--pt-ink, #343f52); border-color: var(--pt-accent, #0f70e6); }
.gr-dir.active { background: var(--pt-accent, #0f70e6); border-color: var(--pt-accent, #0f70e6); color: #fff; }
.gr-dir:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }

/* ── The colour stops ─────────────────────────────────────────────────── */
.gr-stops { display: grid; gap: 6px; }
.gr-stop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 12px;
  background: #fff;
}
.gr-stop.active { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 0 0 3px var(--pt-accent-soft, rgba(15, 112, 230, 0.15)); }
.gr-stop .pt-cswatch { flex: 0 0 38px; min-height: 0; height: 38px; border-radius: 9px; }
.gr-code {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  font: 600 0.72rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  direction: ltr;
}
[dir="rtl"] .gr-code { text-align: right; }
.gr-at { flex: none; display: inline-flex; align-items: center; gap: 3px; color: var(--pt-muted, #6c757d); font-size: 0.72rem; }
.gr-at input { width: 3.6em; height: 38px; padding: 0 6px; text-align: end; font-size: 0.72rem; -moz-appearance: textfield; }
.gr-at input::-webkit-inner-spin-button, .gr-at input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.gr-del {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #b02a37;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gr-del svg { width: 16px; height: 16px; }
.gr-del:hover:not(:disabled) { background: #fde8ea; }
.gr-del:disabled { opacity: 0.3; cursor: default; }
.gr-del:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }
.gr-hint { display: block; margin-top: 6px; color: var(--pt-muted, #6c757d); font-size: 0.65rem; line-height: 1.35; }
.gr-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
/* Neutral, but not the theme's pale outline that reads as disabled. */
.gr-actions .btn { border: 1px solid var(--pt-line, #e3e7ee); background: #fff; color: var(--pt-ink, #343f52); font-weight: 600; }
.gr-actions .btn:hover { border-color: var(--pt-accent, #0f70e6); color: var(--pt-accent, #0f70e6); background: #fff; }

/* ── Presets ──────────────────────────────────────────────────────────── */
/* Twelve: one row where the panel is wide, two rows of six otherwise. */
/* From a photo: the number of colours beside their mood; stacked when the
   panel is narrow (the phone's settings sheet at 320px). */
#gr-photo-field { container-type: inline-size; }
.gr-photo-opts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 20px; align-items: end; }
@container (max-width: 300px) { .gr-photo-opts { grid-template-columns: minmax(0, 1fr); } }
#gr-presets-field { container-type: inline-size; }
.gr-presets { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
@container (min-width: 470px) { .gr-presets { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
.gr-preset {
  aspect-ratio: 1;
  min-height: 40px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--pt-line, #e3e7ee);
}
.gr-preset:hover { box-shadow: 0 0 0 2px var(--pt-accent, #0f70e6); }
.gr-preset:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }

/* ── The CSS ──────────────────────────────────────────────────────────── */
.gr-css {
  margin: 0;
  max-height: 9.5em;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: var(--pt-surface, #f6f8fb);
  color: var(--pt-ink, #343f52);
  font: 0.68rem/1.55 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  direction: ltr;
  text-align: left;
}
.gr-css:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }

/* ── The image to save ────────────────────────────────────────────────── */
.gr-out { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }

/* ── The workspace: the gradient (or the photo), then the bar ─────────── */
#gr-viewport { display: flex; flex-direction: column; overflow: hidden; }
.gr-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 14px 14px 0; }
.gr-frame {
  position: relative;
  flex: none;
  width: 320px;
  height: 180px;
  border-radius: 12px;
  box-shadow: 0 2px 14px rgba(30, 34, 40, 0.14);
}
.gr-preview { position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.gr-center {
  position: absolute;
  z-index: 2;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: rgba(17, 19, 23, 0.2);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: grab;
  touch-action: none;
}
.gr-center[hidden] { display: none; }
.gr-center::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; }
.gr-center:active { cursor: grabbing; }
.gr-center:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 3px; }

.gr-main.gr-photo-view > .gr-frame { display: none; }
.gr-main:not(.gr-photo-view) > .pt-pick-box, .gr-main:not(.gr-photo-view) > .pt-pick-loupe { display: none !important; }
.gr-main.gr-photo-view { padding: 0; }
.gr-has-photo .gr-main:not(.gr-photo-view) { padding-top: 54px; }
.gr-views {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 6;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.72);
}
.gr-views[hidden] { display: none; }
.gr-views button { border: 0; border-radius: 999px; min-height: 32px; padding: 0 12px; background: transparent; color: #fff; font-size: 0.75rem; font-weight: 600; }
.gr-views button[aria-pressed="true"] { background: #fff; color: var(--pt-ink, #343f52); }

/* The bar: the stops along it, left to right in every language. */
.gr-bar-wrap { flex: none; padding: 14px 26px 8px; }
.gr-bar { position: relative; height: 40px; cursor: copy; touch-action: none; -webkit-user-select: none; user-select: none; }
.gr-track { position: absolute; left: 0; right: 0; top: 10px; height: 20px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.gr-handles { position: absolute; inset: 0; }
.gr-handle {
  position: absolute;
  top: 0;
  width: 30px;
  height: 40px;
  margin-left: -15px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
.gr-handle::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 22px;
  height: 32px;
  border-radius: 8px;
  border: 3px solid #fff;
  background: var(--c, #000);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s;
}
/* A finger-sized target round the small handle. */
.gr-handle::after { content: ""; position: absolute; inset: -4px -6px; }
.gr-handle.active { z-index: 1; }
.gr-handle.active::before { box-shadow: 0 0 0 2px var(--pt-ink, #343f52), 0 3px 8px rgba(0, 0, 0, 0.35); transform: scale(1.1); }
.gr-handle:active { cursor: grabbing; }
.gr-handle:focus-visible { outline: none; }
.gr-handle:focus-visible::before { box-shadow: 0 0 0 3px var(--pt-accent, #0f70e6), 0 3px 8px rgba(0, 0, 0, 0.35); }
.gr-bar-native { position: absolute; bottom: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }

.gr-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 6px 12px 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(30, 34, 40, 0.06);
}
.gr-has-photo .gr-foot { display: none; }
.gr-has-photo .gr-bar-wrap { padding-bottom: 14px; }
.gr-foot .sample-thumbnails { display: flex; justify-content: center; gap: 8px; }
.gr-foot .sample-thumbnail { width: 52px; height: 52px; padding: 0; border: 2px solid #dee2e6; border-radius: 10px; overflow: hidden; background: #fff; cursor: pointer; }
.gr-foot .sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); }
.gr-foot .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }

/* ── Phones ───────────────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  #gr-viewport:not(.gr-has-photo):not(.pt-app-viewport) { height: auto !important; min-height: 0 !important; }
  #gr-viewport:not(.gr-has-photo):not(.pt-app-viewport) .gr-main { flex: none; }
  .gr-main { padding: 12px 12px 0; }
  .gr-bar-wrap { padding: 12px 22px 6px; }
  .gr-foot { margin: 6px 10px 10px; }
  /* 16px: iOS zooms into a smaller box on focus. */
  .gr-code, .gr-at input, #gr-angle-n, #gr-count-n, #gr-mood { font-size: 16px; }
  .gr-dirs { gap: 3px; }
}
/* On the phone page a photo is not a work surface (a tap opens the editor). */
html.pt-phone:not(.pt-app-open) #gr-views, html.pt-phone:not(.pt-app-open) #gr-remove-photo { display: none !important; }

/* ── In the phone editor ──────────────────────────────────────────────── */
#pt-app #gr-views, #pt-app .gr-foot { display: none !important; }
#pt-app .gr-main:not(.gr-photo-view) { padding: 10px 8px 0; }
#pt-app .gr-has-photo .gr-main:not(.gr-photo-view) { padding-top: 10px; }
#pt-app .gr-bar-wrap { padding: 10px 22px 12px; }
#pt-app .gr-track { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
