/* ============================================================
   Weekend Wins — Styles
   ============================================================ */

/* --- Custom Properties / Theme --- */
:root {
  --bg: #FAF6F0;
  --bg-card: #FFFFFF;
  --text: #2C2520;
  --text-muted: #9C8E82;
  --text-secondary: #6B5E53;
  --accent: #D4915C;
  --accent-light: #E8B87A;
  --accent-glow: rgba(212, 145, 92, 0.35);
  --danger: #C9544A;
  --danger-bg: rgba(201, 84, 74, 0.1);
  --border: rgba(44, 37, 32, 0.08);
  --shadow: rgba(44, 37, 32, 0.06);
  --input-bg: #FFFFFF;
  --particle-1: #D4915C;
  --particle-2: #E8B87A;
  --particle-3: #F0C97E;
  --particle-4: #E0A07A;
  --particle-5: #C17A4A;
  --radius: 16px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1917;
    --bg-card: #292524;
    --text: #F5F0EB;
    --text-muted: #8C7E72;
    --text-secondary: #B5A89E;
    --accent: #E8A96A;
    --accent-light: #F0C97E;
    --accent-glow: rgba(232, 169, 106, 0.3);
    --border: rgba(245, 240, 235, 0.08);
    --shadow: rgba(0, 0, 0, 0.2);
    --input-bg: #292524;
    --danger: #E06B62;
    --danger-bg: rgba(224, 107, 98, 0.15);
  }
}

/* --- Hidden attribute fix (prevents display overrides) --- */
[hidden] {
  display: none !important;
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

/* --- Header --- */
#header {
  padding: 20px 24px 12px;
  padding-top: max(20px, env(safe-area-inset-top, 20px));
  text-align: center;
  flex-shrink: 0;
}

.app-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.weekend-dates {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* --- Main Content --- */
#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 20px 0;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* --- Empty State --- */
#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 40px;
  animation: fadeIn 0.5s ease;
}

.empty-headline {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 12px;
}

.empty-subtext {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Task List --- */
#task-list {
  list-style: none;
  padding: 0;
}

/* --- Task Item --- */
.task-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px var(--shadow), 0 0 0 1px var(--border);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  will-change: transform, opacity;
}

.task-item:active {
  transform: scale(0.985);
}

/* --- Checkbox --- */
.task-checkbox {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.task-checkbox:hover {
  border-color: var(--accent-light);
  background: rgba(212, 145, 92, 0.08);
}

.task-checkbox svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0);
}

/* Checked state */
.task-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  animation: checkboxPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.task-checkbox.checked svg {
  opacity: 1;
  transform: scale(1);
  animation: checkmarkDraw 0.3s ease 0.1s both;
}

/* --- Task Text --- */
.task-text {
  font-size: 17px;
  line-height: 1.4;
  color: var(--text);
  flex: 1;
  word-break: break-word;
}

/* Glow effect on completion */
.task-item.completing .task-text {
  animation: textGlow 0.6s ease;
}

/* --- Delete Button (revealed on long-press) --- */
.task-delete-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
  opacity: 0;
  background: var(--danger-bg);
  color: var(--danger);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.task-item.delete-revealed .task-delete-btn {
  opacity: 1;
  transform: translateY(-50%) scale(1);
  pointer-events: auto;
}

.task-item.delete-revealed .task-text {
  opacity: 0.4;
}

/* --- Fly-Away Animation (The Money Feature) --- */
.task-item.flying-away {
  animation: taskFlyAway 0.65s cubic-bezier(0.32, 0, 0.67, 0) forwards;
  pointer-events: none;
}

.task-item.collapsing {
  animation: rowCollapse 0.35s ease forwards;
  pointer-events: none;
}

/* --- Delete Animation --- */
.task-item.deleting {
  animation: taskDelete 0.3s ease forwards;
  pointer-events: none;
}

.task-item.delete-collapsing {
  animation: rowCollapse 0.25s ease forwards;
  pointer-events: none;
}

/* --- Wrap-up clear animation --- */
.task-item.fading-out {
  animation: gentleFadeOut 0.5s ease forwards;
  pointer-events: none;
}

/* --- Overload Warning --- */
.overload-warning {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  padding: 8px 20px 16px;
  line-height: 1.5;
  animation: fadeIn 0.4s ease;
}

/* --- Input Bar / Footer --- */
#footer {
  flex-shrink: 0;
  padding: 12px 20px;
  padding-bottom: max(12px, calc(var(--safe-bottom) + 8px));
  background: var(--bg);
}

#input-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

#task-input {
  flex: 1;
  height: 50px;
  padding: 0 18px;
  background: var(--input-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  -webkit-appearance: none;
}

#task-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.8;
}

#task-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#task-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#add-btn {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#add-btn:hover {
  background: var(--accent-light);
}

#add-btn:active {
  transform: scale(0.92);
}

