/*
 * emojirate – Gästeseite
 *
 * Aufbau: oben eine Fläche in der Markenfarbe des Standorts (wer fragt, was wird gefragt),
 * darüber geschoben ein weißes Sheet mit den Gesichtern. Auf großen Bildschirmen und
 * Kiosk-Tablets stehen beide nebeneinander.
 * Farbe kommt aus drei Quellen: Markenfarbe (--brand), Emoji-Gelb (--sun) und der Stimmung
 * der Bewertung (--mood-*), die die Reaktionen nach dem Tippen einfärbt.
 */

@font-face {
  font-family: "Instrument Sans";
  src: url("/assets/fonts/instrument-sans-latin-wght.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --brand: #FFC83D;
  --on-brand: #1C1F26;

  --paper: #FFFFFF;
  --ink: #1C1F26;
  --muted: #5B6170;
  --line: #E2E4EA;
  --field: #F5F6F8;
  --danger: #C2261A;

  --sun: #FFC83D;
  --sun-soft: #FFF5D6;
  --mood-low: #FFE7E0;
  --mood-mid: #FFF3D1;
  --mood-high: #DFF6E8;
  --mood-low-ink: #B3361C;
  --mood-mid-ink: #8A5A00;
  --mood-high-ink: #157347;

  --brand-ink: color-mix(in oklab, var(--brand) 60%, #000);
  --focus: var(--ink);
  --r-sheet: 28px;
  --r-field: 14px;
  --gutter: max(1.25rem, env(safe-area-inset-left), env(safe-area-inset-right));

  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* Seitenhintergrund weiß: Was Safari unten unter der Adressleiste zeigt, ist so immer das Sheet.
   Die Markenfarbe sitzt nur auf .page (hinter den Sheet-Ecken) und oben auf .hero. */
html { background: var(--paper); }

body {
  margin: 0;
  font: 400 1.0625rem/1.5 "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p { margin: 0; }
a { color: var(--brand-ink); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
button, input, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.face-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Text in drei Stimmungs-Varianten: Standard „mid“, sonst passend zur Bewertung */
[data-mood-text] { display: none; }
[data-mood-text="mid"] { display: inline; }
[data-mood="low"] [data-mood-text="mid"], [data-mood="high"] [data-mood-text="mid"] { display: none; }
[data-mood="low"] [data-mood-text="low"], [data-mood="high"] [data-mood-text="high"] { display: inline; }

/* ---------- Gerüst ---------- */

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--brand);
}

.hero,
.sheet { padding-inline: max(var(--gutter), (100% - 36rem) / 2); }

/* ---------- Markenfläche ---------- */

.hero {
  position: relative;
  padding-top: calc(env(safe-area-inset-top) + 1.25rem);
  padding-bottom: calc(var(--r-sheet) + 1.75rem);
  color: var(--on-brand);
}
/* Beim Hochziehen über den Seitenanfang hinaus (iOS) bleibt es oben in Markenfarbe */
.hero::before { content: ""; position: absolute; inset: auto 0 100% 0; height: 100vh; background: var(--brand); }

.host { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; }

.host-logo {
  flex: none;
  display: grid;
  place-items: center;
  height: 2.75rem;
  min-width: 2.75rem;
  max-width: 8rem;
  padding: 0.375rem 0.5rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.08);
}
.host-logo img { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; }

.host-text { min-width: 0; }
.host-name { font-weight: 650; line-height: 1.2; overflow-wrap: anywhere; }
.host-place { font-size: 0.875rem; line-height: 1.3; overflow-wrap: anywhere; }
.brand-mark { font-size: 1.25rem; letter-spacing: -0.02em; }

.hero-ask { margin-top: clamp(1.75rem, 6vh, 3rem); }

.hero h1 {
  max-width: 14ch;
  font-size: clamp(2.35rem, 1.5rem + 4.6vw, 3.4rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.038em;
  text-wrap: balance;
  overflow-wrap: break-word;
  hyphens: auto;
}
.hero-lede { margin-top: 0.875rem; max-width: 30ch; font-size: 1.0625rem; text-wrap: pretty; }
.hero-code { margin-bottom: 0.625rem; font-weight: 600; }

/* Handy, beim Bewerten (und auf Start-/Fehlerseiten): Frage und Gesichter bilden einen Block in der Mitte.
   Freier Platz auf hohen Displays wird gleichmäßig verteilt – über der Frage (Markenfarbe)
   und unter den Gesichtern (weiß) –, damit nirgends ein großes Loch entsteht. */
@media (max-width: 55.99rem) {
  [data-step="rate"] .hero,
  [data-poster] .hero { flex: 1 1 auto; display: flex; flex-direction: column; }
  [data-step="rate"] .hero-ask,
  [data-poster] .hero-ask { margin-top: auto; padding-top: 2rem; }
  [data-step="rate"] .sheet,
  [data-poster] .sheet { flex: 1 1 auto; }
}

/* Nach dem Tippen wird der Kopf kompakt – die Bühne gehört dann der Reaktion */
[data-flow]:not([data-step="rate"]) .hero-ask { display: none; }
[data-flow]:not([data-step="rate"]) .hero { padding-bottom: calc(var(--r-sheet) + 1rem); }

/* ---------- Sheet ---------- */

.sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: calc(var(--r-sheet) * -1);
  padding-top: 1.75rem;
  background: var(--paper);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
}

.step { display: flex; flex-direction: column; }

.sheet h1 {
  font-size: clamp(1.75rem, 1.35rem + 1.8vw, 2.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.lede { margin-top: 0.625rem; max-width: 36ch; color: var(--muted); text-wrap: pretty; }

/* ---------- Gesichter ---------- */

.face { display: block; width: 100%; height: auto; overflow: visible; }
.face-top { transition: transform 90ms ease-out; }

.keys-set { margin: 0; padding: 0; border: 0; min-width: 0; }

.keys {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.25rem;
}

.key {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0 0.375rem;
  background: none;
  border: 0;
  border-radius: 18px;
  transition: opacity 200ms, filter 200ms;
  animation: key-in 560ms cubic-bezier(.3, 1.5, .5, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}

.key .face {
  max-width: 4.75rem;
  transition: transform 220ms cubic-bezier(.3, 1.6, .5, 1);
  filter: drop-shadow(0 6px 8px rgb(217 130 11 / 0.18));
}

.key-label { font-size: 0.875rem; font-weight: 600; line-height: 1.2; color: var(--muted); transition: color 160ms; }

/* Drücken: das Gesicht sinkt auf seine Kante */
.key:active .face-top,
.key.is-pressing .face-top { transform: translateY(3px); }

@media (hover: hover) and (pointer: fine) {
  .key:hover .face { transform: rotate(-7deg) scale(1.08); }
  .key:hover .key-label { color: var(--ink); }
}

.key[aria-pressed="true"] .face { transform: scale(1.12); }
.key[aria-pressed="true"] .key-label { color: var(--ink); }
.keys:has([aria-pressed="true"]) .key:not([aria-pressed="true"]) { opacity: 0.5; filter: saturate(0.35); }
.key.is-picked .face { animation: pick 420ms cubic-bezier(.3, 1.7, .5, 1); }
.key[aria-busy="true"] .face { animation: wobble 700ms ease-in-out infinite; }

/* ---------- Vertrauen & Social Proof ---------- */

.trust {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.375rem 1.125rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  color: var(--muted);
}
.trust li { display: inline-flex; align-items: center; gap: 0.375rem; }
.trust li::before {
  content: "";
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #22B573 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.3l2.2 2.2 4.8-5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}

.proof {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  align-self: center;
  margin-top: 1rem;
  padding: 0.375rem 1rem 0.375rem 0.5rem;
  font-size: 0.9375rem;
  line-height: 1.3;
  background: var(--sun-soft);
  border-radius: 999px;
}
.proof strong { font-weight: 650; }
.proof-faces { display: flex; flex: none; }
.proof-faces .face { width: 1.625rem; }
.proof-faces .face + .face { margin-left: -0.5rem; }

/* ---------- Reaktion nach dem Tippen ---------- */

.reaction {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem 0.75rem 0.75rem;
  background: var(--mood-mid);
  border-radius: 20px;
}
[data-mood="low"] .reaction { background: var(--mood-low); }
[data-mood="high"] .reaction { background: var(--mood-high); }

.reaction-face { flex: none; width: 3.5rem; }
.reaction-compact .reaction-face { width: 2.5rem; }
.reaction-text { min-width: 0; }
.reaction-title { font-weight: 650; line-height: 1.25; color: var(--mood-mid-ink); }
[data-mood="low"] .reaction-title { color: var(--mood-low-ink); }
[data-mood="high"] .reaction-title { color: var(--mood-high-ink); }
.reaction-note { font-size: 0.9375rem; line-height: 1.35; color: var(--ink); }

.link-button {
  display: inline;
  margin-left: 0.25rem;
  padding: 0.5rem 0.25rem;
  font-size: inherit;
  font-weight: 650;
  color: var(--ink);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* ---------- Formulare ---------- */

form.questions,
form.email { display: flex; flex-direction: column; margin-top: 1.75rem; }

.field { margin-bottom: 1.5rem; }
.field fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }

.field-label { display: block; margin-bottom: 0.5rem; padding: 0; font-weight: 600; line-height: 1.3; text-wrap: pretty; }
.req {
  margin-left: 0.375rem;
  padding: 0.0625rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: 0.15em;
  color: var(--mood-low-ink);
  background: var(--mood-low);
  border-radius: 999px;
}

input[type="text"],
input[type="email"],
textarea {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.0625rem; /* ≥ 16px: kein Auto-Zoom auf iOS */
  line-height: 1.4;
  background: var(--field);
  border: 1.5px solid transparent;
  border-radius: var(--r-field);
  transition: border-color 120ms, background-color 120ms;
}
textarea { resize: vertical; min-height: 6.5rem; }
input::placeholder, textarea::placeholder { color: #868C98; }

input[type="text"]:focus-visible,
input[type="email"]:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--brand) 40%, transparent);
  outline-offset: 0;
  background: var(--paper);
  border-color: var(--brand-ink);
}

[aria-invalid="true"] { border-color: var(--danger) !important; }
.field-error { margin-top: 0.45rem; font-size: 0.9375rem; line-height: 1.35; color: var(--danger); }

/* Auswahl-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  min-width: 3rem;
  padding: 0 1.25rem;
  font-weight: 550;
  background: var(--field);
  border-radius: 999px;
  transition: background-color 140ms, color 140ms, transform 140ms cubic-bezier(.3, 1.6, .5, 1);
}
.chip input:checked + span { color: var(--on-brand); background: var(--brand); transform: scale(1.04); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .chip input:not(:checked):hover + span { background: color-mix(in oklab, var(--brand) 14%, var(--field)); }
}

.chips-scale { display: grid; grid-template-columns: repeat(var(--count, 5), minmax(0, 1fr)); gap: 0.375rem; }
.chips-scale .chip { display: flex; }
.chips-scale .chip span { width: 100%; padding: 0; font-variant-numeric: tabular-nums; }
.scale-ends { display: flex; justify-content: space-between; margin-top: 0.4rem; font-size: 0.8125rem; color: var(--muted); }

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  font-size: 0.9375rem;
  line-height: 1.45;
  cursor: pointer;
}
.check input { width: 1.375rem; height: 1.375rem; margin: 0.05rem 0 0; accent-color: var(--brand-ink); }

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

.actions { display: grid; gap: 0.25rem; padding-top: 0.5rem; }

@media (max-width: 55.99rem) {
  .actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-inline: calc(var(--gutter) * -1);
    padding: 0.75rem var(--gutter) calc(0.5rem + env(safe-area-inset-bottom));
    background: var(--paper);
    box-shadow: 0 -1px 0 var(--line);
  }
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.5rem 1.25rem;
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  border: 0;
  border-radius: var(--r-field);
  transition: transform 90ms ease-out, background-color 120ms;
}
.button:active { transform: translateY(1px) scale(0.99); }
.button-primary { color: var(--on-brand); background: var(--brand); box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.14); }
.button-quiet { color: var(--muted); background: transparent; font-weight: 600; }
.button-outline { color: var(--ink); background: var(--field); }
@media (hover: hover) and (pointer: fine) {
  .button-primary:hover { background: color-mix(in oklab, var(--brand) 90%, #000); }
  .button-quiet:hover { color: var(--ink); }
  .button-outline:hover { background: var(--line); }
}
.button[aria-busy="true"] { cursor: progress; opacity: 0.75; }

.form-status:empty { display: none; }
.form-status { margin-top: 0.75rem; font-size: 0.9375rem; color: var(--danger); text-align: center; }

/* ---------- Danke ---------- */

.step-done { align-items: flex-start; margin-block: auto; padding-block: 1rem; }
.done-stage { position: relative; width: 7.5rem; margin-bottom: 1.5rem; }
.done-face .face { filter: drop-shadow(0 10px 14px rgb(217 130 11 / 0.22)); }

.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 13px;
  margin: -6px 0 0 -4px;
  background: var(--c);
  border-radius: 2px;
  opacity: 0;
}
[data-mood="high"] .step-done.is-entering .confetti i { animation: burst 1100ms cubic-bezier(.15, .7, .3, 1) both; }
.step-done.is-entering .done-face { animation: pop 600ms cubic-bezier(.3, 1.6, .5, 1); }

.done-cta, .restart { margin-top: 2rem; width: 100%; }
.countdown { height: 4px; margin-bottom: 0.75rem; overflow: hidden; background: var(--line); border-radius: 2px; }
.countdown span { display: block; height: 100%; background: var(--sun); transform-origin: left; animation: countdown var(--countdown, 8s) linear forwards; }

/* ---------- Fehler, Start, Datenschutz ---------- */

.step-message { align-items: flex-start; }
.message-face { width: 6rem; margin-bottom: 1.25rem; animation: key-in 600ms cubic-bezier(.3, 1.5, .5, 1) both; }
.step-message .lede { margin-top: 0; }
.detail { margin-top: 1.5rem; padding: 1rem; max-width: 100%; overflow-x: auto; font-size: 0.8125rem; background: var(--field); border-radius: var(--r-field); }

.prose { max-width: 62ch; padding-bottom: 1rem; }
.prose .lede { margin-top: 0; }
.prose h2 { margin-top: 2rem; margin-bottom: 0.5rem; font-size: 1.1875rem; font-weight: 650; letter-spacing: -0.01em; }
.prose p + p { margin-top: 0.75rem; }
.prose ul { margin: 0; padding-left: 1.15rem; }
.prose li + li { margin-top: 0.5rem; }
.prose .button { width: auto; margin-top: 2rem; }

/* ---------- Fuß ---------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: auto;
  padding-top: 2.5rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  font-size: 0.8125rem;
  color: var(--muted);
}
.foot-links { display: flex; gap: 1.25rem; }
.foot-links a { color: var(--muted); }
.foot-mark { font-weight: 600; }

/* ---------- Bewegung ---------- */

@keyframes key-in { from { opacity: 0; transform: translateY(14px) scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes pick { 0% { transform: scale(0.88); } 55% { transform: scale(1.22) rotate(-6deg); } 100% { transform: scale(1.12); } }
@keyframes wobble { 0%, 100% { transform: scale(1.12) rotate(0); } 50% { transform: scale(1.12) rotate(-8deg); } }
@keyframes pop { 0% { transform: scale(0.5); } 100% { transform: none; } }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes burst {
  0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(0.4); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) rotate(220deg) scale(1); }
}
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.step.is-entering { animation: enter 300ms ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .confetti { display: none; }
  .countdown span { animation-duration: var(--countdown, 8s) !important; }
}

/* ---------- Groß: Marke links, Sheet rechts ---------- */

@media (min-width: 56rem) {
  .page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }

  .hero {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 3rem clamp(2.5rem, 5vw, 5rem);
  }
  .hero-ask { margin-block: auto; }
  .hero h1 { font-size: clamp(3rem, 1.6rem + 2.6vw, 4.25rem); }
  [data-flow]:not([data-step="rate"]) .hero-ask { display: block; }
  [data-flow]:not([data-step="rate"]) .hero { padding-bottom: 3rem; }

  .sheet {
    margin-top: 0;
    padding: 3rem clamp(2.5rem, 6vw, 6rem) 0;
    border-radius: var(--r-sheet) 0 0 var(--r-sheet);
  }
  .sheet > .step,
  .sheet > .prose { width: 100%; max-width: 34rem; margin-top: auto; padding-top: 2rem; }
  .foot { max-width: 34rem; }
  .key .face { max-width: 6rem; }
}

/* Kiosk-Tablet: noch größere Tasten */
@media (min-width: 56rem) {
  [data-kiosk] .key .face { max-width: 7.5rem; }
  [data-kiosk] .key-label { font-size: 1.0625rem; }
}
