/* The garden: search, tag filter, tile grid and the pop-in reader.
   Builds on css/home.css (colors, type, header, menu). */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.garden { padding-top: clamp(24px, 5vh, 56px); }

.garden-head h1 {
  margin: 0 0 12px;
  font-weight: 800;
  font-size: clamp(48px, 8vw, 104px);
  line-height: 0.95;
  letter-spacing: -0.045em;
  font-variation-settings: 'opsz' 96;
}
.garden-intro { margin: 0 0 32px; font-size: clamp(18px, 1.6vw, 21px); color: var(--ink-soft); max-width: 34em; }

/* ---------- Search and tags ---------- */
.garden-tools { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  padding: 0 18px;
  min-height: 60px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink-soft);
}
.search:focus-within { box-shadow: 4px 4px 0 var(--ink), 0 0 0 4px var(--volt); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 19px;
  padding: 0;
}
.search input::placeholder { color: var(--ink-soft); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-hint {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  border: 1.5px solid currentColor;
  border-radius: 6px;
  padding: 0 6px;
  opacity: 0.8;
}
.search:focus-within .search-hint { display: none; }

.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.tag-btn .n { font-weight: 500; opacity: 0.7; margin-left: 4px; }
.tag-btn:hover { background: var(--paper); }
.tag-btn[aria-pressed="true"] { background: var(--ink); color: var(--field); }

.garden-count { margin: 0 0 14px; font-size: 14px; color: var(--ink-soft); min-height: 1.4em; }

/* ---------- Tiles ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

.tile {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: 6px 6px 0 var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  min-width: 0;
}
.tile:hover { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 var(--ink); }
.tile:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }

/* Three tag looks: notes on paper, projects in lime, thoughts inverted. Other tags look like notes. */
.tile[data-tag="project"] { background: var(--volt); color: var(--volt-ink); }
.tile[data-tag="thought"] { background: var(--ink); color: var(--field); }

.tile-tag {
  font-size: 13px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
}
.tile-title {
  font-weight: 800;
  font-size: clamp(21px, 1.9vw, 26px);
  line-height: 1.12;
  letter-spacing: -0.025em;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.tile-foot { font-size: 14px; font-weight: 500; opacity: 0.75; }

.garden-empty { padding: 40px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.garden-empty[hidden], .garden-tools[hidden], .garden-empty [hidden] { display: none; }
.garden-empty p { margin: 0; font-size: 20px; font-weight: 700; }

/* ---------- Reader ---------- */
.reader {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 26px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
  overflow: hidden;
}
.reader[open] { display: flex; flex-direction: column; }
.reader::backdrop { background: rgba(8, 16, 11, 0.55); }

.reader-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 14px 28px;
  border-bottom: 2px solid var(--ink);
  flex: none;
}
.reader-meta { font-size: 14px; font-weight: 600; color: var(--ink-soft); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reader-meta .tile-tag { color: var(--ink); }
.reader-actions { display: flex; gap: 8px; }
.reader-actions .chip-btn { white-space: nowrap; height: 40px; }
a.chip-btn { text-decoration: none; }
.reader-close { width: 40px; padding: 0; justify-content: center; flex: none; }

.reader-body { overflow-y: auto; padding: 28px clamp(20px, 5vw, 48px) 44px; }
.reader-body h1 {
  margin: 0 0 22px;
  font-weight: 800;
  font-size: clamp(32px, 4.4vw, 46px);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

/* Post typography */
.prose { font-size: 18px; line-height: 1.7; max-width: 64ch; }
.prose > *:first-child { margin-top: 0; }
.prose p { margin: 0 0 1.1em; }
.prose h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin: 1.6em 0 0.5em; }
.prose h3 { font-size: 20px; font-weight: 800; margin: 1.4em 0 0.4em; }
.prose a { color: inherit; text-decoration-color: var(--volt); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.prose a:hover { background: var(--volt); color: var(--volt-ink); }
.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.3em; }
.prose li { margin: 0.25em 0; }
.prose blockquote {
  margin: 0 0 1.1em;
  padding: 10px 18px;
  border-left: 4px solid var(--volt);
  background: var(--field);
  border-radius: 0 12px 12px 0;
}
.prose blockquote p:last-child { margin: 0; }
.prose code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--field);
  padding: 0.1em 0.4em;
  border-radius: 6px;
}
.prose pre {
  margin: 0 0 1.2em;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--field);
  border-radius: 14px;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.55;
}
.prose pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.prose img { max-width: 100%; height: auto; border-radius: 14px; border: 2px solid var(--ink); }
.prose hr { border: 0; border-top: 2px dashed var(--ink-soft); margin: 2em 0; }

/* Fold-away sections in posts: <details><summary>Label</summary> … </details> */
.prose details { margin: 0 0 1.4em; border: 2px solid var(--ink); border-radius: 16px; background: var(--field); }
.prose summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  border-radius: 14px;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::before {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.prose details[open] summary::before { transform: rotate(45deg); }
.prose summary:hover { background: var(--volt); color: var(--volt-ink); }
.prose summary:focus-visible { outline: 3px solid var(--volt); outline-offset: 3px; }
.prose details[open] summary { border-bottom: 2px dashed var(--ink-soft); border-radius: 14px 14px 0 0; }
.prose details > :not(summary) { margin-left: 16px; margin-right: 16px; }
.prose details > summary + * { margin-top: 14px; }
.prose details > :last-child { margin-bottom: 16px; }

/* ---------- A post on its own page (/garden/post-name/) ---------- */
.post-page { max-width: 880px; padding-top: clamp(12px, 3vh, 32px); }
.post-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.post-back:hover { color: var(--ink); }
.post-card {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 26px;
  box-shadow: 10px 10px 0 var(--ink);
  padding: clamp(24px, 5vw, 56px) clamp(20px, 6vw, 72px) clamp(32px, 6vw, 64px);
}
.post-meta { margin: 0 0 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.post-meta .tile-tag { color: var(--ink); }
.post-card h1 {
  margin: 0 0 28px;
  font-weight: 800;
  font-size: clamp(36px, 5.4vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .post-card { border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); }
  .reader-tab-label { display: none; }
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .tile { padding: 14px; border-radius: 18px; box-shadow: 4px 4px 0 var(--ink); }
  .tile-title { font-size: 17px; -webkit-line-clamp: 4; }
  .tile-tag { font-size: 12px; padding: 2px 9px; }
  .tile-foot { font-size: 12px; }
  .reader { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; border: 0; box-shadow: none; }
  .reader-bar { padding-left: 18px; }
  .search-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
}
