@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap');

/* Apple-Style Minimalist Design System (Light Mode) */
:root {
  --bg-color: #fbfbfd;
  --card-bg: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent-color: #2b7fff;
  /* Apple Blue */
  --border-color: #d2d2d7;
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  /* Very subtle */
  --radius: 20px;
  /* Apple-style rounded corners */
  --font-main: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --line-height: 1.8;
  /* Optimized for Japanese */
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

/* 2-Column Grid Layout */
.container {
  display: grid;
  grid-template-columns: 240px 1fr;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Sidebar (Left) */
.sidebar {
  padding: 60px 20px;
  background-color: var(--bg-color);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--border-color);
}

.sidebar-branding {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
  text-align: center;
}

.sidebar-avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  background-color: #fff;
}

.sidebar-logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-primary);
}

/* Navigation - NO bullets */
.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li {
  list-style: none;
  margin-bottom: 16px;
}

.sidebar-nav a {
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

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

/* Main Content */
.main-content {
  padding: 60px 40px;
}

/* Post Cards (Apple Style Tiles) */
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 1100px;
}

.post-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
}

.post-card:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.post-card-img {
  width: 100%;
  aspect-ratio: 3 / 1;
  object-fit: cover;
  border-bottom: 1px solid #f2f2f2;
}

.post-card-body {
  padding: 24px;
}

.post-card-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: block;
}

.post-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
}

