/* Code Sketchbook / Git Minimalist Stylesheet */

:root {
  /* Common Variables */
  --font-mono: 'Space Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
  --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --container-max-width: 900px;
  --gutter-width: 50px;
  --line-height-base: 1.6;

  /* Theme Transitions */
  --theme-transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
                      border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
                      color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                      box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                      opacity 0.25s ease;

  /* Default Theme: Dark (GitHub Dark) */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-subtle: #21262d;
  --bg-active: #30363d;
  
  --fg-primary: #c9d1d9;
  --fg-secondary: #8b949e;
  --fg-muted: #484f58;
  
  --color-blue: #58a6ff;
  --color-green: #7ee787;
  --color-red: #ff7b72;
  --color-orange: #ffe699;
  --color-purple: #d2a8ff;
  --color-cyan: #a5d6ff;
  
  --border-color: #30363d;
  --border-hover: #8b949e;

  /* Layout/Card Extras */
  --card-bg: rgba(22, 27, 34, 0.75);
  --card-header-bg: rgba(13, 17, 34, 0.85);
  --grid-dot-color: rgba(48, 54, 61, 0.25);
  --spotlight-color: rgba(88, 166, 255, 0.05);
  --header-bg: rgba(22, 27, 34, 0.85);
  --gutter-active-bg: rgba(48, 54, 61, 0.15);
}

/* Explicit Dark Theme */
:root[data-theme="dark"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-subtle: #21262d;
  --bg-active: #30363d;
  
  --fg-primary: #c9d1d9;
  --fg-secondary: #8b949e;
  --fg-muted: #484f58;
  
  --color-blue: #58a6ff;
  --color-green: #7ee787;
  --color-red: #ff7b72;
  --color-orange: #ffe699;
  --color-purple: #d2a8ff;
  --color-cyan: #a5d6ff;
  
  --border-color: #30363d;
  --border-hover: #8b949e;

  /* Layout/Card Extras */
  --card-bg: rgba(22, 27, 34, 0.75);
  --card-header-bg: rgba(13, 17, 34, 0.85);
  --grid-dot-color: rgba(48, 54, 61, 0.25);
  --spotlight-color: rgba(88, 166, 255, 0.05);
  --header-bg: rgba(22, 27, 34, 0.85);
  --gutter-active-bg: rgba(48, 54, 61, 0.15);
}

/* Explicit Light Theme */
:root[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-subtle: #eaeef2; /* slightly darker subtle background for light mode buttons and tabs */
  --bg-active: #d0d7de;
  
  --fg-primary: #24292f;
  --fg-secondary: #57606a;
  --fg-muted: #8c959f;
  
  --color-blue: #0969da;
  --color-green: #1a7f37;
  --color-red: #cf222e;
  --color-orange: #9a6700;
  --color-purple: #8250df;
  --color-cyan: #0594fa;
  
  --border-color: #d0d7de;
  --border-hover: #57606a;

  /* Layout/Card Extras */
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-header-bg: rgba(246, 248, 250, 0.95);
  --grid-dot-color: rgba(140, 149, 159, 0.18);
  --spotlight-color: rgba(9, 105, 218, 0.04);
  --header-bg: rgba(255, 255, 255, 0.85);
  --gutter-active-bg: rgba(140, 149, 159, 0.08);
}

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

html, body {
  background-color: var(--bg-primary);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-base);
  min-height: 100vh;
  position: relative;
  transition: var(--theme-transition);
  overflow-wrap: break-word;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: radial-gradient(var(--grid-dot-color) 1px, transparent 1px);
  background-size: 24px 24px;
  z-index: -2;
  pointer-events: none;
  transition: background-image 0.3s ease;
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(
    600px circle at var(--mouse-x, -999px) var(--mouse-y, -999px),
    var(--spotlight-color),
    transparent 80%
  );
  z-index: -1;
  pointer-events: none;
}

/* Base Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-muted);
}

a {
  color: var(--color-blue);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: var(--color-cyan);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* --- Layout Structure --- */

/* Site Header */
.site-header {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--header-bg);
  background-image: linear-gradient(135deg, rgba(56, 189, 248, 0.08), transparent 45%);
  backdrop-filter: blur(12px);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--theme-transition);
}

/* Header Controls container */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: var(--theme-transition);
  outline: none;
  padding: 0;
  margin: 0;
}
.theme-toggle-btn:hover {
  border-color: var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--fg-primary);
}

.theme-toggle-btn svg {
  position: absolute;
  width: 14px;
  height: 14px;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  pointer-events: none;
}

/* Default state: Dark Theme (Sun icon visible, Moon hidden) */
.theme-toggle-btn .sun-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}
.theme-toggle-btn .moon-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

