/* ═══════════════════════════════════════════════
   Nhật ký dev — "Morning Paper" Design System
   Light editorial journal for technical writing
   ═══════════════════════════════════════════════ */

/* ── Tokens ───────────────────────────────────── */
:root {
  --bg:          #faf8f5;
  --bg-cool:     #f4f2ee;
  --surface:     #ffffff;
  --surface-2:   #f0ede8;
  --border:      #e2ddd5;
  --border-light:#ece8e1;
  --text:        #3d3830;
  --text-bright: #1a1714;
  --text-dim:    #8a8279;
  --text-faint:  #b0a99f;
  --accent:      #2d8a6e;
  --accent-soft: #2d8a6e18;
  --accent-bright:#35a080;
  --accent-dark: #1f6b54;
  --code-bg:     #f0ede8;
  --code-text:   #2d8a6e;
  --diagram-text:#3a7a5a;
}

/* ── Reset ────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 17px;
  line-height: 1.85;
  font-weight: 400;
  overflow-x: hidden;
}

/* ── Subtle Paper Texture ─────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Reading Progress Bar (articles only) ─────── */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  z-index: 200;
  transition: width 50ms linear;
}

/* ── Top Bar ──────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(250,248,245,0.9);
  backdrop-filter: blur(16px) saturate(1.2);
  z-index: 100;
}

.blog-brand {
  font-family: 'Lora', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: color 0.3s ease;
}

.blog-brand:hover {
  color: var(--accent);
}

.topbar-tag {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
}

/* ── Layout ───────────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Breadcrumb ───────────────────────────────── */
.breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-faint);
  padding: 1.5rem 0.8rem;
  margin: 1.5rem 0 0;
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 500;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* ── Page Title (above cards) ─────────────────── */
.page-title {
  font-family: 'Lora', serif;
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--text-bright);
  margin: 2rem 0 0.8rem;
}

.page-title em {
  font-style: italic;
  color: var(--accent);
}

.page-desc {
  font-size: 1.05rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 640px;
  margin-bottom: 1.5rem;
}

/* ── Meta Card (git log style) ────────────────── */
.meta-card {
  margin-bottom: 1.5rem;
}

.meta-card .terminal-header {
  background: var(--bg-cool);
}

.meta-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 1rem 1.2rem !important;
}

.meta-item {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.meta-item strong {
  color: var(--accent);
  font-weight: 500;
}

/* ── Article Layout (content + sidebar) ───────── */
.article-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1080px) {
  .article-layout {
    grid-template-columns: 1fr 220px;
  }
}

.article-main {
  min-width: 0;
}

/* ── Content Card ─────────────────────────────── */
.content-body {
  padding: 2.2rem 2.5rem !important;
}

/* ── Sidebar ToC ──────────────────────────────── */
.article-sidebar {
  display: none;
}

@media (min-width: 1080px) {
  .article-sidebar {
    display: block;
    position: sticky;
    top: 5rem;
    align-self: start;
  }
}

/* ── Hero Section (fallback for pages without card) ── */
.hero {
  padding: 5rem 0 3rem;
  border-bottom: 1px solid var(--border);
}

.hero-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.8rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}

.hero-label::before {
  content: '';
  display: inline-block;
  width: 2.5rem;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

h1 {
  font-family: 'Lora', serif;
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text-bright);
  margin-bottom: 1.5rem;
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-intro {
  font-size: 1.05rem;
  color: var(--text-dim);
  line-height: 1.8;
  max-width: 560px;
  margin-bottom: 2rem;
}

.hero-meta {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  display: flex;
  gap: 1rem;
  align-items: center;
  font-weight: 500;
}

.hero-meta::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Article Body ─────────────────────────────── */
.article {
  padding: 3.5rem 0 5rem;
}

.article p {
  margin-bottom: 1.7rem;
  color: var(--text);
  hanging-punctuation: first;
}

.article p + p {
  margin-top: -0.1rem;
}

.article p:first-of-type::first-letter {
  font-family: 'Lora', serif;
  font-size: 4.5em;
  font-weight: 700;
  float: left;
  line-height: 0.78;
  margin-right: 0.08em;
  margin-top: 0.1em;
  color: var(--accent);
}

.article h2 {
  font-family: 'Lora', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: 4rem 0 1.4rem;
  padding-top: 4rem;
  border-top: 1px solid var(--border);
  position: relative;
  scroll-margin-top: 5rem;
}

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

em {
  color: var(--accent-dark);
  font-style: italic;
}

/* ── Pull Quote ───────────────────────────────── */
.pq {
  margin: 3rem 0;
  padding: 2rem 2.2rem 2rem 2.5rem;
  border-left: 2px solid var(--accent);
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-cool) 100%);
  position: relative;
}

.pq::before {
  content: '\201C';
  font-family: 'Lora', serif;
  font-size: 5rem;
  color: var(--accent);
  opacity: 0.12;
  position: absolute;
  top: -0.5rem;
  left: 0.8rem;
  line-height: 1;
}

.pq p {
  font-family: 'Lora', serif;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--text-bright);
  line-height: 1.65;
  margin: 0 !important;
  position: relative;
}

/* ── Callout Box ──────────────────────────────── */
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 1.5rem 1.8rem;
  margin: 2.5rem 0;
  font-size: 0.93rem;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.callout-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.7rem;
}

.callout p {
  color: var(--text);
  margin: 0 !important;
  line-height: 1.75;
}

/* ── Aside / Personal Note ────────────────────── */
.aside {
  padding: 0.8rem 1.2rem;
  margin: 1.5rem 0;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.7;
}

.aside p {
  margin: 0 !important;
  color: var(--text-dim);
}

