/* Karteczki — floating pixel-cat assistant with sticky notes.
   Self-contained: every selector is kz- prefixed so it can't collide with
   paper.css. Colours/radii/spacing come from the paper.css token set and the
   DESIGN.md scale — no invented values. Card tints are mixed INTO
   --paper-raised, so cards follow light/dark automatically and --ink stays
   readable on them in both themes. */

.kz-root {
  /* Per-target paper tints. Hues are DESIGN.md avatar colours:
     avatar-leo-bg (yellow) and avatar-konrad-bg (blue); "oboje" uses the
     existing neutral --ink-faint. Requested mapping: Leo żółty, Konrad
     niebieski, oboje szary. */
  --kz-leo: #f4c542;
  --kz-konrad: #3d5a8a;
  --kz-both: var(--ink-faint);
  --kz-shadow-1: 0 10px 26px color-mix(in srgb, var(--ink) 16%, transparent);
  --kz-shadow-2: 0 3px 7px color-mix(in srgb, var(--ink) 18%, transparent);
}

/* Warstwy z paper.css (--z-toast/--z-sheet). Otwarty panel i dymek to UI —
   stoją nad toastem. Sam kot to trwała ozdoba, nie komunikat: leży POD
   toastem, inaczej zasłania jego X i Cofnij. */
.kz-panel,
.kz-bubble { position: fixed; z-index: var(--z-sheet, 210); }
.kz-orb { position: fixed; z-index: calc(var(--z-toast, 100) - 1); }

/* ── orb (just the pet — no disc behind it) ── */
.kz-orb {
  width: 100px; height: 100px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; touch-action: none; user-select: none;
  transition: transform .15s;
  /* soft ground shadow so the pet doesn't look pasted, without a circle */
  filter: drop-shadow(0 4px 5px color-mix(in srgb, var(--ink) 22%, transparent));
}
.kz-orb:hover { transform: scale(1.05); }
.kz-orb.kz-dragging { cursor: grabbing; transform: scale(1.08); }
.kz-cat-img { display: block; image-rendering: auto; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.kz-orb .kz-cat-img { image-rendering: pixelated; }
.kz-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 19px; height: 19px; border-radius: 999px; padding: 0 4px;
  background: var(--sea); color: var(--paper-raised);
  font: 700 11px/19px ui-monospace, Menlo, monospace; text-align: center;
  box-shadow: var(--kz-shadow-2);
}
.kz-badge[hidden] { display: none; }

/* ── peek bubble (dymek) ── */
.kz-bubble {
  max-width: 210px; padding: 8px 12px;
  background: var(--navbg); color: var(--paper);
  font: 400 12.5px/1.35 system-ui, -apple-system, sans-serif;
  border-radius: 14px 14px 7px 14px;
  box-shadow: var(--kz-shadow-1);
  opacity: 0; transform: translateY(4px) scale(.96); pointer-events: none;
  transition: opacity .28s, transform .28s;
}
.kz-bubble::after {
  content: ""; position: absolute; bottom: -6px; right: 16px;
  width: 12px; height: 12px; background: var(--navbg);
  transform: rotate(45deg);
}
.kz-bubble.kz-show { opacity: 1; transform: translateY(0) scale(1); }
.kz-bubble b { color: var(--paper-raised); }

/* progress bar under the bubble — depletes over PEEK_SHOW ms */
@keyframes kz-bar-shrink { from { width: 100%; } to { width: 0%; } }
.kz-bubble-bar {
  position: absolute; bottom: 4px; left: 12px; width: calc(100% - 24px); height: 2px;
  background: var(--sea); border-radius: 1px; opacity: 0.55;
  animation: kz-bar-shrink 60s linear forwards;
}

