/* MinimalRetro Ghost Theme
 * A minimal theme with 90s terminal aesthetic and switchable color palettes
 * Inspired by IBM 5151, NeXT Cube, SGI Indigo, Xerox Alto
 */

/* ============================================
   CSS Variables - Theme Colors
   ============================================ */

:root {
  /* Base colors (dark background) */
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --text: #e8e4df;
  --text-muted: #9a9590;
  --border: #3a2e25;

  /* Default: Amber Phosphor - IBM 5151, late-night terminals */
  --accent: #d4a574;
  --link: #c4956a;
  --code: #e8b888;
}

/* Theme: Amber Phosphor (default) - IBM 5151, late-night terminals */
[data-theme="amber"] {
  --accent: #d4a574;
  --link: #c4956a;
  --code: #e8b888;
  --border: #3a2e25;
}

/* Theme: Cathode - cool blue-gray CRT glow */
[data-theme="cathode"] {
  --accent: #8799a8;
  --link: #6a8caf;
  --code: #7a9ab8;
  --border: #2a2f35;
}

/* Theme: P1 Phosphor - PDP-11, oscilloscopes */
[data-theme="p1"] {
  --accent: #7a9a7a;
  --link: #6b9a8a;
  --code: #8aaa8a;
  --border: #2a3530;
}

/* Theme: NeXT Cube - PostScript, WWW origin */
[data-theme="next"] {
  --accent: #a89080;
  --link: #9088a0;
  --code: #b0a090;
  --border: #302828;
}

/* Theme: Indigo SGI - Silicon Graphics, Jurassic Park */
[data-theme="sgi"] {
  --accent: #8080a8;
  --link: #7090b0;
  --code: #9898b8;
  --border: #28283a;
}

/* Theme: Xerox Alto - PARC, Smalltalk, Engelbart */
[data-theme="alto"] {
  --accent: #b8a898;
  --link: #8898a8;
  --code: #a8b8b0;
  --border: #302e2a;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
  font-size: 18px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.7;
  min-height: 100vh;
}

/* ============================================
   Layout
   ============================================ */