/* ── Diagram / ASCII Art ──────────────────────── */
.diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.5rem 1.8rem;
  margin: 2rem 0;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--diagram-text);
  overflow-x: auto;
  white-space: pre;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.diagram-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
  font-style: normal;
  font-weight: 600;
}

/* ── Finding Block (claude-interpretability) ──── */
.finding-block {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.5rem 1.8rem;
  margin: 1.8rem 0;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.finding-block::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 40%);
}

.finding-num {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.finding-title {
  font-family: 'Lora', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 0.7rem;
}

.finding-block p {
  margin: 0 !important;
  font-size: 0.93rem;
  color: var(--text);
  line-height: 1.75;
}

/* ── Inline Code ──────────────────────────────── */
code {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 0.82em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Divider ──────────────────────────────────── */
hr.divider, .divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
  position: relative;
}

/* ── Closing Signature ────────────────────────── */
.closing {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.closing .sig {
  font-family: 'Lora', serif;
  font-size: 1rem;
  font-style: italic;
  color: var(--text-faint);
}

/* ── Footer ───────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  text-align: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
}


/* ═══════════════════════════════════════════════
   INDEX PAGE — Terminal Card Layout
   ═══════════════════════════════════════════════ */

.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Terminal Card ────────────────────────────── */
.terminal-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  background: var(--bg-cool);
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}

.terminal-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.red    { background: #f5655b; }
.dot.yellow { background: #f6bd3b; }
.dot.green  { background: #3cc84a; }

.terminal-filename {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

.terminal-status {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-weight: 400;
}

.terminal-body {
  padding: 1.8rem 2rem;
}

/* ── Hero Card ────────────────────────────────── */
.hero-card {
  margin: 3rem 0 2rem;
}

.hero-body h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

.hero-body .hero-intro {
  margin-bottom: 0;
}

/* ── Posts Grid ───────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
  padding-bottom: 5rem;
}

/* ── Post Card (inside terminal card) ─────────── */
.post-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}

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

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

.post-card:hover .dot.green {
  box-shadow: 0 0 6px rgba(60,200,74,0.4);
}

.post-tag {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.8rem;
  display: inline-block;
}

.post-title {
  font-family: 'Lora', serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.3;
  margin-bottom: 0.7rem;
  transition: color 0.25s ease;
  letter-spacing: -0.01em;
}

.post-excerpt {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.75;
}

@media (min-width: 700px) {
  .posts-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
  }
}

@media (max-width: 699px) {
  .terminal-body { padding: 1.4rem 1.2rem; }
  .post-title { font-size: 1.15rem; }
  .hero-card { margin: 2rem 0 1.5rem; }
}


/* ═══════════════════════════════════════════════
   Animations — Scroll Reveal
   ═══════════════════════════════════════════════ */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered delays for children */
.reveal-stagger > .reveal:nth-child(1) { transition-delay: 0s; }
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 0.08s; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 0.16s; }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 0.24s; }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 0.32s; }

/* Hero entrance */
@keyframes heroIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero, .index-hero {
  animation: heroIn 0.7s ease both;
}

.article {
  animation: heroIn 0.7s 0.15s ease both;
}


/* ═══════════════════════════════════════════════
   Table of Contents — Inside Terminal Card
   ═══════════════════════════════════════════════ */

.toc-body {
  padding: 1rem 1.2rem !important;
}

.toc-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.toc-list {
  list-style: none;
  border-left: 1px solid var(--border);
}

.toc-link {
  display: block;
  padding: 0.3rem 0 0.3rem 0.7rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-faint);
  text-decoration: none;
  line-height: 1.4;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: all 0.2s ease;
}

.toc-link:hover {
  color: var(--text-dim);
}

.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}


/* ═══════════════════════════════════════════════
   Post Navigation — Prev / Next
   ═══════════════════════════════════════════════ */

.post-nav {
  display: flex;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.post-nav-item {
  flex: 1;
  text-decoration: none;
  color: inherit;
  padding: 1.2rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.post-nav-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

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

.post-nav-dir {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.post-nav-item:hover .post-nav-dir {
  color: var(--accent);
}

.post-nav-title {
  font-family: 'Lora', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-bright);
  line-height: 1.35;
}

@media (max-width: 640px) {
  .post-nav {
    flex-direction: column;
  }
  .post-nav-item.next {
    text-align: left;
  }
}


/* ═══════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════ */

@media (max-width: 640px) {
  body { font-size: 16px; line-height: 1.8; }
  .topbar { padding: 0.9rem 1rem; }
  .hero, .index-hero { padding-top: 3.5rem; }
  .hero-intro { font-size: 1rem; }
  .article p { margin-bottom: 1.4rem; }
  .article h2 { margin: 3rem 0 1.2rem; padding-top: 3rem; font-size: 1.25rem; }
  .pq { margin: 2rem 0; padding: 1.3rem 1.5rem; }
  .pq::before { font-size: 3.5rem; top: -0.3rem; left: 0.5rem; }
  .pq p { font-size: 1.05rem; }
  .post-title { font-size: 1.15rem; }
  .diagram { font-size: 0.65rem; padding: 1rem; }
  .callout, .finding-block { padding: 1.2rem 1.4rem; }
  .article p:first-of-type::first-letter { font-size: 3.5em; }
  .closing { margin-top: 3rem; }
  .breadcrumb { font-size: 0.7rem; padding: 1rem 0.7rem; margin: 1rem 0 0; }
  .article-hero-card .terminal-body { padding: 1.8rem 1.4rem; }
  .terminal-filename { font-size: 0.7rem; }
  .terminal-status { display: none; }
}

@media (max-width: 400px) {
  .container, .container-wide { padding: 0 1rem; }
  h1 { font-size: 1.7rem; }
  .hero-intro { font-size: 0.95rem; }
}
