/* ==========================================================================
   Digital Agency Design System (DADS) Inspired - Green Theme
   Radius: 0 / Stepwise 1-2-3-4 Card Grid / No Flash on Load
   ========================================================================== */

:root {
  --green-50: #f0fdf4;
  --green-200: #bbf7d0;
  --green-700: #166534;
  --green-800: #14532d;

  --bg-body: #ffffff;
  --bg-surface: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f5f9;
  --text-primary: #111111;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --border-color: #d1d5db;
  --border-strong: #9ca3af;

  --accent: var(--green-700);
  --accent-hover: var(--green-800);
  --accent-soft: var(--green-50);
  --accent-border: var(--green-200);
  --series-bg: #14532d;
  --series-text: #ffffff;
  --focus-ring: #005fcc;

  --info-bg: #eff6ff;
  --info-text: #1e40af;
  --warn-bg: #fffbeb;
  --warn-text: #92400e;

  --radius: 0px;
  --max-width: 1360px;
  --side-pad: 2.25rem;
  --trans-theme: 0.16s ease;
}

[data-theme="dark"] {
  --bg-body: #111315;
  --bg-surface: #181b1e;
  --bg-elevated: #1f2328;
  --bg-hover: #282d34;
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --border-strong: #4b5563;

  --accent: #34d399;
  --accent-hover: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --accent-border: rgba(52, 211, 153, 0.35);
  --series-bg: #065f46;
  --series-text: #ecfdf5;
  --focus-ring: #60a5fa;

  --info-bg: rgba(59, 130, 246, 0.12);
  --info-text: #93c5fd;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --warn-text: #fcd34d;
}

@media (max-width: 960px) {
  :root {
    --side-pad: 1.5rem;
  }
}

@media (max-width: 639px) {
  :root {
    --side-pad: 1rem;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  border-radius: var(--radius);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 15px;
}

/* テーマ変更ボタンを押したときだけ滑らかに切り替える */
body.is-theme-switching,
body.is-theme-switching .site-header,
body.is-theme-switching .site-footer,
body.is-theme-switching .controls-bar,
body.is-theme-switching .article-card-link,
body.is-theme-switching .toc-sidebar,
body.is-theme-switching .filter-btn,
body.is-theme-switching .theme-icon-btn {
  transition:
    background-color var(--trans-theme),
    color var(--trans-theme),
    border-color var(--trans-theme);
}

main {
  flex: 1 0 auto;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--side-pad);
}

/* ==========================================================================
   Header (Compact & Both Ends Aligned)
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-body);
  border-bottom: 2px solid var(--accent);
}

.header-inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.45rem var(--side-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
}

.site-brand-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

.theme-icon-btn {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-icon-btn:hover {
  background-color: var(--bg-hover);
}

.theme-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;
}

/* ==========================================================================
   Home Page: Generous Margins & 1 -> 2 -> 3 -> 4 Column Grid
   ========================================================================== */
.page-hero {
  padding: 2rem 0 1.35rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.75rem;
}

.page-hero h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  line-height: 1.3;
}

