/* Farben der Seite. Im Rahmen bleibt alles neutral grau,
   damit die Grautöne der Form gut lesbar sind. */

:root {
  --green: #00a446;
  --cream: #ffeea4;
  --blue: #8ebbda;
  --black: #000;
  --frame: #e6e6e6;
  --gray: #5c5c5c;
}

* {
  box-sizing: border-box;
}

/* Spalte aus Kopfzeile, Inhalt und Fußzeile. Der Inhalt wächst,
   damit die Fußzeile auch bei wenig Inhalt ganz unten steht. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--cream);
  color: var(--black);
  font: 16px/1.4 system-ui, sans-serif;
}

header {
  border-bottom: 3px solid var(--black);
  background: var(--green);
}

h1,
main,
footer p {
  max-width: 1100px;
  margin: 0 auto;
}

h1 {
  padding: 12px 16px;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
}

main {
  flex: 1;
  width: 100%;
  padding: 24px 16px 32px;
}

button {
  position: relative;
  min-height: 44px;
  padding: 0 16px;
  border: 2px solid var(--black);
  border-radius: 6px;
  background: var(--blue);
  color: var(--black);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button[aria-pressed="true"],
button:active:enabled {
  background: var(--green);
}

/* Hover: Button rutscht nach oben links, der schwarze Schatten bleibt an der
   alten Stelle sichtbar. Gilt nicht für die gewählte Form und inaktive Buttons.
   Nur mit Maus, sonst bleibt der Button auf dem Handy nach dem Tippen oben. */
@media (hover: hover) {
  button:enabled:not([aria-pressed="true"]):hover {
    box-shadow: 4px 4px 0 var(--black);
    transform: translate(-4px, -4px);
  }

  /* Unsichtbare Fläche über dem Schatten (4px + 2px Rand). Ohne sie würde der
     Button am unteren und rechten Rand unter der Maus wegrutschen und zittern. */
  button:enabled:not([aria-pressed="true"]):hover::after {
    content: "";
    position: absolute;
    inset: 0 -6px -6px 0;
  }
}

/* Weiche Bewegung, außer weniger Animationen sind im System eingestellt */
@media (prefers-reduced-motion: no-preference) {
  button {
    transition: transform 0.15s, box-shadow 0.15s;
  }
}

:focus-visible {
  outline: 3px solid var(--black);
  outline-offset: 2px;
}

.shapes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

/* --frame-scale: Größe des Rahmens, 1 = voller Platz (ändert script.js per + und −).
   312px = Breite der Regler (280px) + Abstand (32px).
   Ab 960px kommt rechts das Feedback-Schild dazu: 280 + 128 + 2 × 32 = 472px. */
.workspace {
  --frame-scale: 0.8;
  display: grid;
  grid-template-columns: calc((100% - 312px) * var(--frame-scale)) 280px;
  gap: 32px;
  align-items: start;
}

.frame {
  position: relative;
  aspect-ratio: 5 / 4;
  overflow: hidden;
  border: 3px solid var(--black);
  background: var(--frame);
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: move;
  touch-action: none; /* Wischen im Rahmen dreht die Ansicht, statt die Seite zu scrollen */
}

#view:focus-visible {
  outline-offset: -3px;
}

/* Unter dem Rahmen: Feedback links, − und + rechts */
.frame-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

#message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  text-align: center;
}

#message[hidden] {
  display: none;
}

#controls {
  display: grid;
  gap: 20px;
}

