/*
Theme Name: Ticot Modern
Theme URI: https://ticot.net
Author: ticot
Description: ticot用の軽量モダンテーマ。M PLUS 1pフォント、AdSense対応、ライトボックス、SEO最適化済み。
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: ticot-modern
Tags: blog, one-column, two-columns, custom-menu, featured-images, translation-ready
*/

/* ===== CSS Variables ===== */
:root {
  --font-main: 'M PLUS 1p', sans-serif;
  --c-bg: #FAFAF8;
  --c-surface: #FFFFFF;
  --c-text: #1A1A1A;
  --c-text-sub: #6B6B6B;
  --c-accent: #E8503A;
  --c-accent-hover: #D1402C;
  --c-border: #E8E6E1;
  --c-tag-bg: #F3F1ED;
  --c-tag-text: #5A5A5A;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --max-w: 1200px;
  --content-w: 780px;
  --sidebar-w: 340px;
  --gap: 40px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body {
  font-family: var(--font-main);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.85;
  font-weight: 400;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
/* WordPress alignment classes */
.alignleft { float: left; margin: 0.5em 1.5em 1em 0; }
.alignright { float: right; margin: 0.5em 0 1em 1.5em; }
.aligncenter { display: block; margin: 1em auto; }
.wp-caption { max-width: 100%; }
.wp-caption img { width: 100%; height: auto; }
.wp-block-image img { max-width: 100%; height: auto; }
ul, ol { list-style: none; }

/* ===== Layout ===== */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.main-grid {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: var(--gap);
  align-items: start;
}

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.site-logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--c-text);
}
.site-logo span { color: var(--c-accent); }
.nav-main { display: flex; gap: 28px; }
.nav-main ul { display: flex; gap: 28px; list-style: none; margin: 0; padding: 0; }
.nav-main li { list-style: none; margin: 0; padding: 0; }
.nav-main a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-text-sub);
  transition: color var(--transition);
  position: relative;
}
.nav-main a:hover { color: var(--c-text); }
.nav-main a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--c-accent);
  transition: width var(--transition);
}
.nav-main a:hover::after { width: 100%; }

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--c-text);
  transition: var(--transition);
}

/* ===== Ad Zones ===== */
.ad-zone { text-align: center; padding: 16px 0; }
.ad-zone-sidebar { margin-bottom: 24px; }
.ad-zone-in-article { margin: 2em 0; text-align: center; }

/* ===== Hero removed - all posts displayed equally ===== */

/* ===== Section Heading ===== */
.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-top: 40px;
}
.section-heading h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ===== Post Cards ===== */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}
.post-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.post-card-thumb {
  aspect-ratio: 16/9;
  overflow: hidden;
}
.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.post-card:hover .post-card-thumb img { transform: scale(1.05); }
.post-card-body { padding: 20px; }
.post-card-tag {
  display: inline-block;
  background: var(--c-tag-bg);
  color: var(--c-tag-text);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.post-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}
.post-card-excerpt {
  font-size: 0.8rem;
  color: var(--c-text-sub);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}
/* Post card meta removed - no dates displayed */

/* In-feed Ad */
.infeed-ad {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px 0;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 48px 0 24px;
}
.pagination a, .pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
}
.pagination a {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
}
.pagination a:hover { border-color: var(--c-accent); color: var(--c-accent); }
.pagination .current {
  background: var(--c-accent);
  color: #fff;
}

