/* =====================================================================
   refined-ui.css  —  心のデブを信じろ / kenpos.dev
   Non-destructive UI/UX brush-up layered on top of the Mainroad theme.
   - Keeps the existing layout geometry (1080px, primary/sidebar ratios).
   - Keeps the signature red accent (#e22d30) and dark ink (#2a2a2a).
   - Adds an authentic Japanese web font (Zen Kaku Gothic New) with a
     Japanese-only fallback stack — never falls back to Chinese glyphs.
   ===================================================================== */

:root {
  --accent: #e22d30;
  --accent-strong: #c41f22;
  --accent-soft: rgba(226, 45, 48, 0.09);
  --accent-line: rgba(226, 45, 48, 0.22);
  --ink: #1c1e21;
  --ink-soft: #3a3d42;
  --muted: #6b7178;
  --line: #ececf0;
  --line-soft: #f2f2f5;
  --dark: #24262a;
  --dark-2: #2f3237;
  --page-bg: #eef0f4;
  --surface: #ffffff;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(24, 24, 40, 0.05);
  --shadow: 0 8px 26px -12px rgba(24, 24, 48, 0.16);
  --shadow-lg: 0 26px 60px -22px rgba(24, 24, 52, 0.28);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font-jp: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic", "YuGothic", "Meiryo", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas,
    "Courier New", monospace;
}

/* ---------- Base typography ---------- */
body {
  font-family: var(--font-jp);
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 100% -8%, rgba(226, 45, 48, 0.06), transparent 62%),
    radial-gradient(820px 480px at -6% 6%, rgba(38, 62, 128, 0.05), transparent 58%),
    var(--page-bg);
  background-attachment: fixed;
  font-feature-settings: "palt" 1;
  letter-spacing: 0.012em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-jp);
  color: var(--ink);
  letter-spacing: 0.01em;
  line-height: 1.4;
}

p, li { letter-spacing: 0.012em; }

::selection { background: rgba(226, 45, 48, 0.18); }

