/* Non-critical CSS — loaded asynchronously after initial paint */

/* Prose typography for Japanese readability */
.prose {
  max-width: 65ch;
  font-size: var(--article-font-size, 1.125rem);
  line-height: var(--article-line-height, 1.9);
  color: hsl(var(--foreground));
}

/* Font size modifier classes for article pages */
.font-size-small {
  --article-font-size: 1rem;
  --article-line-height: 1.8;
}

.font-size-medium {
  --article-font-size: 1.125rem;
  --article-line-height: 1.9;
}

.font-size-large {
  --article-font-size: 1.25rem;
  --article-line-height: 2;
}

/* Override for article pages with sidebar */
.article-main .prose {
  max-width: 100%;
}

/* Headings with enhanced styling */
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-weight: 700;
  line-height: 1.4;
  color: hsl(var(--foreground));
  letter-spacing: -0.01em;
}

.prose h1 {
  font-size: 2.25rem;
  margin-top: 2.5rem;
  margin-bottom: 1.25rem;
}

.prose h2 {
  font-size: 1.625rem;
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.625rem;
  position: relative;
}

.prose h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background:
    linear-gradient(90deg,
      hsl(16 100% 55%) 0%, hsl(16 100% 55%) 22%,
      hsl(28 100% 55%) 22%, hsl(28 100% 55%) 38%,
      hsl(40 95% 56%) 38%, hsl(40 95% 56%) 50%,
      hsl(220 35% 22%) 50%, hsl(220 35% 22%) 78%,
      hsl(220 20% 78% / 0.5) 78%, hsl(220 20% 78% / 0.5) 92%,
      transparent 92%);
  border-radius: 0;
}

.dark .prose h2::after {
  background:
    linear-gradient(90deg,
      hsl(16 100% 60%) 0%, hsl(16 100% 60%) 22%,
      hsl(28 100% 58%) 22%, hsl(28 100% 58%) 38%,
      hsl(40 95% 58%) 38%, hsl(40 95% 58%) 50%,
      hsl(220 40% 55%) 50%, hsl(220 40% 55%) 78%,
      hsl(220 25% 35% / 0.7) 78%, hsl(220 25% 35% / 0.7) 92%,
      transparent 92%);
  border-radius: 0;
}

.prose h3 {
  font-size: 1.375rem;
  margin-top: 2.25rem;
  margin-bottom: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prose h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: hsl(16 100% 55%);
  border-radius: 0;
  flex-shrink: 0;
}

.dark .prose h3::before {
  background: hsl(16 100% 60%);
}

