/* ============================================================
   Leaffall v0.1 — vanilla CSS, no dependencies, no fonts, no images
   ============================================================ */

:root {
  --bg: #f3ead8;
  --bg-soft: #eadfc6;
  --paper: #fffdf6;
  --ink: #2b2620;
  --ink-soft: #6b6152;
  --green: #1c2b21;
  --amber: #a8661f;
  --amber-bright: rgba(232, 165, 75, 0.35);
  --on-amber: #241505;
  --line: #d9c9a6;
  --shadow: 0 10px 30px rgba(28, 43, 33, 0.12);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131a15;
    --bg-soft: #1b241d;
    --paper: #171f19;
    --ink: #ece3cf;
    --ink-soft: #a99f8a;
    --green: #0d1310;
    --amber: #e8a54b;
    --amber-bright: rgba(232, 165, 75, 0.25);
    --on-amber: #241505;
    --line: #3a4636;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--amber-bright), transparent 60%),
    var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 48px 20px 64px; }

/* ---- hero ---- */
.hero { text-align: center; margin-bottom: 36px; }

.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--amber);
  margin: 0 0 10px;
}

h1 {
  font-size: clamp(2rem, 6vw, 2.9rem);
  font-weight: normal;
  font-style: italic;
  line-height: 1.15;
  margin: 0 0 12px;
}

.hero-sub { color: var(--ink-soft); margin: 0; }

/* ---- the door (arched chat panel) ---- */
.door {
  background: var(--card, var(--paper));
  border: 2px solid var(--green);
  border-radius: 300px 300px var(--radius) var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 6px var(--bg);
  padding: 44px 24px 24px;
}

:root { --card: var(--paper); }

.chatlog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 6px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  white-space: pre-line;
  font-size: 0.98rem;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bg-soft);
  border-radius: 14px 14px 14px 4px;
}

.msg.user {
  align-self: flex-end;
  background: var(--green);
  color: var(--bg);
  border-radius: 14px 14px 4px 14px;
  border: 1px solid var(--line);
}

/* typing indicator */
.typing { display: flex; gap: 5px; align-items: center; padding: 15px 16px; }

.typing .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: blink 1.2s infinite;
}
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40%           { opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  .typing .dot { animation: none; opacity: 0.6; }
  .chatlog { scroll-behavior: auto; }
}

/* ---- spell card: a note left on the mat ---- */
.card {
  align-self: flex-start;
  max-width: 95%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 20px 20px 16px;
  transform: rotate(-1deg);
  position: relative;
}

/* a strip of "tape" holding the note down */
.card::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 90px;
  height: 22px;
  transform: translateX(-50%) rotate(2deg);
  background: var(--amber-bright);
  border-left: 1px dashed var(--amber);
  border-right: 1px dashed var(--amber);
}

.card-tradition {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: var(--amber);
  margin: 0 0 6px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: normal;
  font-style: italic;
}

.card-blurb { margin: 0 0 6px; color: var(--ink-soft); font-size: 0.95rem; }

.card-label {
  margin: 14px 0 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

.card-list { margin: 0; padding-left: 20px; font-size: 0.95rem; }
.card-list li { margin: 4px 0; }

.card-safety {
  margin: 14px 0 0;
  font-size: 0.82rem;
  color: var(--amber);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

/* ---- chips + input ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 12px; }

.chip {
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: var(--amber); background: var(--amber-bright); }

.ask { display: flex; gap: 8px; }

.ask input {
  flex: 1;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
}
.ask input::placeholder { color: var(--ink-soft); }

.knock {
  font: inherit;
  font-size: 0.9rem;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: var(--green);
  color: var(--bg);
  cursor: pointer;
}
.knock:hover { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }

.ask input:focus-visible,
.chip:focus-visible,
.knock:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.ask input:disabled, .knock:disabled { opacity: 0.5; cursor: wait; }

/* ---- footer ---- */
.foot {
  margin-top: 32px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
}
.foot p { margin: 0; }

/* ---- a11y + small screens ---- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .door { border-radius: 160px 160px 16px 16px; padding: 32px 14px 16px; }
  .msg { max-width: 95%; }
  .card { max-width: 100%; }
}
