/* Ocarina Tracker — your fairy: the corner button and the chat panel (js/fairy.js).
   Linked after styles.css; every colour is a sky token from there
   (html[data-sky="day|dusk|night"]), so all three skies are covered.
   Desktop: a small chat window in the bottom corner of a page that stays
   usable. Phones (767px and under): a full-height sheet. */

/* ---------------------------------------------------- the pixel fairy */
.fairy-sprite { display: block; width: 36px; height: 30px; }
.fairy-sprite__wing { fill: var(--blue); }
.fairy-sprite__glint { fill: var(--panel-hi); }
.fairy-sprite__body { fill: var(--green); }
.fairy-sprite__head { fill: var(--gold); }
.fairy-sprite__spark { fill: var(--accent); }

/* ------------------------------------------------------- corner button */
.fairy-btn {
  position: fixed; right: 16px; bottom: calc(16px + var(--nav-h)); z-index: 55;
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; padding: 0; cursor: pointer;
  background: var(--outer); border: 3px solid var(--border);
  box-shadow: 0 0 0 2px var(--outer), 4px 4px 0 2px var(--drop);
}
.fairy-btn:hover { filter: brightness(1.1); }
.fairy-btn:active { transform: translate(1px, 1px); }
.fairy-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.fairy-btn .fairy-sprite__wing { fill: var(--on-outer-blue); }
.fairy-btn .fairy-sprite__glint { fill: var(--on-outer); }
.fairy-btn .fairy-sprite__body { fill: var(--on-outer-green); }
.fairy-btn .fairy-sprite__head { fill: var(--on-outer-gold); }
.fairy-btn .fairy-sprite__spark { fill: var(--on-outer-accent); }
body.fairy-open .fairy-btn { display: none; }

/* --------------------------------------------------------------- panel */
.fairy-panel {
  position: fixed; right: 16px; bottom: calc(16px + var(--nav-h)); z-index: 64;
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 32px - var(--nav-h))); height: min(560px, calc(100dvh - 32px - var(--nav-h)));
  display: flex; flex-direction: column;
  background: var(--panel); color: var(--text); font-family: var(--body);
  border: 3px solid var(--border); box-shadow: 0 0 0 2px var(--outer), 6px 6px 0 2px var(--drop);
}
.fairy-panel[hidden] { display: none; }
.fairy-panel__head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 2px solid var(--dash); }
.fairy-panel__art { flex: none; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--current); border: 2px solid var(--accent); }
.fairy-panel__art .fairy-sprite { width: 30px; height: 25px; }
.fairy-panel__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.fairy-panel__titles p { margin: 0; }
.fairy-panel__title { font-size: 12px; line-height: 1.5; font-weight: 400; margin: 0; overflow-wrap: anywhere; }
.fairy-panel__title:focus { outline: none; }
.fairy-panel__title:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.fairy-panel__head .btn { flex: none; }
.fairy-panel__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; }
.fairy-panel__foot { padding: 10px 12px; border-top: 2px solid var(--dash); background: var(--current); }
.fairy-panel .btn:disabled { opacity: .5; cursor: default; filter: none; transform: none; }

/* -------------------------------------------------------- conversation */
.fairy-log { display: flex; flex-direction: column; gap: 10px; }
.fairy-msg { max-width: 92%; padding: 10px 12px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.fairy-msg p { margin: 0; }
.fairy-msg p + p { margin-top: 8px; }
.fairy-msg--you { align-self: flex-end; background: var(--outer); color: var(--on-outer); border: 2px solid var(--border); }
.fairy-msg--fairy { align-self: flex-start; background: var(--current); border: 2px solid var(--accent); }
.fairy-msg--note { align-self: stretch; max-width: none; background: var(--warn-bg); color: var(--warn-text); border: 2px dashed var(--warn); }
.fairy-msg--busy { font-family: var(--px); font-size: 10px; color: var(--accent-text); }
.fairy-msg__text { white-space: pre-wrap; }
.fairy-msg__src a { color: var(--accent-text); text-underline-offset: 3px; }
.fairy-msg__more, .fairy-msg__chips { margin-top: 10px; gap: 8px; flex-wrap: wrap; }
.fairy-msg p.fairy-msg__next { margin-top: 10px; }
/* "Ask your fairy" buttons on the page (fairyAsk in js/app.js) */
.fairy-ask-btn { white-space: normal; }
.fairy-msg .suggest { font-size: 14px; }
.fairy-check { padding: 10px 4px; }
.fairy-check p { padding: 0 8px 8px; }

/* ------------------------------------------------------------ ask form */
.fairy-ask__row { display: flex; gap: 8px; align-items: stretch; }
.fairy-ask__row input {
  flex: 1; min-width: 0; font-family: var(--body); font-size: 16px; color: var(--on-outer); background: var(--outer);
  border: 2px solid var(--border); padding: 9px 10px; border-radius: 0;
}
.fairy-ask__row input::placeholder { color: var(--on-outer-dim); opacity: 1; }
.fairy-ask__row input:disabled { opacity: .6; }
.fairy-ask__meta { margin: 8px 0 0; }
.fairy-ask__clear { font-size: 13px; padding: 4px 2px; }

/* ----------------------------------------------------------- naming step */
.fairy-naming { padding-top: 8px; }
.fairy-naming__art { align-self: center; display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; background: var(--current); border: 3px solid var(--accent); }
.fairy-naming__art .fairy-sprite { width: 72px; height: 60px; }
.fairy-naming__q { font-size: 11px; line-height: 1.6; color: var(--text); }
.fairy-naming p { margin: 0; }
.fairy-naming__err { color: var(--warn-text); }
.fairy-naming__err:empty { display: none; }

/* ------------------------------------------------ phones: full-height sheet */
@media (max-width: 767px) {
  .fairy-btn { right: 12px; bottom: calc(12px + var(--nav-h)); width: 52px; height: 52px; }
  .fairy-panel {
    top: 0; right: 0; left: 0; bottom: auto; width: auto; height: 100vh; height: 100dvh;
    border: 0; box-shadow: none;
  }
  .fairy-panel__head { padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px; }
  .fairy-panel__art { width: 48px; height: 48px; }
  .fairy-panel__art .fairy-sprite { width: 36px; height: 30px; }
  .fairy-panel__body { padding: 14px; }
  .fairy-panel__foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .fairy-panel .btn { min-height: 44px; }
  .fairy-ask__row input { min-height: 44px; }
  .fairy-ask__clear, .fairy-msg .suggest { min-height: 44px; }
  .fairy-msg__src a { display: inline-block; padding: 6px 0; }
  body.fairy-open { overflow: hidden; }
}

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: no-preference) {
  .fairy-btn .fairy-sprite { animation: fairy-bob 1.6s steps(2, jump-none) infinite; }
  @keyframes fairy-bob { from { transform: translateY(1px); } to { transform: translateY(-2px); } }
  .fairy-panel { animation: fairy-in .18s ease-out; }
  @keyframes fairy-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 767px) {
  @keyframes fairy-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
}
html.calm .fairy-btn .fairy-sprite, html.calm .fairy-panel { animation: none; }