.prose h4 {
  font-size: 1.125rem;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

/* Paragraph spacing optimized for Japanese reading */
.prose p {
  margin-bottom: 1.75rem;
  text-align: justify;
  text-justify: inter-ideograph;
}

/* Bold/strong text with insight highlight style (exclude lists) */
.prose > p strong, .prose > p b,
.prose > blockquote strong, .prose > blockquote b {
  font-weight: 700;
  background: hsl(38 100% 50% / 0.18);
  padding: 0.1em 0.35em;
  border-radius: 2px;
  color: hsl(220 35% 18%);
}

.dark .prose > p strong, .dark .prose > p b,
.dark .prose > blockquote strong, .dark .prose > blockquote b {
  background: hsl(28 100% 55% / 0.18);
  color: hsl(40 100% 88%);
}

/* Bold in lists - just bold, no highlight */
.prose li strong, .prose li b {
  font-weight: 700;
}

/* Enhanced list styling with visible background */
.prose ul, .prose ol {
  margin-bottom: 1.75rem;
  padding: 1.25rem 1.5rem 1.25rem 2.5rem;
  background: hsl(var(--muted) / 0.5);
  border-radius: 3px;
  border: 1px solid hsl(var(--border) / 0.5);
}

.prose li {
  margin-bottom: 0.625rem;
  line-height: 1.8;
  position: relative;
}

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

.prose li::marker {
  color: hsl(16 100% 55%);
  font-weight: 600;
}

.dark .prose li::marker {
  color: hsl(16 100% 60%);
}

.prose ul li {
  padding-left: 0.375rem;
}

.prose ol li {
  padding-left: 0.375rem;
}

/* Nested lists - no extra background */
.prose ul ul, .prose ol ol, .prose ul ol, .prose ol ul {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  background: transparent;
  border-left: none;
  padding: 0 0 0 1.5rem;
  border-radius: 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 3px;
  margin: 2rem 0;
}

/* Dark mode image blending for better visual integration */
.dark .prose img,
.dark figure img,
.dark .dark-blend-image {
  filter: brightness(0.9) contrast(1.05);
  border: 1px solid hsl(var(--border) / 0.5) !important;
}

/* Enhanced blockquote styling with decorative quote icon */
.prose blockquote {
  padding: 1.5rem 1.5rem 1.5rem 3.5rem;
  margin: 2rem 0;
  background: hsl(var(--muted));
  border-radius: 4px;
  border: 1px solid hsl(var(--border));
  font-style: italic;
  color: hsl(var(--muted-foreground));
  position: relative;
}

.prose blockquote::before {
  content: '\201C';
  position: absolute;
  left: 1rem;
  top: 0.75rem;
  font-size: 2.5rem;
  font-family: Georgia, serif;
  color: hsl(16 100% 55% / 0.45);
  line-height: 1;
}

.prose blockquote p {
  margin-bottom: 0.75rem;
}

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

.prose blockquote cite,
.prose blockquote footer {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  font-style: normal;
  color: hsl(var(--muted-foreground) / 0.8);
}

.prose blockquote cite::before {
  content: '\2014\00a0';
}

/* Inline code - distinctive pill style */
.prose code {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  border: 1px solid hsl(var(--primary) / 0.15);
  font-weight: 500;
}

.dark .prose code {
  background: hsl(var(--accent) / 0.5);
  color: hsl(var(--accent-foreground));
  border-color: hsl(var(--accent) / 0.3);
}

/* Code blocks - clean minimal style */
.prose pre {
  background: hsl(var(--muted));
  padding: 1.5rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid hsl(var(--border) / 0.5);
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.7;
  color: hsl(var(--foreground));
  border: none;
  font-weight: normal;
}

/* Dark mode code block */
.dark .prose pre {
  background: hsl(222 47% 11%);
  border-color: hsl(var(--border) / 0.3);
}

.dark .prose pre code {
  color: hsl(210 40% 90%);
}

/* Horizontal rule */
.prose hr {
  border: none;
  height: 1px;
  background: hsl(var(--border));
  margin: 3rem 0;
}

/* Strong and emphasis */
.prose strong {
  font-weight: 700;
  color: hsl(var(--foreground));
}

.prose em {
  font-style: italic;
}

/* Links in prose */
.prose a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.prose a:hover {
  color: hsl(var(--primary) / 0.8);
}

/* Tables - enhanced with striped rows and hover effects */
.prose .table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 2rem 0;
}

.prose .table-wrapper table {
  margin: 0;
}

.prose table {
  width: 100%;
  min-width: 500px;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2rem 0;
  font-size: 1rem;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px hsl(var(--foreground) / 0.05);
}

.prose th, .prose td {
  padding: 0.875rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid hsl(var(--border) / 0.7);
}

.prose th {
  background: linear-gradient(180deg, hsl(var(--primary) / 0.1) 0%, hsl(var(--primary) / 0.05) 100%);
  font-weight: 600;
  color: hsl(var(--foreground));
  text-transform: none;
  letter-spacing: 0.01em;
  border-bottom: 2px solid hsl(var(--primary) / 0.3);
}

.prose tbody tr {
  transition: background-color 0.15s ease;
}

.prose tbody tr:nth-child(even) {
  background: hsl(var(--muted) / 0.25);
}

.prose tbody tr:hover {
  background: hsl(var(--primary) / 0.08);
}

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

.prose td[data-type="number"],
.prose th[data-type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Lightbox Modal Styles */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.3s, opacity 0.3s ease;
}

