/*
 * DIGITAL GARDEN / PERSONAL WIKI
 * ================================
 * Concept: "Wandering through someone's mind." Non-linear, interconnected,
 * always growing. The sidebar is the map; the main area is the territory.
 * Backlinks show how ideas connect.
 *
 * Hook: The garden metaphor is felt, not just said. Notes grow and connect.
 * Backlinks at the bottom of each note show the web of relationships.
 * The sidebar index with expandable categories lets you explore freely.
 *
 * Why Lora? A warm text serif optimized for screen reading. This is a
 * reading-heavy interface — the font needs to disappear into the content.
 * Lora has enough character to feel personal but enough restraint to not
 * distract during long notes.
 */

:root {
  --font-serif:  'Lora', Georgia, serif;
  --font-mono:   'IBM Plex Mono', 'Consolas', monospace;

  --bg:          #18161a;
  --bg-sidebar:  #141218;
  --bg-raised:   #201e24;
  --text:        #dcd8d0;
  --text-mid:    #9e9690;
  --text-quiet:  #5e5850;
  --accent:      #a88eb0;   /* muted lavender — gardens, growth */
  --accent-dim:  #a88eb020;
  --rule:        #2a262e;

  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #f4f2f0;
    --bg-sidebar:  #ece8e4;
    --bg-raised:   #e6e2de;
    --text:        #2a2624;
    --text-mid:    #6e6660;
    --text-quiet:  #a8a09a;
    --accent:      #7a5e88;
    --accent-dim:  #7a5e8820;
    --rule:        #d8d4d0;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.72;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
}

::selection { background: var(--accent); color: var(--bg); }

/* LAYOUT — sidebar + content */
.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--rule);
}

.sidebar__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 500;
  font-style: italic;
}

.sidebar__toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 1.1rem;
  cursor: pointer;
}

/* Search */
.sidebar__search {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--rule);
}

.search-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.4rem 0.6rem;
  outline: none;
  transition: border-color 0.2s var(--ease);
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-quiet);
}

/* Tree */
.sidebar__tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 0;
}

.tree-group {
  margin-bottom: 0.3rem;
}

.tree-cat {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-quiet);
  background: none;
  border: none;
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.tree-cat:hover { color: var(--text-mid); }

.tree-cat[aria-expanded="false"] + .tree-list {
  display: none;
}

.tree-note {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: var(--text-mid);
  background: none;
  border: none;
  padding: 0.3rem 1rem 0.3rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border-left: 2px solid transparent;
}

.tree-note:hover {
  color: var(--text);
  background: var(--accent-dim);
}

.tree-note--active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.sidebar__meta {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-quiet);
  letter-spacing: 0.04em;
}

/* CONTENT */
.content {
  overflow-y: auto;
  padding: 3rem 3rem 4rem;
  max-width: 680px;
}

/* NOTE */
.note__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.note__cat {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
}

.note__date {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-quiet);
}

.note__title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 1.5rem;
}

/* Note body */
.note__body p {
  margin-bottom: 0.9rem;
  color: var(--text-mid);
  line-height: 1.78;
}

.note__body h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 500;
  font-style: italic;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.note__body ul {
  margin-bottom: 0.9rem;
  padding-left: 1.2rem;
}

.note__body li {
  color: var(--text-mid);
  line-height: 1.75;
  margin-bottom: 0.3rem;
}

.note__body strong {
  color: var(--text);
  font-weight: 600;
}

.note__body em {
  font-style: italic;
}

.note__body a,
.note__body [data-note] {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font: inherit;
  padding: 0;
  transition: border-color 0.2s var(--ease);
}

.note__body a:hover,
.note__body [data-note]:hover {
  border-bottom-color: var(--accent);
}

.note__body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-raised);
  padding: 0.1rem 0.35rem;
  color: var(--text);
}

/* BACKLINKS */
.backlinks {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.backlinks__label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-quiet);
  margin-bottom: 0.6rem;
}

.backlinks__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.backlink {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--rule);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.backlink:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar__toggle {
    display: block;
  }

  /* Show toggle in content area on mobile */
  .content {
    padding: 2rem 1.5rem;
  }

  .content::before {
    content: '☰ Index';
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-quiet);
    margin-bottom: 1.5rem;
    cursor: pointer;
  }
}

/* Scrollbar styling */
.sidebar__tree::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: 4px;
}

.sidebar__tree::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar__tree::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 2px;
}
