/* ═══════════════════════════════════════════
   RAY CHEN — DIGITAL GARDEN
   Design: Ink & Parchment / Editorial Botanical
   ═══════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  --bg:             #f2ece0;
  --surface:        #faf7f1;
  --surface-raised: #e8e0d0;
  --border:         #d0c8b8;
  --border-strong:  #b0a898;
  --text:           #1a1612;
  --text-secondary: #6b5f52;
  --text-faint:     #9e9088;

  --accent:         #7a6e5f;
  --accent-warm:    #a86e22;   /* amber — the signature moment */
  --accent-light:   #f0e6cc;

  --seedling:       #3d6e4a;
  --seedling-bg:    #e8f2eb;
  --seedling-border:#b8d8bf;
  --budding:        #a06b18;
  --budding-bg:     #f5ead4;
  --budding-border: #dfc090;
  --evergreen:      #2a5e42;
  --evergreen-bg:   #dff0e8;
  --evergreen-border:#9dcdb5;

  --link:           #a86e22;
  --link-hover:     #7a5016;

  --font-display:   'Fraunces', Georgia, serif;
  --font-body:      'Crimson Pro', 'Georgia', serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm:      4px;
  --radius:         8px;
  --radius-lg:      14px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Paper grain texture ── */
html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23g)' opacity='0.06'/%3E%3C/svg%3E");
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.75;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-top: 3px solid var(--accent-warm);
}

/* ── Layout shell ── */
.page-wrapper {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 20px;
  margin-bottom: 52px;
  position: relative;
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, var(--accent-warm), var(--border) 60%, transparent);
}

/* ── Logo ── */
.page-header__logo {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--text);
  transition: opacity 0.2s;
}

.page-header__logo:hover {
  opacity: 0.8;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.page-header__logo:hover .logo-mark {
  transform: translateY(-1px);
}

.logo-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}

/* ── Navigation ── */
nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

nav a {
  position: relative;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 2px;
  transition: color 0.2s;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent-warm);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

nav a:hover {
  color: var(--accent-warm);
}

nav a:hover::after {
  width: 100%;
}

nav .nav-sep {
  color: var(--border);
  font-size: 0.7rem;
  user-select: none;
}

/* ── Main ── */
main {
  flex-grow: 1;
  padding-bottom: 72px;
}

/* ── Footer ── */
.page-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: 0.82rem;
  font-family: var(--font-body);
  letter-spacing: 0.03em;
}

.page-footer a {
  color: var(--text-faint);
  text-decoration: none;
}

.page-footer a:hover {
  color: var(--accent-warm);
}

/* ── Links ── */
a[href] {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.18s, color 0.18s;
}

a[href]:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

a[href]:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 2.6rem;
  margin: 0 0 0.75rem;
  font-style: italic;
}

h2 {
  font-size: 1.65rem;
  margin: 2.75rem 0 0.6rem;
  font-style: italic;
}

h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.4rem;
}

h4 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.4rem;
}

p {
  margin: 0 0 1.1rem;
}

ul, ol {
  padding-left: 1.5rem;
  margin: 0 0 1.1rem;
}

li {
  margin-bottom: 0.35rem;
}

blockquote {
  margin: 1.75rem 0;
  padding: 0 0 0 1.25rem;
  border-left: 2px solid var(--accent-warm);
  color: var(--text-secondary);
  font-style: italic;
  font-size: 1.05em;
}

blockquote p:last-child { margin: 0; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  color: var(--text);
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

small { font-size: 0.82rem; }

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ── Note meta row (status + date) ── */
.note-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 1.25rem;
}

.note-date {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-faint);
  letter-spacing: 0.01em;
}

/* ── Note card date ── */
.note-card__date {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--text-faint);
  margin-top: 8px;
}

/* ── Graph container ── */
#graph-container {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 1.75rem 0 1rem;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 2rem;
}

.graph-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
}

.graph-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.graph-legend__dot--seedling  { background: #3d6e4a; }
.graph-legend__dot--budding   { background: #a06b18; }
.graph-legend__dot--evergreen { background: #2a5e42; }
.graph-legend__dot--default   { background: #7a6e5f; }

/* ── Article ── */
article {
  max-width: 66ch;
}

article h1 {
  margin-bottom: 0.5rem;
}

/* ── Note status badge ── */
.note-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 11px;
  border-radius: 20px;
  margin-bottom: 1.25rem;
}

.note-status--seedling {
  background: var(--seedling-bg);
  color: var(--seedling);
  border: 1px solid var(--seedling-border);
}

.note-status--budding {
  background: var(--budding-bg);
  color: var(--budding);
  border: 1px solid var(--budding-border);
}

.note-status--evergreen {
  background: var(--evergreen-bg);
  color: var(--evergreen);
  border: 1px solid var(--evergreen-border);
}

/* ── Notes grid ── */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 1.75rem;
}

.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition:
    border-color 0.2s,
    border-left-color 0.2s,
    box-shadow 0.2s,
    transform 0.15s;
  position: relative;
}

.note-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 20px rgba(26, 22, 18, 0.08);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}

