/* pleometric.net — design system
   Source Serif 4 + JetBrains Mono
   Purple as structural ink, warm neutral surfaces */

/* --------------------------------------------------------
   1. CSS Custom Properties
   -------------------------------------------------------- */

[data-theme="light"] {
  --bg: #faf9f7;
  --bg-alt: #f3f1ed;
  --bg-card: #ffffff;
  --surface: #eeeadf;

  --text: #2c2638;
  --text-secondary: #6b607a;
  --text-tertiary: #9990a8;

  --purple: #6b4c9a;
  --purple-dim: #8b7aad;
  --purple-faint: rgba(107, 76, 154, 0.07);
  --purple-border: rgba(107, 76, 154, 0.15);

  --border: rgba(44, 38, 56, 0.1);
  --border-strong: rgba(44, 38, 56, 0.2);

  --why-bg: rgba(107, 76, 154, 0.04);
  --why-border: rgba(107, 76, 154, 0.25);

  --badge-bg: rgba(107, 76, 154, 0.08);
  --badge-text: #6b4c9a;

  --search-focus: rgba(107, 76, 154, 0.1);

  --popup-shadow-large: rgba(44, 38, 56, 0.08);
  --popup-shadow-small: rgba(44, 38, 56, 0.04);
}

[data-theme="dark"] {
  --bg: #1c1728;
  --bg-alt: #1e1930;
  --bg-card: #241f33;
  --surface: #241f33;

  --text: #e8e3f0;
  --text-secondary: #b8b0c8;
  --text-tertiary: #928aa6;

  --purple: #b99de0;
  --purple-dim: #9080aa;
  --purple-faint: rgba(185, 157, 224, 0.07);
  --purple-border: rgba(185, 157, 224, 0.16);

  --border: rgba(232, 227, 240, 0.12);
  --border-strong: rgba(232, 227, 240, 0.22);

  --why-bg: rgba(185, 157, 224, 0.05);
  --why-border: rgba(185, 157, 224, 0.2);

  --badge-bg: rgba(185, 157, 224, 0.1);
  --badge-text: #b99de0;

  --search-focus: rgba(185, 157, 224, 0.12);

  --popup-shadow-large: rgba(0, 0, 0, 0.3);
  --popup-shadow-small: rgba(0, 0, 0, 0.15);
}

/* --------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------- */

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

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-weight: 400;
  line-height: 1.72;
  color: var(--text);
  background: var(--bg);
  transition: color 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

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

a:hover {
  color: var(--purple);
  text-decoration: underline;
}

img { max-width: 100%; height: auto; }

/* --------------------------------------------------------
   3. Layout
   -------------------------------------------------------- */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --------------------------------------------------------
   4. Site Header
   -------------------------------------------------------- */

.site-header {
  margin-bottom: 0.5rem;
}

.site-header-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.site-header-text {
  min-width: 0;
}

.site-name {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
}

.site-name a {
  color: inherit;
  text-decoration: none;
}

.site-tagline {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.55rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  margin-top: 0.1rem;
}

/* Mascot */

