:root {
  --bg:        #f0f6ff;
  --surface:   #e8f0fb;
  --card-bg:   #ffffff;
  --text:      #0f2a4a;
  --muted:     #5a7a9a;
  --accent:    #3d7ec9;
  --accent-hover: #2b65a8;

  --nav-bg:    #1a3d6b;
  --nav-text:  #e8f4ff;

  --olive:      #3a8a5c;
  --terracotta: #4a7eb5;
  --budding:    #7a9abb;

  --card-border: #c5d8f0;
  --card-shadow: 0 2px 8px rgba(15,42,74,0.08), 0 1px 3px rgba(15,42,74,0.06);
  --card-shadow-hover: 0 8px 24px rgba(15,42,74,0.14), 0 3px 8px rgba(15,42,74,0.10);

  --header-height: 52px;
  --col-left:   200px;
  --col-right:  200px;
  --col-center: minmax(0, 860px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.7;
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 200;
  padding: 0.5rem 1rem;
  background: var(--nav-bg);
  color: var(--nav-text);
  border-radius: 0 0 4px 4px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.15s;
}

.skip-link:focus {
  top: 0;
}

/* ── Layout ── */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top header ── */
.site-header {
  min-height: var(--header-height);
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 1.5rem;
  gap: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.site-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--nav-text);
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 0.75rem 0;
}

.site-title:hover {
  text-decoration: underline;
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem;
  flex: 1;
  justify-content: flex-end;
}

.header-nav a {
  color: var(--nav-text);
  font-size: 0.85rem;
  opacity: 0.82;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
  padding: 0.4rem 0.65rem;
  border-radius: 4px;
  white-space: nowrap;
}

.header-nav a:hover {
  opacity: 1;
  background: rgba(255,255,255,0.12);
}

.header-nav a.nav-active {
  opacity: 1;
  background: rgba(255,255,255,0.18);
  font-weight: 600;
}

/* ── Hamburger toggle ── */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--nav-text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.site-header.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.site-header.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Layout body ── */
.site-layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--col-left) var(--col-center) var(--col-right);
  grid-template-areas: "left main right";
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.site-col-left {
  grid-area: left;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}

.site-col-right {
  grid-area: right;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}

.site-main {
  grid-area: main;
  min-width: 0;
  padding: 2.5rem 2rem 4rem;
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 1.25rem 2rem;
  background: var(--nav-bg);
  color: var(--nav-text);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--nav-text);
  text-decoration: none;
  opacity: 0.82;
}

.site-footer a:hover {
  opacity: 1;
  text-decoration: underline;
}

.footer-tagline {
  font-style: italic;
  color: var(--nav-text);
  opacity: 0.58;
}

.footer-version {
  color: var(--nav-text);
  opacity: 0.4;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

/* ── Typography ── */
h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  color: var(--text);
}

h2 {
  font-size: 1.4rem;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: rgba(61,126,201,0.2);
}

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

a:focus-visible {
  border-radius: 2px;
}

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

/* ── Home page intro ── */
.home-intro {
  margin-bottom: 2rem;
}

.home-intro h1 {
  font-size: 2.4rem;
  margin-bottom: 0.75rem;
}

.home-intro p {
  color: var(--muted);
  font-size: 1.05rem;
}

/* ── Feed controls ── */
.feed-controls {
  margin-bottom: 2rem;
}

.feed-search {
  margin-bottom: 1rem;
}

.feed-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15,42,74,0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.feed-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,126,201,0.15);
}

.feed-search input::placeholder {
  color: var(--muted);
}

.feed-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-chip {
  background: var(--card-bg);
  color: var(--muted);
  border: 1px solid var(--card-border);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.filter-chip.chip-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.filter-sort {
  margin-left: auto;
}

.feed-sort-select {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 3px;
  color: var(--text);
  cursor: pointer;
}

.feed-sort-select:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-clear {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--muted);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  align-self: flex-end;
}

