/* Choredinate — "Forest Quest" theme
   Warm, playful, nature-inspired gamification aesthetic.
   Fredoka headings × DM Sans body. Teal + gold palette. */

:root {
  /* Teal — earthy, fresh, adventurous */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;

  /* Amber — treasure, rewards, warmth */
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;

  /* Rose — alerts, energy, delete actions */
  --rose-50: #fff1f2;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;

  /* Emerald — success, completion */
  --emerald-50: #ecfdf5;
  --emerald-500: #10b981;
  --emerald-600: #059669;

  /* Stone — warm neutrals */
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-800: #292524;
  --stone-900: #1c1917;

  /* Semantic aliases */
  --color-primary: var(--teal-600);
  --color-primary-dark: var(--teal-700);
  --color-primary-light: var(--teal-50);
  --color-accent: var(--amber-500);
  --color-accent-dark: var(--amber-600);
  --color-accent-light: var(--amber-50);
  --color-bg: #faf9f7;
  --color-surface: #ffffff;
  --color-text: var(--stone-900);
  --color-text-muted: var(--stone-500);
  --color-border: var(--stone-200);
  --color-success: var(--emerald-500);
  --color-danger: var(--rose-500);

  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 100px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.09);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);

  --font-display: "Fredoka", "Nunito", sans-serif;
  --font-body: "DM Sans", "Segoe UI", sans-serif;
}

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

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

body {
  font-family: var(--font-body);
  line-height: 1.65;
  color: var(--color-text);
  background:
    var(--color-bg)
    url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23e7e5e4' fill-opacity='0.5'/%3E%3C/svg%3E");
  min-height: 100dvh;
}

/* ─── Header ─── */
header {
  background: linear-gradient(135deg, var(--teal-700) 0%, var(--teal-600) 60%, var(--teal-500) 100%);
  color: white;
  padding: 0.7rem 1.15rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  box-shadow:
    0 2px 12px rgba(13, 148, 136, 0.3),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

header h1 a {
  color: white;
  text-decoration: none;
  transition: opacity var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.logo {
  width: 32px;
  height: 32px;
  display: inline-block;
}

header h1 a:hover { opacity: 0.85; color: white; text-decoration: none; }

header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.88rem;
}

/* Icon system */
.icon {
  width: 1.05em;
  height: 1.05em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

.icon-lg { width: 1.25em; height: 1.25em; }
.icon-sm { width: 0.95em; height: 0.95em; }
.icon-left { margin-right: 0.35rem; }
.icon-right { margin-left: 0.35rem; }

header nav a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  padding: 0.32rem 0.7rem;
  border-radius: var(--radius-pill);
  transition: all var(--transition);
  font-weight: 500;
}

header nav a:hover {
  background: rgba(255, 255, 255, 0.16);
  color: white;
  text-decoration: none;
}

header nav span {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.82rem;
  padding: 0.25rem 0.6rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  font-weight: 500;
  letter-spacing: 0.01em;
}

header nav button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  transition: all var(--transition);
}

header nav button:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
}

header nav form { margin-bottom: auto; }

/* ─── Main ─── */
main {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.15rem;
  animation: pageIn 0.35s ease-out;
}

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

/* ─── Typography ─── */
h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  font-weight: 600;
  color: var(--teal-900);
  margin-bottom: 0.7rem;
}

h1 { font-size: 1.65rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p {
  margin-bottom: 0.85rem;
  color: var(--stone-800);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* Error text */
.error {
  color: var(--rose-600);
  background: var(--rose-50);
  border: 1px solid var(--rose-500);
  border-left: 4px solid var(--rose-500);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  font-weight: 500;
  margin-bottom: 1rem;
}

/* ─── In-page navigation ─── */
main > nav,
nav[style] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  background: var(--color-surface);
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}

main > nav a,
nav[style] a {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  transition: all var(--transition);
  font-weight: 500;
  white-space: nowrap;
}

main > nav a:hover,
nav[style] a:hover {
  background: var(--teal-50);
  color: var(--teal-700);
  text-decoration: none;
}

/* ─── Cards / List items ─── */
ul, ol {
  padding-left: 0;
  list-style: none;
}

li {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-left: 4px solid var(--teal-500);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.65rem;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}

li:hover {
  box-shadow: var(--shadow-sm);
  border-left-color: var(--teal-600);
  transform: translateX(2px);
}

li:nth-child(even) {
  border-left-color: var(--amber-400);
}

li:nth-child(even):hover {
  border-left-color: var(--amber-500);
}

li strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--teal-800);
}

li small {
  color: var(--color-text-muted);
  font-size: 0.86rem;
}