/* ---------- Outer shell ---------- */
.container--outer {
  margin: 34px auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.header { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.footer { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.wrapper { background: transparent; }

/* ---------- Header / logo ---------- */
.header {
  background:
    linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
  border-bottom: 1px solid var(--line-soft);
}

.logo { padding: 30px 30px 26px; }

.logo__title {
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, #1c1e21 0%, #3a3d42 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.logo__tagline {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  border-top: 2px solid var(--accent-line);
}

/* ---------- Main menu ---------- */
@media screen and (min-width: 767px) {
  .menu {
    background: var(--dark);
    border-bottom: 3px solid var(--accent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
  .menu__list { background: transparent; }
}

.menu__list { background: var(--dark); }

.menu__link {
  letter-spacing: 0.05em;
  transition: color 0.2s var(--ease), background 0.25s var(--ease);
}

.menu__item { position: relative; transition: background 0.25s var(--ease); }

.menu__item--active,
.menu__item:hover { background: var(--accent); }

/* ---------- Links ---------- */
a { transition: color 0.18s var(--ease); }

.content a,
.warning a,
.authorbox__description a {
  color: var(--accent);
  background-image: linear-gradient(var(--accent-line), var(--accent-line));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 2px;
  transition: background-size 0.3s var(--ease), color 0.2s var(--ease);
  padding-bottom: 1px;
}

.content a:hover,
.warning a:hover,
.authorbox__description a:hover {
  color: var(--accent-strong);
  text-decoration: none;
  background-size: 100% 2px;
}

/* ---------- Content rhythm ---------- */
.main__title,
.post__title {
  font-weight: 900;
  letter-spacing: 0.01em;
}

.content h2 {
  position: relative;
  margin-top: 2.4rem;
  padding: 0.35rem 0 0.35rem 0.95rem;
  font-weight: 800;
  border-left: 5px solid var(--accent);
}

.content h3 {
  margin-top: 2rem;
  padding-bottom: 0.35rem;
  font-weight: 800;
  border-bottom: 2px solid var(--line);
}

.content h4 {
  font-weight: 800;
  color: var(--ink-soft);
}

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

.content > .content,
.main__content { color: var(--ink-soft); }

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

.content img,
.post__thumbnail img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Content images: shrink oversized (pasted-as-is) images to a comfortable
   reading size, centered. Click opens the full-size lightbox. */
.post__content img,
.main__content img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 60vh;
  height: auto;
  margin: 1.6rem auto;
  cursor: zoom-in;
}

/* リンクに包まれた画像（Amazonカード等）はズームではなくリンクとして扱う */
.post__content a img,
.main__content a img { cursor: pointer; }

/* 記事冒頭のヘッダ画像（サムネ）は控えめなバナーに。切り抜かず高さで抑える。 */
.post__thumbnail {
  margin: 0 auto 1.4rem;
  text-align: center;
}
.post__thumbnail img {
  width: auto;
  max-width: 100%;
  max-height: 340px;
  margin: 0 auto;
}

.content figure img { box-shadow: none; }

figcaption { color: var(--muted); font-size: 0.8rem; }

/* ---------- Blockquote ---------- */
blockquote {
  position: relative;
  padding: 0.85rem 1.1rem 0.85rem 1.4rem;
  margin: 0 0 1.4rem;
  color: var(--ink-soft);
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

blockquote p:last-child { margin: 0; }

/* ---------- Inline code & blocks ---------- */
code {
  padding: 0.12em 0.45em;
  color: var(--accent-strong);
  background-color: #f8f1f1;
  border: 1px solid #f4dede;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre,
.highlight {
  background: #2d3038;
  border: 1px solid #3a3d46;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: #d8dee9;
  padding: 1.05rem 1.15rem;
  overflow-x: auto;
}

pre code,
.highlight pre,
.highlight pre code {
  color: inherit;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.65;
}

.highlight span[style*="background-color:#1e0010"] {
  background-color: transparent !important;
}

.highlight span[style*="color:#f8f8f2"],
.highlight span[style*="color:#cccccc"],
.highlight span[style*="color:#f2f2f2"] {
  color: #d8dee9 !important;
}

.highlight span[style*="color:#f92672"],
.highlight span[style*="color:#960050"],
.highlight span[style*="color:#f2777a"] {
  color: #ec5f67 !important;
}

.highlight span[style*="color:#a6e22e"],
.highlight span[style*="color:#99cc99"] {
  color: #99c794 !important;
}

.highlight span[style*="color:#e6db74"],
.highlight span[style*="color:#ffcc66"] {
  color: #f9c859 !important;
}

.highlight span[style*="color:#66d9ef"],
.highlight span[style*="color:#6699cc"] {
  color: #6699cc !important;
}

.highlight span[style*="color:#75715e"],
.highlight span[style*="color:#999999"] {
  color: #999999 !important;
}

/* ---------- Tables ---------- */
table {
  border: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
}

th {
  background: var(--dark);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 0;
}

td { border-right: 0; border-bottom: 1px solid var(--line); }

tbody tr:nth-child(even) { background: var(--line-soft); }

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--radius-sm);
  background: var(--dark);
  transition: transform 0.18s var(--ease), background 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.btn:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -8px rgba(226, 45, 48, 0.6);
}

/* ---------- List (archive / home) cards ---------- */
.list__item {
  display: flow-root; /* contain floated thumbnail + read-more within the card */
  padding: 20px;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease),
    border-color 0.22s var(--ease);
}

.list__item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent-line);
}

.list__title { font-weight: 800; letter-spacing: 0.01em; }

.list__title a { color: var(--ink); }
.list__title a:hover { color: var(--accent); }

.list__thumbnail img { border-radius: var(--radius-sm); }

.list__footer-readmore .btn { padding: 6px 14px; font-size: 0.8rem; }

/* ---------- Post meta ---------- */
.post__meta,
.list__meta,
.meta { color: var(--muted); }

.post__meta {
  border-top: 1px dotted var(--line);
  border-bottom: 1px dotted var(--line);
}

/* ---------- Table of Contents ---------- */
.toc {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.toc__title {
  background: var(--dark);
  letter-spacing: 0.05em;
}

.toc__menu a {
  color: var(--accent);
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.2s var(--ease), padding-left 0.2s var(--ease);
}

.toc__menu a:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

/* ---------- Sidebar widgets ---------- */
.sidebar .widget {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.widget__title {
  font-weight: 800;
  letter-spacing: 0.04em;
  border-bottom: 3px solid var(--accent);
}

.widget__item { border-bottom: 1px dotted var(--line); }

.widget__item a { color: var(--ink-soft); }
.widget__item a:hover { color: var(--accent); }

/* Search field */
.widget-search__form {
  padding: 0;
  background: transparent;
}

.widget-search__field {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.widget-search__field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Social links (dark pills — force white text so it stays readable) */
.widget-social__link {
  padding: 9px 12px;
  background: var(--dark);
  border-radius: var(--radius-sm);
  transition: transform 0.18s var(--ease), background 0.25s var(--ease);
}

/* Higher specificity than `.widget__item a` so the label doesn't turn dark */
.widget-social__item .widget-social__link,
.widget-social__item .widget-social__link span,
.widget-social__item .widget-social__link:hover,
.widget-social__item .widget-social__link:hover span {
  color: #fff;
}

.widget-social__link-icon { fill: #fff; }

.widget-social__link:hover {
  background: var(--accent);
  transform: translateX(3px);
}

/* Tag pills */
.widget-taglist__link {
  padding: 5px 11px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  transition: all 0.2s var(--ease);
}

.widget-taglist__link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Author box ---------- */
.authorbox {
  padding: 22px;
  background: linear-gradient(180deg, #fbfbfc, #f6f6f8);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.authorbox__avatar { border-radius: 50%; border: 2px solid var(--surface); box-shadow: var(--shadow-sm); }
.authorbox__name { font-weight: 800; }

/* ---------- Pagination / pager ---------- */
.pagination__item {
  border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease);
}

.pagination__item:hover,
.pagination__item--current { background: var(--accent); }

.pager__link { transition: color 0.2s var(--ease); }
.pager__link:hover .pager__title { color: var(--accent); }

/* ---------- Footer ---------- */
.footer {
  background: linear-gradient(180deg, var(--dark-2), var(--dark));
  border-top: 3px solid var(--accent);
  color: #b9bdc4;
}

.footer a { color: #eef0f4; }
.footer a:hover { color: #fff; text-decoration: none; }

/* ---------- Accessibility ---------- */
a:focus-visible,
.btn:focus-visible,
.menu__link:focus-visible,
.widget-search__field:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Responsive tweaks (keep theme breakpoints) ---------- */
@media screen and (max-width: 900px) {
  .container--outer { margin: 16px auto; border-radius: var(--radius); }
  .header { border-radius: var(--radius) var(--radius) 0 0; }
  .footer { border-radius: 0 0 var(--radius) var(--radius); }
}

@media screen and (max-width: 767px) {
  body { font-size: 15px; }
  .sidebar .widget { margin-top: 16px; }
}

/* ---------- Lightbox (click content image to enlarge) ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 12, 16, 0.92);
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.lightbox.is-open { display: flex; opacity: 1; }
.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.lightbox__close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }
