/*
 * logical-web.jp 共通スタイルシート
 * Web の便利屋 / データ職人の工房（クリーム紙色 + 紺インク + コバルト + 錆色）
 */

/* ---------- DESIGN TOKENS ---------- */
:root {
  --ink: #1a2332;
  --ink-soft: #2a3447;
  --paper: #f4f1ea;
  --paper-warm: #ede8db;
  --cobalt: #2a4d7a;
  --cobalt-bright: #3d6ba8;
  --rust: #b85432;
  --rule: #c9c0a8;
  --text: #1a2332;
  --text-soft: #5a6477;
  --text-muted: #8a8470;
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--paper);
  color: var(--text);
  line-height: 1.7;
  font-weight: 400;
  overflow-x: hidden;
}

.serif { font-family: 'Noto Serif JP', serif; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* 日本語タイトル: 句読点・助詞境界で改行（mid-word break 防止） */
h1, h2, h3, h4 {
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: anywhere;
}

/* ---------- A11Y: focus-visible ---------- */
/* マウスクリック時はアウトラインを出さず、キーボード操作時のみ視認可能なフォーカスリング */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
  border-radius: 2px;
}
/* main は skip-link のターゲット。プログラム的フォーカス時にアウトライン抑制 */
main { display: block; }
main:focus { outline: none; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

/* スキップリンク（キーボード操作者用） */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  text-decoration: none;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  transition: top 0.15s ease-out;
}
.skip-link:focus {
  top: 0;
}

/* ---------- TOP BAR ---------- */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(244, 241, 234, 0.92);
}
/* backdrop-filter は PC のみ。モバイルで適用するとフルスクリーンメニュー（position:fixed）
   の containing block が topbar 内に閉じ込められ、メニューが縦に短く開いてしまうため。 */
@media (min-width: 981px) {
  .topbar {
    backdrop-filter: blur(8px);
  }
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}
.brand-icon {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--ink);
  display: grid;
  place-items: center;
  font-family: 'Noto Serif JP', 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  background: var(--paper);
  position: relative;
}
.brand-icon::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid var(--ink);
  pointer-events: none;
}
.brand-text {
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.brand-text small {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  display: block;
  margin-top: -2px;
}

/* ---------- NAV ---------- */
.nav {
  display: flex;
  gap: 28px;
  align-items: center;
}
.nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  padding: 4px 0;
}
.nav a:hover { color: var(--cobalt); }
.nav a.is-current { color: var(--cobalt); }
.nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--cobalt);
  transform: scaleX(0);
  transition: transform 0.3s;
  transform-origin: right;
}
.nav a:hover::after,
.nav a.is-current::after {
  transform: scaleX(1);
  transform-origin: left;
}
.nav-cta {
  background: var(--ink) !important;
  color: var(--paper) !important;
  padding: 10px 18px !important;
  font-size: 13px !important;
  border: 1px solid var(--ink);
  transition: all 0.2s;
}
.nav-cta:hover {
  background: var(--cobalt) !important;
  border-color: var(--cobalt);
  color: var(--paper) !important;
}
.nav-cta::after { display: none !important; }

/* ---------- HERO BASE ---------- */
.hero {
  max-width: 1240px;
  margin: 0 auto;
  padding: 88px 32px 104px;
  position: relative;
}
.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.hero-eyebrow::before {
  content: '';
  width: 32px;
  height: 1px;
  background: var(--text-muted);
}
.hero-title {
  font-family: 'Noto Serif JP', serif;
  font-weight: 900;
  line-height: 1.22;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 32px;
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: anywhere;
}
.hero-title .accent {
  color: var(--cobalt);
  position: relative;
  display: inline-block;
}
.hero-title .accent::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 4px;
  height: 12px;
  background: var(--rust);
  opacity: 0.18;
  z-index: -1;
}
.hero-lede {
  font-size: 16px;
  color: var(--text-soft);
  line-height: 1.95;
  margin-bottom: 44px;
}
.hero-cta-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- BUTTONS ---------- */
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  padding: 16px 32px;
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
  border: 1px solid var(--ink);
}
.btn-primary:hover {
  background: var(--cobalt);
  border-color: var(--cobalt);
  transform: translateY(-1px);
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-secondary {
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  border-bottom: 1px solid var(--text);
  padding-bottom: 2px;
  transition: color 0.2s;
}
.btn-secondary:hover {
  color: var(--cobalt);
  border-color: var(--cobalt);
}

/* ---------- SECTION SHARED ---------- */
.section-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.2em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
}
.section-eyebrow::before {
  content: '';
  width: 32px;
  height: 1px;
  background: currentColor;
}
.section-title {
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: clamp(28px, 3.5vw, 44px);
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 16px;
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: anywhere;
}
.section-lede {
  font-size: 15px;
  color: var(--text-soft);
  line-height: 1.95;
  max-width: 720px;
}

