/* ===== 2min Journal — Styles ===== */

/* --- CSS Custom Properties (Light Mode) --- */
:root {
  --bg-primary: #FDF6EC;
  --bg-card: #FFFFFF;
  --bg-input: #FFF9F2;
  --bg-nav: #FFFFFF;
  --text-primary: #3D2C1E;
  --text-secondary: #7A6555;
  --text-muted: #A89585;
  --accent: #C4A882;
  --accent-hover: #B8976F;
  --accent-green: #8FA87A;
  --accent-pink: #D4A5A5;
  --accent-gold: #D4A55A;
  --border: #EDE4D8;
  --shadow: rgba(61, 44, 30, 0.08);
  --shadow-strong: rgba(61, 44, 30, 0.15);
  --streak-glow: rgba(212, 165, 90, 0.3);
  --done-bg: #C4A882;
  --done-text: #FFFFFF;
  --toggle-bg: #EDE4D8;
  --toggle-active: #8FA87A;
  --overlay: rgba(61, 44, 30, 0.5);
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --bg-primary: #1E1B18;
  --bg-card: #2A2520;
  --bg-input: #332E28;
  --bg-nav: #252220;
  --text-primary: #F0E6D8;
  --text-secondary: #B8A898;
  --text-muted: #8A7A6A;
  --accent: #D4A55A;
  --accent-hover: #C4953A;
  --accent-green: #7A9A6A;
  --accent-pink: #B87878;
  --accent-gold: #D4A55A;
  --border: #3D3530;
  --shadow: rgba(0, 0, 0, 0.2);
  --shadow-strong: rgba(0, 0, 0, 0.4);
  --streak-glow: rgba(212, 165, 90, 0.2);
  --done-bg: #D4A55A;
  --done-text: #1E1B18;
  --toggle-bg: #3D3530;
  --toggle-active: #7A9A6A;
  --overlay: rgba(0, 0, 0, 0.7);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Patrick Hand', cursive;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

/* Subtle paper texture */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  z-index: 0;
}

/* --- App Container --- */
.app-container {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 5rem;
  z-index: 1;
}

/* --- Views --- */
.view {
  display: none;
  padding: 1.5rem 1.25rem;
  padding-top: env(safe-area-inset-top, 1.5rem);
  animation: fadeIn 150ms ease-out;
}

.view.active {
  display: block;
}

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

/* --- Typography --- */
h1 {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 2rem;
  color: var(--text-primary);
}

h2 {
  font-family: 'Caveat', cursive;
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.section-label {
  font-family: 'Caveat', cursive;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* --- Today View --- */
.today-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.today-date {
  font-size: 1.6rem;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.4rem 0.8rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.streak-badge.milestone {
  animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 2px 8px var(--shadow); }
  50% { box-shadow: 0 2px 16px var(--streak-glow); }
}

.streak-flame {
  font-size: 1.1rem;
}

.streak-count {
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* --- Sections --- */
.section {
  margin-bottom: 2rem;
}

/* --- Affirmation Card --- */
.affirmation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem 1.25rem;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
  position: relative;
  overflow: hidden;
}

.affirmation-card::before {
  content: '✦';
  position: absolute;
  top: 0.5rem;
  left: 1rem;
  font-size: 0.9rem;
  color: var(--accent);
  opacity: 0.5;
}

.affirmation-card::after {
  content: '✦';
  position: absolute;
  bottom: 0.5rem;
  right: 1rem;
  font-size: 0.9rem;
  color: var(--accent);
  opacity: 0.5;
}

.affirmation-text {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  font-style: italic;
}

/* --- Mood Selector --- */
.mood-selector {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.mood-btn {
  flex: 1;
  font-size: 1.8rem;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 150ms ease;
  min-height: 3.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mood-btn:active {
  transform: scale(0.93);
}

.mood-btn.selected {
  border-color: var(--accent);
  background: var(--bg-input);
  animation: moodBounce 300ms ease;
}

@keyframes moodBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* --- Prompt Card --- */
.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.prompt-category {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

.prompt-text {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}

.btn-skip {
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 0.75rem;
  padding: 0.3rem 0;
  transition: color 150ms ease;
}

.btn-skip:hover,
.btn-skip:active {
  color: var(--accent);
}

/* --- Journal Input --- */
.journal-input {
  width: 100%;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  resize: none;
  overflow: hidden;
  min-height: 5rem;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.journal-input::placeholder {
  color: var(--text-muted);
}

.journal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 168, 130, 0.15);
}

/* --- Habit List (Today) --- */
.habit-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.habit-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all 150ms ease;
  min-height: 3.2rem;
}

.habit-item:active {
  transform: scale(0.96);
}

.habit-item.checked {
  border-color: var(--accent-green);
  background: rgba(143, 168, 122, 0.08);
}

.habit-checkbox {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 200ms ease;
}

.habit-item.checked .habit-checkbox {
  border-color: var(--accent-green);
  background: var(--accent-green);
}

.habit-checkbox::after {
  content: '✓';
  font-size: 0.85rem;
  color: white;
  opacity: 0;
  transform: scale(0);
  transition: all 200ms ease;
}

.habit-item.checked .habit-checkbox::after {
  opacity: 1;
  transform: scale(1);
  animation: checkPop 300ms ease;
}

@keyframes checkPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.habit-emoji {
  font-size: 1.3rem;
}

.habit-name {
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* --- Done Button --- */
.done-section {
  padding-top: 0.5rem;
  padding-bottom: 2rem;
}

.btn-done {
  width: 100%;
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--done-text);
  background: var(--done-bg);
  border: none;
  border-radius: 1rem;
  padding: 1rem;
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 4px 12px var(--shadow-strong);
  min-height: 3.5rem;
}

.btn-done:active:not(:disabled) {
  transform: scale(0.96);
}

.btn-done:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-done:not(:disabled):hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px var(--shadow-strong);
}

/* --- Celebration Animation --- */
.celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.sparkle {
  position: absolute;
  font-size: 1.5rem;
  animation: sparkleFloat 1.5s ease-out forwards;
}

@keyframes sparkleFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.5); }
}