.filter-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Feed grid ── */
.feed-grid {
  display: grid;
  gap: 1.5rem;
}

.feed-card {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.feed-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

.feed-card-image {
  flex-shrink: 0;
  width: 140px;
  height: 90px;
  border-radius: 4px;
  overflow: hidden;
}

.feed-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-card-body {
  flex: 1;
  min-width: 0;
}

.feed-card-body h3 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}

.feed-card-body h3 a {
  color: var(--text);
}

.feed-card-body h3 a:hover {
  color: var(--accent);
}

.feed-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}

.feed-card-meta span {
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
}

.feed-date {
  font-style: italic;
}

.feed-card-excerpt {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 0.5rem;
  line-height: 1.5;
}

.feed-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag-chip {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  text-decoration: none;
}

a.tag-chip:hover {
  color: var(--accent);
}

.feed-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Zone badges ── */
.zone-badge {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: capitalize;
}

.zone-badge--veranda  { color: #2e7d52; background: #e8f5ee; }
.zone-badge--garden   { color: #2e7d52; background: #e8f5ee; }
.zone-badge--greenhouse { color: #1a6b5a; background: #e5f4f0; }
.zone-badge--cellar   { color: #5a6ea0; background: #edf0f9; }
.zone-badge--well     { color: var(--muted); background: var(--bg); }
.zone-badge--posts    { color: var(--accent); background: #deeaf8; }

/* ── Stage badges ── */
.stage {
  font-weight: 600;
}

.stage--seedling {
  color: #c47d1a;
  background: #fef4e0;
}

.stage--budding {
  color: #5a6ea0;
  background: #edf0f9;
}

.stage--evergreen {
  color: #2e7d52;
  background: #e8f5ee;
}

/* ── Entry metadata strip ── */
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}

.entry-meta span {
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
}

/* ── Post tags ── */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

/* ── Breadcrumb ── */
.breadcrumb {
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--accent);
}

/* ── Individual entry page ── */
.entry-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.entry-header h1 {
  margin-bottom: 0.75rem;
}

.entry-body {
  font-size: 1.05rem;
}

.entry-body > p:first-of-type {
  font-size: 1.15rem;
  line-height: 1.6;
}

.entry-body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  font-style: italic;
  border-radius: 0 4px 4px 0;
}

.entry-body blockquote p:last-child {
  margin-bottom: 0;
}

.entry-body ul,
.entry-body ol {
  padding-left: 1.5rem;
  margin: 0 0 1rem;
}

.entry-body ul { list-style: disc; }
.entry-body ol { list-style: decimal; }

.entry-body li {
  margin-bottom: 0.35rem;
  color: var(--text);
}

.entry-body li::marker {
  color: var(--muted);
}

.entry-body code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--surface);
  color: var(--accent);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.entry-body pre {
  background: var(--surface);
  border-left: 3px solid var(--muted);
  padding: 1rem 1.25rem;
  border-radius: 0 4px 4px 0;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.entry-body pre code {
  background: none;
  color: var(--text);
  padding: 0;
  border-radius: 0;
  font-size: 0.88em;
}

.entry-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 1.5rem 0;
}

.entry-body figure {
  margin: 1.5rem 0;
}

.entry-body figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
  text-align: center;
  font-style: italic;
}

/* ── Reading-specific ── */
.book-meta,
.entry-detail-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.rating {
  color: var(--accent);
}

.confidence {
  text-transform: capitalize;
}

/* ── Wikilinks ── */
.wikilink {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.wikilink:hover {
  text-decoration-style: solid;
}

.wikilink-broken {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
  cursor: help;
}

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

.backlinks h2 {
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
}

.backlinks ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.backlinks li {
  padding: 0.25rem 0;
}

.backlinks a {
  color: var(--accent);
  font-size: 0.95rem;
}

/* ── Workshop ── */
.tool-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: 1.5rem;
}

