/* ═══════════════════════════════════════════════════════
   atarpara.github.io — Design System
   Light-first, toggle to dark. Inter + JetBrains Mono.
   ═══════════════════════════════════════════════════════ */

/* ── Tokens (Light — default) ────────────────────────── */
:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --bg:          #ffffff;
  --bg-surface:  #f6f8fa;
  --bg-elevated: #ffffff;
  --bg-code:     #f6f8fa;

  --text:        #1f2328;
  --text-muted:  #656d76;
  --text-subtle: #8b949e;

  --accent:      #0969da;
  --accent-hover:#0550ae;
  --accent-glow: rgba(9, 105, 218, 0.1);
  --accent-underline: rgba(9, 105, 218, 0.35);
  --accent-secondary: #cf222e;

  --border:      #d0d7de;
  --border-highlight: #0969da;

  --gradient-hero: linear-gradient(135deg, #0969da 0%, #8250df 50%, #cf222e 100%);
  --gradient-text: linear-gradient(135deg, #0969da, #8250df);

  --shadow-sm:  0 1px 3px rgba(31,35,40,0.06);
  --shadow-md:  0 4px 12px rgba(31,35,40,0.08);
  --shadow-lg:  0 8px 30px rgba(31,35,40,0.1);
  --shadow-glow: 0 0 20px rgba(9, 105, 218, 0.06);

  --radius:     8px;
  --radius-lg:  12px;
  --max-width:  760px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Tokens (Dark) ───────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0d1117;
  --bg-surface:  #161b22;
  --bg-elevated: #1c2128;
  --bg-code:     #1c2128;

  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-subtle: #6e7681;

  --accent:      #58a6ff;
  --accent-hover:#79c0ff;
  --accent-glow: rgba(88, 166, 255, 0.15);
  --accent-underline: rgba(88, 166, 255, 0.4);
  --accent-secondary: #f0883e;

  --border:      #30363d;
  --border-highlight: #58a6ff;

  --gradient-hero: linear-gradient(135deg, #58a6ff 0%, #bc8cff 50%, #f0883e 100%);
  --gradient-text: linear-gradient(135deg, #58a6ff, #bc8cff);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 30px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.08);
}

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

/* ── Base ────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.1rem);
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  transition: background var(--transition), color var(--transition);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Scroll-progress bar ─────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--gradient-hero);
  z-index: 1000;
  transition: none;
}

/* ── Header ──────────────────────────────────────────── */
header {
  padding: 1.5rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

header .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

header .site-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  transition: color var(--transition);
}

header .site-title:hover {
  color: var(--accent);
}

header .header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

header .header-right a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}

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

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* ── Main ────────────────────────────────────────────── */
main {
  min-height: 65vh;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ── Hero (Home) ─────────────────────────────────────── */
.hero {
  padding: 3rem 0 3.5rem;
  text-align: left;
}

.hero h1 {
  font-size: clamp(2rem, 1.6rem + 2vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.hero .hero-gradient {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero .tagline {
  color: var(--text-muted);
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.2rem);
  font-weight: 400;
  letter-spacing: 0.04em;
}

/* ── Post List (Home) ────────────────────────────────── */
.posts-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.post-entry {
  display: block;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
}

.post-entry:hover {
  border-color: var(--border-highlight);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  background: var(--bg-elevated);
}

.post-entry .post-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  line-height: 1.4;
}

.post-entry .post-title a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.post-entry:hover .post-title a {
  color: var(--accent);
}

.post-entry .post-excerpt {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.post-entry .post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.post-entry .post-meta .dot {
  opacity: 0.4;
}

.post-entry .post-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.post-entry .tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid transparent;
}

/* ── Article (Post) ──────────────────────────────────── */
article > .post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

article > .post-header h1 {
  font-size: clamp(1.6rem, 1.3rem + 1.5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-bottom: 0.6rem;
  color: var(--text);
}

article > .post-header .post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

article > .post-header .post-meta .dot {
  opacity: 0.4;
}

article > .post-header .post-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

article > .post-header .tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent);
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 2rem;
  transition: color var(--transition);
}

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

/* TOC */
.toc {
  margin-bottom: 2.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.toc summary {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc summary::-webkit-details-marker { display: none; }

.toc summary::before {
  content: '▸';
  font-size: 0.75rem;
  transition: transform var(--transition);
}

.toc[open] summary::before {
  transform: rotate(90deg);
}

.toc ol {
  margin-top: 0.75rem;
  padding-left: 1.25rem;
  list-style: none;
  counter-reset: toc-counter;
}

.toc ol li {
  counter-increment: toc-counter;
  margin-bottom: 0.35rem;
}

.toc ol li::before {
  content: counter(toc-counter) ".";
  color: var(--text-subtle);
  font-size: 0.82rem;
  margin-right: 0.5rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.toc ol li a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: color var(--transition);
}

.toc ol li a:hover {
  color: var(--accent);
}

/* ── Article typography ──────────────────────────────── */
article h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.015em;
  color: var(--text);
}

article h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
  color: var(--text);
}

article p {
  margin-bottom: 1.15rem;
  color: var(--text);
}

article a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-underline);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--transition);
}