/* Light Theme state (Moon icon visible, Sun hidden) */
:root[data-theme="light"] .theme-toggle-btn .sun-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}
:root[data-theme="light"] .theme-toggle-btn .moon-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.header-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
}
.site-logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--fg-primary);
  text-decoration: none;
}
.logo-mark {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(119, 70, 255, 0.18), rgba(56, 189, 248, 0.14));
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 rgba(56, 189, 248, 0);
  transition: transform 0.35s ease, box-shadow 0.35s ease, background-color 0.35s ease;
}
.site-logo:hover .logo-mark {
  transform: translateY(-2px) rotate(4deg);
  box-shadow: 0 18px 28px rgba(56, 189, 248, 0.12);
}
.logo-mark svg {
  width: 26px;
  height: 26px;
}
.logo-name {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.logo-caption {
  font-size: 0.75rem;
  color: var(--fg-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
}
.site-logo .owner {
  color: var(--color-purple);
}
.site-logo .separator {
  color: var(--fg-muted);
}
.site-logo .repo {
  color: var(--color-cyan);
}

.git-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background-color: var(--bg-subtle);
  color: var(--fg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.6rem;
  border-radius: 2em;
}

/* Green dot for git status */
.git-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-green);
  box-shadow: 0 0 6px var(--color-green);
}
.git-badge svg {
  fill: currentColor;
  width: 12px;
  height: 12px;
}

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.03);
  padding-top: 0.5rem;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}
.nav-links a, .nav-links .nav-file-tab {
  color: var(--fg-secondary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.nav-links a:hover, .nav-links a.active, .nav-links .nav-file-tab.active {
  color: var(--fg-primary);
  text-decoration: none;
}
.nav-links a.active, .nav-links .nav-file-tab.active {
  border-bottom: 2px solid var(--color-orange);
  padding-bottom: 2px;
}

.nav-socials {
  display: flex;
  gap: 0.75rem;
}
.nav-socials a {
  color: var(--fg-secondary);
}
.nav-socials a:hover {
  color: var(--fg-primary);
}

/* Main Workspace with Line Numbers */
.workspace-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  display: flex;
  position: relative;
  min-height: calc(100vh - 120px);
}

/* The Line Gutter */
.line-gutter {
  width: var(--gutter-width);
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  padding: 2rem 0.5rem 2rem 0;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-muted);
  user-select: none;
  display: flex;
  flex-direction: column;
  transition: var(--theme-transition);
}
.line-number {
  height: 1.6rem;
  line-height: 1.6rem;
  padding-right: 0.5rem;
  display: block;
  transition: color 0.15s ease, background-color 0.15s ease;
  border-radius: 3px 0 0 3px;
}
.line-number:hover, .line-number.active {
  color: var(--color-blue);
  background-color: var(--gutter-active-bg);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 2rem 2rem 4rem 2rem;
  min-width: 0; /* fixes markdown overflow issues */
  overflow-wrap: break-word;
  word-break: break-word;
}

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

/* Footer styling */
.site-footer {
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  padding: 1.5rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-secondary);
  transition: var(--theme-transition);
}
.footer-container {
  max-width: var(--container-max-width);
  margin: 0 auto;
}

/* --- Code-Like Blog Styling Elements --- */

.file-info-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-secondary);
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-bottom: 2rem;
  transition: var(--theme-transition);
}
.file-info-bar svg {
  fill: currentColor;
  width: 14px;
  height: 14px;
}
.file-info-bar .file-path {
  color: var(--fg-primary);
}

/* Hero & Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg-primary);
  margin-top: 1.75em;
  margin-bottom: 0.75em;
  line-height: 1.25;
}
h1:first-child {
  margin-top: 0;
}
h1 {
  font-size: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3em;
}
h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3em;
}
h3 {
  font-size: 1.25rem;
}

/* Add custom "// type" comments or "// comment" details to titles */
.title-comment {
  font-weight: normal;
  color: var(--fg-secondary);
  font-size: 0.9rem;
}

p, ul, ol, blockquote, table, pre {
  margin-bottom: 1rem;
}

p {
  color: var(--fg-primary);
  text-align: justify;
}

/* List elements */
ul, ol {
  padding-left: 1.5rem;
}
li {
  margin-bottom: 0.25rem;
}
ul {
  list-style: none;
}
ul li::before {
  content: "-";
  color: var(--color-blue);
  display: inline-block;
  width: 1em;
  margin-left: -1em;
}

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--border-color);
  padding: 0.5rem 1rem;
  color: var(--fg-secondary);
  background-color: var(--bg-secondary);
  border-radius: 0 4px 4px 0;
}

/* Inline code & Code blocks */
code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background-color: var(--bg-secondary);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--color-orange);
  border: 1px solid var(--border-color);
}
pre code {
  color: inherit;
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  border: none;
}
pre {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
}

/* Custom post cards (Home/Index) */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-card {
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, background-color 0.3s ease;
  animation: fadeInUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.post-card:nth-child(1) { animation-delay: 0.04s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.16s; }
.post-card:nth-child(4) { animation-delay: 0.22s; }
.post-card:nth-child(5) { animation-delay: 0.28s; }

.post-card:hover {
  border-color: var(--color-blue);
  box-shadow: 0 8px 30px rgba(88, 166, 255, 0.12);
  transform: translateY(-4px) scale(1.01);
}

.post-card-header {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--card-header-bg);
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-secondary);
  transition: var(--theme-transition);
}

