/* ================================
   POPUP STYLES
   ================================ */

/* Scrollbar-Sprung verhindern */
body.popup-open {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0px);
}

.rsvp-overlay {
  display: flex;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: rgba(58, 58, 58, 0.6);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.rsvp-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.rsvp-popup {
  background: var(--white);
  border-radius: 24px;
  max-width: 550px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ================================
   POPUP HEADER
   ================================ */

.popup-header {
  padding: clamp(1.5rem, 4vw, 2rem) clamp(1.5rem, 4vw, 2.5rem) clamp(1.2rem, 3vw, 1.5rem);
  border-bottom: 2px solid var(--subtle-gray);
  position: relative;
}

.popup-title {
  font-family: "Cherolina", cursive;
  font-size: clamp(2rem, 5vw, 2.5rem);
  color: var(--sage-green-dark);
  margin-bottom: 0.5rem;
  font-weight: 400;
}

.popup-subtitle {
  font-family: "Cormorant", serif;
  font-size: var(--fs-body);
  font-weight: 400;
  color: #666;
}

.rsvp-deadline {
  font-family: "Montserrat", sans-serif;
  font-size: clamp(0.75rem, 1.8vw, 0.8rem);
  font-weight: 600;
  color: var(--warm-gold-dark);
  margin-top: 0.5rem;
  letter-spacing: 0.05em;
}

.close-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 1.8rem;
  color: #999;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  border-radius: 8px;
}

.close-btn:hover {
  color: var(--sage-green);
  /* Leichter Hintergrund beim Hover für bessere Trefferzone-Erkennbarkeit */
  background: rgba(168, 181, 160, 0.12);
}

.close-btn:focus-visible {
  outline: 2px solid var(--sage-green);
  outline-offset: 2px;
}

/* ================================
   POPUP BODY
   ================================ */

.popup-body {
  padding: clamp(1.5rem, 4vw, 2rem) clamp(1.5rem, 4vw, 2.5rem) clamp(2rem, 5vw, 2.5rem);
}

/* ================================
   FORMULAR
   ================================ */

.form-group {
  margin-bottom: clamp(1.2rem, 3vw, 1.8rem);
}

.form-group.error .form-input,
.form-group.error .form-select {
  border-color: var(--error-red);
  box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.1);
}

.error-message {
  display: none;
  font-family: "Montserrat", sans-serif;
  font-size: clamp(0.75rem, 1.8vw, 0.8rem);
  font-weight: 500;
  color: var(--error-red);
  margin-top: 0.5rem;
  animation: shake 0.3s ease-in-out;
}

.form-group.error .error-message {
  display: block;
}

@keyframes shake {
  0%,  100% { transform: translateX(0);   }
  25%        { transform: translateX(-5px); }
  75%        { transform: translateX(5px);  }
}

.form-label {
  font-family: "Montserrat", sans-serif;
  font-size: clamp(0.85rem, 2vw, 0.9rem);
  font-weight: 600;
  color: var(--anthracite);
  margin-bottom: 0.6rem;
  display: block;
  letter-spacing: 0.03em;
}

.form-label .required {
  color: var(--sage-green);
}

.form-input,
.form-select {
  width: 100%;
  padding: clamp(0.8rem, 2vw, 0.9rem) 1rem;
  border: 2px solid var(--light-gray);
  border-radius: 12px;
  font-family: "Montserrat", sans-serif;
  font-size: var(--fs-body);
  color: var(--anthracite);
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--white);
  min-height: 48px;
  box-sizing: border-box;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--sage-green);
  box-shadow: 0 0 0 3px rgba(168, 181, 160, 0.2);
}

/* Valides, ausgefülltes Feld – dezentes visuelles Feedback */
.form-input:not(:placeholder-shown):valid {
  border-color: var(--sage-green);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a8b5a0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ================================
   PERSONEN-ANZAHL
   ================================ */

.person-count-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 0.8rem;
}

/* ================================
   NAMEN-FELDER
   ================================ */

