/* ========================================
   Reset & Base Styles
   ======================================== */
:root {
  --color-bg: #f2f7f8;
  --color-text: #333;
  --color-text-emphasis: #222;
  --color-text-secondary: #666;
  --color-text-muted: #888;
  --color-text-faint: #999;
  --color-accent: #f08300;
  --color-accent-dark: #d47400;
  --color-link: #005c8f;
  --color-link-hover: #004067;
  --color-selected: #555;
  --color-unselected: #e0e2e8;
  --color-btn-bg: #333;
  --color-btn-text: #fff;
  --color-border: #e5e5e5;
  --color-border-light: #ddd;
  --color-border-input: #ccc;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  line-height: 1.8;
  color: var(--color-text);
  background-color: var(--color-bg);
  font-size: 16px;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ========================================
   Layout
   ======================================== */
header {
  margin-bottom: 3rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

main {
  margin-bottom: 0;
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* Footer RSS Link */
.footer-feed {
  margin-bottom: 0.4rem;
}

.feed-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  transition: color 0.2s;
}

.feed-link span {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: color-mix(in srgb, var(--color-text-muted) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.2s;
}

.feed-icon {
  width: 14px;
  height: 14px;
  display: block;
  opacity: 0.9;
  transition: opacity 0.2s;
}

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

.feed-link:hover span {
  text-decoration-color: var(--color-link);
}

.feed-link:hover .feed-icon {
  opacity: 0.7;
}

/* ========================================
   Navigation
   ======================================== */
nav {
  gap: 1.5rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: color-mix(in srgb, var(--color-text-secondary) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 0.2s, text-decoration-color 0.2s;
}

nav a:hover {
  color: var(--color-text);
  text-decoration-color: color-mix(in srgb, var(--color-text) 60%, transparent);
}

/* ========================================
   Typography
   ======================================== */
main > h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text-emphasis);
}

article {
  margin-bottom: 1rem;
}

article h1 {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  color: var(--color-text-emphasis);
}

article time {
  display: block;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

/* Post Icon */
.post-icon {
  margin-bottom: 0.4rem;
}

.post-icon-text {
  font-size: 2rem;
  line-height: 1;
  display: inline-block;
}

/* Content Typography */
.content {
  font-size: 1rem;
  line-height: 1.9;
}

.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-emphasis);
}

.content h1 { font-size: 1.5rem; }
.content h2 { font-size: 1.3rem; }
.content h3 { font-size: 1.15rem; }

.content p {
  margin-bottom: 1.5rem;
}

.content ul,
.content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.content li {
  margin-bottom: 0.5rem;
}

.content blockquote {
  border-left: 3px solid var(--color-border-light);
  padding-left: 1rem;
  margin-left: 0;
  margin-bottom: 1.5rem;
  color: var(--color-text-secondary);
}

.content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

.content code {
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background-color: #f5f5f5;
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

.content pre {
  background-color: #f5f5f5;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.content pre code {
  background-color: transparent;
  padding: 0;
}

.content img {
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 4px;
}

/* ========================================
   Links (共通スタイル)
   ======================================== */
/* コンテンツ内のリンク */
.content a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: text-decoration-color 0.2s, color 0.2s;
}

.content a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-link-hover);
}

