/*
Theme Name: Kanoayu Theme
Theme URI: https://kanoayu.blog
Author: かのあゆ
Description: A clean, modern WordPress theme inspired by tech news sites. Responsive & reader-friendly.
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: kanoayu-theme
*/

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  --color-primary:     #0f172a;
  --color-accent:      #6366f1;
  --color-accent-dark: #4f46e5;
  --color-accent-light:#e0e7ff;
  --color-surface:     #ffffff;
  --color-surface-2:   #f8fafc;
  --color-border:      #e2e8f0;
  --color-text:        #1e293b;
  --color-text-muted:  #64748b;
  --color-text-light:  #94a3b8;
  --color-tag-bg:      #f1f5f9;
  --color-banner-bg:   #0f172a;
  --color-banner-text: #f8fafc;
  --font-sans: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.1);
  --header-h:   60px;
  --banner-h:   44px;
  --content-w:  1200px;
  --sidebar-w:  300px;
  --transition: 0.2s ease;
}

/* ============================================
   RESET / BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-surface-2);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-accent-dark); }

/* ============================================
   TOP BANNER
   ============================================ */
.site-banner {
  background: var(--color-banner-bg);
  color: var(--color-banner-text);
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .01em;
  padding: 0 16px;
  height: var(--banner-h);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 200;
}

.site-banner a {
  color: var(--color-accent-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-banner:empty { display: none; }
body:not(.has-banner) .site-banner { display: none; }

/* ============================================
   HEADER
   ============================================ */
.site-header {
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
}

.site-branding { flex-shrink: 0; }

.site-logo img { height: 36px; width: auto; }

.site-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--color-primary);
  line-height: 1;
}

.site-title a { color: inherit; }
.site-title a:hover { color: var(--color-accent); }

.site-title span {
  color: var(--color-accent);
}

/* ============================================
   NAVIGATION
   ============================================ */
.main-nav { flex: 1; }

.main-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav ul li a {
  display: block;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.main-nav ul li a:hover,
.main-nav ul li.current-menu-item > a {
  color: var(--color-accent);
  background: var(--color-accent-light);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  transition: background var(--transition);
}

.menu-toggle:hover { background: var(--color-tag-bg); }

.menu-toggle .bar {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  margin: 5px 0;
  transition: transform var(--transition), opacity var(--transition);
  border-radius: 2px;
}

.menu-toggle.is-active .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.is-active .bar:nth-child(2) { opacity: 0; }
.menu-toggle.is-active .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Header search */
.header-search { flex-shrink: 0; }

.header-search form {
  display: flex;
  align-items: center;
  background: var(--color-tag-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.header-search form:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.header-search input {
  background: none;
  border: none;
  outline: none;
  padding: 7px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  width: 200px;
}

.header-search button {
  background: none;
  border: none;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.header-search button:hover { color: var(--color-accent); }

/* ============================================
   CONTAINER / LAYOUT
   ============================================ */
.container {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 20px;
}

.content-area {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: 32px;
  padding: 32px 0 48px;
}

.content-area.no-sidebar {
  grid-template-columns: 1fr;
}

/* ============================================
   HERO / FEATURED POST
   ============================================ */
.hero-section {
  background: var(--color-primary);
  padding: 0;
  margin-bottom: 0;
}

.hero-post {
  position: relative;
  height: 480px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.hero-post-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s ease;
}

.hero-post:hover .hero-post-image { transform: scale(1.03); }

.hero-post-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.3) 50%, transparent 100%);
}

.hero-post-content {
  position: relative;
  z-index: 1;
  padding: 32px 40px;
  color: #fff;
  width: 100%;
  max-width: 800px;
}

.hero-post-content .post-category {
  margin-bottom: 12px;
}

.hero-post-content .post-title {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.02em;
  margin-bottom: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.hero-post-content .post-title a { color: #fff; }
.hero-post-content .post-title a:hover { color: rgba(255,255,255,.8); }

.hero-post-content .post-meta { color: rgba(255,255,255,.7); font-size: 13px; }

/* ============================================
   POST CATEGORY BADGE
   ============================================ */
.post-category {
  display: inline-flex;
  align-items: center;
}

.post-category a,
.cat-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: #fff;
  transition: background var(--transition);
}

.post-category a:hover { background: var(--color-accent-dark); color: #fff; }

/* ============================================
   POST CARDS
   ============================================ */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.posts-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.post-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}

.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card-image {
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--color-tag-bg);
  flex-shrink: 0;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}

.post-card:hover .post-card-image img { transform: scale(1.04); }

.post-card-image.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
}

.post-card-image.no-image svg { width: 48px; height: 48px; opacity: .3; }

.post-card-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-card .post-category { margin-bottom: 10px; }

.post-card .post-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -.01em;
  margin-bottom: 10px;
  flex: 1;
}

.post-card .post-title a { color: var(--color-text); }
.post-card .post-title a:hover { color: var(--color-accent); }

.post-card .post-excerpt {
  font-size: 13.5px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--color-text-light);
  flex-wrap: wrap;
}

.post-meta time { display: flex; align-items: center; gap: 4px; }
.post-meta .author { display: flex; align-items: center; gap: 4px; }

