/* Dad Joke Maker 3000 — warm, cozy, dad-cardigan aesthetic. */

:root {
  --bg: #f6f1e7;
  --card: #fffdf8;
  --ink: #2d2a26;
  --muted: #7a736a;
  --accent: #e07a3f;
  --accent-dark: #b95c28;
  --accent-soft: #fbe9dc;
  --line: #e8dfd0;
  --good: #3f8f5f;
  --meh: #d9a13b;
  --bad: #cf5b4e;
  --shadow: 0 10px 30px rgba(61, 46, 30, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, #fdf3e3 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 30%, #f3e8d7 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ---------- hero ---------- */

.hero { text-align: center; margin-bottom: 28px; }

.hero-emoji { font-size: 64px; line-height: 1; margin-bottom: 10px; transition: transform 0.2s ease; }
.hero-emoji.spin { animation: wiggle 0.9s ease; }

@keyframes wiggle {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg) scale(1.1); }
  50% { transform: rotate(10deg) scale(1.15); }
  75% { transform: rotate(-6deg); }
  100% { transform: rotate(0deg); }
}

h1 {
  font-size: 40px;
  margin: 0 0 8px;
  letter-spacing: -0.5px;
}

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

.tagline { color: var(--muted); margin: 0; font-size: 15px; }

code {
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.9em;
  color: var(--accent-dark);
}

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

/* ---------- controls ---------- */

.row { display: flex; gap: 10px; flex-wrap: wrap; }

#topicInput {
  flex: 1 1 240px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#topicInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(224, 122, 63, 0.35);
}

.btn.primary:hover:not(:disabled) { box-shadow: 0 8px 20px rgba(224, 122, 63, 0.45); }

.btn.ghost {
  background: transparent;
  color: var(--accent-dark);
  border: 1.5px solid var(--line);
}

.btn.ghost:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }

.btn.small { padding: 7px 14px; font-size: 13px; }

.chips { margin-top: 12px; align-items: center; }

.chips .chip {
  font: inherit;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s ease;
}

.chips .chip:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }

.chips .chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- joke stage ---------- */

.placeholder { text-align: center; color: var(--muted); padding: 26px 10px; }
.placeholder-icon { font-size: 44px; display: block; margin-bottom: 8px; }

.joke-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.badge {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.icon-btn {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.12s ease;
}

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

.setup { font-size: 24px; font-weight: 700; margin: 6px 0 10px; }

.punchline {
  font-size: 22px;
  color: var(--accent-dark);
  font-weight: 600;
  margin: 4px 0 18px;
  animation: pop 0.35s ease;
}

@keyframes pop {
  0% { transform: scale(0.92); opacity: 0; }
  70% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

.joke-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.cursor {
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ---------- rating ---------- */

.rating { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 16px; }

.rating-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }

.rating-emoji { font-size: 42px; }

.rating-verdict { font-weight: 800; font-size: 18px; }
.rating-comment { color: var(--muted); font-size: 14px; }

.meter {
  position: relative;
  height: 26px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bad) 0%, var(--meh) 55%, var(--good) 100%);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.meter-score {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #3d2e1e;
}

.style-picker { display: flex; gap: 8px; flex-wrap: wrap; }

.style-chip[aria-checked="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ---------- history ---------- */

.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-head h2 { margin: 0; font-size: 20px; }

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

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.history-list li:last-child { border-bottom: none; }

.history-joke { font-size: 15px; }
.history-joke .setup-line { font-weight: 700; }
.history-joke .punchline-line { color: var(--accent-dark); }
.history-joke .topic-tag { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

.history-score {
  flex-shrink: 0;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.history-score.none { opacity: 0.4; }

.history-empty { color: var(--muted); text-align: center; padding: 16px 0; margin: 0; }

/* ---------- footer / toast ---------- */

.footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 30px; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
}

.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(12px); pointer-events: none; }

.hidden { display: none !important; }

@media (max-width: 560px) {
  h1 { font-size: 30px; }
  .setup { font-size: 20px; }
  .punchline { font-size: 18px; }
  .btn.primary { width: 100%; }
}
