/* Loof — rustige groentinten, Fraunces + Inter */

:root {
  --paper:      #F3F5EE;
  --surface:    #FFFFFF;
  --ink:        #2B3328;
  --ink-soft:   #5B6B55;
  --ink-faint:  #8A9583;
  --sage:       #7C9473;
  --moss:       #4B6146;
  --moss-dark:  #37452F;
  --border:     #DEE5D5;
  --focus:      #8FB27C;
  --danger:     #A85B3F;

  --note-default: #FFFFFF;
  --note-sage:    #E2EBD9;
  --note-moss:    #CFE0C6;
  --note-mist:    #DCE7E6;
  --note-sand:    #F2E9D8;
  --note-clay:    #F1E0D1;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --shadow-sm: 0 1px 2px rgba(43, 51, 40, 0.06), 0 1px 1px rgba(43, 51, 40, 0.04);
  --shadow-md: 0 6px 20px rgba(43, 51, 40, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

/* Garandeert dat het [hidden]-attribuut altijd werkt, ook op elementen die
   verderop hun eigen "display" instellen (zoals flex-containers). Zonder
   deze regel kan een element met hidden="" toch zichtbaar blijven. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--moss-dark); }

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.leaf {
  width: 22px;
  height: 22px;
  fill: var(--moss);
  flex-shrink: 0;
}

/* ---------- Auth pages (login / setup) ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(124,148,115,0.14), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(75,97,70,0.10), transparent 40%),
    var(--paper);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

.auth-card .brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  color: var(--moss-dark);
}

.auth-sub {
  color: var(--ink-soft);
  margin: 0 0 24px;
}

.auth-error {
  background: #FBEDE7;
  color: var(--danger);
  border: 1px solid #E8C9B8;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

.auth-ok {
  background: var(--note-sage);
  color: var(--moss-dark);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}

.auth-form input {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}

.auth-form input:focus { border-color: var(--sage); }

.auth-form button {
  margin-top: 8px;
  background: var(--moss);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s ease;
}

.auth-form button:hover { background: var(--moss-dark); }

/* ---------- App shell ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--moss-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.search-wrap { flex: 1; max-width: 560px; }

#search {
  width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--paper);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

#search:focus { border-color: var(--sage); background: var(--surface); }

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
  white-space: nowrap;
}

.nav-link {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover { color: var(--moss-dark); }

.username {
  font-size: 13px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

.content {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 36px 0 16px;
}

/* ---------- Composer ---------- */
.composer {
  max-width: 600px;
  margin: 0 auto;
}

.composer-collapsed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 18px;
  cursor: text;
  color: var(--ink-soft);
}

.composer-collapsed button {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--ink-faint);
}

.composer-expanded {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px 18px;
}

.composer-expanded input[type="text"]#composer-title {
  border: none;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  width: 100%;
  margin-bottom: 8px;
  background: transparent;
  color: var(--ink);
}

.composer-expanded textarea {
  border: none;
  width: 100%;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  background: transparent;
  color: var(--ink);
}

.composer-expanded input:focus,
.composer-expanded textarea:focus { outline: none; }

.composer-footer, .modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.calendar-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
}

.calendar-panel input,
.calendar-panel select {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.calendar-panel button {
  background: var(--moss);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
}
.calendar-panel button:hover { background: var(--moss-dark); }

.attach-btn {
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
.attach-btn svg { width: 18px; height: 18px; }
.attach-btn:hover { background: var(--paper); color: var(--moss-dark); }

.composer-footer button, .modal-footer #modal-close {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
}

.composer-footer button:hover, .modal-footer #modal-close:hover { background: var(--paper); }

/* ---------- Colour swatches ---------- */
.color-swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(43,51,40,0.15);
  cursor: pointer;
  position: relative;
}

.swatch[data-active="true"]::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid var(--moss);
  border-radius: 50%;
}

/* ---------- Notes grid (masonry via CSS columns) ---------- */
.notes-grid {
  column-width: 240px;
  column-gap: 16px;
}

.note-card {
  break-inside: avoid;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px 10px;
  position: relative;
  transition: box-shadow 0.15s ease;
  cursor: pointer;
}

.note-card:hover { box-shadow: var(--shadow-md); }

.note-card[data-color="sage"]   { background: var(--note-sage); }
.note-card[data-color="moss"]   { background: var(--note-moss); }
.note-card[data-color="mist"]   { background: var(--note-mist); }
.note-card[data-color="sand"]   { background: var(--note-sand); }
.note-card[data-color="clay"]   { background: var(--note-clay); }

.note-leaf-tag {
  position: absolute;
  top: -1px;
  left: 18px;
  width: 16px;
  height: 20px;
  background: var(--moss);
  clip-path: path("M0 0 C 10 0 16 6 16 14 C 16 19 8 20 0 20 Z");
  opacity: 0;
  transition: opacity 0.15s ease;
}

.note-card[data-pinned="true"] .note-leaf-tag { opacity: 1; }

.note-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 6px;
  color: var(--ink);
  word-wrap: break-word;
}

.note-content {
  font-size: 14px;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

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

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  padding: 3px 0;
}

