/* ===========================
   Daily Wins - styles
   Base tone matches tokens.css (Terracotta & Cream);
   accent overridden to violet for the small-celebration theme.
   =========================== */

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

:root {
  color-scheme: light;

  /* Base tone (from tokens.css) */
  --bg: #FAF4EC;
  --card: #FFFFFF;
  --border: #EDE2D4;
  --divider: #F4EBDF;
  --ink: #3D3229;
  --text-2: #6B5F51;
  --muted: #8C7F70;
  --faint: #B5A794;
  --error: #C0392B;
  --error-tint: rgba(192, 57, 43, 0.08);
  --success: #2E9E54;
  --success-tint: #F0FAF3;

  /* Accent overridden to violet for this app */
  --accent: #8E5FD9;
  --accent-hover: #6F3FB8;
  --accent-tint: #F1E9FB;
  --accent-line: #D9C5F0;

  --radius-card: 20px;
  --radius-input: 12px;
  --radius-pill: 999px;
  --shadow-card: 0 2px 10px rgba(60, 40, 20, 0.06);
  --focus-ring: 0 0 0 3px rgba(142, 95, 217, 0.15);

  --font: "Nunito", sans-serif;
}

body {
  font-family: var(--font);
  margin: 0;
  padding: 40px 20px;
  background-color: var(--bg);
  color: var(--ink);
}

header, main {
  max-width: 680px;
  margin: 0 auto;
}

header {
  margin-bottom: 40px;
}

h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 8px;
}

.title-icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
  flex-shrink: 0;
}

.title-accent {
  color: var(--accent);
}

header p {
  color: var(--text-2);
  font-size: 14px;
  margin: 0;
}

h2.card-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--ink);
  background: var(--card);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.btn {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color 150ms ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-row {
  position: relative;
  display: inline-flex;
  align-self: flex-start;
}

.confetti-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.confetti-burst .spark {
  position: absolute;
  top: 0;
  left: 0;
  font-style: normal;
  font-size: 15px;
  line-height: 1;
  color: var(--accent);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
}

.confetti-burst.is-active .spark {
  animation: sparkFly 650ms ease-out forwards;
}

.confetti-burst .spark:nth-child(1) { --tx: -34px; --ty: -26px; --rot: -35deg; animation-delay: 0ms; }
.confetti-burst .spark:nth-child(2) { --tx: 4px;   --ty: -42px; --rot: 10deg;  animation-delay: 20ms; }
.confetti-burst .spark:nth-child(3) { --tx: 40px;  --ty: -20px; --rot: 45deg;  animation-delay: 40ms; }
.confetti-burst .spark:nth-child(4) { --tx: -40px; --ty: 14px;  --rot: -55deg; animation-delay: 60ms; }
.confetti-burst .spark:nth-child(5) { --tx: 0px;   --ty: 40px;  --rot: 20deg;  animation-delay: 30ms; }
.confetti-burst .spark:nth-child(6) { --tx: 38px;  --ty: 18px;  --rot: 60deg;  animation-delay: 50ms; }

@keyframes sparkFly {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(var(--rot));
  }
}

.form-error {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--error);
  min-height: 1em;
}

.today-badge[hidden] {
  display: none;
}

.today-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-hover);
  background: var(--accent-tint);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  margin: 14px 0 0;
  width: fit-content;
}

#win-section {
  margin-bottom: 40px;
}

.day-group {
  margin-bottom: 24px;
}

.day-heading {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  margin: 0 0 10px;
}

.win-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.win-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 14px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 10px;
  border-left: 4px solid var(--accent);
}

.win-entry.is-new {
  animation: winPop 500ms ease;
}

@keyframes winPop {
  0% {
    transform: scale(0.94);
    box-shadow: 0 0 0 0 rgba(142, 95, 217, 0.35);
  }
  50% {
    transform: scale(1.015);
    box-shadow: 0 0 0 6px rgba(142, 95, 217, 0.12);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 2px 10px rgba(60, 40, 20, 0.06);
  }
}

.win-text {
  font-size: 14px;
  word-break: break-word;
}

.win-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.win-time {
  font-size: 12px;
  color: var(--faint);
  white-space: nowrap;
}

.win-delete {
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
  border-radius: 50%;
}

.win-delete:hover {
  color: var(--error);
  background: var(--error-tint);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 32px 16px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

@media (max-width: 480px) {
  .btn-primary {
    align-self: stretch;
  }

  .win-entry {
    flex-wrap: wrap;
  }
}