.post-meta svg { width: 13px; height: 13px; flex-shrink: 0; }

/* List style card */
.post-card-list {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.post-card-list:hover { box-shadow: var(--shadow-md); }

.post-card-list .post-card-image {
  width: 120px;
  min-width: 120px;
  aspect-ratio: 4/3;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.post-card-list .post-card-body { padding: 0; }

.post-card-list .post-title { font-size: 14px; margin-bottom: 6px; }

/* ============================================
   SECTION HEADER
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-border);
}

.section-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 18px;
  background: var(--color-accent);
  border-radius: 2px;
}

.section-more {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 4px;
}

.section-more:hover { color: var(--color-accent-dark); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar { min-width: 0; }

.widget {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.widget-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

/* ============================================
   SINGLE POST
   ============================================ */
.single-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 48px 0 0;
}

.single-header .container { max-width: 800px; }

.single-header .post-category { margin-bottom: 16px; }

.post-title-main {
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.03em;
  color: var(--color-primary);
  margin-bottom: 20px;
}

.post-thumbnail-wrap {
  margin-top: 32px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  max-height: 480px;
}

.post-thumbnail-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Article body */
.article-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.entry-content { line-height: 1.85; }

.entry-content h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--color-primary);
  margin: 40px 0 16px;
  padding-left: 14px;
  border-left: 4px solid var(--color-accent);
}

.entry-content h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  margin: 32px 0 12px;
}

.entry-content h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 10px;
}

.entry-content p { margin-bottom: 20px; }

.entry-content ul, .entry-content ol {
  margin: 0 0 20px 24px;
}

.entry-content li { margin-bottom: 6px; }

.entry-content blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--color-accent);
  background: var(--color-accent-light);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
  color: var(--color-text-muted);
}

.entry-content code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--color-tag-bg);
  border: 1px solid var(--color-border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-accent-dark);
}

.entry-content pre {
  background: var(--color-primary);
  color: #e2e8f0;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 24px 0;
}

.entry-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 14px;
}

.entry-content img {
  border-radius: var(--radius-md);
  margin: 24px 0;
}

.entry-content a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 32px 0;
}

.pagination a,
.pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all var(--transition);
}

.pagination a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
}

.pagination .current {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  background: var(--color-primary);
  color: rgba(255,255,255,.7);
  padding: 48px 0 24px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand .site-title {
  color: #fff;
  margin-bottom: 12px;
  font-size: 22px;
}

.footer-brand .site-description {
  font-size: 14px;
  color: rgba(255,255,255,.5);
  line-height: 1.7;
}

.footer-nav-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  margin-bottom: 14px;
}

.footer-nav ul { list-style: none; }

.footer-nav ul li { margin-bottom: 10px; }

.footer-nav ul li a {
  font-size: 14px;
  color: rgba(255,255,255,.6);
  transition: color var(--transition);
}

.footer-nav ul li a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(255,255,255,.35);
}

/* ============================================
   UTILITIES
   ============================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--color-accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  transition: top var(--transition);
}

.skip-link:focus { top: 16px; color: #fff; }

.screen-reader-text {
  clip: rect(1px, 1px, 1px, 1px);
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition), transform var(--transition);
  z-index: 50;
}

.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-3px); }

/* Tag list */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }

.tag-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--color-tag-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: all var(--transition);
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 260px; }
}

@media (max-width: 900px) {
  .content-area {
    grid-template-columns: 1fr;
  }

  .posts-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-post { height: 360px; }
  .hero-post-content { padding: 24px; }
}

@media (max-width: 768px) {
  .menu-toggle { display: flex; flex-direction: column; justify-content: center; }

  .main-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: 12px 0;
  }

  .main-nav.is-open { display: block; }

  .main-nav ul {
    flex-direction: column;
    gap: 0;
    padding: 0 12px;
  }

  .main-nav ul li a {
    padding: 12px 16px;
    font-size: 15px;
  }

  .header-search input { width: 140px; }

  .posts-grid { grid-template-columns: 1fr; }
  .posts-grid.cols-3 { grid-template-columns: 1fr; }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .hero-post { height: 280px; }
}

@media (max-width: 480px) {
  :root { --header-h: 54px; }

  .post-card-list {
    flex-direction: column;
  }

  .post-card-list .post-card-image {
    width: 100%;
    aspect-ratio: 16/9;
  }

  .back-to-top { bottom: 16px; right: 16px; }
  .header-search { display: none; }
}

/* ============================================
   DARK MODE (prefers-color-scheme)
   ============================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --color-primary:     #f1f5f9;
    --color-surface:     #0f172a;
    --color-surface-2:   #1e293b;
    --color-border:      #334155;
    --color-text:        #e2e8f0;
    --color-text-muted:  #94a3b8;
    --color-text-light:  #64748b;
    --color-tag-bg:      #1e293b;
    --color-accent-light:#312e81;
    --color-banner-bg:   #020617;
    --color-banner-text: #e2e8f0;
  }

  .site-header {
    background: rgba(15,23,42,.92);
    border-color: var(--color-border);
  }
}
