@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,600;1,400&family=Noto+Serif:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --bg: #ffffff;
  --fg: #111111;
  --fg-secondary: #888888;
  --fg-tertiary: #999999;
  --fg-muted: #bbbbbb;
  --border: #eeeeee;
  --link: #1a54a5;
  --highlight: rgba(255, 230, 100, 0.35);
  --font-body: 'Noto Sans', sans-serif;
  --post-width: 744px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  transition: background 0.3s, color 0.3s;
}

/* ---- Mobile block ---- */

.mobile-block {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.mobile-block p {
  max-width: 320px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--fg-secondary);
}

@media (max-width: 768px) and (orientation: portrait) {
  .mobile-block {
    display: flex;
  }
  .shell {
    display: none !important;
  }
}

/* ---- Layout shell ---- */

.shell {
  margin: 0;
  padding: 0 2rem 3rem 2.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Top options bar (fixed size) ---- */

.top-menu {
  padding: 11px 0;
  font-size: 12px;
  margin-bottom: 16px;
}

.top-menu-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.nav-links {
  display: flex;
  gap: 14px;
  font-size: 12px;
}

.nav-link {
  color: var(--fg-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
  font-family: var(--font-body);
}

.nav-link:hover {
  color: var(--fg);
}

.nav-link.active {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.menu-toggle {
  color: var(--fg-tertiary);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-family: var(--font-body);
  background: none;
  border: none;
  padding: 0;
  transition: color 0.15s;
}

.menu-toggle:hover {
  color: var(--fg);
}

.menu-panel {
  display: none;
  padding-top: 10px;
}

.menu-panel.open {
  display: flex;
  align-items: center;
  gap: 24px;
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.setting-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-size: 11px;
  color: var(--fg-tertiary);
}

.font-btn, .size-btn {
  background: none;
  border: none;
  padding: 3px 7px;
  font-size: 12px;
  cursor: pointer;
  color: var(--fg-secondary);
  transition: all 0.15s;
  font-family: var(--font-body);
}

.font-btn:hover, .size-btn:hover {
  color: var(--fg);
}

.font-btn.active, .size-btn.active {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.brightness-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.brightness-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--fg-muted);
  transition: transform 0.15s;
}

.brightness-dot:hover {
  transform: scale(1.2);
}

.brightness-dot.active {
  border-color: var(--fg);
  box-shadow: 0 0 0 1.5px var(--fg);
}

/* ---- Header ---- */

.site-header {
  padding-bottom: 0;
  margin-bottom: 3rem;
}

.site-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  color: var(--fg);
}

/* ---- Main ---- */

.main {
  flex: 1;
}

/* ---- Post list ---- */

.post-list {
  list-style: none;
}

.post-item {
  padding: 0.5rem 0;
  
}

.post-item:first-child {
  padding-top: 0;
}

.post-link {
  text-decoration: none;
  color: var(--fg);
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}

.post-link:hover .post-title-text {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-date {
  font-size: 0.78rem;
  color: var(--fg-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.post-title {
  font-size: 0.95rem;
  font-weight: 400;
}

.post-wordcount {
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-left: 0.2rem;
}

.post-modified-dot {
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-left: 0.15rem;
  cursor: help;
}

/* ---- Filter bar ---- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--fg-secondary);
}

.filter-bar .clear-filter {
  color: var(--fg);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---- Tags footer (collapsible) ---- */

.tag-footer {
  margin-top: 3rem;
  padding-top: 1.2rem;
  
}

.tag-footer-toggle {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-tertiary);
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  transition: color 0.15s;
}

.tag-footer-toggle:hover {
  color: var(--fg);
}

.tag-footer-content {
  display: none;
  margin-top: 0.6rem;
}

.tag-footer-content.open {
  display: block;
}

.tag-footer-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.8rem;
}

.tag-footer-item {
  font-size: 0.8rem;
  color: var(--fg-secondary);
  cursor: pointer;
  transition: color 0.15s;
}

.tag-footer-item:hover {
  color: var(--fg);
}

.tag-footer-item.active {
  color: var(--fg);
  font-weight: 600;
}

.tag-count {
  color: var(--fg-muted);
  font-size: 0.72rem;
  margin-left: 0.15rem;
}

/* ---- Geo footer ---- */

.geo-footer {
  position: fixed;
  bottom: 1rem;
  right: 1.5rem;
  font-size: 12px;
  color: var(--fg-muted);
  pointer-events: none;
  z-index: 50;
}

/* ---- Reading progress bar ---- */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--fg-muted);
  z-index: 9000;
  transition: width 0.1s;
  width: 0%;
}