/* ── panel ── */
.kz-panel {
  width: 320px; max-width: calc(100vw - 28px);
  background: var(--paper-raised); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--kz-shadow-1);
  transform-origin: bottom right;
  transition: opacity .18s, transform .18s;
}
.kz-panel[hidden] { display: none; }
.kz-panel.kz-closing { opacity: 0; transform: scale(.92); }
.kz-body {
  border-radius: 22px; overflow: hidden;
  display: flex; flex-direction: column; max-height: min(420px, 62vh);
}

.kz-head {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 8px; border-bottom: 1px solid var(--line);
}
/* Small companion in the top-left corner of the popup — fully inside the header
   so nothing is clipped by the panel's rounded top / overflow. */
.kz-head .kz-cat { position: absolute; top: 6px; left: 10px; line-height: 0; }
.kz-head .kz-cat-img { display: block; }
.kz-title {
  flex: 1; margin-left: 44px; color: var(--ink);
  font: 700 15px/1.2 "Iowan Old Style", Georgia, serif;
}
.kz-count { font: 400 11px ui-monospace, Menlo, monospace; color: var(--ink-soft); }
.kz-close, .kz-ask {
  border: 0; background: none; cursor: pointer; color: var(--ink-soft);
  font-size: 17px; line-height: 1; padding: 4px; border-radius: 7px;
}
.kz-ask { font-size: 15px; }
.kz-close:hover, .kz-ask:hover, .kz-ask:focus-visible {
  background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); outline: none;
}

/* the cat's spoken line, inline under the header (morning/evening/on-demand) */
.kz-said {
  margin: 10px 12px 0; padding: 9px 11px;
  background: color-mix(in srgb, var(--sea) 12%, var(--paper-raised));
  border: 1px solid color-mix(in srgb, var(--sea) 30%, transparent);
  border-radius: 14px 14px 14px 7px;
  font: 400 12.5px/1.4 system-ui, -apple-system, sans-serif; color: var(--ink);
}
.kz-said-bar {
  height: 2px; background: var(--sea); border-radius: 1px; opacity: 0.55;
  margin-top: 7px;
  animation: kz-bar-shrink 60s linear forwards;
}

/* B "Kot mówi": one column so longer notes fit without word-breaking. */
.kz-list {
  overflow-y: auto; padding: 14px 12px 6px;
  display: grid; grid-template-columns: 1fr; gap: 11px; align-content: start;
}
.kz-empty {
  text-align: center; padding: 16px 8px;
  font: 400 12px ui-monospace, Menlo, monospace; color: var(--ink-soft);
}

/* status chips under the header: Wrocław weather + tasks done today */
.kz-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.kz-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
  font: 400 10.5px ui-monospace, Menlo, monospace; color: var(--ink-soft);
  background: var(--paper);
}
.kz-chip b { color: var(--ink); font-weight: 600; }

/* ── a karteczka ── */
.kz-note {
  position: relative; padding: 9px 34px 10px 11px; /* right room for the ✕ */
  border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  border-radius: 7px 7px 14px 7px;
  box-shadow: var(--kz-shadow-2);
  /* dotted bullet-journal paper; both layers set inline per target in JS */
  background-repeat: repeat; background-size: 11px 11px;
  color: var(--ink);
}
/* ✕ pinned to the top-right corner of every note */
.kz-del {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px; border-radius: 7px; border: 0; cursor: pointer;
  display: grid; place-items: center; line-height: 1;
  background: color-mix(in srgb, var(--paper-raised) 70%, transparent);
  color: var(--ink-soft); font: 400 12px ui-monospace, Menlo, monospace;
  transition: background .15s, color .15s;
}
.kz-del:hover, .kz-del:focus-visible {
  background: #c0392b; color: #fff; outline: none;
}
.kz-text {
  font: 600 12.5px/1.34 system-ui, -apple-system, sans-serif;
  word-break: break-word; hyphens: auto; margin-bottom: 8px; white-space: pre-wrap;
  cursor: pointer; /* click to edit */
}
.kz-text[contenteditable="true"] {
  outline: 2px solid color-mix(in srgb, var(--ink) 40%, transparent);
  outline-offset: 2px; border-radius: 7px;
  background: color-mix(in srgb, var(--paper-raised) 60%, transparent);
}
.kz-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.kz-who {
  display: inline-flex; align-items: center; gap: 4px;
  font: 400 9.5px ui-monospace, Menlo, monospace; color: var(--ink-soft);
}
.kz-who i { width: 8px; height: 8px; border-radius: 999px; }