.lightbox-modal.is-open {
  visibility: visible;
  opacity: 1;
  transition: visibility 0s, opacity 0.3s ease;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.lightbox-close:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.lightbox-image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.lightbox-caption {
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  text-align: center;
  max-width: 600px;
}

/* Footer */
.footer {
  border-top: 1px solid hsl(var(--border));
  margin-top: 4rem;
  padding: 2rem 0;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.footer-text {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.375rem 0.5rem;
  margin-top: 0.875rem;
  font-size: 0.8125rem;
}

.footer-nav-link {
  color: hsl(var(--foreground) / 0.85);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-nav-link:hover { color: #FF3D6E; text-decoration: underline; }
.footer-nav-sep { color: hsl(var(--muted-foreground)); opacity: 0.5; }

.footer-org {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.6;
}

.footer-org-name { font-weight: 600; color: hsl(var(--foreground)); }
.footer-org-desc, .footer-org-addr { margin: 0.125rem 0; }
.footer-org-links { margin-top: 0.25rem; }
.footer-org-link {
  color: hsl(var(--primary));
  text-decoration: none;
}
.footer-org-link:hover { text-decoration: underline; }
.footer-org-sep { margin: 0 0.5rem; opacity: 0.5; }

.footer-social {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.footer-rss {
  display: flex;
  align-items: center;
  margin-top: 0.5rem;
}

.footer-rss-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  line-height: 1;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.footer-rss-link:hover {
  color: #ee802f;
  border-color: #ee802f;
  background: hsl(var(--muted));
}

.footer-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  color: hsl(var(--muted-foreground));
  transition: color 0.2s, background 0.2s;
}

.footer-social-link:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

/* Mega Dropdown (hover-only, not visible on initial paint) */
.mega-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 3px;
  padding: 1rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  z-index: 100;
}

.mega-nav-item:hover .mega-dropdown,
.mega-nav-item:focus-within .mega-dropdown {
  display: block !important;
}

.mega-nav-item:focus-within .mega-nav-trigger svg {
  transform: rotate(180deg);
}

.mega-nav-trigger svg {
  transition: transform 0.2s;
}

.mega-dropdown-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 0.75rem;
  margin: -0.25rem -0.5rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  color: inherit;
  text-decoration: none;
  border-radius: 2px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a.mega-dropdown-header:hover,
a.mega-dropdown-header:focus-visible {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  text-decoration: none;
  outline: none;
}

a.mega-dropdown-header:focus-visible {
  box-shadow: 0 0 0 2px hsl(var(--ring));
}

.mega-dropdown-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
}

.mega-dropdown-desc {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin: 0.25rem 0 0 0;
  line-height: 1.4;
}

.mega-dropdown-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.mega-dropdown-link {
  display: block;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  border-radius: 2px;
  transition: background 0.15s;
}

.mega-dropdown-link:hover {
  background: hsl(var(--muted));
}

/* Mobile Drawer (initially hidden, opened on interaction) */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: hsl(var(--background));
  z-index: 1000;
  overflow-y: auto;
  padding-top: 64px;
}

.mobile-drawer.is-open {
  display: block;
}

.mobile-drawer-content {
  padding: 1rem;
}

.mobile-drawer-header {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 1rem;
}

.mobile-nav-item {
  border-bottom: 1px solid hsl(var(--border));
}

.mobile-nav-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 0;
  font-size: 1rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}

.mobile-nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mobile-nav-label {
  flex: 1;
}

.mobile-nav-arrow {
  transition: transform 0.2s;
}

.mobile-nav-item.is-open .mobile-nav-arrow {
  transform: rotate(180deg);
}

.mobile-submenu {
  display: none;
  padding: 0 0 1rem 1.75rem;
}

.mobile-nav-item.is-open .mobile-submenu {
  display: block;
}

.mobile-submenu-desc {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
}

.mobile-submenu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-submenu-link {
  display: block;
  padding: 0.625rem 0;
  font-size: 0.9375rem;
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border) / 0.5);
}

.mobile-submenu-list li:last-child .mobile-submenu-link {
  border-bottom: none;
}

.mobile-view-all {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--primary));
}

/* Footer responsive */
@media (max-width: 768px) {
  .footer {
    margin-top: 2rem;
    padding: 1.5rem 0;
  }

  .footer-inner {
    padding: 0 1rem;
  }

  .footer-brand {
    font-size: 0.9375rem;
  }

  .footer-text {
    font-size: 0.8125rem;
  }
}

/* TOC active state styling for article pages */
.toc-item.active {
  color: hsl(var(--primary)) !important;
  background: hsl(var(--primary) / 0.1) !important;
  font-weight: 500 !important;
}