.note-item input[type="checkbox"] {
  accent-color: var(--moss);
  margin-top: 3px;
  flex-shrink: 0;
}

.note-item.checked span { color: var(--ink-faint); text-decoration: line-through; }

.note-toolbar {
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.15s ease;
  margin-top: 8px;
  gap: 4px;
}

.note-card:hover .note-toolbar,
.note-card:focus-within .note-toolbar { opacity: 1; }

.note-toolbar button {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 4px 8px;
  border-radius: 6px;
}

/* Op aanraakschermen bestaat "hover" niet, dus tonen we de knoppen altijd. */
@media (hover: none) {
  .note-toolbar { opacity: 1; }
  .note-toolbar button { padding: 8px 10px; font-size: 13px; }
  .attachment-remove { width: 24px; height: 24px; }
}

.note-toolbar button:hover { background: rgba(43,51,40,0.06); }

.note-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 6px;
}

/* ---------- Bijlagen: bewerkbare weergave (composer / modal) ---------- */
.attachments-area:empty { display: none; }

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 2px;
}

.attachment-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  max-width: 220px;
}

.attachment-chip.is-image {
  padding: 0;
  overflow: hidden;
  width: 72px;
  height: 72px;
}

.attachment-chip.is-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment-chip .file-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-chip .file-icon { flex-shrink: 0; display: flex; }

.attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(43,51,40,0.65);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-chip:not(.is-image) .attachment-remove {
  position: static;
  background: none;
  color: var(--ink-faint);
  width: auto;
  height: auto;
  margin-left: 2px;
}
.attachment-chip:not(.is-image) .attachment-remove:hover { color: var(--danger); }

/* ---------- Bijlagen: weergave op de notitiekaart ---------- */
.note-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  margin: -2px 0 8px;
}

.note-thumbs img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.note-files {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.note-file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--moss-dark);
  text-decoration: none;
  background: rgba(75,97,70,0.08);
  padding: 5px 9px;
  border-radius: 8px;
  overflow: hidden;
}

.note-file-chip span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  color: var(--ink-faint);
  margin-top: 60px;
  font-family: var(--font-display);
  font-size: 15px;
}

.sprout { width: 120px; height: 100px; margin-bottom: 6px; }
.sprout path {
  fill: none;
  stroke: var(--sage);
  stroke-width: 3;
  stroke-linecap: round;
}
.sprout-leaf-l, .sprout-leaf-r { fill: var(--note-moss); stroke: var(--moss); }

.sprout-stem {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: grow-stem 0.9s ease-out forwards;
}
.sprout-leaf-l, .sprout-leaf-r {
  transform-origin: 100px 95px;
  transform: scale(0);
  animation: grow-leaf 0.5s ease-out 0.7s forwards;
}

@keyframes grow-stem { to { stroke-dashoffset: 0; } }
@keyframes grow-leaf { to { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .sprout-stem, .sprout-leaf-l, .sprout-leaf-r { animation: none; stroke-dashoffset: 0; transform: scale(1); }
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43,51,40,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 22px;
}

.modal input[type="text"]#modal-title {
  border: none;
  width: 100%;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 10px;
  background: transparent;
  color: var(--ink);
}

.modal textarea {
  border: none;
  width: 100%;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  background: transparent;
  color: var(--ink);
}

.modal input:focus, .modal textarea:focus { outline: none; }

.modal-actions { display: flex; gap: 6px; align-items: center; }

.icon-btn {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--paper); }
.icon-btn.danger:hover { background: #FBEDE7; color: var(--danger); }

/* ---------- Checklist rows (shared) ---------- */
.add-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.checkbox-dummy {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--ink-faint);
  border-radius: 4px;
  flex-shrink: 0;
}

.add-item-row input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  color: var(--ink);
}
.add-item-row input:focus { outline: none; }

ul#composer-items, ul#modal-items {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
}

.edit-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.edit-item-row input[type="text"] {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  flex: 1;
  color: var(--ink);
}
.edit-item-row input[type="text"]:focus { outline: none; }
.edit-item-row .remove-item {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
}
.edit-item-row .remove-item:hover { color: var(--danger); }
.edit-item-row input[type="checkbox"] { accent-color: var(--moss); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar .brand { font-size: 19px; }
  .search-wrap { order: 3; max-width: none; width: 100%; }
  .topnav { gap: 12px; margin-left: auto; }
  .username { display: none; }

  .content { padding: 16px 12px 60px; }
  .section-title { margin: 24px 0 12px; }
  .notes-grid { column-width: 100%; }

  .composer-collapsed { padding: 14px 16px; }

  /* Modal vult het scherm op een telefoon, net als de Keep-app. */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .modal-footer { position: sticky; bottom: 0; background: var(--surface); }
  .modal-actions { width: 100%; justify-content: flex-end; }

  /* Grotere aanraakdoelen voor knoppen (kleurbolletjes uitgesloten —
     die moeten altijd een perfecte cirkel blijven). */
  .nav-link, .icon-btn, .composer-collapsed button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .swatch { width: 28px; height: 28px; }
}

@media (max-width: 380px) {
  .topbar .brand span { display: none; }
}