/* ---- Breadcrumbs ---- */

.breadcrumbs {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--fg-tertiary);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  max-width: var(--post-width);
}

.breadcrumb-link {
  color: var(--fg-muted);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

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

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

.breadcrumb-current {
  color: var(--fg-secondary);
}

/* ---- Post view ---- */

.post-view-wrapper {
  position: relative;
}

.post-view {
  max-width: var(--post-width);
}

.post-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
}

.post-view h1 {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.4rem;
}

.post-modified {
  font-size: 0.72rem;
  color: var(--fg-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-view .post-meta {
  font-size: 0.78rem;
  color: var(--fg-secondary);
  margin-bottom: 2rem;
}

.post-view .post-body p {
  margin-bottom: 1.1rem;
}

.post-view .post-body h1 {
  display: none;
}

.post-view .post-body h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

.post-view .post-body a.wiki-link {
  color: var(--link);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: text-decoration-style 0.15s;
}

.post-view .post-body a.wiki-link:hover {
  text-decoration-style: solid;
}

.post-view .post-body a.ext-link {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: text-decoration-style 0.15s;
}

.post-view .post-body a.ext-link::after {
  content: ' ↗';
  font-size: 0.75em;
  color: var(--fg-muted);
}

.post-view .post-body a.ext-link:hover {
  text-decoration-style: dotted;
}

/* ---- Author highlights ---- */

.author-highlight {
  background: var(--highlight);
  padding: 1px 2px;
  border-radius: 2px;
}

/* ---- Images with loader ---- */

.post-view .post-body .img-wrap {
  width: 100%;
  position: relative;
  margin: 1.2rem 0;
  min-height: 120px;
  background: transparent;
}

.post-view .post-body .img-wrap.loading {
  background: var(--border);
}

.post-view .post-body .img-wrap.loading img {
  opacity: 0;
}

.post-view .post-body .img-wrap img {
  width: 100%;
  height: auto;
  display: block;
  opacity: 1;
  transition: opacity 0.3s;
}

.img-loader {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
}

.img-wrap.loading .img-loader {
  display: flex;
}

.img-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--fg-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.post-view .post-tags {
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.post-view .post-tag {
  font-size: 0.78rem;
  color: var(--fg-secondary);
  cursor: pointer;
}

.post-view .post-tag:hover {
  color: var(--fg);
}

/* ---- Footnotes ---- */

.fn-ref {
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
  color: var(--link);
  cursor: pointer;
  text-decoration: none;
  padding: 0 1px;
}

.fn-ref:hover {
  text-decoration: underline;
}

.fn-popup {
  display: none;
  position: absolute;
  left: calc(var(--post-width) + 2.5rem);
  width: 240px;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--fg-secondary);
  background: transparent;
  border: none;
  z-index: 100;
  pointer-events: none;
}

.fn-popup.visible {
  display: block;
}

.fn-inline {
  display: none;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--fg-secondary);
  padding: 0.6rem 0 0.4rem 1.5rem;
  margin: 0.3rem 0 1rem 0;
}

.fn-inline.visible {
  display: block;
}

/* ---- Citation tooltip ---- */

.cite-tooltip {
  position: fixed;
  background: var(--fg);
  color: var(--bg);
  font-size: 12px;
  font-family: var(--font-body);
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  z-index: 200;
  user-select: none;
  display: none;
  white-space: nowrap;
}

.cite-tooltip.visible {
  display: block;
}

.cite-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--fg);
}

/* ---- Backlinks ---- */

.backlinks {
  margin-top: 2rem;
  padding-top: 1rem;
  
}

.backlinks-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-tertiary);
  margin-bottom: 0.5rem;
}

