/* ==================================================================
   ARCHITECT'S SKETCHBOOK - repo-tree global theme
   Paper, pencil, grid. Warm, tactile, unhurried.
   ================================================================== */

/* Emoji rendering uses each platform's system emoji font (no web font download). */

:root {
  --paper:         #f5f0e6;
  --paper-dark:    #ece4d6;
  --card:          #fffcf5;
  --card-border:   #d9d0be;
  --ink:           #2c2822;
  --ink-soft:      #6b6355;
  --ink-faint:     #b8b0a4;
  --terracotta:    #c4613b;
  --teal:          #4a7a7a;
  --mustard:       #c9a84b;
  --link:          #2c4a6b;
  --link-visited:  #4a2c4a;
  --thermal-bg:    #eef4ec;
  --thermal-line:  #c0d4c0;
  --grid-size:     24px;
  --rule:          #d4cdbf;
  --sans:          'Inter', 'Segoe UI', system-ui, 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  --mono:          'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'Cascadia Mono', 'Consolas', monospace;
  --border-radius: 4px;
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: 40px 32px;
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.618;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(   0deg, rgba(192, 182, 164, 0.18) 1px, transparent 1px),
    linear-gradient(  90deg, rgba(192, 182, 164, 0.18) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: -12px -12px;
  min-height: 100vh;
}

/* ── Site header ───────────────────────────────────────────── */

#site-header {
  max-width: 960px;
  margin: 0 auto 8px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}

#site-logo {
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
}

#site-logo:hover {
  color: var(--terracotta);
}

#site-subtitle {
  font-size: 0.78rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#site-subtitle a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

#site-subtitle a:hover {
  color: var(--terracotta);
}

#site-subtitle .subtitle-repo {
  font-family: var(--mono);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.92em;
}

/* ── Site footer ───────────────────────────────────────────── */

#site-footer {
  max-width: 960px;
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
}

#site-footer a {
  color: var(--link);
  text-decoration: underline dotted;
}

#footer-rule {
  flex: 1;
  height: 1px;
  background-image: linear-gradient(
    90deg,
    var(--teal) 0px, var(--teal) 4px,
    transparent 4px, transparent 12px
  );
  background-size: 16px 100%;
  background-repeat: repeat-x;
  opacity: 0.4;
}

/* ── Container ─────────────────────────────────────────────── */

#container {
  max-width: 960px;
  margin: 0 auto;
  background: var(--paper-dark);
  border: 1px solid var(--rule);
  border-radius: var(--border-radius);
  padding: 32px 36px;
  position: relative;
}

#container::before {
  content: '';
  position: absolute;
  inset: -3px;
  border: 1px solid rgba(180, 170, 150, 0.25);
  border-radius: 6px;
  pointer-events: none;
}

/* ── Loading ────────────────────────────────────────────────── */

#loading {
  text-align: center;
  padding: 64px 24px;
}

#loading p {
  font-size: 0.9rem;
  color: var(--ink-soft);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  position: relative;
}

#loading p::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  margin: 12px auto 0;
  background: var(--terracotta);
  animation: ld 1.8s ease-in-out infinite alternate;
}

@keyframes ld {
  0%   { width: 20px; opacity: 0.3; }
  100% { width: 100px; opacity: 1; }
}

/* ── Error ──────────────────────────────────────────────────── */

#error {
  padding: 48px 24px;
  text-align: center;
}

#error p {
  font-size: 1.05rem;
  color: var(--ink-soft);
  padding: 16px 24px;
  border: 1px dashed var(--terracotta);
  background: rgba(196, 97, 59, 0.06);
  display: inline-block;
}

#error a {
  color: var(--link);
  text-decoration: underline dotted;
  font-size: 0.9rem;
}

/* ── Repo List ──────────────────────────────────────────────── */

#repo-list {
  padding: 0;
}

/* filters bar */

#repo-list > div:first-child {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 8px 0 20px;
  border-bottom: 1px solid var(--rule);
}

#repo-list > div:first-child::before {
  content: 'Filters';
  font-size: 0.7rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 4px;
}

#repo-search {
  flex: 1;
  min-width: 180px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--ink-soft);
  padding: 4px 0;
  outline: none;
  transition: border-color 0.2s;
}

#repo-search:focus {
  border-bottom-color: var(--terracotta);
}

#repo-search::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}

#filter-lang,
#filter-sort {
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 4px 24px 4px 8px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0,0 4,4 8,0' fill='%236b6355'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* repo grid */

#repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

.repo-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 16px 18px;
  position: relative;
  transition: box-shadow 0.25s, transform 0.25s;
  box-shadow: 0 1px 3px rgba(100, 90, 75, 0.12);
}