/* Single Article Styling */
.article-page {
  max-width: 900px;
  margin: 0 auto;
  background-color: var(--card-bg);
  padding: 80px 60px;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.article-header {
  text-align: center;
  margin-bottom: 60px;
}

.article-title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.article-meta {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.article-content {
  font-size: 1rem;
}

/* Inline Code - TOC Taste (Only for non-code blocks) */
:not(pre) > code {
  background-color: #f5f5f7;
  padding: 0.2em 0.4em;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.9em;
  color: var(--text-primary);
  word-break: break-word;
}

/* Specific reset for code blocks to ensure they keep their dark appearance */
.highlight code {
  background-color: transparent !important;
  border: none !important;
  padding: 0 !important;
  color: inherit !important;
  word-break: normal !important;
}

/* Prevents code inside headings from getting extra padding */
h1 code, h2 code, h3 code, h4 code {
  background-color: transparent !important;
  border: none !important;
  padding: 0 !important;
}

/* Table of Contents - Card Style */
.article-toc {
  background-color: #f5f5f7;
  border-radius: 16px;
  padding: 24px 32px;
  margin-bottom: 40px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.toc-title {
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  margin-bottom: 12px !important;
  padding: 0 !important;
}

.toc-separator {
  border: none;
  border-top: 1px solid #e5e5e7;
  margin-bottom: 20px;
}

.article-toc nav > ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.article-toc nav ul ul {
  list-style: none;
  padding-left: 1.5rem;
  margin-top: 8px;
}

.article-toc li {
  list-style: none;
  margin-bottom: 8px;
  line-height: 1.4;
}

.article-toc li:last-child {
  margin-bottom: 0;
}

.article-toc a {
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s;
  display: block;
}

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

.article-toc nav > ul > li > a {
  font-weight: 600;
  color: var(--text-primary);
}

.article-content ul,
.article-content ol {
  padding-left: 1.5em !important;
  padding-inline-start: 1.5em !important;
  margin-left: 0.5em !important;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.article-content li {
  margin-bottom: 0.3em;
  padding-left: 0.3em;
}

.article-content h2 {
  font-size: 1.3rem;
  margin: 2.5rem 0 1rem;
}

.article-content h3 {
  font-size: 1.1rem;
  margin: 2rem 0 0.8rem;
}

.article-content h4 {
  font-size: 1rem;
  margin: 1.5rem 0 0.6rem;
}

/* Category Pill Tags */
.article-categories {
  margin-top: 16px;
}

.category-pill {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 50px;
  background-color: #f0f1f6;
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
  margin: 0 4px;
}

.category-pill:hover {
  background-color: var(--accent-color);
  color: #ffffff;
}

/* Apple-style image rounding and 90% width */
.custom-image-wrapper {
  width: 90%;
  margin: 3rem auto;
  text-align: center;
}

.custom-image-wrapper .image-container {
  cursor: zoom-in;
}

.custom-image-wrapper img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.custom-image-wrapper figcaption {
  margin-top: 5px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Side-by-side images: Flex row for consecutive figures */
.image-pair {
  display: flex;
  gap: 16px;
  width: 100%;
  margin: 3rem auto;
  justify-content: center;
  align-items: flex-start;
}

.image-pair .custom-image-wrapper {
  flex: 1 1 0%;
  /* Fallback - JS handles precise aspect ratio flex */
  width: auto;
  margin: 0;
  height: auto;
}

.image-pair .custom-image-wrapper .image-container {
  height: 100%;
}

.image-pair .custom-image-wrapper img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Pagination - Apple-style pill buttons */
.pagination {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 60px;
}

.pagination-link {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 50px;
  background-color: var(--card-bg);
  color: var(--accent-color);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--card-shadow);
  transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.pagination-link:hover {
  background-color: var(--accent-color);
  color: #ffffff;
  transform: translateY(-2px);
}

/* Markdown Tables */
.article-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.8rem 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  font-size: 0.9rem;
}

.article-content thead th {
  background-color: #f5f5f7;
  font-weight: 700;
  text-align: left;
  padding: 14px 18px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
}

.article-content tbody td {
  padding: 12px 18px;
  border-bottom: 1px solid #f0f0f2;
  color: var(--text-primary);
}

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

.article-content tbody tr:nth-child(even) {
  background-color: #fafafa;
}

.article-content tbody tr:hover {
  background-color: #f0f1f6;
}

/* List page header */
.list-header {
  margin-bottom: 40px;
}

/* Category terms page: hide dates */
.taxonomy-list .post-card-date {
  display: none;
}

/* Archive post list - year groups */
.archive-year-group {
  margin-bottom: 40px;
}

.archive-year-group h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.archive-post-list {
  list-style: none;
  padding: 0;
}

.archive-post-list li {
  list-style: none;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f2;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.archive-post-list li:last-child {
  border-bottom: none;
}

.archive-post-list a {
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
  transition: color 0.2s;
}

.archive-post-list a:hover {
  color: var(--accent-color);
}

.archive-post-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Minimalist MacOS Code Blocks */
.highlight {
  position: relative;
  background: #111111;
  border-radius: 12px;
  margin-bottom: 2.5rem;
  padding-top: 36px;
  overflow: hidden;
}

.highlight::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 14px;
  width: 42px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='10'%3E%3Ccircle cx='5' cy='5' r='5' fill='%23ff5f56'/%3E%3Ccircle cx='21' cy='5' r='5' fill='%23ffbd2e'/%3E%3Ccircle cx='37' cy='5' r='5' fill='%2327c93f'/%3E%3C/svg%3E");
  background-size: 42px 10px;
}

.highlight pre {
  padding: 20px;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #eeeeee;
  overflow-x: auto;
}

/* Lightbox Overlay */
#lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}

#lightbox-img {
  max-width: 90%;
  max-height: 90%;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* Footer navigation */
.footer-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 60px;
}

.next-prev {
  text-decoration: none;
  color: var(--accent-color);
  font-weight: 500;
  transition: opacity 0.2s;
}

.next-prev:hover {
  opacity: 0.7;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {

  html,
  body {
    overflow-x: hidden;
    width: 100%;
  }

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

  .container {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .sidebar {
    position: relative;
    padding: 30px 20px;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-nav ul {
    display: flex;
    justify-content: center;
    gap: 12px 24px;
    flex-wrap: wrap;
  }

  .sidebar-nav li {
    margin-bottom: 0;
  }

  .main-content {
    padding: 30px 20px;
    width: 100%;
  }

  .article-page {
    padding: 40px 20px;
  }

  .article-title {
    font-size: 2rem;
  }

  .image-pair {
    flex-direction: column;
    width: 100%;
    gap: 24px;
  }

  .image-pair .custom-image-wrapper {
    width: 100%;
  }

  .custom-image-wrapper {
    width: 100%;
    margin: 2rem auto;
  }

  .post-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}