article a:hover {
  text-decoration-color: var(--accent);
}

article strong {
  font-weight: 600;
  color: var(--text);
}

article em {
  font-style: italic;
}

article ul, article ol {
  margin: 0 0 1.15rem 1.5rem;
}

article li {
  margin-bottom: 0.3rem;
}

article li::marker {
  color: var(--text-subtle);
}

/* Blockquotes */
article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
}

article blockquote p {
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

article blockquote p:last-child {
  margin-bottom: 0;
}

/* Inline code */
article code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  color: var(--accent-secondary);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Code blocks */
article pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-lg);
  line-height: 1.55;
  position: relative;
}

article pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.85rem;
}

article pre::-webkit-scrollbar {
  height: 6px;
}

article pre::-webkit-scrollbar-track {
  background: transparent;
}

article pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Horizontal rules */
article hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 3rem 0;
}

/* Images */
article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

/* ── Tables ──────────────────────────────────────────── */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

article th, article td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

article th {
  background: var(--bg-surface);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

article td {
  color: var(--text);
}

article tr:last-child td {
  border-bottom: none;
}

article tbody tr:hover {
  background: var(--bg-surface);
}

/* Table inline code */
article td code {
  font-size: 0.82em;
}

/* ── KaTeX overrides ─────────────────────────────────── */
.katex-display {
  margin: 1.5rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

.katex {
  font-size: 1.05em;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-subtle);
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--text-subtle);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--text-base);
  text-decoration: none;
}

.badge-link {
  text-decoration: none !important;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.badge-link:hover {
  text-decoration: none !important;
}

.open-to-work {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-base);
  margin-left: 0.5rem;
  vertical-align: middle;
  user-select: none;
  -webkit-user-select: none;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #10b981;
  border-radius: 50%;
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot::after {
    animation: none;
  }
}

/* ── Mermaid ─────────────────────────────────────────── */
.mermaid {
  margin: 1.5rem 0;
  text-align: center;
}

/* ── About page ──────────────────────────────────────── */
.about-content {
  max-width: var(--max-width);
}

.about-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.about-content p {
  margin-bottom: 1rem;
}

.about-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-underline);
  text-underline-offset: 2px;
}

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeInUp 0.5s ease-out both;
}

.post-entry {
  animation: fadeInUp 0.4s ease-out both;
}

.post-entry:nth-child(1) { animation-delay: 0.05s; }
.post-entry:nth-child(2) { animation-delay: 0.1s; }
.post-entry:nth-child(3) { animation-delay: 0.15s; }
.post-entry:nth-child(4) { animation-delay: 0.2s; }
.post-entry:nth-child(5) { animation-delay: 0.25s; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 1rem; }

  .hero { padding: 2rem 0 2.5rem; }

  .post-entry {
    padding: 1rem 1.15rem;
  }

  article pre {
    padding: 1rem;
    border-radius: var(--radius);
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }

  .header-inner {
    gap: 0.75rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
}

/* ── Focus & Accessibility ───────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.theme-toggle:focus-visible {
  outline-offset: 2px;
}

.post-entry:focus-visible {
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .post-entry:hover {
    transform: none;
  }
}

/* ── Print ───────────────────────────────────────────── */
@media print {
  :root {
    --bg: #fff;
    --text: #000;
    --bg-surface: #f5f5f5;
    --border: #ccc;
  }

  .scroll-progress,
  .theme-toggle,
  .back-link,
  .toc { display: none; }
}
