/* controls.css — buttons, inputs, option toggles, drawers, motion pads,
   color grid, language flags. Shared controls used across the studio. */

#inputText,
#inputTextCooldown,
.font-toolbar input,
.font-output {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--body-font);
  font-size: 16px;
  font-weight: 700;
  min-height: 48px;
  outline: none;
  padding: 10px 12px;
  width: 100%;
}

#inputText:focus,
.font-toolbar input:focus,
.font-output:focus {
  border-color: rgba(109, 76, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(109, 76, 255, 0.12);
}

.cooldown-input {
  display: none;
}

.darkbuttonboxes,
.lightbuttonboxes,
.btn-custom {
  align-items: center;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(37, 45, 82, 0.06);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--body-font);
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  padding: 8px 12px;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.lightbuttonboxes {
  background: #fff7c5;
}

#customskindiv,
.font-toolbar button,
.font-toolbar a {
  white-space: nowrap;
}

.darkbuttonboxes:hover,
.lightbuttonboxes:hover,
.btn-custom:hover {
  border-color: rgba(109, 76, 255, 0.3);
  box-shadow: 0 12px 30px rgba(87, 70, 180, 0.12);
  transform: translateY(-2px);
}

.darkbuttonboxes:active,
.lightbuttonboxes:active,
.btn-custom:active {
  transform: translateY(1px);
}

.theme-toggle input,
.option-toggle input,
.btn-custom input[type="checkbox"] {
  accent-color: var(--grass-dark);
  height: 18px;
  width: 18px;
}

.theme-toggle {
  align-items: center;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(37, 45, 82, 0.06);
  display: inline-flex;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
}

.theme-toggle label {
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

/* Icon-only triggers in the top action bar (theme + language).
   The checkbox stays in the DOM for state + a11y, but is visually hidden;
   the label renders the SVG and swaps sun/moon via :checked. */
.icon-toggle {
  padding: 0;
  width: 42px;
}

.icon-toggle input {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  opacity: 0;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.icon-toggle .icon-label {
  align-items: center;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  width: 100%;
}

.icon-summary {
  align-items: center;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  padding: 0 12px;
}

.icon {
  display: block;
  height: 20px;
  width: 20px;
}

.icon-toggle .icon-moon { display: none; }
.icon-toggle input:checked + .icon-label .icon-sun { display: none; }
.icon-toggle input:checked + .icon-label .icon-moon { display: block; }

.icon-toggle input:focus-visible + .icon-label {
  border-radius: 10px;
  outline: 3px solid rgba(109, 76, 255, 0.45);
  outline-offset: 2px;
}

.arrow-button,
.button-left,
.button-right {
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(52, 60, 105, 0.12);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  filter: none;
  font-family: var(--body-font);
  font-size: 26px;
  font-weight: 700;
  height: 46px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transform: none;
  transition: transform 0.16s ease, background 0.16s ease;
  width: 46px;
  z-index: 3;
}

.arrow-button:hover,
.button-small:hover {
  transform: translateY(-2px);
}

.arrow-button:active,
.button-small:active {
  transform: translateY(1px);
}

.arrow-button span {
  margin-top: -3px;
}

.button-small {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(37, 45, 82, 0.08);
  color: var(--ink);
  cursor: pointer;
  filter: none;
  font-family: var(--body-font);
  font-weight: 700;
  height: 40px;
  padding: 0;
  transform: none;
  transition: transform 0.16s ease, background 0.16s ease;
  width: 40px;
}

.value-pill {
  cursor: default;
  min-width: 54px;
}

#downloadall {
  display: none;
}

.download-button {
  align-items: center;
  background: linear-gradient(135deg, var(--violet), var(--violet-2));
  border: 0;
  border-radius: 10px;
  box-shadow: 0 18px 34px rgba(109, 76, 255, 0.28);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 52px;
  /* No explicit width: the track decides (max-content on desktop, stretch in
     the mobile 1fr column). width: 100% would fight the max-content track. */
}

.download-button label {
  cursor: pointer;
  font-family: var(--body-font);
  font-weight: 700;
}

/* Unify the three buttons in the download row — the primary .download-button
   and the two .secondary-download actions — to one height, padding, and
   font-size. The <button> UA default otherwise leaves the secondary buttons
   shorter (~38px) and at a smaller font (~13px) than the primary (52px /
   16px). The .download-row scoping outranks the scattered single-class
   rules and the coarse-pointer media query, so it holds on every breakpoint. */
.download-row .download-button,
.download-row .secondary-download {
  font-size: inherit;
  min-height: 48px;
  padding: 8px 14px;
}

.fieldset.group,
.options-card {
  border-color: var(--line);
}

.nested-panel > legend {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--ink);
  display: flex;
  font-family: var(--body-font);
  font-size: 16px;
  font-weight: 700;
  gap: 12px;
  max-width: 100%;
  min-width: 0;
  padding: 0 12px 12px;
}

.nested-panel > legend > span {
  min-width: 0;
}

#options-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.option-toggle {
  align-items: center;
  background: rgba(247, 248, 255, 0.72);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  min-height: 48px;
  padding: 10px 12px;
  width: 100%;
}