/* ===== Sidebar ===== */
.sidebar { position: sticky; top: 80px; }
.sidebar-widget {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.widget-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--c-accent);
  display: inline-block;
}
.widget-search {
  display: flex;
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--c-bg);
  transition: border-color var(--transition);
}
.widget-search:focus-within {
  border-color: var(--c-accent);
}
.widget-search input {
  flex: 1;
  border: none;
  padding: 12px 16px;
  font-family: var(--font-main);
  font-size: 0.84rem;
  outline: none;
  background: transparent;
  color: var(--c-text);
}
.widget-search input::placeholder {
  color: #B0ADA6;
}
.widget-search button {
  background: var(--c-accent);
  border: none;
  color: #fff;
  padding: 12px 20px;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background var(--transition);
  letter-spacing: 0.02em;
}
.widget-search button:hover { background: var(--c-accent-hover); }
.popular-list li {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
  align-items: center;
}
.popular-list li:last-child { border-bottom: none; }
.popular-rank {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--c-tag-bg);
  color: var(--c-text-sub);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.popular-rank.top { background: var(--c-accent); color: #fff; }
.popular-title {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.category-list { display: flex; flex-wrap: wrap; gap: 8px; }
.category-list a {
  background: var(--c-tag-bg);
  color: var(--c-tag-text);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  transition: var(--transition);
}
.category-list a:hover { background: var(--c-accent); color: #fff; }

/* ===== Article (Single) ===== */
.article-header { padding: 32px 0 24px; }
.breadcrumb {
  font-size: 0.72rem;
  color: var(--c-text-sub);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--c-accent); }
.article-header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 14px;
}
.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--c-text-sub);
}
.article-meta .cat-label {
  background: var(--c-accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}
.article-featured-img {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
  cursor: pointer;
  max-width: 100%;
  width: 100%;
}
.article-featured-img img {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  display: block;
  object-fit: cover;
}

/* Article Content Typography */
.article-content {
  max-width: var(--content-w);
  font-size: 0.95rem;
  line-height: 2;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow: hidden;
}
.article-content p { margin-bottom: 1.6em; }
.article-content p img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 0 auto;
}
.article-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 2.5em 0 1em;
  padding-left: 16px;
  border-left: 4px solid var(--c-accent);
}
.article-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2em 0 0.8em;
}
.article-content ul, .article-content ol {
  padding-left: 1.5em;
  margin-bottom: 1.6em;
}
.article-content ul { list-style: disc; }
.article-content ol { list-style: decimal; }
.article-content li { margin-bottom: 0.5em; }
.article-content strong { font-weight: 600; }
.article-content hr {
  border: none;
  height: 1px;
  background: var(--c-border);
  margin: 2.5em 0;
}
/* CRITICAL: Force all images to respect container width regardless of inline attrs */
.article-content img,
.article-content img[width],
.article-content img[style] {
  max-width: 100% !important;
  height: auto !important;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity var(--transition);
  display: block;
  box-sizing: border-box;
}
.article-content img:hover { opacity: 0.9; }
.article-content figure {
  max-width: 100%;
  margin: 1.6em 0;
  overflow: hidden;
}
.article-content figure img {
  width: 100%;
  height: auto !important;
}
.article-content figcaption {
  font-size: 0.78rem;
  color: var(--c-text-sub);
  text-align: center;
  margin-top: 8px;
}
.article-content iframe,
.article-content embed,
.article-content video,
.article-content object {
  max-width: 100% !important;
  height: auto;
}
.article-content .wp-block-image,
.article-content .wp-block-embed,
.article-content .wp-block-gallery {
  max-width: 100%;
  overflow: hidden;
}
/* WordPress classic editor image captions */
.article-content .wp-caption {
  max-width: 100% !important;
  width: auto !important;
  overflow: hidden;
}
.article-content .wp-caption img {
  width: 100% !important;
  height: auto !important;
}
.article-content .wp-caption-text {
  font-size: 0.78rem;
  color: var(--c-text-sub);
  text-align: center;
  margin-top: 6px;
  padding: 0 4px;
}
/* Gallery grids */
.article-content .gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 1.6em 0;
}
.article-content .gallery-item {
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.article-content .gallery-item img {
  width: 100% !important;
  height: auto !important;
  object-fit: cover;
}
.article-content blockquote {
  border-left: 3px solid var(--c-accent);
  padding: 16px 20px;
  background: var(--c-tag-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.6em 0;
  font-style: italic;
  color: var(--c-text-sub);
}
.article-content a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.article-content th,
.article-content td {
  border: 1px solid var(--c-border);
  padding: 10px 14px;
  font-size: 0.88rem;
  text-align: left;
}
.article-content th {
  background: var(--c-tag-bg);
  font-weight: 600;
}

/* TOC */
.toc-box {
  background: var(--c-tag-bg);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0 32px;
}
.toc-box .toc-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.toc-box ol { list-style: decimal; padding-left: 1.4em; }
.toc-box li { font-size: 0.82rem; margin-bottom: 6px; }
.toc-box a { color: var(--c-accent); }

/* Related Posts */
.related-section { padding: 48px 0; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ===== Lightbox ===== */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: lbFadeIn 0.25s ease;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
  animation: lbZoom 0.3s ease;
}
.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 10000;
  opacity: 0.7;
  transition: opacity var(--transition);
}
.lightbox-close:hover { opacity: 1; }
@keyframes lbFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes lbZoom { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--c-accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  transition: var(--transition);
  z-index: 90;
}
.back-to-top.visible { opacity: 1; transform: translateY(0); }
.back-to-top:hover { background: var(--c-accent-hover); }

/* ===== Footer ===== */
.site-footer {
  background: #1A1A1A;
  color: rgba(255,255,255,0.6);
  padding: 48px 0 24px;
  margin-top: 64px;
}
.footer-inner {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
.footer-col h3 {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.footer-col a {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 8px;
  transition: color var(--transition);
}
.footer-col a:hover { color: #fff; }
.footer-bottom {
  text-align: center;
  font-size: 0.72rem;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}
@media (max-width: 768px) {
  .nav-main { display: none; }
  .nav-main ul { flex-direction: column; gap: 0; }
  .menu-toggle { display: flex; }
  .nav-main.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--c-surface);
    padding: 12px 24px 20px;
    gap: 0;
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow-md);
  }
  .nav-main.open ul {
    flex-direction: column;
    gap: 0;
  }
  .nav-main.open li {
    border-bottom: 1px solid var(--c-border);
  }
  .nav-main.open li:last-child {
    border-bottom: none;
  }
  .nav-main.open a {
    display: block;
    padding: 12px 0;
    font-size: 0.88rem;
  }
  .nav-main.open a::after { display: none; }
  .posts-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .article-header h1 { font-size: 1.3rem; }
  /* Mobile image fixes */
  .article-featured-img {
    margin-left: -24px;
    margin-right: -24px;
    border-radius: 0;
    width: calc(100% + 48px);
    max-width: calc(100% + 48px);
    overflow: hidden;
  }
  .article-featured-img img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block;
  }
  .article-content img,
  .article-content img[width],
  .article-content img[height],
  .article-content img[style],
  .article-content p img,
  .article-content a img {
    max-width: 100% !important;
    height: auto !important;
  }
  .article-content figure,
  .article-content .wp-caption {
    max-width: 100% !important;
    width: auto !important;
    margin-left: 0;
    margin-right: 0;
  }
  .article-content .wp-block-image {
    margin-left: 0;
    margin-right: 0;
  }
  .article-content .wp-block-image.alignfull,
  .article-content .wp-block-image.alignwide {
    margin-left: -24px;
    margin-right: -24px;
    max-width: calc(100% + 48px);
    width: calc(100% + 48px);
  }
  .article-content .wp-block-image.alignfull img,
  .article-content .wp-block-image.alignwide img {
    width: 100% !important;
    border-radius: 0;
  }
  .article-content iframe {
    max-width: 100% !important;
  }
  .article-content table {
    font-size: 0.8rem;
  }
  .article-content th,
  .article-content td {
    padding: 8px 10px;
  }
  .post-card-thumb img {
    width: 100%;
    height: 100%;
  }
}