.names-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.name-input-wrapper {
  animation: fadeInDown 0.3s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0);     }
}

/* ================================
   RADIO & CHECKBOX
   ================================ */

.radio-group {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  min-height: 44px;
}

.radio-option input[type="radio"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: var(--sage-green);
  flex-shrink: 0;
}

.radio-option label {
  font-family: "Cormorant", serif;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--anthracite);
  cursor: pointer;
  user-select: none;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
  min-height: 44px;
}

.checkbox-option input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: var(--sage-green);
  flex-shrink: 0;
}

.checkbox-option label {
  font-family: "Cormorant", serif;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--anthracite);
  cursor: pointer;
  user-select: none;
  flex: 1;
}

/* ================================
   ERNÄHRUNG / VEGGIE
   ================================ */

.count-input {
  width: 70px;
  padding: 0.5rem;
  text-align: center;
  min-height: 44px;
}

.diet-count-item {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--subtle-gray);
  border-radius: 12px;
  gap: 1rem;
  flex-wrap: wrap;
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.diet-count-item.active {
  display: flex;
}

.diet-count-item.error {
  border-color: var(--error-red);
  box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.1);
}

.diet-count-label {
  font-family: "Montserrat", sans-serif;
  font-size: clamp(0.8rem, 2vw, 0.85rem);
  font-weight: 500;
  color: #666;
}

/* ================================
   SUBMIT BUTTON
   ================================ */

.submit-btn {
  width: 100%;
  padding: clamp(1rem, 2.5vw, 1.1rem);
  background: var(--light-gray);
  color: var(--anthracite);
  border: none;
  border-radius: 12px;
  font-family: "Montserrat", sans-serif;
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, transform 0.2s, box-shadow 0.3s;
  margin-top: 1rem;
  min-height: 48px;
  touch-action: manipulation;
}

.submit-btn:hover:not(:disabled) {
  background: var(--sage-green);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(168, 181, 160, 0.35);
}

.submit-btn:focus-visible {
  outline: 2px solid var(--sage-green);
  outline-offset: 2px;
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Deaktiviert: pointer-events aus, damit kein Hover-Effekt feuert */
.submit-btn:disabled {
  background: var(--light-gray);
  color: #aaa;
  cursor: not-allowed;
  pointer-events: none;
}

/* ================================
   ERFOLGSMELDUNG
   ================================ */

.submit-success {
  font-family: "Montserrat", sans-serif;
  font-size: clamp(0.8rem, 2vw, 0.85rem);
  font-weight: 600;
  color: var(--sage-green-dark);
  text-align: center;
  margin-top: 0.8rem;
  animation: fadeInDown 0.3s ease-out;
}

/* ================================
   MOBILE  (max 767px)
   ================================ */

@media (max-width: 767px) {
  /* Cherolina funktioniert auf kleinen Screens schlecht —
     bewusster Wechsel zu Cormorant italic für mobile */
  .popup-title {
    font-family: "Cormorant", serif;
    font-size: clamp(2.2rem, 7vw, 2.8rem);
    font-weight: 600;
    font-style: italic;
  }

  .person-count-grid {
    grid-template-columns: 1fr;
  }

  .radio-group {
    flex-direction: column;
    gap: 1rem;
  }

  .rsvp-popup {
    max-height: 95vh;
    border-radius: 16px;
  }

  /* Auf Touch-Geräten kein translateY-Hover (kein Hover-Intent möglich) */
  .submit-btn:hover:not(:disabled) {
    transform: none;
  }
}

/* ================================
   REDUCED MOTION
   ================================ */

@media (prefers-reduced-motion: reduce) {
  .rsvp-popup {
    animation: none;
  }

  .name-input-wrapper,
  .error-message,
  .submit-success {
    animation: none;
  }

  .form-input,
  .form-select,
  .submit-btn,
  .close-btn,
  .diet-count-item {
    transition: none;
  }
}

.form-label--sub {
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
}