.mascot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--purple-border);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-alt);
  transition: border-color 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.mascot svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mascot-eyes  { fill: #f3f1ed; }
.mascot-belly { fill: #f3f1ed; }
.mascot-body  { fill: #6b4c9a; }
.mascot-hearts { fill: #3d2a6b; }
.mascot-beak  { fill: #a898c4; }
.mascot-beak-shadow { fill: #8b7aad; }

[data-theme="dark"] .mascot {
  background: #2a2040;
  border-color: #6b4c9a;
}

[data-theme="dark"] .mascot-eyes  { fill: #e8e3f0; }
[data-theme="dark"] .mascot-belly { fill: #e8e3f0; }

/* --------------------------------------------------------
   5. Navigation
   -------------------------------------------------------- */

.site-nav {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.8rem;
}

.site-nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  text-decoration: none;
  position: relative;
  padding-bottom: 0.15rem;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--purple);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

.site-nav a:hover {
  color: var(--purple);
  text-decoration: none;
}

.site-nav a:hover::after {
  transform: scaleX(1);
}

.site-nav a.active {
  color: var(--purple);
}

/* --------------------------------------------------------
   6. Page Title
   -------------------------------------------------------- */

h1.page-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 1rem;
}

/* --------------------------------------------------------
   7. Section Headers
   -------------------------------------------------------- */

h2.section-title {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
  margin-top: 1.5rem;
}

/* --------------------------------------------------------
   8. Stats Line
   -------------------------------------------------------- */

.stats-line {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-bottom: 1rem;
}

.stats-line .stats-num {
  color: var(--text-secondary);
  font-weight: 500;
}

/* --------------------------------------------------------
   9. Search Bar
   -------------------------------------------------------- */

.search-wrap {
  margin-bottom: 1.2rem;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  padding: 0.55rem 0.75rem 0.55rem 2.2rem;
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  border-color: var(--purple-border);
  box-shadow: 0 0 0 3px var(--search-focus);
}

/* --------------------------------------------------------
   10. Resource Card
   -------------------------------------------------------- */

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

.card {
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 0;
}

.card:first-child {
  padding-top: 0;
}

.card-top {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-tertiary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

.card-date {
  color: var(--text-secondary);
}

.card-duration {
  color: var(--text-tertiary);
}

.card-source {
  color: var(--text-secondary);
  margin-left: auto;
}

.card-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.35rem;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.card-title a:hover {
  color: var(--purple);
}

.card-why {
  font-family: 'Source Serif 4', Georgia, serif;
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.55;
  padding: 0.4rem 0.65rem;
  background: var(--why-bg);
  border-left: 2px solid var(--why-border);
  border-radius: 0 3px 3px 0;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.tag {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.58rem;
  font-weight: 400;
  padding: 0.15rem 0.45rem;
  background: var(--purple-faint);
  color: var(--purple);
  border: 1px solid var(--purple-border);
  border-radius: 3px;
  line-height: 1.4;
}

/* --------------------------------------------------------
   11. Type Badges
   -------------------------------------------------------- */

.type-badge {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.58rem;
  font-weight: 500;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.type-badge.video  { background: rgba(200, 120, 60, 0.1); color: #b87040; }
.type-badge.paper  { background: rgba(60, 140, 180, 0.1); color: #4a9ab8; }
.type-badge.link   { background: var(--badge-bg); color: var(--badge-text); }
.type-badge.essay  { background: rgba(90, 160, 90, 0.1); color: #5a9a5a; }
.type-badge.note   { background: rgba(160, 140, 80, 0.1); color: #a09050; }

[data-theme="dark"] .type-badge.video { background: rgba(200, 120, 60, 0.12); color: #d49060; }
[data-theme="dark"] .type-badge.paper { background: rgba(60, 140, 180, 0.12); color: #6bbada; }
[data-theme="dark"] .type-badge.essay { background: rgba(90, 160, 90, 0.12); color: #7aba7a; }
[data-theme="dark"] .type-badge.note  { background: rgba(160, 140, 80, 0.12); color: #c0aa60; }

/* --------------------------------------------------------
   12. Annotation Popup
   -------------------------------------------------------- */

.annotation-popup {
  position: absolute;
  z-index: 100;
  max-width: 360px;
  width: calc(100vw - 2rem);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  box-shadow:
    0 8px 30px var(--popup-shadow-large),
    0 2px 6px var(--popup-shadow-small);
  display: none;
}

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

.popup-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.popup-meta {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.6rem;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.popup-why {
  font-family: 'Source Serif 4', Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.35rem 0.55rem;
  background: var(--why-bg);
  border-left: 2px solid var(--why-border);
  border-radius: 0 3px 3px 0;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}

.popup-link {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  color: var(--purple);
}

/* --------------------------------------------------------
   13. Writings / Post
   -------------------------------------------------------- */

.post-body {
  line-height: 1.72;
}

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

.post-body h2 {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.post-body h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.post-body code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  background: var(--bg-alt);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.post-body pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

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

.post-body blockquote {
  border-left: 2px solid var(--purple-border);
  padding-left: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 1rem;
}

.drop-cap::first-letter {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 3.3em;
  font-weight: 700;
  float: left;
  line-height: 0.8;
  padding-right: 0.08em;
  margin-top: 0.05em;
  color: var(--purple);
}

/* --------------------------------------------------------
   14. Writing Card (list item)
   -------------------------------------------------------- */

.writing-card {
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0;
}

.writing-card-date {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  color: var(--text-tertiary);
}

.writing-card-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.writing-card-title a {
  color: var(--text);
  text-decoration: none;
}

.writing-card-title a:hover {
  color: var(--purple);
}

/* --------------------------------------------------------
   15. Theme Toggle
   -------------------------------------------------------- */

.theme-toggle {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 2px 8px var(--popup-shadow-small);
  transition: border-color 0.2s ease, background 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
}

.theme-toggle:hover {
  border-color: var(--purple-border);
}

/* --------------------------------------------------------
   16. Footer
   -------------------------------------------------------- */

.site-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.6rem;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-footer a {
  color: var(--purple-dim);
}

/* --------------------------------------------------------
   17. Empty State
   -------------------------------------------------------- */

.empty-state {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: 2rem 0;
  text-align: center;
}

.empty-state code {
  font-size: 0.7rem;
  background: var(--bg-alt);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

/* --------------------------------------------------------
   18. No-results state (search)
   -------------------------------------------------------- */

.no-results {
  display: none;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: 1.5rem 0;
  text-align: center;
}

/* --------------------------------------------------------
   19. Responsive
   -------------------------------------------------------- */

@media (max-width: 600px) {
  html { font-size: 16px; }

  .page {
    padding: 1.2rem 1rem;
  }

  .site-nav ul {
    gap: 1rem;
  }

  .card-source {
    margin-left: 0;
  }

  .annotation-popup {
    max-width: calc(100vw - 2rem);
  }
}