.option-toggle label {
  cursor: pointer;
  flex: 1;
}

.motion-pad,
.option-detail {
  align-items: center;
  background: rgba(109, 76, 255, 0.06);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  padding: 12px;
  text-align: center;
}

.motion-pad span,
.option-detail span {
  font-family: var(--body-font);
  font-weight: 700;
}

.motion-pad-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.hidden-box,
#custom-gradient-box,
#ornaments-box,
#background-box,
#frame-box {
  height: 0;
  overflow: hidden;
  transition: height 0.25s ease;
}

.hidden-box:not(.expanded) {
  border-width: 0 !important;
  gap: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.expanded {
  height: auto !important;
  overflow: visible !important;
}

.option-drawer.expanded,
.hidden-box.expanded {
  margin: 2px 0 8px;
}

.nested-panel,
.movement-editor {
  background: rgba(247, 248, 255, 0.72);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
}

.movement-editor {
  display: grid;
}

.fit-button {
  max-width: 220px;
}

.colors-grid {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.colors-grid input[type="color"] {
  border: 2px solid var(--line);
  border-radius: 6px;
  height: 42px;
  width: 58px;
}

.stepper-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.language-row {
  flex-wrap: wrap;
}

#langAutoBtn {
  background: rgba(109, 76, 255, 0.1);
  color: var(--violet);
  min-height: 38px;
}

.lang-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 0;
}

.lang-flag {
  border: 2px solid transparent;
  border-radius: 4px;
  box-shadow: 2px 2px 0 rgba(23, 27, 37, 0.22);
  cursor: pointer;
  height: 26px;
  object-fit: cover;
  transition: transform 0.16s ease, border-color 0.16s ease;
  width: 36px !important;
}

.lang-flag.active {
  border-color: var(--grass);
  transform: translateY(-2px);
}

/* Range slider for pixelate size (replaces the arrow stepper). */
.size-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  min-width: 80px;
  height: 6px;
  border-radius: 999px;
  background: var(--line-soft);
  outline: none;
  cursor: pointer;
}
.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--grass);
  border: 2px solid var(--obsidian);
  box-shadow: 2px 2px 0 rgba(23, 27, 37, 0.3);
}
.size-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--grass);
  border: 2px solid var(--obsidian);
}
.size-slider:focus-visible {
  outline: 2px solid var(--grass);
  outline-offset: 4px;
}

/* Pixelate box lays out as slider + value readout on one row. */
#pixelate-background-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
#pixelate-background-size {
  min-width: 2.5em;
  text-align: center;
}

body[data-theme="dark"] .option-toggle,
body[data-theme="dark"] .render-frame-card,
body[data-theme="dark"] .render-ornament-card,
body[data-theme="dark"] .render-background-card,
body[data-theme="dark"] .section-tab,
body[data-theme="dark"] .summary-grid span {
  background: rgba(255, 255, 255, 0.04);
}

body[data-theme="dark"] .arrow-button,
body[data-theme="dark"] .button-small {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}
