@layer base, layout, components, utilities, pages;

@layer pages {

  /* ========================================
     Molding Child Pages
     親ページとは異なるシンプルで読みやすいデザイン
     ======================================== */

  .molding--child {
    --mc-primary: #1a365d;
    --mc-accent: #2b6cb0;
    --mc-accent-light: #4299e1;
    --mc-bg: #ffffff;
    --mc-bg-alt: #f8fafc;
    --mc-bg-hero: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    --mc-text: #334155;
    --mc-muted: #64748b;
    --mc-border: #e2e8f0;
    --mc-max: 1200px;
    background: var(--mc-bg);
  }

  /* ========================================
     Hero - 画像背景 + テキストオーバーレイ
     ======================================== */
  .molding--child .molding-hero {
    all: unset;
    display: block;
    position: relative;
    min-height: 400px;
    overflow: hidden;
  }
  .molding--child .molding-hero__inner {
    all: unset;
    display: block;
    position: relative;
    min-height: 400px;
  }
  /* 画像を背景として配置 (z-index: 1) */
  .molding--child .molding-hero__visual {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
  }
  .molding--child .molding-hero__visual::before,
  .molding--child .molding-hero__visual::after { display: none; }
  .molding--child .molding-hero__visual img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  /* グラデーションオーバーレイ (z-index: 2) */
  .molding--child .molding-hero__inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
      to right,
      rgba(248, 250, 252, 0.97) 0%,
      rgba(248, 250, 252, 0.92) 35%,
      rgba(248, 250, 252, 0.6) 60%,
      transparent 100%
    );
    z-index: 2;
  }
  /* テキストを前面に配置 (z-index: 3) */
  .molding--child .molding-hero__body {
    all: unset;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    position: relative;
    z-index: 3;
    max-width: 560px;
    min-height: 400px;
    padding: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 4vw, 3rem);
    box-sizing: border-box;
  }
  .molding--child .molding-hero__body::before,
  .molding--child .molding-hero__body::after { display: none; }
  .molding--child .molding-hero__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--mc-accent);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
  }
  .molding--child .molding-hero__eyebrow::before {
    content: '';
    width: 1.5rem;
    height: 2px;
    background: var(--mc-accent);
  }
  .molding--child .molding-hero__title {
    margin: 0;
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    font-weight: 700;
    line-height: 1.4;
    color: var(--mc-primary);
  }
  .molding--child .molding-hero__lead {
    margin: 0;
    font-size: .9375rem;
    line-height: 1.8;
    color: var(--mc-text);
  }
  .molding--child .molding-hero__meta {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .75rem;
    color: var(--mc-muted);
  }
  .molding--child .molding-hero__meta dt { font-weight: 500; }
  .molding--child .molding-hero__meta dd { margin: 0; }
  .molding--child .molding-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .625rem;
    margin-top: .5rem;
  }
  .molding--child .molding-hero__cta,
  .molding--child .molding-hero__actions .btn {
    padding: .75rem 2rem;
    font-size: .875rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: all .2s;
  }
  .molding--child .molding-hero__actions .btn--primary {
    background: var(--mc-primary);
    color: #fff;
    border: none;
  }
  .molding--child .molding-hero__actions .btn--primary:hover {
    background: var(--mc-accent);
  }
  .molding--child .molding-hero__visual--logo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mc-bg-alt);
  }
  .molding--child .molding-hero__visual--logo img {
    position: static;
    width: auto;
    height: auto;
    max-width: 40%;
    max-height: 60%;
    object-fit: contain;
  }
  @media (max-width: 768px) {
    .molding--child .molding-hero,
    .molding--child .molding-hero__inner,
    .molding--child .molding-hero__body {
      min-height: 320px;
    }
    .molding--child .molding-hero__inner::before {
      background: linear-gradient(
        to bottom,
        rgba(248, 250, 252, 0.95) 0%,
        rgba(248, 250, 252, 0.85) 50%,
        rgba(248, 250, 252, 0.5) 100%
      );
    }
    .molding--child .molding-hero__body {
      max-width: 100%;
      padding: 2rem clamp(1rem, 4vw, 1.5rem);
    }
  }

  /* ========================================
     Content - 横幅1200px、モダンなレイアウト
     ======================================== */
  .molding--child .molding-content {
    all: unset;
    display: block;
    padding: clamp(3rem, 8vw, 5rem) clamp(1rem, 4vw, 2rem);
    background: var(--mc-bg);
    margin-top: 0;
    border-top: none;
  }
  .molding--child .molding-content > .container {
    max-width: var(--mc-max);
    margin: 0 auto;
  }
  .molding--child .molding-content__inner {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: clamp(2rem, 5vw, 4rem);
    align-items: start;
  }

  /* TOC - サイドバー */
  .molding--child .molding-content__toc {
    position: sticky;
    top: 2rem;
    padding: 1.5rem;
    background: var(--mc-bg-alt);
    border-radius: 12px;
    border: 1px solid var(--mc-border);
  }
  .molding--child .molding-content__toc-title {
    display: block;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--mc-muted);
    border-bottom: 1px solid var(--mc-border);
  }
  .molding--child .molding-content__toc .toc,
  .molding--child .molding-content__toc .toc__list {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .molding--child .molding-content__toc .toc__list {
    display: flex;
    flex-direction: column;
    gap: .25rem;
  }
  .molding--child .molding-content__toc .toc__item a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    font-size: .8125rem;
    line-height: 1.4;
    color: var(--mc-text);
    text-decoration: none;
    border-radius: 6px;
    transition: all .2s;
  }
  .molding--child .molding-content__toc .toc__item a:hover {
    background: rgba(43, 108, 176, .08);
    color: var(--mc-accent);
  }
  .molding--child .molding-content__toc .toc__index {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--mc-accent);
    color: #fff;
    font-size: .6875rem;
    font-weight: 700;
    border-radius: 4px;
    flex-shrink: 0;
  }
  .molding--child .molding-content__toc .toc__text {
    flex: 1;
    min-width: 0;
  }
  .molding--child .molding-content__toc .toc__item--child a {
    padding-left: 2.5rem;
    font-size: .75rem;
    color: var(--mc-muted);
  }
  .molding--child .molding-content__toc .toc__item--child .toc__index {
    width: 1.25rem;
    height: 1.25rem;
    background: var(--mc-border);
    color: var(--mc-muted);
    font-size: .625rem;
  }

  /* Body - 本文エリア */
  .molding--child .molding-content__body {
    min-width: 0;
  }
  .molding--child .molding-content__body.entry-content {
    font-size: 1rem;
    line-height: 1.9;
    color: var(--mc-text);
  }
  .molding--child .molding-content__body h2 {
    margin: 3rem 0 1.5rem;
    padding: 1rem 1.5rem;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--mc-primary);
    background: var(--mc-bg-alt);
    border-left: 4px solid var(--mc-accent);
    border-radius: 0 8px 8px 0;
  }
  .molding--child .molding-content__body h2:first-child { margin-top: 0; }
  .molding--child .molding-content__body h3 {
    margin: 2.5rem 0 1rem;
    padding-bottom: .5rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--mc-primary);
    border-bottom: 2px solid var(--mc-border);
  }
  .molding--child .molding-content__body h4 {
    margin: 2rem 0 .75rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--mc-primary);
  }
  .molding--child .molding-content__body p {
    margin: 0 0 1.5rem;
  }
  .molding--child .molding-content__body ul,
  .molding--child .molding-content__body ol {
    margin: 0 0 1.5rem;
    padding-left: 1.5rem;
  }
  .molding--child .molding-content__body li {
    margin-bottom: .625rem;
  }
  .molding--child .molding-content__body li::marker {
    color: var(--mc-accent);
  }
  .molding--child .molding-content__body table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
    font-size: .9375rem;
    border: 1px solid var(--mc-border);
    border-radius: 8px;
    overflow: hidden;
  }
  .molding--child .molding-content__body th,
  .molding--child .molding-content__body td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--mc-border);
    text-align: left;
  }
  .molding--child .molding-content__body th {
    background: var(--mc-primary);
    color: #fff;
    font-weight: 600;
  }
  .molding--child .molding-content__body tbody th {
    background: var(--mc-bg-alt);
    color: var(--mc-primary);
  }
  .molding--child .molding-content__body tr:last-child td,
  .molding--child .molding-content__body tr:last-child th {
    border-bottom: none;
  }
  .molding--child .molding-content__body blockquote {
    margin: 2rem 0;
    padding: 1.5rem 2rem;
    background: var(--mc-bg-alt);
    border-left: 4px solid var(--mc-accent);
    border-radius: 0 12px 12px 0;
    font-style: normal;
  }
  .molding--child .molding-content__body blockquote p:last-child { margin-bottom: 0; }
  .molding--child .molding-content__body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
  }
  .molding--child .molding-content__body a {
    color: var(--mc-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .molding--child .molding-content__body a:hover {
    color: var(--mc-primary);
  }

  /* CTA at bottom */
  .molding--child .molding-content__body::after {
    content: none;
  }

  @media (max-width: 900px) {
    .molding--child .molding-content__inner {
      grid-template-columns: 1fr;
      gap: 2rem;
    }
    .molding--child .molding-content__toc {
      position: static;
      order: -1;
    }
    .molding--child .molding-content__toc .toc__list {
      flex-direction: row;
      flex-wrap: wrap;
      gap: .5rem;
    }
    .molding--child .molding-content__toc .toc__item a {
      padding: .5rem .75rem;
      background: #fff;
      border: 1px solid var(--mc-border);
    }
    .molding--child .molding-content__toc .toc__item--child { display: none; }
  }

  @media (max-width: 600px) {
    .molding--child .molding-content {
      padding: 2rem 1rem 3rem;
    }
    .molding--child .molding-content__body h2 {
      font-size: 1.25rem;
      margin: 2.5rem 0 1rem;
      padding: .875rem 1.25rem;
    }
    .molding--child .molding-content__body h3 { font-size: 1rem; }
  }

}