/* ---------- CTA SECTION ---------- */
.cta-section {
  padding: 120px 32px;
  position: relative;
  overflow: hidden;
}
.cta-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.4;
  mask-image: radial-gradient(ellipse 800px 500px at center, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 800px 500px at center, black 30%, transparent 70%);
}
.cta-inner {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  position: relative;
}
.cta-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.cta-title {
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: clamp(30px, 3.8vw, 44px);
  line-height: 1.4;
  margin-bottom: 24px;
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: anywhere;
}
.cta-lede {
  font-size: 16px;
  color: var(--text-soft);
  line-height: 1.95;
  margin-bottom: 48px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- FOOTER ---------- */
.footer {
  background: var(--ink);
  color: rgba(244, 241, 234, 0.6);
  padding: 60px 32px 32px;
}
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 48px;
  padding-bottom: 48px;
  border-bottom: 1px solid rgba(244, 241, 234, 0.15);
}
.footer-brand .brand-mark { margin-bottom: 16px; }
.footer-brand .brand-text { color: var(--paper); }
.footer-brand .brand-icon {
  border-color: rgba(244, 241, 234, 0.4);
  color: var(--paper);
  background: transparent;
}
.footer-brand .brand-icon::before {
  border-color: rgba(244, 241, 234, 0.4);
}
.footer-tagline {
  font-size: 13px;
  color: rgba(244, 241, 234, 0.5);
  line-height: 1.85;
  max-width: 320px;
}
.footer-col h2,
.footer-col h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(244, 241, 234, 0.4);
  margin-bottom: 16px;
  font-weight: 500;
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 10px; }
.footer-col a {
  color: rgba(244, 241, 234, 0.7);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}
.footer-col a:hover { color: var(--paper); }
.footer-meta {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(244, 241, 234, 0.4);
  letter-spacing: 0.1em;
}

/* ---------- HAMBURGER NAV (mobile) ---------- */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--ink);
  /* WCAG タップ領域 44x44 以上 */
  width: 44px;
  height: 44px;
  padding: 0;
  position: relative;
  cursor: pointer;
  /* メニューを開いた状態でも閉じる X をタップできるよう、.nav (z-index:90) より前面に置く */
  z-index: 110;
}
.nav-toggle span {
  display: block;
  position: absolute;
  left: 9px;
  right: 9px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease-out;
}
.nav-toggle span:nth-child(1) { top: 15px; }
.nav-toggle span:nth-child(2) { top: 21px; }
.nav-toggle span:nth-child(3) { top: 27px; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile menu body lock (no backdrop — panel is opaque full-screen) */
body.nav-open {
  overflow: hidden;
}

/* ---------- RESPONSIVE COMMON ---------- */
@media (max-width: 980px) {
  .nav-toggle { display: block; }

  /* Full-screen panel that slides in from right, sits BELOW topbar (z-index 90 < topbar 100).
     iOS の Safari ツールバー伸縮で 100vh が想定外になるのを防ぐため top/right/bottom/left を
     明示し、フォールバックの高さも併記する（dvh→vh）。 */
  .nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--paper);
    padding: 96px 32px 40px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 90;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: none;
  }
  .nav.is-open {
    transform: translateX(0);
    pointer-events: auto;
  }
  .nav a {
    padding: 22px 4px;
    border-bottom: 1px solid var(--rule);
    font-size: 18px;
    font-family: 'Noto Serif JP', serif;
    font-weight: 700;
    width: 100%;
    color: var(--ink);
  }
  .nav a::after { display: none; }
  .nav .nav-cta {
    margin-top: 32px;
    background: var(--ink) !important;
    color: var(--paper) !important;
    border: 1px solid var(--ink);
    text-align: center;
    padding: 18px !important;
    font-size: 15px !important;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 500;
  }
  .nav .nav-cta:hover { transform: none; }

  /* Hide the underline animation override since we're using border-bottom only */
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .topbar-inner,
  .hero,
  .cta-section {
    padding-left: 20px;
    padding-right: 20px;
  }
  .footer-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 56px; padding-bottom: 72px; }
  .hero-eyebrow {
    font-size: 11px;
    letter-spacing: 0.15em;
    margin-bottom: 24px;
  }
  .hero-lede {
    font-size: 15px;
    line-height: 1.85;
    margin-bottom: 32px;
  }
  .cta-section { padding-top: 64px; padding-bottom: 64px; }
  .cta-title {
    font-size: 24px;
    line-height: 1.45;
    margin-bottom: 20px;
  }
  .cta-lede {
    font-size: 14px;
    margin-bottom: 32px;
  }
}

