/* ── Tokens ─────────────────────────────────────────── */
:root {
  --bg: #090909;
  --fg: #f5f5f7;
  --fg-soft: #d7d7de;
  --muted: #9b9ba3;
  --accent: #5b8def;
  --accent-bright: #8fb4ff;
  --glass: rgba(255, 255, 255, 0.04);
  --stroke: rgba(255, 255, 255, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Base ───────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection {
  background: rgba(91, 141, 239, 0.35);
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.title:focus-visible {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Ambiente: Orbs, Grain, Konfetti ────────────────── */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
}

.orb {
  position: absolute;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  filter: blur(90px);
}

.orb-a {
  top: -180px;
  left: -140px;
  background: radial-gradient(circle at 35% 35%, rgba(91, 141, 239, 0.32), transparent 62%);
  animation: driftA 26s ease-in-out infinite alternate;
}

.orb-b {
  bottom: -200px;
  right: -160px;
  background: radial-gradient(circle at 65% 65%, rgba(122, 91, 239, 0.2), transparent 62%);
  animation: driftB 32s ease-in-out infinite alternate;
}

@keyframes driftA {
  to { transform: translate3d(70px, 50px, 0) scale(1.08); }
}

@keyframes driftB {
  to { transform: translate3d(-60px, -40px, 0) scale(1.05); }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
  pointer-events: none;
}

/* ── Layout ─────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 4;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 800px;
  padding: 48px 22px 110px;
  padding-left: max(22px, env(safe-area-inset-left));
  padding-right: max(22px, env(safe-area-inset-right));
}

.screen.is-active {
  display: flex;
  animation: screenIn 0.6s var(--ease) both;
}

.screen.is-active.is-leaving {
  animation: screenOut 0.24s ease-in both;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
    filter: blur(12px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes screenOut {
  to {
    opacity: 0;
    transform: translateY(-12px) scale(0.99);
    filter: blur(10px);
  }
}

/* ── Typografie ─────────────────────────────────────── */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: glowPulse 2.6s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.title {
  font-size: clamp(2.3rem, 5.4vw + 1rem, 4.4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 700;
  text-wrap: balance;
}

.title-md {
  font-size: clamp(1.9rem, 3.4vw + 0.8rem, 3.1rem);
}

.grad {
  color: var(--accent);
}

.sub {
  margin-top: 16px;
  color: var(--muted);
  font-size: 16px;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease),
    opacity 0.3s ease, background 0.3s ease;
}

.btn-primary {
  color: #0a0a0c;
  background: linear-gradient(180deg, #ffffff, #e9ebf2);
  padding: 15px 34px;
  min-height: 54px;
  font-size: 16.5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 10px 34px rgba(91, 141, 239, 0.22), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 16px 44px rgba(91, 141, 239, 0.38), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.3;
  pointer-events: none;
  box-shadow: none;
}

.btn-xl {
  padding: 20px 50px;
  min-height: 64px;
  font-size: 19px;
  transform: scale(var(--grow, 1));
}

.btn-xl:hover {
  transform: scale(calc(var(--grow, 1) * 1.045)) translateY(-2px);
}

.btn-xl:active {
  transform: scale(calc(var(--grow, 1) * 0.96));
}

.arr {
  display: inline-block;
  transition: transform 0.3s var(--ease);
}

.btn:hover .arr {
  transform: translateX(3px);
}

.btn.pulse {
  animation: pulseIn 0.55s var(--ease);
}

@keyframes pulseIn {
  0% { transform: scale(0.96); }
  55% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

/* Screen-Buttons unterhalb von Inhalten */
#btn-date-next,
#btn-time-next,
#btn-confirm,
#btn-intro-next {
  margin-top: 36px;
}

#btn-intro-next.is-waiting {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* ── Screen 1: Frage ────────────────────────────────── */
.ask-actions {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.btn-no {
  padding: 12px 16px; /* großzügige Touch-Fläche trotz Mini-Schrift */
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.38);
  letter-spacing: 0.03em;
  transition: transform 0.4s var(--ease), color 0.3s ease;
}

.btn-no:hover {
  color: rgba(255, 255, 255, 0.6);
}

.no-quip {
  min-height: 22px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
  opacity: 0;
}

.no-quip.pop {
  animation: rise 0.5s var(--ease) both;
}

/* ── Zwischenruf ────────────────────────────────────── */
.sorry-emoji {
  font-size: 78px;
  line-height: 1;
  animation: popIn 0.7s var(--ease) both;
}

.sorry-text {
  margin-top: 28px;
  font-size: 20px;
  font-weight: 500;
  color: var(--fg-soft);
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.5); }
  60% { transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ── Screen 2: Typewriter ───────────────────────────── */
.type-area {
  margin-top: 30px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  min-height: 3.6em; /* Platz für zwei Zeilen reservieren → kein Layout-Shift beim Tippen */
}

.type-area p {
  font-size: 17px;
  line-height: 1.65;
  color: var(--fg-soft);
  margin: 0.45em 0;
  min-height: 1.65em;
}

.type-area p.last {
  font-weight: 600;
  color: #ffffff;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: -0.15em;
  animation: blink 1.05s steps(1) infinite;
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

.hint {
  margin-top: 26px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.3);
  transition: opacity 0.4s ease;
}

.hint.is-hidden {
  opacity: 0;
}

/* ── Glass ──────────────────────────────────────────── */
.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ── Screen 3: Kalender ─────────────────────────────── */
.calendar {
  width: 100%;
  max-width: 384px;
  margin-top: 36px;
  padding: 20px;
  border-radius: 24px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-label {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.cal-nav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: background 0.25s ease, opacity 0.25s ease, transform 0.25s var(--ease);
}

.cal-nav:hover {
  background: rgba(255, 255, 255, 0.1);
}

.cal-nav:active {
  transform: scale(0.94);
}

.cal-nav:disabled {
  opacity: 0.25;
  pointer-events: none;
}

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day {
  aspect-ratio: 1;
  min-height: 44px;
  border-radius: 50%;
  border: 0;
  background: none;
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.25s var(--ease),
    color 0.2s ease, box-shadow 0.25s ease;
}

.cal-day:hover:not(:disabled):not(.is-selected) {
  background: rgba(255, 255, 255, 0.08);
}

.cal-day:disabled {
  color: rgba(255, 255, 255, 0.18);
  cursor: default;
}

.cal-day.is-today {
  box-shadow: inset 0 0 0 1px rgba(91, 141, 239, 0.55);
}

.cal-day.is-selected {
  background: var(--accent);
  color: #0a0f1e;
  font-weight: 700;
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(91, 141, 239, 0.45);
}

/* ── Screens 4 + 5: Auswahlkarten ───────────────────── */
.grid {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 36px;
}

.times {
  max-width: 560px;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
}

.foods {
  max-width: 660px;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
}

.card {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.3s var(--ease), background 0.25s ease,
    border-color 0.25s ease, box-shadow 0.3s var(--ease);
}

.card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

.card:active {
  transform: translateY(0) scale(0.97);
}

.card.is-selected {
  background: rgba(91, 141, 239, 0.14);
  border-color: rgba(91, 141, 239, 0.65);
  box-shadow: 0 8px 30px rgba(91, 141, 239, 0.2),
    inset 0 0 0 1px rgba(91, 141, 239, 0.35);
  transform: translateY(-2px);
}

.time-card {
  padding: 16px 8px;
  min-height: 54px;
  font-weight: 600;
  font-size: 15.5px;
  font-variant-numeric: tabular-nums;
}

.food-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 18px 12px;
  min-height: 98px;
}

.food-emoji {
  font-size: 27px;
  line-height: 1;
}

.food-label {
  font-size: 13.5px;
  font-weight: 500;
  color: #e3e3e8;
  line-height: 1.35;
}

/* ── Eigene Idee ────────────────────────────────────── */
.custom-wrap {
  display: grid;
  grid-template-rows: 0fr;
  width: 100%;
  max-width: 660px;
  transition: grid-template-rows 0.45s var(--ease);
}

.custom-wrap.is-open {
  grid-template-rows: 1fr;
}

.custom-inner {
  overflow: hidden;
  padding: 0 6px;
}

#custom-food {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 16px auto 6px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

#custom-food:focus {
  border-color: rgba(91, 141, 239, 0.7);
  box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.15);
  background: rgba(255, 255, 255, 0.07);
}

#custom-food::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* ── Screen 6: Fertig ───────────────────────────────── */
.check-wrap {
  width: 104px;
  height: 104px;
  animation: popIn 0.8s var(--ease) both;
}

.check {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 10px 30px rgba(91, 141, 239, 0.35));
}

.check-ring {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1s cubic-bezier(0.65, 0, 0.35, 1) 0.25s forwards;
}

.check-mark {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 0.5s cubic-bezier(0.65, 0, 0.35, 1) 0.95s forwards;
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

.done-title {
  margin-top: 30px;
  opacity: 0;
  animation: rise 0.6s var(--ease) 0.5s forwards;
}

.summary {
  width: 100%;
  max-width: 460px;
  margin-top: 32px;
  padding: 10px 26px;
  border-radius: 22px;
  text-align: left;
  opacity: 0;
  animation: rise 0.6s var(--ease) 0.75s forwards;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-value {
  font-size: 15.5px;
  font-weight: 600;
  text-align: right;
}

.done-lines {
  margin-top: 32px;
}

.done-lines p {
  color: #c9c9d1;
  font-size: 15.5px;
  margin: 9px 0;
  opacity: 0;
  animation: rise 0.7s var(--ease) forwards;
}

.done-lines p:nth-child(1) { animation-delay: 1.15s; }
.done-lines p:nth-child(2) { animation-delay: 1.35s; }

.done-lines .closing {
  margin-top: 26px;
  font-size: 17.5px;
  font-weight: 600;
  color: #ffffff;
  animation-delay: 1.7s;
}

/* ── Fortschritts-Dots ──────────────────────────────── */
.dots {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  gap: 7px;
  z-index: 5;
  transition: opacity 0.5s ease;
}

.dots.is-hidden {
  opacity: 0;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transition: width 0.45s var(--ease), background 0.45s ease, box-shadow 0.45s ease;
}

.dot.is-active {
  width: 22px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(91, 141, 239, 0.6);
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
  .btn-xl {
    padding: 18px 44px;
    font-size: 18px;
  }

  .times {
    grid-template-columns: repeat(3, 1fr);
  }

  .foods {
    grid-template-columns: repeat(2, 1fr);
  }

  .type-area {
    min-height: 5.2em;
  }

  .type-area p {
    font-size: 16px;
  }

  .calendar {
    padding: 14px;
  }

  .summary {
    padding: 6px 20px;
  }
}

/* ── Reduced Motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
