/* Mood — daily emotional journal
 * Palette: lavender-pastel + dusty-rose
 * © אופיר ברנס (Ofir Baranes) 2026
 */

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg-1: #1a1432;
  --bg-2: #221a3f;
  --bg-3: #2d2354;
  --lav-100: #f5f3ff;
  --lav-200: #ede9fe;
  --lav-300: #ddd6fe;
  --lav-400: #c4b5fd;
  --lav-500: #a78bfa;
  --lav-600: #8b5cf6;
  --lav-700: #7c3aed;
  --rose-300: #fda4af;
  --rose-400: #fb7185;
  --pink-300: #fbcfe8;
  --gold: #fcd34d;
  --green: #86efac;
  --text-primary: #f5f3ff;
  --text-secondary: rgba(245,243,255,0.7);
  --text-muted: rgba(245,243,255,0.42);
  --surface: rgba(245,243,255,0.06);
  --surface-strong: rgba(245,243,255,0.10);
  --border: rgba(196,181,253,0.16);
  --border-strong: rgba(196,181,253,0.28);
  --shadow-glass: 0 30px 60px -25px rgba(26,20,50,0.65);
  --bezier: cubic-bezier(.34,1.56,.64,1);
  --bezier-soft: cubic-bezier(.4,0,.2,1);
}

html, body {
  background: var(--bg-1);
  color: var(--text-primary);
  font-family: 'Heebo', system-ui, sans-serif;
  font-weight: 400;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 700px 800px at 80% -10%, rgba(167,139,250,0.20), transparent 60%),
    radial-gradient(ellipse 500px 600px at -10% 60%, rgba(251,113,133,0.14), transparent 65%),
    radial-gradient(ellipse 800px 1000px at 50% 110%, rgba(124,58,237,0.18), transparent 70%),
    linear-gradient(180deg, #1a1432 0%, #221a3f 60%, #2d2354 110%);
  background-attachment: fixed;
  position: relative;
  padding-bottom: 60px;
}

/* Ambient orbs */
.ambient-bg {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb-blur {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.45;
}
.orb-blur.o1 { width: 420px; height: 420px; top: -120px; right: -120px; background: radial-gradient(circle, #a78bfa 0%, transparent 70%); animation: drift1 26s ease-in-out infinite; }
.orb-blur.o2 { width: 340px; height: 340px; bottom: 5%; left: -100px; background: radial-gradient(circle, #fda4af 0%, transparent 70%); opacity: 0.32; animation: drift2 32s ease-in-out infinite; }
.orb-blur.o3 { width: 260px; height: 260px; top: 40%; right: 30%; background: radial-gradient(circle, #c4b5fd 0%, transparent 70%); opacity: 0.28; animation: drift3 38s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-30px,40px) scale(1.1); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,-30px) scale(1.08); } }
@keyframes drift3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-25px,-35px) scale(1.12); } }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(26,20,50,0.85) 0%, rgba(26,20,50,0.55) 100%);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--lav-100);
  letter-spacing: -0.01em;
}
.mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--lav-400), var(--rose-400));
  color: var(--bg-1);
  box-shadow: 0 0 18px rgba(196,181,253,0.45);
}
.mark svg { width: 18px; height: 18px; }

.header-actions { display: flex; gap: 8px; }
.icon-btn, .install-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  border-radius: 12px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.2s var(--bezier-soft);
  backdrop-filter: blur(10px);
}
.icon-btn { padding: 7px 9px; font-size: 16px; }
.icon-btn:hover, .install-btn:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.install-btn {
  background: linear-gradient(135deg, var(--lav-400), var(--rose-400));
  border: none;
  color: var(--bg-1);
  font-weight: 600;
}

main {
  position: relative;
  z-index: 1;
  padding: 22px 18px;
  max-width: 720px;
  margin: 0 auto;
}
.hidden { display: none !important; }

/* ===== Hero ===== */
.hero {
  text-align: center;
  margin-bottom: 28px;
}
.hero-kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--lav-300);
  margin-bottom: 18px;
}
.hero-kicker span {
  color: var(--lav-100);
  font-weight: 600;
}

.face-stage {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 18px;
}
.big-face {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 18px 30px rgba(124,58,237,0.35));
  transition: filter 0.5s var(--bezier-soft);
}
.big-face.bounce {
  animation: face-bounce 0.6s var(--bezier);
}
@keyframes face-bounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.1) rotate(-3deg); }
  70% { transform: scale(0.96) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}
#mouth, #leftEye, #rightEye, #faceGrad stop {
  transition: all 0.6s var(--bezier);
}

.sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.sparkle {
  position: absolute;
  font-size: 18px;
  opacity: 0;
  animation: sparkle-out 1.6s ease-out forwards;
}
@keyframes sparkle-out {
  0% { opacity: 0; transform: translate(0,0) scale(0.4) rotate(0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx,40px),var(--ty,-40px)) scale(1.2) rotate(180deg); }
}