.post-card-header span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Green status indicator dot */
.post-card-header span:first-child::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-green);
  box-shadow: 0 0 6px var(--color-green);
}

.post-card-header .post-date {
  color: var(--color-purple);
}

.post-card-body {
  padding: 1.25rem 1.5rem;
}

.post-card-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.35rem;
  border: none;
  padding-bottom: 0;
}
.post-card-title a {
  color: var(--color-blue);
}
.post-card-title a:hover {
  color: var(--color-cyan);
}

.post-card-excerpt {
  color: var(--fg-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.post-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.post-tags {
  display: flex;
  gap: 0.5rem;
}
.post-tag {
  font-size: 0.75rem;
  color: var(--color-green);
  background-color: rgba(126, 231, 135, 0.05);
  border: 1px solid rgba(126, 231, 135, 0.15);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}
.post-tag::before {
  content: "#";
}

.post-read-more {
  color: var(--color-orange);
  transition: color 0.15s ease;
}
.post-read-more::after {
  content: "()";
}
.post-read-more:hover {
  color: var(--color-cyan);
  text-decoration: none;
}

/* Post view metadata */
.post-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: -0.5rem;
  margin-bottom: 2rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}
.post-metadata span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.post-metadata svg {
  fill: currentColor;
  width: 14px;
  height: 14px;
}

/* Git Diff markers for styling quotes or highlights */
.diff-added {
  border-left: 4px solid var(--color-green) !important;
  background-color: rgba(126, 231, 135, 0.05) !important;
}
.diff-removed {
  border-left: 4px solid var(--color-red) !important;
  background-color: rgba(255, 123, 114, 0.05) !important;
}

/* Archive List Item */
.archive-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
}
.archive-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.archive-item:hover {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
}
.archive-date {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--color-purple);
  width: 100px;
  flex-shrink: 0;
}
.archive-title {
  font-size: 1.05rem;
  font-weight: 500;
}

/* ASCII Art Logo */
.ascii-logo {
  font-family: var(--font-mono);
  color: var(--color-green);
  background-color: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin-top: 1.5rem;
  margin-bottom: 2.5rem;
  font-size: clamp(0.35rem, 1.8vw, 0.85rem);
  line-height: 1.15;
  white-space: pre;
  word-break: keep-all;
  overflow-wrap: normal;
  overflow-x: auto;
  user-select: none;
  text-shadow: 0 0 12px rgba(126, 231, 135, 0.25);
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.1s;
}

:root[data-theme="light"] .ascii-logo {
  text-shadow: 0 0 5px rgba(26, 127, 55, 0.1);
}

@media (max-width: 768px) {
  .ascii-logo {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    font-size: clamp(0.3rem, 1.7vw, 0.6rem);
  }
}

@media (max-width: 480px) {
  .ascii-logo {
    font-size: clamp(0.24rem, 1.5vw, 0.45rem);
  }
}

/* Responsiveness */
@media (max-width: 768px) {
  :root {
    --gutter-width: 0px;
  }
  .line-gutter {
    display: none;
  }
  .main-content {
    padding: 1.5rem 1rem 3rem 1rem;
  }
  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ===================================================
   ANIMATIONS & INTERACTIONS
   =================================================== */

/* Page entrance */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0);    }
}
.main-content {
  animation: pageFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Scroll reveal */
.scroll-reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}
.scroll-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Blinking cursor on post h1 */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
h1 .title-comment::after {
  content: "▋";
  animation: blink 1.1s step-end infinite;
  color: var(--color-green);
  margin-left: 0.25em;
  font-size: 0.8em;
  vertical-align: baseline;
}

/* Code block hover glow */
pre {
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
pre:hover {
  border-color: var(--color-blue);
  box-shadow: 0 0 28px rgba(88, 166, 255, 0.09), 0 4px 14px rgba(0, 0, 0, 0.18);
}

/* Animated underline for content links */
.main-content a:not([class]) {
  background-image: linear-gradient(var(--color-cyan), var(--color-cyan));
  background-size: 0% 1px;
  background-position: left bottom;
  background-repeat: no-repeat;
  text-decoration: none !important;
  transition: background-size 0.3s ease, color 0.2s ease;
}
.main-content a:not([class]):hover {
  background-size: 100% 1px;
  color: var(--color-cyan);
}

/* Archive items entrance animation (stagger applied via JS) */
.archive-item {
  opacity: 0;
}

/* Heading highlight bar on hover */
h2, h3 {
  transition: color 0.2s ease, padding-left 0.2s ease;
}
h2:hover, h3:hover {
  color: var(--color-blue);
  padding-left: 0.4em;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .scroll-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  h1 .title-comment::after { animation: none; opacity: 1; }
  .main-content { animation: none; }
  .post-card    { animation: none; }
  .archive-item { opacity: 1; animation: none; }
}