.backlink-item {
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.backlink-item a {
  color: var(--link);
  text-decoration: none;
}

.backlink-item a:hover {
  text-decoration: underline;
}

/* ---- Context panel (right side, collapsible) ---- */

.context-panel {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 150;
  display: flex;
  align-items: flex-start;
}

.context-toggle {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: var(--bg);
  border: none;
  padding: 12px 6px;
  font-size: 11px;
  font-family: var(--font-body);
  color: var(--fg-tertiary);
  cursor: pointer;
  transition: color 0.15s;
}

.context-toggle:hover {
  color: var(--fg);
}

.context-body {
  width: 0;
  height: 350px;
  overflow: hidden;
  background: var(--bg);
  border: none;
  transition: width 0.3s, padding 0.3s;
  padding: 0;
}

.context-panel.open .context-body {
  width: 320px;
  padding: 12px;
}

.context-panel .local-graph-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.context-panel .local-graph-container svg {
  width: 100%;
  height: 100%;
}

/* ---- Global graph ---- */

.graph-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  
  position: relative;
  overflow: hidden;
}

.graph-container svg {
  width: 100%;
  height: 100%;
}

.graph-link {
  stroke: var(--border);
  stroke-width: 1;
}

.graph-node text {
  font-family: var(--font-body);
  pointer-events: none;
}

.graph-legend {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-size: 12px;
  color: var(--fg-muted);
  display: flex;
  gap: 1.2rem;
}

.graph-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.article {
  background: var(--fg);
}

.legend-dot.concept {
  background: var(--bg);
  border: 1.2px solid var(--fg-tertiary);
}

/* ---- Index view ---- */

.index-view {
  max-width: var(--post-width);
}

.index-view h1 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 2rem;
}

.index-letter {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--fg);
}

.index-letter:first-child {
  margin-top: 0;
}

.index-entry {
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  padding-left: 0.5rem;
}

.index-concept {
  color: var(--fg);
}

.index-refs {
  color: var(--fg-tertiary);
  font-size: 0.82rem;
}

.index-refs a {
  color: var(--link);
  text-decoration: none;
}

.index-refs a:hover {
  text-decoration: underline;
}

/* ---- Timeline view ---- */

.timeline-view {
  overflow-x: auto;
  padding-bottom: 2rem;
}

.timeline-view h1 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 2rem;
}

.timeline-container {
  position: relative;
  min-height: 300px;
}

.timeline-axis {
  stroke: var(--border);
  stroke-width: 1;
}

.timeline-tick text {
  font-family: var(--font-body);
  font-size: 11px;
  fill: var(--fg-tertiary);
}

.timeline-tick line {
  stroke: var(--border);
  stroke-width: 1;
}

.timeline-node {
  cursor: pointer;
}

.timeline-node circle {
  fill: var(--fg);
  transition: r 0.15s;
}

.timeline-node:hover circle {
  r: 6;
}

.timeline-node text {
  font-family: var(--font-body);
  font-size: 11px;
  fill: var(--fg);
}

.timeline-arc {
  fill: none;
  stroke: var(--fg-muted);
  stroke-width: 1;
  opacity: 0.5;
}

/* ---- Info panel (bottom slide) ---- */

.info-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 140;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.35s ease;
  padding: 0 2.5rem;
}

.info-panel.open {
  transform: translateY(0);
}

.info-panel-content {
  max-width: 600px;
  padding: 2rem 0 2.5rem 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--fg-secondary);
}

.info-panel-content p {
  margin-bottom: 0.8rem;
}

.info-panel-content a {
  color: var(--link);
  text-decoration: none;
}

.info-panel-content a:hover {
  text-decoration: underline;
}

.info-edit-link {
  margin-top: 2rem;
}

.info-edit-link a {
  font-size: 0.7rem;
  color: var(--fg-muted) !important;
}

.info-edit-link a:hover {
  color: var(--fg-secondary) !important;
}

/* ---- Utilities ---- */

.empty-state {
  color: var(--fg-tertiary);
  font-size: 0.9rem;
  padding: 2rem 0;
}

.inline-tag {
  display: none;
}
