@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #FAF8F5;
  --question: #1A1A1A;
  --button: #2C3A36;
  --button-text: #FFFFFF;
  --font: 'Inter', -apple-system, 'Helvetica Neue', sans-serif;
  --accent: #2C3A36;
  --light-gray: #D6D1CB;
  --mid-gray: #8E8983;
  --error: #E25B45;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--question);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Only hide overflow on desktop */
@media (min-width: 769px) {
  html, body {
    overflow: hidden;
  }
}

/* ── Progress bar ── */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: var(--accent);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  border-radius: 0 2px 2px 0;
}

/* ── Slide container ── */
.form-container {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 2rem 5rem;
  overflow-y: auto;
}

.slide {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  max-width: 1000px;
  width: 100%;
  opacity: 0;
  transform: translateY(16px);
}

.slide.active {
  display: flex;
  animation: slideIn 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Question number ── */
.question-number {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  letter-spacing: 0.01em;
}

/* ── Question text ── */
.question-text {
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.question-description {
  font-size: 1.1rem;
  color: var(--mid-gray);
  margin-bottom: 2rem;
  line-height: 1.55;
  font-weight: 400;
}

.required-star {
  color: var(--error);
}

/* ── Input fields ── */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
textarea {
  width: 100%;
  border-width: 0 0 2px 0;
  border-style: solid;
  border-color: var(--light-gray);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  font-family: var(--font);
  font-size: 1.75rem;
  font-weight: 300;
  padding: 0.75rem 0;
  color: var(--question);
  outline: none;
  box-shadow: none;
  transition: border-color 0.25s ease;
  caret-color: var(--accent);
}

input:focus,
textarea:focus {
  border-bottom-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: var(--light-gray);
  font-weight: 300;
}

textarea {
  min-height: 80px;
  resize: none;
  line-height: 1.5;
}

input[type="date"] {
  font-size: 1.25rem;
  color-scheme: light;
}

/* ── Multiple choice ── */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.25rem;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border: 1px solid var(--light-gray);
  border-radius: 8px;
  background: transparent;
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--question);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
  line-height: 1.4;
}

.option-btn:hover {
  border-color: var(--accent);
  background: rgba(44, 58, 54, 0.03);
}

.option-btn.selected {
  border-color: var(--accent);
  background: rgba(44, 58, 54, 0.07);
  font-weight: 500;
}

.option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 5px;
  border: 1px solid var(--light-gray);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
}

.option-btn:hover .option-key {
  border-color: var(--accent);
}

.option-btn.selected .option-key {
  background: var(--accent);
  color: var(--button-text);
  border-color: var(--accent);
}

.multi-hint {
  font-size: 0.8rem;
  color: var(--mid-gray);
  margin-bottom: 0.6rem;
  font-weight: 400;
}

/* ── Picture choice ── */
.picture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 1rem;
  width: 100%;
  margin-top: 0.25rem;
}

.picture-option {
  border: 2px solid var(--light-gray);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fff;
}

.picture-option:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.picture-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.picture-option.selected .picture-label {
  font-weight: 600;
}

.picture-option img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.picture-option .picture-label {
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 400;
  text-align: center;
  line-height: 1.3;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--button);
  color: var(--button-text);
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 1.5rem;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.btn:hover {
  opacity: 0.88;
  transform: translateY(-0.5px);
}

.btn:active {
  transform: translateY(0);
}

/* ── OK button + Enter hint ── */
.btn-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.btn-group .btn {
  margin-top: 0;
}

.enter-hint {
  font-size: 0.78rem;
  color: var(--mid-gray);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.enter-hint kbd {
  display: inline-block;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--light-gray);
  border-radius: 3px;
  background: rgba(255,255,255,0.6);
  line-height: 1.3;
}

/* ── Navigation ── */
.nav-buttons {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 50;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.nav-btn {
  width: 36px;
  height: 34px;
  border: none;
  background: var(--button);
  color: var(--button-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  font-size: 0.85rem;
}

.nav-btn:first-child {
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.nav-btn:hover {
  background: #3a4e48;
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-btn:disabled:hover {
  background: var(--button);
}

/* ── Welcome screen ── */
.welcome-slide {
  max-width: 1000px;
}

.welcome-slide .question-text {
  font-size: 2.75rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.welcome-slide .question-description {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  line-height: 1.65;
  color: var(--mid-gray);
}

.welcome-slide .btn {
  font-size: 1.1rem;
  padding: 0.85rem 2rem;
}

/* ── Thank you screen ── */
.thankyou-slide {
  text-align: center;
  align-items: center;
}

.thankyou-slide .question-text {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.thankyou-slide .question-description {
  font-size: 1.15rem;
  color: var(--mid-gray);
  margin-bottom: 2rem;
  line-height: 1.65;
  max-width: 480px;
}

.thankyou-slide .btn {
  font-size: 1rem;
  padding: 0.75rem 1.75rem;
}

/* ── Validation error ── */
.error-msg {
  color: var(--error);
  font-size: 0.82rem;
  margin-top: 0.5rem;
  display: none;
  font-weight: 400;
}

.error-msg.visible {
  display: block;
  animation: shakeIn 0.3s ease;
}

@keyframes shakeIn {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  html, body {
    height: 100%;
    overflow: auto;
  }

  .form-container {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    padding: 2rem 1.5rem 5.5rem;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
  }

  .slide {
    max-width: 100%;
    padding-bottom: 5rem;
    position: relative;
    z-index: 1;
  }

  .question-number {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  .question-text {
    font-size: 1.4rem;
    line-height: 1.35;
  }

  .question-description {
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
  }

  /* Inputs: 16px minimum to prevent iOS zoom */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="date"],
  textarea {
    font-size: 18px;
    padding: 0.75rem 0;
  }

  textarea {
    min-height: 70px;
  }

  /* Options: full width, touch-friendly sizing */
  .options-grid {
    gap: 0.5rem;
  }

  .option-btn {
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    gap: 0.7rem;
    min-height: 48px;
  }

  .option-key {
    min-width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }

  .multi-hint {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
  }

  /* Picture choice: 2-column grid */
  .picture-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .picture-option img {
    height: 90px;
  }

  .picture-option .picture-label {
    padding: 0.4rem;
    font-size: 0.78rem;
  }

  /* OK button fixed to bottom */
  .btn-group {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    padding: 0.75rem 1.25rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    margin-top: 0;
    border-top: none;
    z-index: 40;
  }

  .btn-group .btn {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    min-height: 48px;
  }

  .enter-hint {
    display: none;
  }

  /* Welcome & Thank you buttons — also fixed bottom on mobile */
  .welcome-slide,
  .thankyou-slide {
    padding-bottom: 5rem;
  }

  .welcome-slide .question-text {
    font-size: 1.65rem;
    margin-bottom: 0.75rem;
  }

  .welcome-slide .question-description {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
  }

  .welcome-slide .btn,
  .thankyou-slide .btn {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    margin: 0;
    border-radius: 0;
    justify-content: center;
    padding: 0.85rem 1.5rem;
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
    font-size: 1rem;
    min-height: 48px;
    z-index: 40;
  }

  .thankyou-slide .question-text {
    font-size: 1.5rem;
  }

  .thankyou-slide .question-description {
    font-size: 0.95rem;
    max-width: 100%;
  }

  /* Hide nav arrows on mobile */
  .nav-buttons {
    display: none !important;
  }

  .error-msg {
    font-size: 0.85rem;
  }

  .progress-bar {
    height: 3px;
  }
}