.mood-label {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: clamp(28px, 6vw, 38px);
  font-weight: 700;
  color: var(--lav-100);
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin-bottom: 4px;
}
.mood-time {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ===== Picker ===== */
.picker, .triggers, .note-section {
  margin-bottom: 22px;
}
.picker-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--lav-300);
  margin-bottom: 12px;
  padding-right: 4px;
}

.mood-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}
.mood-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--mb-grad, linear-gradient(180deg, transparent, transparent));
  opacity: 0;
  transition: opacity 0.3s;
}
.mood-btn:hover {
  transform: translateY(-3px);
  border-color: var(--mb-color, var(--lav-400));
  box-shadow: 0 10px 24px rgba(26,20,50,0.4);
}
.mood-btn:hover::before { opacity: 0.18; }
.mood-btn.selected {
  border-color: var(--mb-color, var(--lav-400));
  background: color-mix(in srgb, var(--mb-color, var(--lav-400)) 18%, transparent);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--mb-color, var(--lav-400)) 35%, transparent);
}
.mood-btn.selected::before { opacity: 0.25; }
.mood-btn.selected .mb-face { transform: scale(1.1); }
.mb-face {
  width: 36px;
  height: 36px;
  position: relative;
  z-index: 1;
  transition: transform 0.3s var(--bezier);
}
.mb-face svg { width: 100%; height: 100%; }
.mb-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
  letter-spacing: 0.02em;
}
.mood-btn.selected .mb-label { color: var(--lav-100); }

/* ===== Triggers ===== */
.trigger-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.trigger-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--bezier-soft);
}
.trigger-chip:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
  color: var(--lav-100);
}
.trigger-chip.active {
  background: linear-gradient(135deg, var(--lav-500), var(--rose-400));
  border-color: transparent;
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(167,139,250,0.4);
}
.tc-icon { font-size: 14px; }

/* ===== Note ===== */
.note-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--lav-100);
  font-family: 'Heebo', sans-serif;
  font-size: 14px;
  resize: vertical;
  transition: all 0.2s;
  text-align: right;
  direction: rtl;
  line-height: 1.55;
}
.note-input:focus {
  outline: none;
  border-color: var(--lav-400);
  background: var(--surface-strong);
}
.note-input::placeholder { color: var(--text-muted); }

/* ===== Save button ===== */
.btn-save {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--lav-500), var(--lav-700));
  border: none;
  border-radius: 18px;
  color: white;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
  box-shadow: 0 10px 28px rgba(124,58,237,0.4);
  margin-bottom: 28px;
  letter-spacing: 0.01em;
}
.btn-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(124,58,237,0.55);
}
.btn-save:active { transform: translateY(0); }
.btn-save:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-save.saved {
  background: linear-gradient(135deg, #86efac, #16a34a);
}

/* ===== Stats row ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 8px;
  text-align: center;
  transition: all 0.3s var(--bezier-soft);
}
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 26px;
  font-weight: 600;
  color: var(--lav-100);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  line-height: 1;
}
.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Chart ===== */
.chart-card {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-glass);
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
}
.chart-title {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--lav-100);
  letter-spacing: -0.015em;
}
.chart-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.chart-wrap {
  position: relative;
  margin-bottom: 14px;
}
.chart-svg {
  width: 100%;
  height: 160px;
  overflow: visible;
}
.chart-x-labels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}
.chart-legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-secondary);
}
.leg-item { display: inline-flex; align-items: center; gap: 5px; }
.leg-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(20,15,40,0.65);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: modal-fade 0.25s var(--bezier-soft);
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%;
  max-width: 540px;
  background: linear-gradient(180deg, #2a2050 0%, #1a1432 100%);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 20px 22px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  animation: modal-slide 0.4s var(--bezier);
  max-height: 88vh;
  overflow-y: auto;
}
@keyframes modal-slide {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.handle {
  width: 38px; height: 4px;
  background: var(--border-strong);
  border-radius: 4px;
  margin: 0 auto 16px;
}
.modal-card h3 {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  color: var(--lav-100);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}
.modal-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 14px;
}
.mark-big {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--lav-400), var(--rose-400));
  border-radius: 18px;
  color: var(--bg-1);
  margin: 4px auto 14px;
  box-shadow: 0 0 30px rgba(167,139,250,0.4);
}
.mark-big svg { width: 32px; height: 32px; }

.hist-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.hs-item {
  text-align: center;
  padding: 14px 6px;
  background: rgba(245,243,255,0.05);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.hs-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--lav-300);
  font-variant-numeric: tabular-nums;
}
.hs-label {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}
.hist-list::-webkit-scrollbar { width: 4px; }
.hist-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(245,243,255,0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.hist-mood-icon {
  width: 32px; height: 32px;
  flex-shrink: 0;
}
.hist-mood-icon svg { width: 100%; height: 100%; }
.hist-body { flex: 1; min-width: 0; }
.hist-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--lav-200);
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}
.hist-trigs {
  font-size: 11px;
  color: var(--text-muted);
}
.hist-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 13px 18px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
  border: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--lav-500), var(--lav-700));
  color: white;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(124,58,237,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(124,58,237,0.5); }
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--lav-100);
}
.btn-secondary:hover { background: var(--surface-strong); }