/* --- History View --- */
.view-header {
  margin-bottom: 1.5rem;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.calendar-month {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  font-weight: 600;
}

.btn-nav {
  font-size: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.btn-nav:active {
  transform: scale(0.93);
  background: var(--bg-input);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  margin-bottom: 1.5rem;
}

.calendar-day-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  padding: 0.3rem;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0.6rem;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  position: relative;
}

.calendar-day:active {
  transform: scale(0.9);
}

.calendar-day.today {
  font-weight: 600;
  color: var(--accent);
}

.calendar-day.completed::after {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  position: absolute;
  bottom: 3px;
}

.calendar-day.selected {
  background: var(--accent);
  color: var(--done-text);
}

.calendar-day.selected::after {
  background: var(--done-text);
}

.calendar-day.empty {
  cursor: default;
}

/* Entry Detail */
.entry-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  display: none;
  animation: fadeIn 150ms ease-out;
}

.entry-detail.visible {
  display: block;
}

.entry-date {
  font-family: 'Caveat', cursive;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.entry-mood {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.entry-prompt {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-style: italic;
}

.entry-response {
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.entry-habits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.entry-habit-tag {
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.3rem 0.7rem;
}

.entry-habit-tag.done {
  border-color: var(--accent-green);
  background: rgba(143, 168, 122, 0.1);
}

.entry-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 1.1rem;
}

/* --- Habits Settings View --- */
.habits-info {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.habits-manage-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.habit-manage-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
}

.habit-manage-item .habit-emoji {
  font-size: 1.3rem;
}

.habit-manage-item .habit-name {
  flex: 1;
  font-size: 1.05rem;
}

.toggle-switch {
  width: 3rem;
  height: 1.7rem;
  border-radius: 1rem;
  background: var(--toggle-bg);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 200ms ease;
  flex-shrink: 0;
}

.toggle-switch.active {
  background: var(--toggle-active);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: white;
  transition: transform 200ms ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch.active .toggle-knob {
  transform: translateX(1.3rem);
}

.btn-delete-habit {
  font-size: 1.1rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.btn-delete-habit:hover {
  color: var(--accent-pink);
  background: rgba(212, 165, 165, 0.1);
}

/* Add Habit Form */
.add-habit-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
}

.add-habit-form h2 {
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.form-row input {
  flex: 1;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 200ms ease;
}

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

.btn-emoji-pick {
  width: 3rem;
  height: 3rem;
  font-size: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-input);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.btn-emoji-pick:active {
  transform: scale(0.93);
}

.btn-add-habit {
  width: 100%;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 2px solid var(--accent);
  border-radius: 0.75rem;
  padding: 0.7rem;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn-add-habit:active {
  transform: scale(0.96);
  background: rgba(196, 168, 130, 0.1);
}

/* --- Settings View --- */
.settings-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 1rem 1.25rem;
}

.setting-label {
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  z-index: 100;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 150ms ease;
  min-height: 3rem;
}

.nav-tab.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

.nav-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- Onboarding Overlay --- */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
  overflow-y: auto;
}

.onboarding-overlay[hidden] {
  display: none;
}

.onboarding-card {
  background: var(--bg-card);
  border-radius: 1.5rem;
  padding: 2rem 1.5rem;
  max-width: 360px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  text-align: center;
  animation: fadeIn 300ms ease-out;
}

.onboarding-card h1 {
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.app-name {
  color: var(--accent);
}

.onboarding-card p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.4;
  flex-shrink: 0;
}

.onboarding-habits {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  text-align: left;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.onboarding-habit {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;
}

.onboarding-habit:active {
  transform: scale(0.96);
}

.onboarding-habit.selected {
  border-color: var(--accent-green);
  background: rgba(143, 168, 122, 0.08);
}

.onboarding-habit .habit-checkbox {
  width: 1.3rem;
  height: 1.3rem;
}

.onboarding-habit.selected .habit-checkbox {
  border-color: var(--accent-green);
  background: var(--accent-green);
}

.onboarding-habit.selected .habit-checkbox::after {
  opacity: 1;
  transform: scale(1);
}

.btn-start {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 1rem;
  width: 100%;
  position: sticky;
  bottom: 0;
}

/* Ensure btn-start is never disabled */
.btn-start:disabled {
  opacity: 1;
  cursor: pointer;
}

/* --- Emoji Picker (Simple) --- */
.emoji-picker {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.75rem;
  box-shadow: 0 4px 16px var(--shadow-strong);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.3rem;
  z-index: 50;
  animation: fadeIn 150ms ease-out;
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-option {
  font-size: 1.4rem;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: none;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease;
}

.emoji-option:hover {
  background: var(--bg-input);
}

.emoji-option:active {
  transform: scale(0.9);
}

/* --- Utility --- */
.hidden {
  display: none !important;
}