/* Stagger list items */
li { animation: cardIn 0.3s ease-out both; }
li:nth-child(1) { animation-delay: 0.03s; }
li:nth-child(2) { animation-delay: 0.06s; }
li:nth-child(3) { animation-delay: 0.09s; }
li:nth-child(4) { animation-delay: 0.12s; }
li:nth-child(5) { animation-delay: 0.15s; }
li:nth-child(6) { animation-delay: 0.18s; }
li:nth-child(7) { animation-delay: 0.21s; }
li:nth-child(8) { animation-delay: 0.24s; }

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

/* ─── Forms ─── */
form { margin-bottom: 1rem; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--teal-800);
  font-family: var(--font-display);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  display: block;
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

fieldset {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin: 0.9rem 0;
  background: var(--color-surface);
}

fieldset legend {
  font-family: var(--font-display);
  font-weight: 600;
  padding: 0 0.4rem;
  font-size: 0.92rem;
  color: var(--teal-700);
}

input[type="checkbox"] {
  margin-right: 0.4rem;
  accent-color: var(--color-primary);
  width: 1.15em;
  height: 1.15em;
}

/* ─── Buttons ─── */
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.15rem;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  background: linear-gradient(135deg, var(--teal-600), var(--teal-500));
  color: white;
  transition: all var(--transition);
  min-height: 44px;
  min-width: 44px;
  margin-top: 12px;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.2);
  position: relative;
  overflow: hidden;
}

button:hover,
input[type="submit"]:hover {
  background: linear-gradient(135deg, var(--teal-700), var(--teal-600));
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
  transform: translateY(-1px);
}

button:active,
input[type="submit"]:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-xs);
}

/* Inline/card buttons — smaller */
form[style*="display:inline"] button,
li button {
  padding: 0.28rem 0.65rem;
  font-size: 0.8rem;
  min-height: 32px;
  margin: 0.2rem 0.2rem 0.2rem 0;
  border-radius: var(--radius-pill);
}

form[style*="display:inline"] {
  margin: 0;
}

/* ✅ Complete button — golden accent */
li form:first-of-type button {
  background: linear-gradient(135deg, var(--amber-500), var(--amber-400));
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

li form:first-of-type button:hover {
  background: linear-gradient(135deg, var(--amber-600), var(--amber-500));
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

/* 🗑️ Delete button — ghost with rose (only for confirm-gated destructive actions) */
li button[hx-confirm] {
  background: transparent;
  color: var(--rose-500);
  border: 1.5px solid var(--stone-300);
  box-shadow: none;
}

li button[hx-confirm]:hover {
  background: var(--rose-50);
  border-color: var(--rose-500);
  box-shadow: none;
  transform: none;
}

/* ─── Tables ─── */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  border: 1.5px solid var(--color-border);
}

th, td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: linear-gradient(135deg, var(--teal-700), var(--teal-600));
  color: white;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
}

tr:last-child td { border-bottom: none; }

tr:nth-child(even) td {
  background: var(--teal-50);
}

tr:hover td {
  background: var(--teal-100);
}

/* Leaderboard rank column — golden highlight */
td:first-child {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--amber-600);
  font-size: 1.05rem;
}

/* Points column — bold */
td:last-child {
  font-weight: 700;
  color: var(--teal-700);
}

/* ─── Definition lists (dashboard stats) ─── */
dl {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 1.5rem;
}

dt {
  font-family: var(--font-display);
  font-weight: 500;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--stone-500);
  grid-column: auto;
}

dt:first-child,
dt:nth-child(2) {
  margin-top: 0;
}

dd {
  margin-left: 0;
  margin-bottom: 0.65rem;
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--teal-800);
}

/* Golden accent for the first stat (points balance) */
dd:first-of-type {
  color: var(--amber-600);
}

/* ─── Status badges ─── */
.status {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--amber-100);
  color: var(--amber-700);
}

.reward-message {
  margin-top: 0.35rem;
}

/* ─── Invite code ─── */
main p > strong:only-child {
  display: inline-block;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  background: var(--amber-50);
  color: var(--amber-700);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  border: 2px dashed var(--amber-400);
}

/* ─── Points display ─── */
li strong + span,
li strong ~ span[title] {
  font-weight: 600;
}

/* ─── HTMX loading ─── */
.htmx-request {
  opacity: 0.55;
  transition: opacity 0.35s;
}

.htmx-settling { opacity: 1; }

/* ─── Responsive ─── */
@media (min-width: 640px) {
  main { padding: 2.5rem 1.5rem; }
  h1 { font-size: 1.95rem; }
  h2 { font-size: 1.6rem; }
  header { padding: 0.8rem 1.5rem; }
}

@media (max-width: 480px) {
  dl {
    grid-template-columns: 1fr;
  }
}

@media print {
  header { display: none; }
  main { padding: 0; max-width: none; }
  body { background: white; }
}