#add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.list-full-msg {
  text-align: center;
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 8px;
  animation: fadeIn 0.4s ease;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
}

.footer-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 2px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.footer-link:hover {
  color: var(--accent);
}

/* --- Overlays --- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  animation: fadeIn 0.3s ease;
}

.overlay[hidden] {
  display: none;
}

/* --- Onboarding --- */
.onboarding-step {
  max-width: 380px;
  text-align: center;
  animation: slideUp 0.4s ease;
}

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

.onboarding-icon {
  margin-bottom: 28px;
}

.onboarding-step h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

.onboarding-body {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.onboarding-body.muted {
  color: var(--text-muted);
  font-size: 15px;
}

.onboarding-actions {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Install instructions */
.install-instructions {
  text-align: left;
  margin: 20px 0;
}

.install-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.install-step-num {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.install-step p {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-secondary);
  padding-top: 4px;
}

.share-icon {
  display: inline-flex;
  vertical-align: middle;
  color: var(--accent);
}

.menu-icon {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

/* --- Buttons --- */
.btn-primary {
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-ghost {
  width: 100%;
  padding: 14px 24px;
  background: none;
  color: var(--text-muted);
  border: none;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.btn-ghost:hover {
  color: var(--text-secondary);
}

/* --- Wrap-Up --- */
.wrapup-content {
  max-width: 380px;
  text-align: center;
  animation: slideUp 0.4s ease;
}

.wrapup-emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

.wrapup-content h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

#wrapup-tasks {
  list-style: none;
  margin: 24px 0;
  text-align: left;
}

#wrapup-tasks .task-item {
  opacity: 0.6;
  background: var(--bg-card);
}

#wrapup-tasks .task-checkbox {
  border-color: var(--text-muted);
  opacity: 0.5;
}

.wrapup-end-content {
  text-align: center;
  animation: slideUp 0.4s ease;
}

.wrapup-end-emoji {
  font-size: 56px;
  margin-bottom: 16px;
}

.wrapup-end-content h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

/* --- Muted / Small text --- */
.muted {
  color: var(--text-muted);
}

.small {
  font-size: 14px;
}

/* --- Particle Container --- */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
}

.particle.star {
  border-radius: 0;
  font-size: 12px;
  line-height: 1;
  background: none !important;
}

/* ============================================================
   KEYFRAME ANIMATIONS
   ============================================================ */

/* --- Checkbox pop --- */
@keyframes checkboxPop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.3); }
  55%  { transform: scale(0.9); }
  75%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* --- Checkmark draw --- */
@keyframes checkmarkDraw {
  0%   { opacity: 0; transform: scale(0) rotate(-10deg); }
  50%  { opacity: 1; transform: scale(1.2) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* --- Text glow on completion --- */
@keyframes textGlow {
  0%   { color: var(--text); }
  30%  { color: var(--accent); text-shadow: 0 0 8px var(--accent-glow); }
  100% { color: var(--text); text-shadow: none; }
}

/* --- Task fly-away (THE MONEY ANIMATION) --- */
@keyframes taskFlyAway {
  0% {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1) rotate(0deg);
  }
  25% {
    opacity: 1;
    transform: translateX(0) translateY(-4px) scale(1.03) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateX(120px) translateY(-30px) scale(0.9) rotate(4deg);
  }
}

/* --- Row collapse after fly-away --- */
@keyframes rowCollapse {
  0%   { max-height: 80px; margin-bottom: 10px; padding-top: 16px; padding-bottom: 16px; opacity: 0; }
  100% { max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; opacity: 0; overflow: hidden; }
}

/* --- Task delete (red fade) --- */
@keyframes taskDelete {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.95); }
}

/* --- Gentle fade out (wrap-up clear) --- */
@keyframes gentleFadeOut {
  0%   { opacity: 0.6; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(8px); }
}

/* --- Particle burst --- */
@keyframes particleBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0) rotate(var(--rot));
  }
}

/* --- Sparkle twinkle (for star particles) --- */
@keyframes sparkleTwinkle {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  50%  { opacity: 1; transform: translate(calc(var(--tx) * 0.5), calc(var(--ty) * 0.5)) scale(1.3); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

/* --- Generic utils --- */
@keyframes fadeIn {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes slideUp {
  0%   { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes slideInTask {
  0%   { opacity: 0; transform: translateY(12px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* New task entrance */
.task-item.entering {
  animation: slideInTask 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* iPhone SE / small screens */
@media (max-height: 667px) {
  #header { padding: 14px 20px 8px; }
  .weekend-dates { font-size: 20px; }
  .task-item { padding: 14px 16px; margin-bottom: 8px; }
  #empty-state { padding: 40px 20px 30px; }
  .empty-headline { font-size: 20px; }
}

/* Tablet and up */
@media (min-width: 600px) {
  #app { padding: 0 20px; }
  .task-item { border-radius: var(--radius); }
}