.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main {
  flex: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

h1 { font-size: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; margin-top: 2.5rem; margin-bottom: 1rem; color: var(--accent); }
h3 { font-size: 1.25rem; margin-top: 2rem; margin-bottom: 0.75rem; color: var(--accent); }

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

p {
  margin-bottom: 1.5rem;
}

/* ============================================
   Forms
   ============================================ */

label {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  border-radius: 2px;
  margin-bottom: 1.5rem;
  transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

button,
input[type="submit"] {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--accent);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover,
input[type="submit"]:hover {
  background: var(--accent);
  color: var(--bg);
}

button:focus,
input[type="submit"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================
   Header
   ============================================ */

.site-header {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-bottom: 1px solid var(--border);
}

.site-name {
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: lowercase;
  border-bottom: none;
}

.site-name:hover {
  border-bottom: none;
}

/* Hide site name on homepage */
.home-template .site-name {
  display: none;
}

/* Center nav on homepage when site name is hidden */
.home-template .site-header {
  justify-content: center;
}

.site-nav {
  display: flex;
  gap: 2rem;
}

/* Ghost {{navigation}} helper outputs ul.nav */
.site-nav ul,
.site-nav .nav {
  display: flex;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav li {
  margin: 0;
  padding: 0;
}

.site-nav a {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: none;
  text-transform: lowercase;
}

.site-nav a:hover {
  color: var(--link);
  border-bottom: none;
}

.site-nav a.active,
.site-nav a[aria-current="page"],
.site-nav .nav-current a {
  color: var(--accent);
}

/* ============================================
   Hero (Homepage)
   ============================================ */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 4rem 2rem;
  /* Break out of container constraints */
  width: 100vw;
  margin-left: calc(-50vw + 50%);
}

.hero-name {
  font-family: 'Space Mono', monospace;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.hero-tagline {
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin: 0;
}

/* Legacy class for backwards compatibility */
.hero-title {
  font-family: 'Space Mono', monospace;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
  max-width: 600px;
  line-height: 1.5;
}

/* ============================================
   Archive / Post Feed
   ============================================ */

.archive {
  padding-top: 2rem;
}

.archive-header {
  margin-bottom: 3rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.archive-title {
  font-size: 1.25rem;
  color: var(--accent);
  text-transform: lowercase;
}

.post-feed {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

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

.post-card:last-child {
  border-bottom: none;
}

.post-card-meta {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.post-card-meta .separator {
  margin: 0 0.5rem;
}

.post-card-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.post-card-title a {
  color: var(--text);
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.post-card-title a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.post-card-excerpt {
  color: var(--text-muted);
  margin-bottom: 0;
  font-size: 0.95rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   Single Post
   ============================================ */

/* Reading progress bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  width: 0%;
  z-index: 1000;
  transition: width 0.1s ease-out;
}

.post {
  padding-top: 2rem;
}

.back-link {
  display: inline-block;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  border-bottom: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--accent);
  border-bottom: none;
}

.post-header {
  margin-bottom: 3rem;
}

.post-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.post-meta {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.post-meta .separator {
  margin: 0 0.5rem;
}

/* Feature image */
.post-feature-image {
  margin: 2rem 0 3rem;
}

.post-feature-image img {
  width: 100%;
  height: auto;
  border-radius: 2px;
  border: 1px solid var(--border);
}

.post-feature-image figcaption {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.75rem;
}

/* Post content */
.post-content {
  font-size: 1rem;
  line-height: 1.8;
}

.post-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.post-content h3 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content li::marker {
  color: var(--accent);
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.post-content code {
  font-family: 'Space Mono', monospace;
  font-size: 0.9em;
  background: var(--bg-elevated);
  color: var(--code);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

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

/* Post footer */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-tags a {
  display: inline-block;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.3em 0.6em;
  border-radius: 3px;
  margin-right: 0.5rem;
  border-bottom: none;
}

.post-tags a:hover {
  color: var(--accent);
  border-bottom: none;
}

/* Post navigation */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  gap: 2rem;
}

.post-nav-prev,
.post-nav-next {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: none;
}

.post-nav-next {
  text-align: right;
}

.post-nav-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.post-nav-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
  color: var(--link);
}

.post-nav-prev:hover .post-nav-title,
.post-nav-next:hover .post-nav-title {
  color: var(--accent);
}

/* ============================================
   Page (Static)
   ============================================ */

.page {
  padding-top: 2rem;
}

.page-header {
  margin-bottom: 3rem;
}

.page-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.page-feature-image {
  margin-top: 1.5rem;
}

.page-feature-image img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.page-content {
  font-size: 1rem;
  line-height: 1.8;
}

.page-content ul,
.page-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.page-content li {
  margin-bottom: 0.5rem;
}

.page-content li::marker {
  color: var(--accent);
}

/* ============================================
   Error Page
   ============================================ */

.error-page {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.error-code {
  font-family: 'Space Mono', monospace;
  font-size: 6rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 1rem;
}

.error-message {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.error-link {
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
}

/* ============================================
   Footer
   ============================================ */

.site-footer {
  max-width: 680px;
  margin: 0 auto;
  margin-top: 2rem;
  padding: 1.5rem 2rem;
  width: 100%;
  border-top: 1px solid var(--border);
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
}

.social-links a {
  display: inline-flex;
  color: var(--text-muted);
  opacity: 0.6;
  transition: opacity 0.2s ease, color 0.2s ease;
  text-decoration: none;
  border: 0;
  border-bottom: 0;
  background: transparent;
}

.social-links a:hover {
  color: var(--accent);
  opacity: 1;
  border: 0;
  border-bottom: 0;
}

.social-links svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
}

/* ============================================
   Theme Toggle
   ============================================ */

.theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 6px;
  z-index: 100;
  padding: 6px;
  border-radius: 12px;
  opacity: 0.3;
  transition: opacity 0.3s ease, background 0.3s ease;
}

.theme-toggle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.03);
}

.theme-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover .theme-dot {
  opacity: 1;
  transform: scale(1);
}

.theme-dot.active {
  opacity: 1;
  transform: scale(1);
}

.theme-dot:hover {
  transform: scale(1.5);
}

.theme-dot:focus {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.theme-dot:focus:not(:focus-visible) {
  outline: none;
}

.theme-dot:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Theme dot colors for visual indication */
.theme-dot[data-theme="amber"] { background: #d4a574; }
.theme-dot[data-theme="cathode"] { background: #8799a8; }
.theme-dot[data-theme="p1"] { background: #7a9a7a; }
.theme-dot[data-theme="next"] { background: #a89080; }
.theme-dot[data-theme="sgi"] { background: #8080a8; }
.theme-dot[data-theme="alto"] { background: #b8a898; }

/* ============================================
   Pagination
   ============================================ */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
}

.pagination a {
  color: var(--link);
}

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

.page-number {
  color: var(--text-muted);
}

/* ============================================
   Ghost Editor Cards (for rich content)
   ============================================ */

.kg-card {
  margin: 1.5rem 0;
}

.kg-image-card img {
  max-width: 100%;
  height: auto;
}

.kg-width-wide {
  max-width: 100%;
}

.kg-width-full {
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.kg-bookmark-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.kg-bookmark-container {
  display: flex;
  text-decoration: none;
  color: inherit;
}

.kg-bookmark-content {
  flex: 1;
  padding: 1rem;
}

.kg-bookmark-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.kg-bookmark-description {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.kg-bookmark-thumbnail {
  width: 200px;
}

.kg-bookmark-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kg-bookmark-metadata {
  display: flex;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.kg-bookmark-icon {
  width: 16px;
  height: 16px;
  margin-right: 0.5rem;
}

.kg-bookmark-author {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.kg-bookmark-author::after {
  content: "•";
  margin: 0 0.5rem;
}

.kg-bookmark-publisher {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Gallery Cards */
.kg-gallery-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.kg-gallery-row {
  display: flex;
  gap: 0.5rem;
}

.kg-gallery-row:not(:first-of-type) {
  margin-top: 0;
}

.kg-gallery-image {
  flex: 1;
  height: 100%;
}

.kg-gallery-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

/* ============================================
   Responsive
   ============================================ */

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

  .site-header {
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
  }

  .site-nav {
    gap: 1.5rem;
  }

  .site-nav-home {
    justify-content: center;
  }

  .site-main {
    padding: 1.5rem;
  }

  .hero-title {
    font-size: 1.25rem;
  }

  .post-title {
    font-size: 1.5rem;
  }

  .post-nav {
    flex-direction: column;
  }

  .post-nav-next {
    text-align: left;
  }

  .theme-toggle {
    bottom: 1rem;
    right: 1rem;
  }
}