/* リスト内のリンク（記事一覧、最近の記事など） */
.post-list article h2 a,
.recent-posts-list a,
.note-posts-list a {
  color: var(--color-text-emphasis);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: color-mix(in srgb, var(--color-text-emphasis) 30%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  font-size: 1.1rem;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.post-list article h2 a:hover,
.recent-posts-list a:hover,
.note-posts-list a:hover {
  color: var(--color-link);
  text-decoration-color: var(--color-link);
}

/* その他のリンク */
.more-link a {
  color: var(--color-text-secondary);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: color-mix(in srgb, var(--color-text-secondary) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  font-size: 1rem;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.more-link a:hover {
  color: var(--color-link);
  text-decoration-color: var(--color-link);
}

/* ========================================
   Components
   ======================================== */

/* Link Card */
.link-card {
  margin: 1.5rem 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background-color: #fff;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.link-card:hover {
  border-color: var(--color-border-input);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.link-card-content {
  display: flex;
  align-items: stretch;
  text-decoration: none;
  color: inherit;
}

.link-card-image {
  width: 120px;
  min-width: 120px;
  min-height: 120px;
  height: auto;
  align-self: stretch;
  overflow: hidden;
  background-color: #fff;
  flex-shrink: 0;
  margin-left: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 8px 8px 0;
}

.link-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 0 8px 8px 0;
}

.link-card-info {
  flex: 1;
  min-width: 0;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.link-card-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-emphasis);
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.link-card-description {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.link-card-url {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: auto;
}

.link-card-icon {
  font-size: 1.2rem;
  color: var(--color-text-faint);
  margin: 1rem 1.25rem;
  flex-shrink: 0;
  transition: transform 0.2s;
  align-self: center;
}

.link-card:hover .link-card-icon {
  transform: translateX(4px);
  color: var(--color-text-secondary);
}

.link-card-content:not(:has(.link-card-image)) {
  align-items: center;
}

.link-card-content:not(:has(.link-card-image)) .link-card-info {
  padding-right: 0;
}

/* Embed Card (oEmbed) */
.embed-card {
  margin: 1.5rem 0;
}

/*
  note.com（同じくSpeakerDeckを埋め込んでおり、iPadOS Safariでも正しく表示される）の
  実際の埋め込みマークアップに倣った構造。position:relative + padding-bottom比率の
  親要素に、position:absoluteのiframeを重ねてレスポンシブ対応する
  （oembed-fetcher.tsのbuildEmbedHtml()が生成）。
*/
.embed-card-ratio {
  position: relative;
  width: 100%;
  height: 0;
  overflow: hidden;
}

.embed-card-ratio iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Post List */
.post-list {
  display: flex;
  flex-direction: column;
}

.year-archive-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 2rem 0 2.5rem;
}

.year-archive-links a,
.year-archive-links span {
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.25;
}

.year-archive-links a {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: color-mix(in srgb, var(--color-text) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.year-archive-links a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-link-hover);
}

.post-list .month-group {
  margin-bottom: 2rem;
}

.post-list .month-group h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text-secondary);
}

.post-list .month-group:first-child h3 {
  margin-top: 0;
}

.post-list article {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.post-list article:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.post-list article h2 {
  font-size: 1.3rem;
  font-weight: 400;
}

.post-list article time {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

.post-list article p {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

/* Post Navigation */
.post-navigation {
  margin-top: 3rem;
  padding: 15px 6px;
  border-top: 1px solid var(--color-border);
}

.post-nav-list {
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
}

.post-nav-item {
  overflow: hidden;
  flex-basis: 46%;
}

.post-nav-prev {
  display: flex;
  justify-content: flex-start;
}

.post-nav-next {
  display: flex;
  justify-content: flex-end;
}

.post-nav-item a {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--color-text-emphasis);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: color-mix(in srgb, var(--color-text-emphasis) 30%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.post-nav-prev a {
  padding-left: 26px;
  text-align: left;
  background-image: url(/icons/prev.svg);
  background-size: 22px, 0;
  background-position: left -4px center;
  background-repeat: no-repeat;
}

.post-nav-next a {
  text-align: right;
  padding-right: 26px;
  background-image: url(/icons/next.svg);
  background-size: 22px, 0;
  background-position: right -4px center;
  background-repeat: no-repeat;
}

.post-nav-item a:hover {
  color: var(--color-link);
  text-decoration-color: var(--color-link);
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag {
  font-size: 0.85rem !important;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  background-color: #f5f5f5;
  border-radius: 3px;
  transition: background-color 0.2s;
}

.tag:hover {
  background-color: var(--color-border);
}

/* Social Links */
.social-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.social-link {
  display: inline-block;
  transition: opacity 0.2s, transform 0.2s;
}

.social-link:hover {
  opacity: 0.7;
  transform: translateY(-2px);
}

.social-icon {
  width: 24px;
  height: 24px;
  background-color: #fff;
  padding: 0.25rem;
  border-radius: 4px;
  object-fit: contain;
}

/* ========================================
   Pages
   ======================================== */

/* Index Page */
.intro {
  margin-bottom: 3rem;
  line-height: 1.9;
}

.intro p {
  margin-bottom: 1rem;
}

/* Recent Posts */
.recent-posts {
  margin-top: 3rem;
}

.recent-posts h2 {
  font-size: 1.3rem;
  font-weight: 600;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-emphasis);
}

.recent-posts h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.recent-posts-list,
.note-posts-list {
  list-style: none;
  padding: 0;
}

.recent-posts-list li,
.note-posts-list li {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.recent-posts-list li:last-child,
.note-posts-list li:last-child {
  margin-bottom: 0;
  border-bottom: none;
}

.post-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  display: block;
}

.more-link {
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

/* Note Posts */
.note-posts {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.note-posts h2 {
  font-size: 1.3rem;
  font-weight: 600;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-emphasis);
}

.note-posts-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.note-icon {
  width: 1.5rem;
  height: 1.5rem;
  background-color: #fff;
  padding: 0.25rem;
  border-radius: 4px;
  object-fit: contain;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  body {
    padding: 1.5rem 1rem;
  }

  article h1 {
    font-size: 1.5rem;
  }

  .content {
    font-size: 0.95rem;
  }

  nav {
    gap: 1rem;
  }
}
