/* ============================================
   Mon Sommelier IA — Styles
   Mobile-first, warm & professional design
   ============================================ */

:root {
  --color-bg: #FBF8F3;
  --color-surface: #FFFFFF;
  --color-primary: #7B2D3B;
  --color-primary-light: #9E4654;
  --color-primary-lighter: #F3E8EA;
  --color-primary-dark: #5C1E2B;
  --color-accent: #C9A96E;
  --color-accent-light: #E8D5AA;
  --color-accent-dark: #A8894E;
  --color-text: #2D1F1A;
  --color-text-secondary: #6B5B54;
  --color-text-light: #9A8B83;
  --color-border: #E8E0D8;
  --color-border-light: #F0EBE5;
  --color-success: #4A7C59;
  --color-success-light: #E8F3EC;
  --color-shadow: rgba(45, 31, 26, 0.08);
  --color-shadow-lg: rgba(45, 31, 26, 0.12);
  --color-rouge: #8B1A2B;
  --color-blanc: #F5E6A3;
  --color-rose: #E8A0B5;
  --color-petillant: #D4C98A;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---- App Layout ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ---- Header ---- */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 8px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  background: var(--color-bg);
}

.btn-back {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-primary);
  transition: background 0.2s, opacity 0.3s, transform 0.3s;
}

.btn-back:active {
  background: var(--color-primary-lighter);
}

.step-indicator {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-light);
  letter-spacing: 0.02em;
}

.header-spacer {
  width: 44px;
}

.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---- Screens ---- */
#main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  z-index: 10;
}

.screen.exit-back {
  opacity: 0;
  transform: translateX(40px);
}

.screen.enter-back {
  transform: translateX(-40px);
}

.screen-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 24px 24px;
}

.screen-content-centered {
  justify-content: center;
  align-items: center;
}

.screen-header-text {
  margin-bottom: 24px;
}

.screen-header-text h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.subtitle strong {
  color: var(--color-primary);
}

.subtitle em {
  color: var(--color-text-light);
  font-style: italic;
  animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.screen-footer {
  margin-top: auto;
  padding-top: 20px;
  padding-bottom: var(--safe-bottom);
}

/* ---- Typography ---- */
h1, h2, h3 {
  font-family: var(--font-serif);
}

small {
  font-size: 12px;
  color: var(--color-text-light);
  font-weight: 400;
}

.text-muted {
  color: var(--color-text-light);
  font-size: 13px;
}

/* ---- Buttons ---- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius-lg);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.btn-lg {
  height: 56px;
  padding: 0 28px;
  font-size: 16px;
  width: 100%;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(123, 45, 59, 0.25);
}

.btn-primary:active {
  background: var(--color-primary-dark);
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--color-border);
  color: var(--color-text-light);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 2px solid var(--color-primary-lighter);
  box-shadow: 0 2px 8px var(--color-shadow);
}

.btn-secondary:active {
  background: var(--color-primary-lighter);
  transform: scale(0.98);
}

.btn-accent {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(201, 169, 110, 0.3);
}

.btn-accent:active {
  background: var(--color-accent-dark);
  transform: scale(0.98);
}

.btn-emoji {
  font-size: 22px;
  line-height: 1;
}

.btn-arrow {
  flex-shrink: 0;
}

.btn-next {
  animation: subtle-pulse 2s infinite;
}

.btn-next:disabled {
  animation: none;
}

@keyframes subtle-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(123, 45, 59, 0.25); }
  50% { box-shadow: 0 4px 24px rgba(123, 45, 59, 0.4); }
}

/* ---- Home Screen ---- */
.home-content {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding-top: 0;
}

.home-hero {
  margin-bottom: 40px;
}

.home-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.home-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 10px;
  line-height: 1.2;
}

.home-title em {
  color: var(--color-primary);
  font-style: italic;
}

.home-tagline {
  font-size: 16px;
  color: var(--color-text-secondary);
  max-width: 260px;
  margin: 0 auto;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-bottom: 32px;
}

.home-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  max-width: 360px;
}

.home-note-icon {
  font-size: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.home-note p {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* ---- Options Grid (Parcours A - Step 1) ---- */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-light);
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
  text-align: center;
}

.option-card:active {
  transform: scale(0.97);
}

.option-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-lighter);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.option-emoji {
  font-size: 32px;
  line-height: 1;
}

.option-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}

.options-grid .option-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ---- Free text ---- */
.free-text-section {
  margin-bottom: 16px;
}

.free-text-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.input-textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-light);
  border-radius: var(--radius-md);
  resize: none;
  transition: border-color 0.2s;
  font-size: 15px;
  line-height: 1.5;
}

.input-textarea:focus {
  outline: none;
  border-color: var(--color-primary-light);
}

.input-textarea::placeholder {
  color: var(--color-text-light);
}

/* ---- Color Options (Parcours A - Step 2) ---- */
.color-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.color-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  transition: all 0.25s ease;
}

.color-card:active {
  transform: scale(0.97);
}

.color-card.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary), 0 4px 12px var(--color-shadow);
}

.color-card.recommended {
  position: relative;
}

.color-card.recommended::after {
  content: 'Suggéré';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-accent-dark);
  background: var(--color-accent-light);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

.color-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 8px var(--color-shadow);
}