.tool-card {
  padding: 1.5rem;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.15s;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--accent);
}

.tool-card h3 {
  margin: 0 0 0.5rem;
}

.tool-card h3 a {
  color: var(--text);
}

.tool-card p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

/* ── Tool iframe pages ── */
.tool-frame-container {
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 1rem;
  border: 1px solid #c0d0e4;
}

.tool-frame {
  width: 100%;
  min-height: 600px;
  border: none;
  display: block;
  border-radius: 12px;
  transition: height 0.15s ease;
}

.tool-page-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  list-style: none;
  padding: 0;
}

.tool-page-features li {
  background: var(--surface);
  border: 1px solid var(--card-border);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.tool-page-note {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0;
}

/* ── Zone index pages ── */
.zone-header {
  margin-bottom: 2.5rem;
}

.zone-header h1 {
  margin-bottom: 0.4rem;
}

.zone-header p {
  color: var(--muted);
  margin: 0;
}

.entry-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.5rem;
}

.entry-card {
  padding: 1.25rem 1.5rem;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.entry-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

.entry-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.entry-card h3 a {
  color: var(--text);
}

.entry-card h3 a:hover {
  color: var(--accent);
}

.entry-card .entry-excerpt {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}

/* ── Library tables ── */
.library-year {
  font-size: 1.3rem;
  color: var(--muted);
  margin: 2rem 0 0.75rem;
}

.library-year:first-of-type {
  margin-top: 0;
}

.library-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.library-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.library-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--card-border);
  white-space: nowrap;
}

.library-table td {
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--surface);
  vertical-align: middle;
}

.library-table tbody tr:last-child td {
  border-bottom: none;
}

.library-table tbody tr:hover {
  background: var(--surface);
}

.rating-cell {
  white-space: nowrap;
  letter-spacing: 0.05em;
}

.star-full {
  color: var(--accent);
}

.star-half {
  color: var(--accent);
  font-size: 0.85em;
}

.star-empty {
  color: var(--card-border);
}

/* ── 404 ── */
.not-found {
  text-align: center;
  padding: 4rem 0;
}

.not-found h1 {
  font-size: 3rem;
  color: var(--muted);
}

/* ── About ── */
.about-content h1 {
  margin-bottom: 1.5rem;
}

/* ── Almanac / Cellar ── */
.almanac-entry {
  margin-bottom: 3rem;
}

/* ── Greenhouse note ── */
.greenhouse-note {
  background: #e5f4f0;
  border-left: 3px solid #2e8b6a;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  border-radius: 0 4px 4px 0;
  margin-bottom: 2rem;
}

/* ── Tablet ── */
@media (max-width: 1024px) {
  .site-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
  }

  .site-col-left,
  .site-col-right {
    display: none;
  }
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .site-main {
    padding: 1.5rem 1.25rem 3rem;
  }

  .feed-card {
    flex-direction: column;
  }

  .feed-card-image {
    width: 100%;
    height: 160px;
  }

  .feed-filters {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .filter-group {
    min-width: 0;
    width: 100%;
  }

  .filter-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .filter-chips::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    flex-shrink: 0;
  }

  .filter-sort {
    margin-left: 0;
  }

  .feed-card:hover,
  .entry-card:hover,
  .tool-card:hover {
    transform: none;
    box-shadow: var(--card-shadow);
  }

  .nav-toggle {
    display: flex;
  }

  .header-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    padding: 0.5rem 0 0.75rem;
    gap: 0;
  }

  .site-header.nav-open .header-nav {
    display: flex;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 0.5rem;
  }

  .header-nav a {
    padding: 0.6rem 0.5rem;
    border-radius: 0;
    font-size: 0.95rem;
    opacity: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .header-nav a:last-child {
    border-bottom: none;
  }

  .header-nav a:active {
    background: rgba(255, 255, 255, 0.12);
  }
}