.page-hero p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 0.9rem 1.15rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.filter-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.filter-btn {
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  height: 26px;
  padding: 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.filter-btn:hover {
  background-color: var(--bg-hover);
}

.filter-btn.is-series {
  border-color: var(--series-bg);
}

.filter-btn.is-active {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.filter-btn.is-series.is-active {
  background-color: var(--series-bg);
  color: var(--series-text);
  border-color: var(--series-bg);
}

[data-theme="dark"] .filter-btn.is-active:not(.is-series) {
  color: #052e16;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.sort-control select {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  height: 26px;
  padding: 0 0.5rem;
  font-size: 0.8rem;
}

/* 1列 -> 2列 -> 3列 -> 4列 */
.article-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 3.5rem;
  transition: opacity 0.14s ease;
}

@media (min-width: 640px) {
  .article-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .article-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1240px) {
  .article-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.article-grid.is-updating {
  opacity: 0.35;
}

.article-card-link {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  text-decoration: none;
  color: inherit;
}

.article-card-link:hover {
  border-color: var(--accent);
  color: inherit;
}

.card-thumb-wrap {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
}

.card-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-content {
  padding: 1.05rem 1.1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 0.85rem;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  min-height: 1.1em;
}

.card-title {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text-primary);
}

.article-card-link:hover .card-title {
  color: var(--accent);
}

.card-summary {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.series-badge,
.tag-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 0.45rem;
  font-size: 0.72rem;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.series-badge {
  font-weight: 700;
  background-color: var(--series-bg);
  color: var(--series-text);
}

a.series-badge:hover {
  opacity: 0.9;
  color: var(--series-text);
}

.tag-badge {
  font-weight: 600;
  background-color: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

a.tag-badge:hover {
  background-color: var(--bg-hover);
}

/* ==========================================================================
   Article Page: Generous Spacing & Right Sidebar
   ========================================================================== */
.article-page-wrap {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem var(--side-pad) 3.5rem;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2.75rem;
  align-items: start;
}

@media (max-width: 960px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
  .toc-sidebar {
    order: -1;
  }
}

.toc-sidebar {
  position: sticky;
  top: 3.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 1.05rem;
}

@media (max-width: 960px) {
  .toc-sidebar {
    position: static;
  }
}

.toc-thumb-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border-color);
  margin-bottom: 0.8rem;
}

@media (max-width: 960px) {
  .toc-thumb-img {
    display: none;
  }
}

.toc-article-title {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

.toc-heading {
  margin: 0 0 0.55rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.3rem 0;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
}

.toc-list a {
  display: block;
  padding: 0.22rem 0.45rem;
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
}

.toc-list a:hover {
  color: var(--accent);
}

.toc-list a.is-current {
  color: var(--accent);
  font-weight: 700;
  border-left-color: var(--accent);
  background-color: var(--accent-soft);
}

.article-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.article-header h1 {
  margin: 0.6rem 0 0.45rem;
  font-size: clamp(1.5rem, 2.5vw, 1.95rem);
  line-height: 1.3;
}

.article-date {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.article-summary {
  margin: 0;
  font-size: 0.94rem;
  color: var(--text-secondary);
}

.article-body h2 {
  margin: 2.25rem 0 0.85rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--accent);
  font-size: 1.24rem;
  scroll-margin-top: 3.75rem;
}

.article-body h3 {
  margin: 1.65rem 0 0.55rem;
  font-size: 1.05rem;
}

.article-body p {
  margin: 0.85rem 0;
}

.callout {
  margin: 1.4rem 0;
  padding: 0.95rem 1.2rem;
  border-left: 4px solid var(--accent);
  background-color: var(--accent-soft);
}

.callout.is-info {
  border-left-color: var(--info-text);
  background-color: var(--info-bg);
  color: var(--info-text);
}

.callout.is-warn {
  border-left-color: var(--warn-text);
  background-color: var(--warn-bg);
  color: var(--warn-text);
}

.callout-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
  display: block;
  font-size: 0.88rem;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.52rem 1rem;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
}

[data-theme="dark"] .btn-primary {
  color: #052e16;
}

.btn-secondary {
  background-color: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  margin: 1.4rem 0;
}

.dads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.dads-table th,
.dads-table td {
  border: 1px solid var(--border-color);
  padding: 0.6rem 0.85rem;
  text-align: left;
}

.dads-table th {
  background-color: var(--bg-surface);
  font-weight: 700;
}

.dads-accordion {
  margin: 1.25rem 0;
  border: 1px solid var(--border-color);
  background-color: var(--bg-elevated);
}

.dads-accordion summary {
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dads-accordion summary::after {
  content: "+";
  font-size: 1.1rem;
  color: var(--accent);
}

.dads-accordion[open] summary::after {
  content: "−";
}

.dads-accordion .accordion-body {
  padding: 0.75rem 1rem 0.95rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

blockquote {
  margin: 1.4rem 0;
  padding: 0.7rem 1.1rem;
  border-left: 3px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

pre {
  background-color: #1e293b;
  color: #f8fafc;
  padding: 0.95rem 1.15rem;
  overflow-x: auto;
  font-size: 0.82rem;
  margin: 1.25rem 0;
}

.embed-box {
  margin: 1.4rem 0;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
}

.embed-ratio {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.embed-ratio iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed-caption {
  padding: 0.45rem 0.8rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

.series-nav {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 639px) {
  .series-nav {
    grid-template-columns: 1fr;
  }
}

.series-nav-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  text-decoration: none;
  color: var(--text-primary);
}

.series-nav-link:hover {
  border-color: var(--accent);
}

.series-nav-link.is-next {
  flex-direction: row-reverse;
  text-align: right;
}

.series-nav-thumb {
  width: 88px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.series-nav-dir {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

.series-nav-title {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

/* ==========================================================================
   Compact Footer (Both Ends Aligned)
   ========================================================================== */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  padding: 0.75rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-inner a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
}

.footer-inner a:hover {
  color: var(--accent);
  text-decoration: underline;
}