/* ── add zone (collapsed by default — the "always-on" form was the noise) ── */
.kz-addbar {
  padding: 8px 12px 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.kz-addtoggle {
  width: 100%; text-align: left; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: 14px; padding: 9px 10px;
  background: none; color: var(--ink-soft);
  font: 400 12.5px system-ui, -apple-system, sans-serif;
  transition: border-color .15s, color .15s;
}
.kz-addtoggle:hover, .kz-addtoggle:focus-visible,
.kz-addtoggle.kz-open { border-color: var(--sea); color: var(--sea); outline: none; }

.kz-add {
  border: 1.5px dashed var(--line); border-radius: 14px;
  display: flex; flex-direction: column; gap: 8px; padding: 8px;
}
.kz-add[hidden] { display: none; }
.kz-add input {
  width: 100%; font: 400 max(16px, 1rem) system-ui, sans-serif; /* 16px: no iOS zoom */
  padding: 8px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--paper); color: var(--ink);
}
.kz-seg-row { display: flex; gap: 4px; }
.kz-seg {
  flex: 1; cursor: pointer; padding: 4px 0; border-radius: 7px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  font: 400 9.5px ui-monospace, Menlo, monospace;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.kz-seg i { width: 8px; height: 8px; border-radius: 999px; }
.kz-seg.kz-on { border-color: var(--ink); color: var(--ink); }
.kz-go {
  border: 0; cursor: pointer; border-radius: 7px; padding: 8px;
  background: var(--sea); color: var(--paper-raised);
  font: 700 12.5px system-ui, sans-serif;
}
.kz-go:disabled { opacity: .5; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .kz-orb, .kz-panel, .kz-bubble, .kz-edit { transition: none; }
  .kz-bubble-bar, .kz-said-bar { animation: none; }
}

/* #02 — posture also reads without motion: after hours the cat desaturates and
   dims, so "the app wants nothing from you right now" is visible at a glance. */
.kz-cat-off .kz-cat-img{filter:grayscale(1) opacity(.55);}
.kz-cat-alert .kz-cat-img{filter:none;}

/* ---- minimise: the cat runs up to a perch in the top-right corner ---- */
.kz-perch{position:fixed;top:calc(8px + env(safe-area-inset-top,0px));right:14px;z-index:calc(var(--z-toast, 100) - 1);
  width:40px;height:40px;padding:0;border:1px solid var(--line,#dcdad0);border-radius:50%;
  background:var(--paper-raised,#fff);cursor:pointer;display:flex;align-items:center;
  justify-content:center;overflow:hidden;box-shadow:0 3px 10px rgba(0,0,0,.14);
  transition:transform .18s cubic-bezier(.34,1.4,.5,1),box-shadow .18s ease;}
.kz-perch:hover{transform:scale(1.12);box-shadow:0 5px 16px rgba(0,0,0,.2);}
.kz-perch[hidden]{display:none;}
.kz-perch .kz-cat-img{image-rendering:pixelated;transform:translateY(1px);}
.kz-min{background:none;border:0;cursor:pointer;font-size:15px;line-height:1;
  color:var(--ink-faint,#a3a196);padding:2px 5px;}
.kz-min:hover{color:var(--ink,#1f1e1b);}
@media (prefers-reduced-motion: reduce){
  .kz-perch{transition:none;}
}

/* [hidden] loses to the display rules above, so state it explicitly */
.kz-orb[hidden], .kz-panel[hidden], .kz-bubble[hidden]{display:none !important;}
