/* ═══════════════════════════════════════════════════════════════════════════
   Kōri — Le Compagnon Contre le Cortisol
   Wabi-sabi : doux, pastel, arrondi, apaisant
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --kori-bg:       #f7f5f0;
  --kori-surface:  #ffffff;
  --kori-border:   #e8e4dc;
  --kori-text:     #4a4642;
  --kori-muted:    #8a8480;
  --kori-blue:     #a8c8e8;
  --kori-blue-dk:  #7aaec8;
  --kori-green:    #a8d8b8;
  --kori-yellow:   #f0dea0;
  --kori-red:      #f0b0a0;
  --kori-radius:   18px;
  --kori-shadow:   0 2px 12px rgba(0,0,0,0.06);
}

/* ─── Layout ────────────────────────────────────────────────────────────── */
.kori-app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0 40px;
  background: var(--kori-bg);
  min-height: 100vh;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--kori-text);
}

/* ─── Hero / Mochi zone ─────────────────────────────────────────────────── */
.kori-hero {
  text-align: center;
  padding: 24px 16px 16px;
  position: relative;
}

.mochi-wrap {
  display: inline-block;
  width: 200px;
  height: 220px;
  margin: 0 auto;
}

.mochi-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.10));
}

/* Breathing animation */
@keyframes breathe {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  45%       { transform: scaleY(1.025) scaleX(0.985); }
}
.mochi-svg {
  animation: breathe 3.5s ease-in-out infinite;
  transform-origin: center bottom;
}

/* Stressed — rapid trembling */
@keyframes tremble {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-2px) rotate(-0.5deg); }
  40%       { transform: translateX(2px) rotate(0.5deg); }
  60%       { transform: translateX(-1px); }
  80%       { transform: translateX(1px); }
}
.mochi-stressed {
  animation: tremble 0.7s ease-in-out infinite;
}

/* Serene — slow gentle float */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}
.mochi-serene {
  animation: float 4s ease-in-out infinite;
}

/* Happy — small bounce */
@keyframes bounce {
  0%, 100% { transform: translateY(0) scaleY(1); }
  40%       { transform: translateY(-6px) scaleY(1.02); }
  70%       { transform: translateY(-2px); }
}
.mochi-happy {
  animation: bounce 2s ease-in-out infinite;
}

/* Phase label */
.phase-label {
  font-size: 0.85rem;
  color: var(--kori-muted);
  margin-top: 10px;
  letter-spacing: 0.02em;
}

/* Streak */
.streak-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e07030;
  min-height: 1.2em;
}

/* Reaction bubble */
.reaction-bubble {
  margin: 10px auto 0;
  max-width: 360px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}
.reaction-positive {
  background: #dff0e8;
  border: 1px solid #a8d8b8;
  color: #2a6a40;
}
.reaction-negative {
  background: #fce8e4;
  border: 1px solid #f0b0a0;
  color: #703028;
}

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

/* ─── Sections ───────────────────────────────────────────────────────────── */
.kori-section {
  margin: 12px 16px;
  background: var(--kori-surface);
  border: 1px solid var(--kori-border);
  border-radius: var(--kori-radius);
  padding: 16px;
  box-shadow: var(--kori-shadow);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--kori-text);
}

.section-sub {
  font-size: 0.78rem;
  color: var(--kori-muted);
  margin: 0 0 14px;
}

/* ─── Stats ─────────────────────────────────────────────────────────────── */
.stats-container {
  display: grid;
  gap: 10px;
}

.stat-item {
  display: grid;
  grid-template-columns: 130px 1fr 38px;
  align-items: center;
  gap: 8px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--kori-muted);
  white-space: nowrap;
}

.stat-bar-wrap {
  background: #f0ece4;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.stat-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.4s ease;
}

.stat-value {
  font-size: 0.78rem;
  color: var(--kori-muted);
  text-align: right;
}

/* ─── Action cards ──────────────────────────────────────────────────────── */
.algo-cards {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.action-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--kori-bg);
  border: 1.5px solid var(--kori-border);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  width: 100%;
  font-family: inherit;
  color: var(--kori-text);
}

.action-card:hover {
  border-color: var(--kori-blue-dk);
  box-shadow: 0 2px 10px rgba(100,160,200,0.18);
  transform: translateY(-1px);
}

.action-card:active {
  transform: translateY(0);
}

.card-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.card-content {
  flex: 1;
  min-width: 0;
}

.card-label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.card-reason {
  font-size: 0.78rem;
  color: var(--kori-muted);
  margin-bottom: 4px;
  font-style: italic;
}

.card-effect {
  font-size: 0.72rem;
  color: var(--kori-blue-dk);
}

/* ─── Free card ─────────────────────────────────────────────────────────── */
.free-card-wrap {
  margin-top: 4px;
}

.free-card {
  border-color: var(--kori-blue);
  background: #f0f7ff;
}

.free-card:hover {
  border-color: var(--kori-blue-dk);
}

.free-card textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--kori-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--kori-text);
  background: #fff;
  resize: vertical;
  margin: 6px 0;
  transition: border-color 0.2s;
}

.free-card textarea:focus {
  outline: none;
  border-color: var(--kori-blue-dk);
}

.btn-free-submit {
  background: var(--kori-blue);
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-free-submit:hover  { background: var(--kori-blue-dk); }
.btn-free-submit:active { transform: scale(0.97); }
.btn-free-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ─── Loader ────────────────────────────────────────────────────────────── */
.free-loader {
  text-align: center;
  font-size: 0.85rem;
  color: var(--kori-muted);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.loader-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--kori-blue);
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ─── History / Journal ─────────────────────────────────────────────────── */
.history-container {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.history-empty {
  font-size: 0.85rem;
  color: var(--kori-muted);
  text-align: center;
  padding: 16px 0;
  font-style: italic;
}

.history-entry {
  background: var(--kori-bg);
  border: 1px solid var(--kori-border);
  border-radius: 10px;
  padding: 8px 12px;
}

.history-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.history-icon   { font-size: 1rem; }
.history-label  { font-size: 0.82rem; font-weight: 600; flex: 1; }
.history-time   { font-size: 0.72rem; color: var(--kori-muted); white-space: nowrap; }

.history-message {
  font-size: 0.78rem;
  color: var(--kori-muted);
  font-style: italic;
  margin-top: 3px;
  line-height: 1.35;
}

/* ─── Footer options ────────────────────────────────────────────────────── */
.kori-footer-opts {
  text-align: center;
  padding: 24px 16px 8px;
}

.btn-reset {
  background: none;
  border: 1px solid var(--kori-border);
  border-radius: 99px;
  padding: 6px 16px;
  font-size: 0.75rem;
  color: var(--kori-muted);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}

.btn-reset:hover {
  border-color: var(--kori-red);
  color: #a04030;
}
