/*
 * Styles for the Gray-Scott app, light Ocean theme: made for pages with a
 * light blue (#cfe2ff) background, with accents taken from the Ocean palette.
 * Sunset-accent version: gray-scott.css. Dark original: gray-scott-dark.css.
 * Every class starts with "gs-", so this file can be added to any page
 * without clashing.
 */

/* ---------- Theme ---------- */

.gs-app,
.gs-error {
  --gs-surface: #ffffff;                    /* white panel stands out from the blue page */
  --gs-surface-2: #e8f6fb;                  /* inputs and tracks: icy tint of Ocean's #90e0ef */
  --gs-border: rgba(3, 4, 94, 0.1);
  --gs-border-strong: rgba(3, 4, 94, 0.22); /* swatch rings, so white swatches stay visible */
  --gs-text: #03045e;                       /* Ocean's deepest blue */
  --gs-text-muted: #4a5a85;
  --gs-accent: #0077b6;                     /* Ocean blue -> cyan accent */
  --gs-accent-2: #00b4d8;
  --gs-on-accent: #03045e;                  /* text on the accent gradient */
  --gs-gradient: linear-gradient(135deg, var(--gs-accent), var(--gs-accent-2));
  --gs-shadow: 0 12px 32px -14px rgba(3, 4, 94, 0.28);
  --gs-radius: 16px;
  --gs-gap: 16px;
  color: var(--gs-text);
}

.gs-app *,
.gs-app *::before,
.gs-app *::after {
  box-sizing: border-box;
}

/* ---------- Layout ---------- */

.gs-app {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--gs-gap);
  container-type: inline-size; /* lets the controls react to the app's own width */
}

/* The drawing buffer is always 640x480; CSS scales it down, keeping 4:3. */
.gs-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: var(--gs-radius);
  cursor: crosshair;
  touch-action: none; /* painting with a finger must not scroll the page */
  box-shadow: 0 20px 50px -18px rgba(3, 4, 94, 0.45), 0 0 0 1px var(--gs-border);
}

.gs-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px calc(var(--gs-gap) * 1.5);
  padding: 20px;
  background: var(--gs-surface);
  border: 1px solid var(--gs-border);
  border-radius: var(--gs-radius);
  box-shadow: var(--gs-shadow);
}

@container (max-width: 520px) {
  .gs-controls {
    grid-template-columns: 1fr;
  }
}

/* ---------- Groups ---------- */

.gs-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.gs-group legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gs-text-muted);
}

.gs-group legend::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gs-gradient);
}

/* ---------- Fields: label and readout on one line, control below ---------- */

.gs-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 8px;
  font-size: 0.875rem;
}

.gs-label {
  grid-row: 1;
  grid-column: 1;
  font-weight: 500;
}

.gs-value {
  grid-row: 1;
  grid-column: 2;
  color: var(--gs-text-muted);
  font-variant-numeric: tabular-nums; /* digits keep the same width */
}

.gs-slider,
.gs-select {
  grid-row: 2;
  grid-column: 1 / -1;
}

/* ---------- Sliders ---------- */

.gs-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 8px 0;
  border-radius: 999px;
  background: var(--gs-surface-2);
  cursor: pointer;
}

.gs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--gs-gradient);
  box-shadow: 0 1px 4px rgba(3, 4, 94, 0.35); /* lifts the white ring off the white panel */
  transition: transform 150ms ease;
}

.gs-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--gs-gradient);
  box-shadow: 0 1px 4px rgba(3, 4, 94, 0.35);
  transition: transform 150ms ease;
}

.gs-slider:hover::-webkit-slider-thumb { transform: scale(1.1); }
.gs-slider:hover::-moz-range-thumb { transform: scale(1.1); }

/* ---------- Selects ---------- */

.gs-select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 9px 36px 9px 12px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  color: var(--gs-text);
  cursor: pointer;
  /* Custom chevron */
  background: var(--gs-surface-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234a5a85' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 14px center / 12px 8px;
}

.gs-select option {
  background: var(--gs-surface-2);
  color: var(--gs-text);
}

/* ---------- Buttons ---------- */

.gs-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.gs-button {
  flex: 1;
  padding: 10px 18px;
  border: 1px solid var(--gs-border);
  border-radius: 999px;
  background: var(--gs-surface-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gs-text);
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.gs-button--primary {
  border-color: transparent;
  background: var(--gs-gradient);
  color: var(--gs-on-accent);
}

.gs-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.gs-button:active { transform: translateY(0); filter: brightness(0.95); }

/* ---------- Seed / Erase toggle ---------- */

.gs-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--gs-surface-2);
}

.gs-toggle-option {
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gs-text-muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.gs-toggle-option:hover { color: var(--gs-text); }

.gs-toggle-option.is-active {
  background: var(--gs-gradient);
  color: var(--gs-on-accent);
}

/* ---------- Checkbox (Sharp edges) ---------- */

.gs-field--check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gs-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--gs-accent);
  cursor: pointer;
}

/* ---------- Colour swatches ---------- */

.gs-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gs-swatch {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--gs-border-strong);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transition: transform 150ms ease;
}

.gs-swatch:hover { transform: scale(1.08); }

/* Remove the browser's own padding and border around the colour */
.gs-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.gs-swatch::-webkit-color-swatch { border: 0; border-radius: 50%; }
.gs-swatch::-moz-color-swatch { border: 0; border-radius: 50%; }

/* Text only screen readers see (labels for the swatches) */
.gs-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Keyboard focus ---------- */

.gs-app :focus-visible {
  outline: 2px solid var(--gs-accent);
  outline-offset: 2px;
}

/* ---------- Error message ---------- */

.gs-error {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 24px;
  text-align: center;
  background: var(--gs-surface);
  border: 1px solid var(--gs-border);
  border-radius: var(--gs-radius);
  box-shadow: var(--gs-shadow);
}

/* ---------- Less motion when the user asks for it ---------- */

@media (prefers-reduced-motion: reduce) {
  .gs-app *,
  .gs-app *::before,
  .gs-app *::after {
    transition: none !important;
  }
  .gs-button:hover,
  .gs-swatch:hover {
    transform: none;
  }
}