fieldset {
  display: grid;
  gap: 20px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 12px;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.control output {
  font-variant-numeric: tabular-nums;
}

.control input {
  grid-column: 1 / -1;
  width: 100%;
  height: 32px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.control input:disabled {
  cursor: default;
}

/* Regler: grüne Linie mit blauem Griff. Chrome/Safari (-webkit-) und
   Firefox (-moz-) brauchen dafür jeweils eigene Regeln. */
.control input::-webkit-slider-runnable-track {
  box-sizing: border-box;
  height: 10px;
  border: 2px solid var(--black);
  border-radius: 5px;
  background: var(--green);
}

.control input::-moz-range-track {
  box-sizing: border-box;
  height: 10px;
  border: 2px solid var(--black);
  border-radius: 5px;
  background: var(--green);
}

.control input::-webkit-slider-thumb {
  appearance: none;
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  margin-top: -9px; /* Griff mittig auf die Linie setzen */
  border: 3px solid var(--black);
  border-radius: 50%;
  background: var(--blue);
}

.control input::-moz-range-thumb {
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  border: 3px solid var(--black);
  border-radius: 50%;
  background: var(--blue);
}

.control:has(input:disabled) {
  opacity: 0.4;
}

@media (min-width: 960px) {
  .workspace {
    grid-template-columns: calc((100% - 472px) * var(--frame-scale)) 280px minmax(128px, 1fr);
  }

  /* Schild auf Höhe von "Light" und mittig zwischen Reglern und Fensterrand.
     Die negativen Ränder beziehen die Spaltenlücke links (32px) und den Platz bis
     zum Fensterrand rechts mit ein. --gutter = Abstand vom Inhalt zum Fensterrand.
     194px = Abstand von oben bis zur Überschrift "Light". */
  .workspace .feedback-sign {
    --gutter: calc(max(0px, (100vw - 1100px) / 2) + 16px);
    justify-self: center;
    margin-top: 194px;
    margin-right: calc(-1 * var(--gutter));
    margin-left: -32px;
  }
}

/* Mittlere Breite: Schild unter den Reglern */
@media (min-width: 721px) and (max-width: 959px) {
  .feedback-sign {
    grid-column: 2;
  }
}

.frame-size {
  display: flex;
  gap: 8px;
}

dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 3px solid var(--black);
  border-radius: 6px;
  background: var(--cream);
  box-shadow: 6px 6px 0 var(--black);
  color: var(--black);
}

dialog::backdrop {
  background: rgb(0 0 0 / 50%);
}

#feedback-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  font-weight: 600;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 2px solid var(--black);
  border-radius: 6px;
  background: #fff;
  color: var(--black);
  font: inherit;
}

.field textarea {
  resize: vertical;
}

#feedback-status {
  margin: 0;
}

/* Spam-Falle: unsichtbar, ein Bot kreuzt sie trotzdem an */
.botcheck {
  display: none;
}

#feedback-status:empty {
  display: none;
}

/* Schalter für den Pencil look: Kreis wandert nach rechts, Hintergrund wird grün.
   Er steht links unter dem Rahmen, − und + rechts. */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  cursor: pointer;
}

.switch input {
  position: relative;
  flex: none;
  width: 52px;
  height: 30px;
  margin: 0;
  border: 2px solid var(--black);
  border-radius: 15px;
  background: var(--cream);
  appearance: none;
  cursor: pointer;
}

.switch input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  border: 2px solid var(--black);
  border-radius: 50%;
  background: var(--blue);
}

.switch input:checked {
  background: var(--green);
}

.switch input:checked::before {
  left: 24px;
}

@media (prefers-reduced-motion: no-preference) {
  .switch input::before {
    transition: left 0.15s;
  }
}

/* Feedback-Schild: Der Button selbst ist unsichtbar, man sieht nur Schild und Hände */
.feedback-sign {
  align-self: start;
  justify-self: start;
  width: 128px;
  min-height: 0;
  padding: 0 0 46px; /* Platz für die Hände unter dem Schild */
  border: 0;
  background: none;
}

.sign-board {
  display: block;
  padding: 16px 8px;
  border: 3px solid var(--black);
  border-radius: 6px;
  background: var(--blue);
  box-shadow: 4px 4px 0 var(--black);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.sign-hand {
  position: absolute;
  bottom: 0;
  width: 44px;
  height: 60px;
  stroke: var(--black);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sign-hand-left {
  left: 8px;
}

/* Rechte Hand: gespiegelte linke Hand */
.sign-hand-right {
  right: 8px;
  transform: scaleX(-1);
}

.sign-hand .glove {
  fill: #fff;
}

.sign-hand .cuff {
  fill: var(--green);
}

.sign-hand .seams {
  fill: none;
}

/* Beim Hover wird das Schild ein Stück hochgehoben und leicht geschwenkt */
@media (hover: hover) {
  button.feedback-sign:enabled:hover {
    box-shadow: none;
    transform: translateY(-6px) rotate(-3deg);
  }
}

button.feedback-sign:active:enabled {
  background: none;
}

.feedback-sign:active .sign-board {
  background: var(--green);
}

footer p {
  margin: 0 auto;
  padding: 0 16px 24px;
  color: var(--gray);
  font-size: 14px;
  text-align: center;
}

/* Name im Footer: gleiche graue Farbe, unterstrichen, damit man den Link erkennt */
footer a {
  color: inherit;
  text-underline-offset: 2px;
}

footer a:hover {
  color: var(--black);
}

/* Handy: Formen → Rahmen → Regler untereinander */
@media (max-width: 720px) {
  .shapes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .shapes button {
    padding: 0 8px;
  }

  .feedback-sign {
    justify-self: center;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .frame-area {
    width: calc(100% * var(--frame-scale));
    margin: 0 auto;
  }

  .frame {
    aspect-ratio: 1;
  }
}
