/* ── Reset & variables ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --text:       #1a1a1a;
  --muted:      #6b7280;
  --accent:     #2563eb;
  --bg:         #ffffff;
  --border:     #bcbdc2;
  --code-bg:    #f3f4f6;
  --max-w:      680px;
  --font-sans:  'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
  --font-mono:  'SF Mono', 'Fira Code', Consolas, 'Liberation Mono', monospace;
}

body {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* ── Header ──────────────────────────────────────────────── */
.site-header {
  padding: 1rem 2rem;
  background: #01066b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-name {
  font-family: var(--font-sans);
  font-size: 1.6rem;
  font-weight: 900;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-name:hover { color: rgba(255,255,255,0.75); }

/* ── Header nav dropdown ─────────────────────────────────── */
.header-nav {
  position: relative;
}

.header-nav-btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s;
}

.header-nav-btn:hover { background: rgba(255,255,255,0.25); }

.header-nav-btn svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s;
}

.header-nav-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.header-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 200px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 100;
}

.header-dropdown a {
  font-family: var(--font-sans);
  display: block;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

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

.header-dropdown a:hover { background: var(--code-bg); }

/* ── Layout ──────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 3.5rem auto;
  padding: 0 2rem;
}

/* ── Index: page list ────────────────────────────────────── */
.page-list {
  list-style: none;
}

.page-list li {
  border-bottom: 1px solid var(--border);
}

.page-list li:last-child {
  border-bottom: none;
}

.page-list a {
  font-family: var(--font-sans);
  display: block;
  padding: 0.6rem 0;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  transition: color 0.15s;
}

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

/* ── Page: markdown content ──────────────────────────────── */
.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
  font-family: var(--font-sans);
  line-height: 1.3;
  margin: 2rem 0 0.6rem;
  font-weight: 700;
}

.content h1 { font-size: 1.9rem; margin-top: 0; letter-spacing: -0.02em; }
.content h2 { font-size: 1.35rem; letter-spacing: -0.01em; }
.content h3 { font-size: 1.1rem; }

.content p {
  margin-bottom: 1.25rem;
}

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

.content ul,
.content ol {
  margin: 0 0 1.25rem 1.5rem;
}

.content li {
  margin-bottom: 0.35rem;
}

.content li > ul,
.content li > ol {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.content blockquote {
  border-left: 3px solid var(--border);
  margin: 1.5rem 0;
  padding: 0.25rem 1.25rem;
  color: var(--muted);
}

.content blockquote p {
  margin-bottom: 0;
}

.content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

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

.content img {
  max-width: 100%;
  border-radius: 6px;
  margin: 1rem 0;
}

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

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.content th,
.content td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
}

.content th {
  background: var(--code-bg);
  font-weight: 600;
}

/* ── Page footer ─────────────────────────────────────────── */
.page-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

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

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

/* ── Site footer ─────────────────────────────────────────── */
.site-footer {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 2rem;
  margin-top: 4rem;
  border-top: 1px solid var(--border);
}

/* ── States ──────────────────────────────────────────────── */
.loading { color: var(--muted); }
.error   { color: #dc2626; }

/* ── Page layout (with nav sidebar) ─────────────────────── */
.page-layout {
  max-width: 940px;
  margin: 3.5rem auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 180px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "home    content"
    "nav     content";
  column-gap: 3.5rem;
  row-gap: 1rem;
  align-items: start;
}

.page-nav-home {
  grid-area: home;
  display: block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  align-self: center;
}

.page-nav-home:hover { color: var(--accent); }

.page-body {
  grid-area: content;
}

.page-nav {
  grid-area: nav;
  position: sticky;
  top: 2rem;
}

.page-nav ul {
  list-style: none;
}

.page-nav li {
  border-bottom: 1px solid var(--border);
}

.page-nav li:last-child {
  border-bottom: none;
}

.page-nav a {
  font-family: var(--font-sans);
  display: block;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.page-nav a:hover { color: var(--text); }

.page-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

/* ── Index layout ────────────────────────────────────────── */
.index-container {
  max-width: 1080px;
  margin: 3.5rem auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 4rem;
  align-items: start;
}

.index-left {
  min-width: 0;
}

.homepage-content {
  margin-bottom: 1.5rem;
}

.pages-section {
  min-width: 0;
}

/* ── Shared nav box (index + page sidebar) ───────────────── */
.nav-box {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.nav-box-heading {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* ── Bluesky feed ────────────────────────────────────────── */
.feed-section {
  min-width: 0;
  background: var(--code-bg);
  border: 1px solid #bcbdc2;
  border-radius: 8px;
  padding: 1.25rem;
}

.feed-heading {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bsky-icon {
  width: 14px;
  height: 14px;
  color: #0085ff;
  flex-shrink: 0;
}

.feed-item {
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid #bcbdc2;
}

.feed-item:first-of-type {
  border-top: 1px solid #bcbdc2;
}

.feed-item:nth-of-type(even) {
  background: rgba(0, 0, 0, 0.025);
  border-radius: 4px;
}

.feed-text {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 0.6rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.feed-text a {
  color: var(--accent);
  text-decoration: none;
}

.feed-text a:hover { text-decoration: underline; }

/* Link preview card */
.link-card {
  display: flex;
  gap: 0.75rem;
  border: 1px solid #bcbdc2;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  margin-bottom: 0.5rem;
  transition: border-color 0.15s;
}

.link-card:hover { border-color: #9ca3af; }

.link-card-thumb {
  width: 80px;
  min-height: 80px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--code-bg);
}

.link-card-body {
  padding: 0.6rem 0.75rem 0.6rem 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  justify-content: center;
}

.link-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.link-card-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.link-card-host {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Inline images */
.feed-image {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  display: block;
  background: var(--code-bg);
}

.feed-meta {
  margin-top: 0.4rem;
}

.feed-time {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}

.feed-time:hover { color: var(--accent); }

.feed-profile-link {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  margin-top: 1rem;
}

.feed-profile-link:hover { color: var(--accent); }

.feed-empty { font-size: 0.9rem; color: var(--muted); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 800px) {
  .index-container {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 640px) {
  .page-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "home"
      "content"
      "nav";
    gap: 1.5rem;
  }
  .page-nav {
    position: static;
  }
}

@media (max-width: 600px) {
  .container,
  .index-container { margin: 2rem auto; }
  .content h1 { font-size: 1.5rem; }
}