.note-card--seedling:hover   { border-left-color: var(--seedling); }
.note-card--budding:hover    { border-left-color: var(--budding); }
.note-card--evergreen:hover  { border-left-color: var(--evergreen); }
.note-card:not([class*="note-card--"]):hover { border-left-color: var(--accent-warm); }

.note-card__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 400;
  margin: 0 0 8px;
  color: var(--text);
  line-height: 1.3;
}

/* ── Note card badge ── */
.note-card__badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.note-card__badge--seedling {
  background: var(--seedling-bg);
  color: var(--seedling);
  border: 1px solid var(--seedling-border);
}

.note-card__badge--budding {
  background: var(--budding-bg);
  color: var(--budding);
  border: 1px solid var(--budding-border);
}

.note-card__badge--evergreen {
  background: var(--evergreen-bg);
  color: var(--evergreen);
  border: 1px solid var(--evergreen-border);
}

/* ── Note card tags ── */
.note-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

/* ── Notes empty ── */
.notes-empty {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 1.05rem;
}

/* ── Tag pills ── */
.tag-pill {
  display: inline-block;
  padding: 2px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

a.tag-pill:hover {
  border-color: var(--accent-warm);
  background: var(--accent-light);
  color: var(--accent-warm);
  text-decoration: none;
}

.tag-pill--sm {
  font-size: 0.7rem;
  padding: 1px 8px;
}

.tag-pill--active {
  border-color: var(--accent-warm);
  background: var(--accent-light);
  color: var(--accent-warm);
  font-weight: 600;
}

/* ── Tags on note pages ── */
.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Tag index ── */
.tag-index {
  list-style: none;
  padding: 0;
  margin: 1.75rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.tag-index__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tag-index__item:hover {
  border-color: var(--accent-warm);
  box-shadow: 0 2px 8px rgba(168, 110, 34, 0.1);
  text-decoration: none;
}

.tag-index__item:hover .tag-pill {
  border-color: var(--accent-warm);
  background: var(--accent-light);
  color: var(--accent-warm);
}

.tag-index__count {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-family: var(--font-body);
}

/* ── Per-tag page ── */
.tag-page-header {
  margin-bottom: 1.75rem;
}

.tag-page-back {
  font-size: 0.82rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

.tag-page-back:hover {
  color: var(--accent-warm);
  text-decoration: none;
}

.tag-page-title {
  margin: 8px 0 0;
  font-size: 2rem;
  color: var(--text);
}

.tag-page-count {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Backlinks ── */
.backlinks-section {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.backlinks-title {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 0 0 0.75rem;
}

.backlinks-container {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.backlink {
  position: relative;
}

.backlink__link {
  display: inline-block;
  padding: 3px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--link);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.backlink__link:hover {
  border-color: var(--accent-warm);
  background: var(--accent-light);
  color: var(--accent-warm);
}

.backlinks-default {
  color: var(--text-faint);
  font-size: 0.875rem;
  font-style: italic;
  margin: 0;
}

.backlink__preview {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 8px 28px rgba(26, 22, 18, 0.12);
  width: 300px;
  max-height: 160px;
  overflow: hidden;
  z-index: 10;
  font-size: 0.85rem;
}

.backlink__preview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, var(--surface));
  height: 36px;
}

.backlink__preview h1 {
  font-size: 0.95rem;
  margin: 0 0 6px;
  font-style: normal;
}

.backlink:hover .backlink__preview {
  display: block;
}

/* ── Footnotes ── */
.footnotes {
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  padding-top: 1rem;
}

/* ── Pagination ── */
.pagination-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.pagination-nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.pagination-nav__btn:hover:not(.pagination-nav__btn--disabled) {
  border-color: var(--accent-warm);
  background: var(--accent-light);
  color: var(--accent-warm);
  text-decoration: none;
}

.pagination-nav__btn--disabled {
  color: var(--text-faint);
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.pagination-nav__info {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-secondary);
  min-width: 90px;
  text-align: center;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .page-wrapper {
    padding: 0 20px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 36px;
  }

  nav {
    flex-wrap: wrap;
    gap: 4px;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.35rem; }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .tag-index {
    grid-template-columns: 1fr;
  }

  .page-footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
}