.repo-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: 3px;
  background-image: linear-gradient(
    90deg,
    var(--terracotta) 0px, var(--terracotta) 8px,
    transparent 8px, transparent 16px
  );
  background-size: 16px 3px;
  background-repeat: repeat-x;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  opacity: 0.5;
}

.repo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(100, 90, 75, 0.18);
}

.repo-card.filtered-out {
  display: none;
}

.repo-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--link);
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
}

.repo-name:hover {
  text-decoration: underline;
  color: var(--terracotta);
}

.repo-desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 8px;
}

.repo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-top: auto;
}

.repo-lang {
  font-weight: 500;
  color: var(--teal);
}

.repo-stars,
.repo-forks {
  color: var(--mustard);
}

.repo-update {
  color: var(--ink-faint);
}

/* repo count */

#repo-count {
  font-size: 0.8rem;
  color: var(--ink-soft);
  padding: 6px 0;
  border-top: 1px solid var(--rule);
}

#repo-count::before {
  content: '· ';
  color: var(--ink-faint);
}

/* ── Repo View ──────────────────────────────────────────────── */

#repo-view {
  padding: 0;
}

/* back link */

#repo-header > p:first-child,
#repo-view > p:last-child {
  margin: 0;
  padding-left: 22px;
  position: relative;
}

#repo-header > p:first-child::before,
#repo-view > p:last-child::before {
  content: '↩';
  position: absolute;
  left: 0;
  top: 4px;
  color: var(--ink-faint);
  font-size: 0.9em;
  transition: transform 0.2s;
}

#repo-header > p:first-child:hover::before,
#repo-view > p:last-child:hover::before {
  transform: translateX(-3px);
}

#repo-header > p a[href="."],
#repo-view > p a[href="."] {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.82rem;
  transition: color 0.2s;
}

#repo-header > p a[href="."]:hover,
#repo-view > p a[href="."]:hover {
  color: var(--terracotta);
}

/* repo header */

#repo-header {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
}

#repo-title {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.2;
}

#repo-title a {
  color: inherit;
  text-decoration: none;
}

#repo-title a:hover {
  color: var(--terracotta);
}

#repo-header .repo-desc {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 4px 0;
}

/* repo actions */

#repo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
  align-items: center;
}

#repo-actions a,
#repo-actions button {
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 4px 12px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#repo-actions a:hover,
#repo-actions button:hover {
  background: var(--ink);
  color: var(--card);
  border-color: var(--ink);
}

/* filepath */

#repo-filepath {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  padding: 4px 10px;
  background: rgba(74, 122, 122, 0.06);
  border: 1px dashed var(--teal);
  border-radius: var(--border-radius);
}

#repo-filepath::before {
  content: '📄 ';
  font-size: 0.75rem;
}

/* ── Markdown Content ───────────────────────────────────────── */

#markdown-content {
  padding: 0;
  line-height: 1.7;
}

#markdown-content h1,
#markdown-content h2,
#markdown-content h3,
#markdown-content h4,
#markdown-content h5,
#markdown-content h6 {
  font-weight: 600;
  color: var(--ink);
  margin: 1.2em 0 0.4em;
  line-height: 1.25;
  position: relative;
}

#markdown-content h1 { font-size: 1.5rem; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
#markdown-content h2 { font-size: 1.25rem; }
#markdown-content h3 { font-size: 1.05rem; }
#markdown-content h4 { font-size: 0.95rem; }
#markdown-content h5 { font-size: 0.88rem; }
#markdown-content h6 { font-size: 0.82rem; color: var(--ink-soft); }

#markdown-content h2,
#markdown-content h3 {
  padding-left: 12px;
}

#markdown-content h2::before,
#markdown-content h3::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.1em;
  bottom: 0.1em;
  width: 3px;
  background: var(--terracotta);
  border-radius: 2px;
}

.heading-anchor {
  opacity: 0;
  margin-left: 4px;
  margin-right: 5px;
  color: var(--ink-faint);
  text-decoration: none;
  font-size: 0.8em;
  transition: opacity 0.2s;
}

h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
  opacity: 1;
}

#markdown-content p {
  margin: 0.6em 0;
}

#markdown-content a {
  color: var(--link);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

#markdown-content a:hover {
  color: var(--terracotta);
}

#markdown-content strong {
  font-weight: 600;
}

#markdown-content em {
  font-style: italic;
}

#markdown-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 1.5em 0;
}

#markdown-content blockquote {
  margin: 0.8em 0;
  padding: 8px 16px;
  border-left: 3px solid var(--teal);
  background: rgba(74, 122, 122, 0.04);
  color: var(--ink-soft);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

#markdown-content ul,
#markdown-content ol {
  padding-left: 24px;
  margin: 0.6em 0;
}

#markdown-content li {
  margin: 4px 0;
}

#markdown-content table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.88rem;
  width: 100%;
}

#markdown-content th,
#markdown-content td {
  border: 1px solid var(--card-border);
  padding: 6px 10px;
  text-align: left;
}

#markdown-content th {
  background: rgba(200, 192, 176, 0.2);
  font-weight: 600;
  color: var(--ink);
}

#markdown-content td {
  color: var(--ink-soft);
}

#markdown-content tr:nth-child(even) td {
  background: rgba(200, 192, 176, 0.08);
}

/* ── Code blocks ────────────────────────────────────────────── */

.code-block {
  position: relative;
  margin: 1em 0;
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 12px 14px;
  background: var(--thermal-bg);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-x: auto;
}

.code-block pre code {
  background: none;
  padding: 0;
}

#markdown-content pre code,
#markdown-content pre code:not(.hljs),
#markdown-content pre code.hljs {
  display: block;
  padding: 0;
  background: none;
}

#markdown-content code:not(.hljs) {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--terracotta);
  background: rgba(196, 97, 59, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
}

.copy-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10;
  opacity: 0;
  font: inherit;
  font-size: 0.72rem;
  padding: 2px 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  color: var(--ink-soft);
  cursor: pointer;
  transition: opacity 0.25s, background 0.2s;
}

pre:hover .copy-btn,
.code-block:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--ink);
  color: var(--card);
}

/* ── code block highlight.js overrides ─────────────────────── */

.hljs {
  background: transparent;
}

/* ── Images ─────────────────────────────────────────────────── */

#markdown-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin: 0.8em 0;
}

#markdown-content img[alt*="shields"] {
  vertical-align: middle;
}

/* ── Releases ───────────────────────────────────────────────── */

#releases {
  margin-top: 32px;
  border-top: 1px solid var(--rule);
  padding-top: 8px;
}

#release-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 8px;
}

#release-heading:hover {
  color: var(--terracotta);
}

#release-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.release-item {
  background: var(--paper-dark);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
}

.release-tag {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal);
  text-decoration: none;
  padding: 2px 8px;
  background: rgba(74, 122, 122, 0.08);
  border-radius: var(--border-radius);
}

.release-tag:hover {
  color: var(--card);
  background: var(--teal);
}

.release-name {
  font-size: 0.9rem;
  color: var(--ink);
}

.release-date {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.release-assets {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
}

.release-asset-link {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-decoration: none;
  border: 1px solid var(--card-border);
  padding: 2px 8px;
  border-radius: var(--border-radius);
  background: var(--card);
}

.release-asset-link:hover {
  background: var(--ink);
  color: var(--card);
}

/* ── Blocked / not-found ────────────────────────────────────── */

.not-found-message,
.blocked-message,
#error p {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.not-found-message a,
.blocked-message a {
  color: var(--link);
  text-decoration: underline dotted;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  font-size: 0.95rem;
  color: var(--ink-soft);
  border: 1px dashed var(--card-border);
}

/* ── 404 Error Page ─────────────────────────────────────────── */

.error-page {
  text-align: center;
  padding: 48px 36px 52px !important;
}

.error-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  user-select: none;
}

.error-digit {
  font-family: var(--mono);
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--teal);
  text-shadow:
    0 2px 0 var(--card-border),
    0 4px 6px rgba(100, 90, 75, 0.15);
  letter-spacing: -4px;
}

.error-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}

.error-message {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 380px;
  margin: 0 auto 24px;
}

.error-compass {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  background: var(--card);
  box-shadow: 0 1px 3px rgba(100, 90, 75, 0.10);
  transition: box-shadow 0.25s, transform 0.25s;
}

.error-compass:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(100, 90, 75, 0.16);
}

.compass-needle {
  font-size: 1.2rem;
  color: var(--terracotta);
  transition: transform 0.3s;
}

.error-compass:hover .compass-needle {
  transform: translateX(-4px);
}

.error-back {
  font-size: 0.88rem;
  color: var(--link);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.error-back:hover {
  color: var(--terracotta);
}

/* ── Hidden utility ─────────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 640px) {
  body {
    padding: 16px;
  }
  #container {
    padding: 16px 18px;
  }
  #repo-grid {
    grid-template-columns: 1fr;
  }
  #repo-list > div:first-child {
    flex-direction: column;
    align-items: stretch;
  }
  #repo-search {
    min-width: unset;
  }
}