/*
Theme Name: The Project Manager JP
Theme URI: https://theprojectmanager.jp
Author: The Project Manager
Description: Block theme for theprojectmanager.jp — a Japanese project-management tool review/comparison site. Tuned for Japanese typography, Core Web Vitals, and affiliate reader UX. Renders the pipeline's Gutenberg HTML natively (no Elementor).
Version: 0.1.0
Requires at least: 6.5
Tested up to: 6.7
Requires PHP: 8.0
Text Domain: theprojectmanager-jp
Tags: blog, block-styles, full-site-editing
*/

/* ─────────────────────────────────────────────────────────────
   Japanese typography — the parts theme.json can't express.
   Kinsoku (禁則) line-breaking + proportional metrics for clean JA.
   ───────────────────────────────────────────────────────────── */
:root {
  --tpm-measure: 40em; /* comfortable JA line length */
}

body {
  /* JIS-strict line breaking; never break mid-word, wrap long latin/URLs */
  line-break: strict;
  word-break: normal;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Proportional alternate metrics tighten JA spacing (esp. punctuation/kana). */
h1, h2, h3, h4, .wp-block-heading,
.tpm-hero, .site-title {
  font-feature-settings: "palt" 1;
}

/* Body copy: generous leading is essential for CJK readability. */
.entry-content p,
.entry-content li {
  line-height: 1.9;
}

/* Keep the reading measure tight on wide screens even inside full-width layouts. */
.entry-content > p,
.entry-content > ul,
.entry-content > ol,
.entry-content > h2,
.entry-content > h3,
.entry-content > blockquote {
  max-width: var(--tpm-measure);
  margin-left: auto;
  margin-right: auto;
}

/* ─────────────────────────────────────────────────────────────
   Media + tables (comparison tables are core to affiliate posts)
   ───────────────────────────────────────────────────────────── */
.entry-content img { height: auto; max-width: 100%; border-radius: 8px; }

figure.wp-block-image figcaption {
  color: var(--wp--preset--color--ink-muted);
  font-size: var(--wp--preset--font-size--small);
  text-align: center;
}

/* Comparison tables must scroll horizontally on mobile, never overflow the page. */
.entry-content .wp-block-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.entry-content .wp-block-table table { min-width: 640px; border-collapse: collapse; }
.entry-content .wp-block-table th {
  background: var(--wp--preset--color--navy);
  color: var(--wp--preset--color--base);
  font-weight: 700;
}
.entry-content .wp-block-table td,
.entry-content .wp-block-table th {
  border: 1px solid var(--wp--preset--color--border);
  padding: 0.7rem 0.9rem;
  vertical-align: middle;
}
.entry-content .wp-block-table tr:nth-child(even) td { background: var(--wp--preset--color--surface); }

/* ─────────────────────────────────────────────────────────────
   Header / footer basics (parts define structure; this refines)
   ───────────────────────────────────────────────────────────── */
.wp-block-site-logo img { max-height: 40px; width: auto; }

.tpm-header {
  border-bottom: 1px solid var(--wp--preset--color--border);
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--wp--preset--color--base) 92%, transparent);
  backdrop-filter: saturate(1.1) blur(6px);
}

.wp-block-navigation a { text-decoration: none; font-weight: 500; }
.wp-block-navigation a:hover { color: var(--wp--preset--color--coral-600); }

.tpm-footer { background: var(--wp--preset--color--navy-700); color: #C7CEDE; }
.tpm-footer a { color: #E6EAF3; }

/* ─────────────────────────────────────────────────────────────
   Reading progress bar + sticky mobile CTA (JS wires these in functions.php)
   ───────────────────────────────────────────────────────────── */
.tpm-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--wp--preset--color--coral); z-index: 100;
  transition: width 0.1s linear;
}