/* ---------- SECTION ICONS ---------- */
.section-icon {
  width: 36px;
  height: 36px;
  display: block;
  margin-bottom: 20px;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.pillars .section-icon { color: rgba(244, 241, 234, 0.7); }
.service .section-icon,
.compare-card .section-icon,
.service-detail .section-icon { color: var(--cobalt); }
.service .section-icon { margin-bottom: 14px; margin-top: -4px; }

/* ---------- COUNT-UP NUMBERS ---------- */
.metric-value, .hero-card-value .big {
  font-variant-numeric: tabular-nums;
}

/* ---------- ANIMATIONS ---------- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.hero-eyebrow,
.hero-title,
.hero-lede,
.hero-cta-row {
  animation: fadeUp 0.7s ease-out backwards;
}
.hero-eyebrow { animation-delay: 0.1s; }
.hero-title { animation-delay: 0.2s; }
.hero-lede { animation-delay: 0.35s; }
.hero-cta-row { animation-delay: 0.5s; }

/* ---------- MICRO-INTERACTIONS ---------- */

/* Smooth transitions for interactive elements */
a, button {
  transition-property: color, background-color, border-color, transform, box-shadow, opacity;
  transition-duration: 0.22s;
  transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Card hover lift (proximity + contrast principles) */
.pillar,
.service,
.compare-card,
.pattern-card,
.tool-cat,
.blog-card,
.case-card,
.principle,
.flow-step {
  transition:
    transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 0.22s ease-out,
    box-shadow 0.28s ease-out,
    border-color 0.22s ease-out;
}
.service:hover,
.compare-card:hover,
.pattern-card:hover,
.tool-cat:hover,
.blog-card:hover,
.case-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px -12px rgba(26, 35, 50, 0.18);
}

/* Pillar (dark bg) variant */
.pillar:hover {
  transform: translateY(-3px);
}

/* Button press feedback (tactile) */
.btn-primary,
.contact-form-submit {
  transform: translateY(0);
}
.btn-primary:active,
.contact-form-submit:active {
  transform: translateY(1px);
  transition-duration: 0.06s;
}

/* Btn-secondary: underline scale animation */
.btn-secondary {
  position: relative;
  border-bottom: none;
  padding-bottom: 4px;
  display: inline-block;
}
.btn-secondary::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--text);
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.22s ease-out;
}
.btn-secondary:hover::after {
  background: var(--cobalt);
  transform-origin: right;
  animation: scaleX-cycle 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes scaleX-cycle {
  0% { transform: scaleX(1); transform-origin: right; }
  50% { transform: scaleX(0); transform-origin: right; }
  51% { transform: scaleX(0); transform-origin: left; }
  100% { transform: scaleX(1); transform-origin: left; }
}

/* Section-icon: subtle scale on parent hover */
.section-icon {
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pillar:hover .section-icon,
.service:hover .section-icon,
.compare-card:hover .section-icon {
  transform: translateY(-2px) scale(1.06);
}

/* Industry bar: hover highlight */
.industry-row {
  transition: background-color 0.22s ease-out;
  padding-left: 8px;
  padding-right: 8px;
  margin-left: -8px;
  margin-right: -8px;
}
.industry-row:hover {
  background-color: rgba(244, 241, 234, 0.5);
}
.industry-fill {
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Pattern-tag micro hover */
.pattern-card:hover .pattern-tag {
  letter-spacing: 0.24em;
  transition: letter-spacing 0.32s ease-out;
}

/* Compare-card arrow shift */
.compare-card-arrow {
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: inline-block;
}
.compare-card:hover .compare-card-arrow {
  transform: translateX(4px);
}

/* Form fields focus enhancement */
.form-row input[type="text"],
.form-row input[type="email"],
.form-row select,
.form-row textarea {
  transition: border-color 0.22s ease-out, background-color 0.22s ease-out, box-shadow 0.22s ease-out;
}

/* Topbar nav cta hover (already smooth via base; extend) */
.nav-cta {
  transition: background-color 0.22s ease-out, color 0.22s ease-out, transform 0.22s ease-out;
}
.nav-cta:hover {
  transform: translateY(-1px);
}

/* ---------- SCROLL REVEAL (progressive enhancement) ---------- */
/* JS が body に .has-reveal を付けたときのみ有効 */
body.has-reveal .reveal-target {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 0.85s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}
body.has-reveal .reveal-target.is-visible {
  opacity: 1;
  transform: translateY(0);
  will-change: auto;
}

/* ---------- PARALLAX (subtle, decorative) ---------- */
/* JS が data-parallax を読んで scroll position に応じて translateY 設定 */
.hero-card,
.cases::before,
.metrics::before {
  will-change: transform;
}

/* ---------- ACCESSIBILITY: REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  body.has-reveal .reveal-target {
    opacity: 1;
    transform: none;
  }
}
