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

:root {
  --primary: #7C3AED;
  --primary-dark: #5B21B6;
  --btn: #7C3AED;
  --btn-dark: #5B21B6;
  --yellow: #F7B500;
  --yellow-dark: #E0A000;
  --turquoise: #22C7D6;
  --turquoise-dark: #159AAA;
  --coral: #FB5C7A;
  --coral-dark: #D03055;
  --green: #4ADE80;
  --green-dark: #16A34A;
  --blue: #3B82F6;
  --blue-dark: #1D4ED8;
  --bg: #FAF8FF;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --radius: 24px;
  --shadow: 0 6px 0;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 40px;
}

/* HEADER */
header {
  background: var(--primary);
  box-shadow: 0 4px 0 var(--primary-dark);
  padding: 28px 16px;
  position: relative;
}

.header-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Ninja centré sur la largeur totale du header */
.header-inner .ninja-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.logo {
  font-size: 1.1rem;
  font-weight: 900;
  color: white;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

/* NINJA BADGE */
.ninja-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 30px;
  padding: 8px 20px 8px 8px;
  transition: transform 0.2s;
  white-space: nowrap;
}
.ninja-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  flex-shrink: 0;
}
.ninja-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.ninja-info { display: flex; flex-direction: column; }
.ninja-level {
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}
.ninja-name {
  font-size: 1.2rem;
  font-weight: 900;
  color: white;
  line-height: 1.3;
}
.ninja-badge.levelup {
  animation: levelUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes levelUp {
  0%   { transform: translate(-50%, -50%) scale(1); }
  40%  { transform: translate(-50%, -50%) scale(1.15); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.settings-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: transform 0.2s;
}
.settings-btn:hover { transform: rotate(30deg); }

/* MAIN */
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tagline {
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary-dark);
  line-height: 1.3;
}

/* INPUTS CARD */
.inputs-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 16px rgba(124,58,237,0.08);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group { display: flex; flex-direction: column; gap: 10px; }

.input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 0.95rem;
}


/* SLIDER */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 10px;
  border-radius: 10px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--btn);
  box-shadow: 0 3px 0 var(--btn-dark);
  cursor: pointer;
  transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.slider-value {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--primary-dark);
  min-width: 54px;
  text-align: right;
}

/* CONTEXT TOGGLE */
.context-toggle {
  display: flex;
  gap: 10px;
}
.ctx-btn {
  flex: 1;
  padding: 10px;
  border: 3px solid var(--border);
  border-radius: 16px;
  background: white;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.ctx-btn.active {
  border-color: var(--btn);
  background: #F5F3FF;
  color: var(--primary-dark);
}

/* RESULT CARDS */
.results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-card {
  border-radius: 20px;
  padding: 20px 20px 20px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  position: relative;
  overflow: hidden;
}
.result-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(255,255,255,0.4);
}
.result-card:active { transform: scale(0.98); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

.result-card.yellow {
  background: linear-gradient(135deg, #F7B500 0%, #FFD60A 100%);
  color: #1A1000;
}
.result-card.green {
  background: linear-gradient(135deg, #22C7D6 0%, #159AAA 100%);
  color: white;
}
.result-card.coral {
  background: linear-gradient(135deg, #FB5C7A 0%, #D03055 100%);
  color: white;
}

.result-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}

.result-value {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  transition: all 0.2s;
  letter-spacing: -1px;
}

.result-label {
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.8;
  margin-top: 3px;
  line-height: 1.3;
}

.result-equiv {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  margin-top: 6px;
  background: rgba(255,255,255,0.25);
  padding: 3px 10px;
  border-radius: 20px;
  font-style: normal;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.result-card.bump {
  animation: bump 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* AMORT TOGGLE */
.amort-toggle-row { margin-top: 0; }
.amort-toggle-btn {
  width: 100%;
  background: white;
  border: 2px dashed #DDD6FE;
  border-radius: var(--radius);
  padding: 20px 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
}
.amort-toggle-btn:hover { background: #F5F3FF; }
.amort-chevron { font-size: 1.1rem; transition: transform 0.25s; }
.amort-chevron.open { transform: rotate(90deg); }

/* CARD PURPLE → BLEU pour amortissement */
.result-card.purple {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: white;
}

/* CARD CYAN → VERT pour CO₂ */
.result-card.cyan {
  background: linear-gradient(135deg, #4ADE80 0%, #16A34A 100%);
  color: white;
}

/* SHARE BUTTON */
.share-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--btn) 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 0.3px;
}
.share-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius) var(--radius) 16px 16px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 900;
  font-size: 1.1rem;
}
.modal-close {
  background: var(--border);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 900;
}

.param-group { display: flex; flex-direction: column; gap: 8px; }
.param-group label { font-weight: 800; font-size: 0.9rem; color: var(--primary-dark); }

select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.param-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.param-note input {
  width: 90px;
  padding: 4px 8px;
  border: 2px solid var(--btn);
  border-radius: 8px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  text-align: center;
}

.param-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
}
.param-slider-row span:last-child {
  font-weight: 800;
  font-size: 0.85rem;
  min-width: 100px;
  text-align: right;
}

.modal-actions {
  display: flex;
  gap: 10px;
}
.btn-reset {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: white;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  cursor: pointer;
  color: var(--text-secondary);
}
.btn-apply {
  flex: 2;
  padding: 12px;
  border: none;
  border-radius: 14px;
  background: var(--btn);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--btn-dark);
}

/* SEO HEADER */
.seo-header {
  text-align: center;
  padding: 0 4px;
}
.seo-header h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.3;
  margin-bottom: 6px;
  text-align: center;
}
.seo-header p {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* SEO CONTENT & FAQ */
.seo-content, .faq {
  padding: 4px 8px;
}

.credit-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
}
.seo-content h2, .faq h2 {
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--primary-dark);
  margin: 14px 0 4px;
}
.seo-content h3, .faq h3 {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text);
  margin: 10px 0 3px;
}
.seo-content p, .faq p {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* CREDIT */
.credit {
  text-align: center;
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.credit a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 800;
}
.credit a:hover { opacity: 0.75; }

/* TOAST */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 0.95rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* RESPONSIVE */
@media (max-width: 480px) {
  header { padding: 12px 16px; }
  .ninja-badge {
    gap: 7px;
    padding: 5px 12px 5px 5px;
    border-radius: 22px;
  }
  .ninja-avatar {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }
  .ninja-name { font-size: 0.85rem; }
  .ninja-level { font-size: 0.6rem; }
  .logo { font-size: 0.9rem; }
  .result-value { font-size: 1.8rem; }
}