.color-rouge { background: var(--color-rouge); }
.color-blanc { background: linear-gradient(135deg, #F7EFB5, #E8D98A); }
.color-rose { background: var(--color-rose); }
.color-petillant { background: linear-gradient(135deg, #F5F0C8, #E8E0A0); border: 3px dashed rgba(180, 170, 120, 0.5); }

.color-label {
  font-size: 14px;
  font-weight: 600;
}

/* ---- Budget error ---- */
.budget-error {
  font-size: 14px;
  color: #C0392B;
  background: #FDECEA;
  padding: 0;
  border-radius: var(--radius-sm);
  margin-bottom: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}

.budget-error-visible {
  max-height: 80px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ---- Format Toggle ---- */
.format-toggle {
  display: flex;
  background: var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 20px;
}

.format-btn {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all 0.3s ease;
}

.format-btn.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: 0 2px 8px var(--color-shadow);
}

/* ---- Budget Options ---- */
.budget-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.budget-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-light);
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
  text-align: left;
}

.budget-card:active {
  transform: scale(0.98);
}

.budget-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-lighter);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.budget-badge {
  font-size: 28px;
  flex-shrink: 0;
}

.budget-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.budget-name {
  font-size: 15px;
  font-weight: 600;
}

.budget-price {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* ---- Sensory Options (Parcours B) ---- */
.sensory-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}

.sensory-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  transition: all 0.3s ease;
  text-align: left;
}

.sensory-card:active {
  transform: scale(0.97);
}

.sensory-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-lighter);
  box-shadow: 0 0 0 1px var(--color-primary);
  transform: scale(1.02);
}

.sensory-emoji {
  font-size: 36px;
  flex-shrink: 0;
  line-height: 1;
}

.sensory-title {
  font-size: 15px;
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.sensory-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  display: block;
}

.sensory-options-wide {
  max-width: 400px;
}

.sensory-card-wide {
  padding: 24px;
}

/* ---- Profile Card ---- */
.profile-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 4px 24px var(--color-shadow-lg);
  margin-bottom: 24px;
}

.profile-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.profile-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.profile-name {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 16px;
}

.profile-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.profile-reco {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-light);
}

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

.profile-reco-color {
  font-size: 18px;
  font-weight: 600;
}

/* ---- Loading Screen ---- */
.loading-container {
  text-align: center;
}

.loading-icon {
  font-size: 64px;
  animation: loading-bounce 1.2s ease-in-out infinite;
}

@keyframes loading-bounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-12px) rotate(-5deg); }
  75% { transform: translateY(-6px) rotate(5deg); }
}

.loading-text {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--color-text-secondary);
  margin: 24px 0;
  font-style: italic;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: dot-bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- Wine Cards (Recommendation) ---- */
.wine-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.wine-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 2px 12px var(--color-shadow);
  border: 1px solid var(--color-border-light);
  animation: card-appear 0.5s ease both;
}

.wine-card:nth-child(2) {
  animation-delay: 0.15s;
}

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

.wine-card-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.badge-malin {
  background: #EDF5F0;
  color: var(--color-success);
}

.badge-prestige {
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
}

.wine-name {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.wine-meta {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.wine-color {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.wine-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.wine-pitch {
  font-size: 14px;
  font-style: italic;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-accent);
}

.wine-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wine-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wine-bar-label {
  width: 60px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-align: right;
}

.wine-bar-track {
  flex: 1;
  height: 6px;
  background: var(--color-border-light);
  border-radius: 3px;
  overflow: hidden;
}

.wine-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
  width: 0;
}

.wine-bar-fill.fruity { background: linear-gradient(90deg, #E88FA0, var(--color-primary-light)); }
.wine-bar-fill.body { background: linear-gradient(90deg, var(--color-accent), var(--color-accent-dark)); }
.wine-bar-fill.acidity { background: linear-gradient(90deg, #B8D4A8, var(--color-success)); }

/* ---- Coffee Section ---- */
.coffee-section {
  padding-bottom: var(--safe-bottom);
}

.coffee-card {
  background: var(--color-surface);
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
}

.coffee-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.coffee-icon {
  font-size: 28px;
}

.coffee-header h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.coffee-desc {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.input-email {
  height: 52px;
  padding: 0 16px;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 16px;
  transition: border-color 0.2s;
}

.input-email:focus {
  outline: none;
  border-color: var(--color-accent);
}

.input-email::placeholder {
  color: var(--color-text-light);
}

.email-message {
  font-size: 14px;
  padding: 0;
  border-radius: var(--radius-sm);
  text-align: center;
  line-height: 1.4;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
  margin: 0;
}

.email-message:not(:empty) {
  max-height: 80px;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.email-message-error {
  background: #FDECEA;
  color: #C0392B;
}

.email-message-warn {
  background: #FFF8E7;
  color: #92700C;
}

.coffee-fine-print {
  font-size: 11px;
  color: var(--color-text-light);
  line-height: 1.5;
  text-align: center;
}

/* ---- Success Screen ---- */
.success-container {
  text-align: center;
  padding: 0 24px;
}

.success-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.success-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

.success-desc {
  font-size: 16px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.success-thanks {
  font-size: 18px;
  color: var(--color-primary);
  font-weight: 500;
  margin-bottom: 40px;
}

/* ---- Utilities ---- */
.fade-in {
  animation: fadeIn 0.4s ease;
}

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

/* ---- Responsive: larger phones & tablets ---- */
@media (min-width: 420px) {
  .screen-content {
    padding: 12px 32px 32px;
  }

  .home-title {
    font-size: 36px;
  }

  .home-icon {
    font-size: 72px;
  }
}

@media (min-width: 600px) {
  #app {
    margin-top: 20px;
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 40px var(--color-shadow-lg);
    height: calc(100dvh - 40px);
  }

  #app-header {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
}