.tpm-sticky-cta {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  display: none; /* shown by JS after scroll threshold, mobile only */
  padding: 0.6rem 1rem;
  background: var(--wp--preset--color--base);
  border-top: 1px solid var(--wp--preset--color--border);
  box-shadow: 0 -6px 20px rgba(26,34,51,0.08);
}
.tpm-sticky-cta a {
  display: block; text-align: center; text-decoration: none;
  background: var(--wp--preset--color--coral); color: #fff; font-weight: 700;
  padding: 0.8rem; border-radius: 10px;
}
@media (min-width: 782px) { .tpm-sticky-cta { display: none !important; } }

/* ─────────────────────────────────────────────────────────────
   Enrichment components (breadcrumbs, TOC, read-time, author box)
   ───────────────────────────────────────────────────────────── */
.tpm-breadcrumb {
  max-width: var(--tpm-measure); margin: 0 auto 0.75rem;
  font-size: 0.8rem; color: var(--wp--preset--color--ink-muted);
}
.tpm-breadcrumb a { color: var(--wp--preset--color--ink-muted); text-decoration: none; }
.tpm-breadcrumb a:hover { color: var(--wp--preset--color--coral-600); text-decoration: underline; }
.tpm-breadcrumb__sep { opacity: 0.5; }

.tpm-readtime {
  max-width: var(--tpm-measure); margin: 0 auto 1rem;
  font-size: 0.82rem; color: var(--wp--preset--color--ink-muted);
}

.tpm-toc {
  max-width: var(--tpm-measure); margin: 0 auto 2rem;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 12px; padding: 1.1rem 1.4rem;
}
.tpm-toc__title { font-weight: 700; color: var(--wp--preset--color--navy); margin: 0 0 0.5rem; }
.tpm-toc ul { margin: 0; padding-left: 1.1rem; }
.tpm-toc li { margin: 0.3rem 0; line-height: 1.5; }
.tpm-toc__sub { list-style: circle; margin-left: 1rem; font-size: 0.95em; }
.tpm-toc a { color: var(--wp--preset--color--navy-300); text-decoration: none; }
.tpm-toc a:hover { color: var(--wp--preset--color--coral-600); text-decoration: underline; }

.tpm-author {
  max-width: var(--tpm-measure); margin: 3rem auto 0;
  display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--wp--preset--color--coral-50);
  border-left: 4px solid var(--wp--preset--color--coral);
  border-radius: 0 10px 10px 0; padding: 1.1rem 1.3rem;
}
.tpm-author__name { font-weight: 700; color: var(--wp--preset--color--navy); margin: 0; }
.tpm-author__bio { font-size: 0.9rem; color: var(--wp--preset--color--ink-muted); margin: 0; line-height: 1.7; }

/* ─────────────────────────────────────────────────────────────
   Revenue patterns (best-pick, comparison-CTA, hero) + shared CTA
   ───────────────────────────────────────────────────────────── */
.tpm-cta {
  display: inline-block; text-decoration: none; font-weight: 700; line-height: 1.3;
  background: var(--wp--preset--color--coral); color: #fff !important;
  padding: 0.8rem 1.6rem; border-radius: 10px; transition: background 0.15s ease;
}
.tpm-cta:hover { background: var(--wp--preset--color--coral-600); }
.tpm-cta--center { display: block; max-width: 360px; margin: 0 auto; text-align: center; }

.tpm-bestpick {
  max-width: var(--tpm-measure); margin: 0 auto 2rem;
  background: var(--wp--preset--color--coral-50);
  border: 1px solid #FBD5D5; border-left: 5px solid var(--wp--preset--color--coral);
  border-radius: 0 12px 12px 0; padding: 1.4rem 1.6rem;
}
.tpm-bestpick__eyebrow {
  display: inline-block; margin: 0 0 0.2rem; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; color: #fff; background: var(--wp--preset--color--coral);
  padding: 0.15rem 0.65rem; border-radius: 100px;
}
.tpm-bestpick h3 { color: var(--wp--preset--color--navy); }

.tpm-postcta { margin: 2rem auto; }

.tpm-hero h1 { color: var(--wp--preset--color--navy); }
.tpm-hero { border-bottom: 1px solid var(--wp--preset--color--border); }
