/* NOTIZEN — notes.html, Notiz-Editor, Notizliste
   ==========================================================================
   Aus `styles.css` herausgeloest (Block 6e). Die Regeln sind WOERTLICH
   uebernommen, keine einzige wurde angefasst.

   --- Kaskade: das Wichtigste an dieser Datei ---------------------------

   Sie MUSS ueber `{% block seiten_css %}` eingebunden werden, also zwischen
   `styles.css` und `tailwind.css`. Steht sie dahinter, schlaegt jede
   `display`-Regel hier die Tailwind-Utility `.hidden`, und per JS
   ausgeblendete Elemente bleiben sichtbar. Genau das ist in Block 3 mit
   `connected.css` passiert und lag bis Block 6a auch in `trends.css` vor.
   Festgenagelt in `tests/test_css_kaskade.py`.

   --- Warum gerade dieser Abschnitt sicher war -------------------------

   Gemessen wurde vor dem Verschieben, ob ein Selektor hier ALS AUCH weiter
   unten in `styles.css` dieselbe Eigenschaft setzt -- denn die Regeln
   dahinter kommen jetzt davor. Ergebnis fuer diesen Abschnitt: kein
   einziger Konflikt. Der Responsive-Block ist unkritisch, weil er ohnehin
   VOR diesem Abschnitt stand und das so bleibt.
   ========================================================================== */

/* =========================================================================
   NOTIZEN
   ========================================================================= */

/* --- Note-Button in der Paper-Card Action-Bar --- */
.paper-card__note-btn {
  position: relative;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
}
.paper-card__note-btn.has-note {
  color: var(--moss-deep);
}
.paper-card__note-btn.has-note:hover {
  /* Konsistent mit anderen Action-Link-Hovers */
  background: var(--accent-lime-soft);
}
.paper-card__note-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-lime-deep);
  box-shadow: 0 0 0 2px var(--surface);
}

/* --- /notes Uebersichtsseite --- */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.notes-toolbar__stats {
  font-size: 13px;
  color: var(--ink-muted);
}
.notes-toolbar__count strong {
  color: var(--ink);
}
.notes-toolbar__filter {
  margin-left: 4px;
  color: var(--ink-subtle);
}

.notes-search {
  position: relative;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px 0 36px;
  display: flex;
  align-items: center;
  transition: border-color var(--dur) var(--ease);
}
.notes-search:focus-within {
  border-color: var(--brand-blue);
}
.notes-search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-subtle);
}
.notes-search__input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 13px;
  outline: none;
}
.notes-search__clear {
  color: var(--ink-subtle);
  text-decoration: none;
  padding: 0 8px;
  font-size: 18px;
  line-height: 1;
}
.notes-search__clear:hover {
  color: var(--ink);
}

.notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notes-list-item {
  display: flex;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.notes-list-item:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 12px -4px rgba(14, 27, 44, 0.08);
  transform: translateY(-1px);
}
.notes-list-item:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}
.notes-list-item__main {
  flex: 1;
  min-width: 0;
}
.notes-list-item__title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notes-list-item__meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.notes-list-item__sep {
  color: var(--ink-subtle);
}
.notes-list-item__excerpt {
  font-size: 12.5px;
  max-width: var(--text-max);
  color: var(--ink-muted);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  /* Markdown bleibt als Text sichtbar — pre-line behaelt Zeilenumbrueche */
  white-space: pre-line;
}
.notes-list-item__aside {
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.notes-list-item__date {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.notes-list-item__time {
  font-size: 11px;
  color: var(--ink-subtle);
  margin-top: 2px;
}

/* Loeschen-Mülleimer: dezent, default low-opacity, hover zeigt es klar.
   Standard ist Mute, nicht abgelenkt von der Notiz selbst — Hover wird's
   rot-akzentuiert. */
.notes-list-item__delete {
  margin-top: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-subtle);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 120ms var(--ease), color 120ms var(--ease),
              background 120ms var(--ease), border-color 120ms var(--ease);
}
.notes-list-item:hover .notes-list-item__delete {
  opacity: 1;
}
.notes-list-item__delete:hover {
  color: #B91C1C;
  background: #FEF2F2;
  border-color: #FECACA;
  opacity: 1;
}
.notes-list-item__delete:focus-visible {
  outline: 2px solid #DC2626;
  outline-offset: 1px;
  opacity: 1;
}
.notes-list-item__delete.is-loading {
  opacity: 0.4;
  cursor: wait;
}

/* Slide-Out-Animation beim Loeschen */
.notes-list-item.is-removing {
  animation: notes-item-remove 280ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}
@keyframes notes-item-remove {
  0%   { opacity: 1; transform: translateX(0); max-height: 200px; margin-bottom: 8px; padding: 14px 16px; border-width: 1px; }
  60%  { opacity: 0; transform: translateX(40px); }
  100% { opacity: 0; transform: translateX(40px); max-height: 0; margin: 0; padding: 0; border-width: 0; }
}
.notes-list__limit {
  font-size: 11.5px;
  color: var(--ink-subtle);
  text-align: center;
  margin-top: 16px;
}

.notes-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-muted);
}
.notes-empty svg {
  color: var(--ink-subtle);
  margin: 0 auto 14px;
  display: block;
}
.notes-empty__title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 8px;
}
.notes-empty__hint {
  font-size: 13px;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.55;
}

@media (max-width: 480px) {
  .notes-list-item {
    flex-direction: column;
    gap: 8px;
  }
  .notes-list-item__aside {
    text-align: left;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
  }
  /* Datum + Uhrzeit gehoeren visuell zusammen */
  .notes-list-item__time {
    margin-top: 0;
    margin-left: 6px;
  }
  /* Muelleimer nach rechts */
  .notes-list-item__delete {
    margin-top: 0;
    margin-left: auto;
    /* Auf Touch: nicht hover-abhaengig sichtbar machen */
    opacity: 0.85;
  }
}

/* --- Note-Editor Modal --- */
.note-editor {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
}
.note-editor.is-open {
  display: block;
}
body.note-editor-open {
  overflow: hidden;
}
.note-editor__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 27, 44, 0.45);
  backdrop-filter: blur(2px);
  animation: note-editor-fade 200ms ease;
}
@keyframes note-editor-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.note-editor__panel {
  position: absolute;
  inset: 5vh 50% auto 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 32px));
  max-height: 90vh;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 64px -8px rgba(14, 27, 44, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: note-editor-slide 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes note-editor-slide {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.note-editor__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.note-editor__head-text {
  flex: 1;
  min-width: 0;
}
.note-editor__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-subtle);
  font-weight: 600;
  margin-bottom: 4px;
}
.note-editor__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.note-editor__close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur) var(--ease);
}
.note-editor__close:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.note-editor__toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}
.note-editor__tool {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 13px;
  transition: all 120ms var(--ease);
}
.note-editor__tool:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
.note-editor__tool code {
  font-family: var(--font-mono);
  font-size: 11px;
}
.note-editor__tool-sep {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 4px;
}
.note-editor__hint {
  margin-left: auto;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
  font-family: var(--font-mono);
}

.note-editor__body {
  flex: 1;
  overflow: hidden;
  display: flex;
}
.note-editor__textarea {
  flex: 1;
  width: 100%;
  min-height: 280px;
  border: none;
  background: transparent;
  padding: 18px 22px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink);
  resize: none;
  outline: none;
}
.note-editor__textarea::placeholder {
  color: var(--ink-subtle);
  font-style: italic;
}

.note-editor__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
}
.note-editor__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.note-editor__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-subtle);
  transition: background 200ms ease;
}
.note-editor__status-dot.is-saved {
  background: var(--accent-lime-deep);
}
.note-editor__status-dot.is-error {
  background: #DC2626;
}
.note-editor__footer-actions {
  display: inline-flex;
  gap: 8px;
}
.note-editor__del-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 6px 14px;
  font-size: 12px;
  transition: all 120ms var(--ease);
}
.note-editor__del-btn:hover {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
}
.note-editor__done-btn {
  background: var(--brand-blue-deep);
  border: 1px solid var(--brand-blue-deep);
  color: white;
  border-radius: 8px;
  padding: 6px 18px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 120ms var(--ease);
}
.note-editor__done-btn:hover {
  background: var(--brand-blue);
}

@media (max-width: 640px) {
  .note-editor__panel {
    inset: 0;
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    transform: none;
    animation: note-editor-slide-mobile 240ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes note-editor-slide-mobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .note-editor__header { padding: 16px 16px 12px; }
  .note-editor__textarea { padding: 14px 16px; font-size: 14px; }
  /* Phase 3f: Safe-Area unten beachten (iPhone Home-Indicator) — der Footer
     mit „Loeschen"/„Fertig" darf nicht unter dem Indicator klemmen. Der
     Header + Close-Button sitzen bereits oben fix und sind erreichbar. */
  .note-editor__footer {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

