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

/* Type-level CSS for Case Study (課題解決事例) - 2025 Premium Industrial Design */

@layer pages {
  body.single-case_study {
    --case-bg: #fafafa;
    --case-surface: #ffffff;
    --case-text: #0f0f0f;
    --case-text-secondary: #525252;
    --case-text-muted: #a3a3a3;
    --case-accent: #b38f2d;
    --case-accent-hover: #d4a833;
    --case-accent-subtle: rgba(179, 143, 45, 0.08);
    --case-accent-glow: rgba(179, 143, 45, 0.25);
    --case-border: rgba(0, 0, 0, 0.06);
    --case-border-strong: rgba(0, 0, 0, 0.12);
    --case-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --case-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --case-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --case-radius-sm: 8px;
    --case-radius-md: 16px;
    --case-radius-lg: 24px;
    --case-transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --case-transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    background: var(--case-bg);
  }

  .case-entry {
    margin-bottom: clamp(80px, 12vw, 140px);
  }

  /* ─────────────────────────────────────────────
     共通セクション
     ───────────────────────────────────────────── */
  .case-section {
    margin-top: clamp(48px, 8vw, 72px);
  }

  .case-section__title {
    margin: 0 0 clamp(24px, 4vw, 32px);
    font-family: var(--font-serif);
    font-size: clamp(1.3rem, 2.5vw, 1.6rem);
    font-weight: 700;
    line-height: 1.4;
    color: var(--case-text);
    position: relative;
    padding-left: clamp(20px, 3vw, 28px);
  }

  .case-section__title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    bottom: 0.15em;
    width: 4px;
    background: linear-gradient(180deg, var(--case-accent), var(--case-accent-hover));
    border-radius: 2px;
  }

  /* ─────────────────────────────────────────────
     お客様の業種
     ───────────────────────────────────────────── */
  .case-industry {
    background: var(--case-surface);
    border-radius: var(--case-radius-lg);
    border: 1px solid var(--case-border);
    box-shadow: var(--case-shadow-md);
    padding: clamp(24px, 4vw, 40px) 0;
  }

  .case-industry .container {
    padding-left: clamp(24px, 4vw, 40px);
    padding-right: clamp(24px, 4vw, 40px);
  }

  .case-industry__text {
    margin: 0;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    line-height: 1.8;
    color: var(--case-text);
    font-weight: 500;
  }

  /* ─────────────────────────────────────────────
     Before / After
     ───────────────────────────────────────────── */
  .case-before-after__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(20px, 4vw, 32px);
  }

  .case-before-after__item {
    margin: 0;
    background: var(--case-surface);
    border-radius: var(--case-radius-md);
    border: 1px solid var(--case-border);
    overflow: hidden;
    box-shadow: var(--case-shadow-md);
    transition: all var(--case-transition-smooth);
  }

  .case-before-after__item:hover {
    box-shadow: var(--case-shadow-lg);
    transform: translateY(-2px);
  }

  .case-before-after__label {
    display: block;
    padding: clamp(10px, 2vw, 14px) clamp(16px, 2vw, 20px);
    font-family: "DM Sans", var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--case-surface);
    background: var(--case-accent);
  }

  .case-before-after__image {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4/3;
    object-fit: cover;
  }

  /* ─────────────────────────────────────────────
     課題セクション
     ───────────────────────────────────────────── */
  .case-items {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 24px);
  }

  .case-item {
    background: var(--case-surface);
    border-radius: var(--case-radius-md);
    border: 1px solid var(--case-border);
    padding: clamp(20px, 4vw, 32px);
    box-shadow: var(--case-shadow-sm);
    transition: all var(--case-transition-smooth);
  }

  .case-item:hover {
    box-shadow: var(--case-shadow-md);
    border-color: var(--case-accent-subtle);
  }

  .case-item__title {
    margin: 0 0 clamp(8px, 1.5vw, 12px);
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    font-weight: 700;
    color: var(--case-accent);
  }

  .case-item__content {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--case-text-secondary);
  }

  .case-item__content p {
    margin: 0 0 0.75em;
  }

  .case-item__content p:last-child {
    margin-bottom: 0;
  }

  /* ─────────────────────────────────────────────
     解決アプローチ（ステップ形式）
     ───────────────────────────────────────────── */
  .case-steps {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 24px);
  }

  .case-step {
    display: flex;
    gap: clamp(16px, 3vw, 24px);
    background: var(--case-surface);
    border-radius: var(--case-radius-md);
    border: 1px solid var(--case-border);
    padding: clamp(20px, 4vw, 32px);
    box-shadow: var(--case-shadow-sm);
    transition: all var(--case-transition-smooth);
  }

  .case-step:hover {
    box-shadow: var(--case-shadow-md);
  }

  .case-step__number {
    flex-shrink: 0;
    width: clamp(36px, 5vw, 48px);
    height: clamp(36px, 5vw, 48px);
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--case-accent), var(--case-accent-hover));
    color: #fff;
    font-family: "DM Sans", var(--font-sans);
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    font-weight: 700;
    border-radius: 50%;
    box-shadow: 0 4px 12px var(--case-accent-glow);
  }

  .case-step__body {
    flex: 1;
    min-width: 0;
  }

  .case-step__title {
    margin: 0 0 clamp(8px, 1.5vw, 12px);
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    font-weight: 700;
    color: var(--case-text);
  }

  .case-step__content {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--case-text-secondary);
  }

  .case-step__content p {
    margin: 0;
  }

  /* ─────────────────────────────────────────────
     成果セクション
     ───────────────────────────────────────────── */
  .case-results__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2vw, 16px);
  }

  .case-results__item {
    display: flex;
    align-items: baseline;
    gap: clamp(12px, 2vw, 16px);
    padding: clamp(16px, 3vw, 24px);
    background: var(--case-surface);
    border-radius: var(--case-radius-md);
    border: 1px solid var(--case-border);
    box-shadow: var(--case-shadow-sm);
    transition: all var(--case-transition-smooth);
  }

  .case-results__item:hover {
    box-shadow: var(--case-shadow-md);
    background: var(--case-accent-subtle);
  }

  .case-results__item::before {
    content: '✓';
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    background: var(--case-accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
  }

  .case-results__label {
    font-weight: 700;
    color: var(--case-text);
    margin-right: 0.5em;
  }

  .case-results__value {
    color: var(--case-text-secondary);
    font-size: 0.95rem;
  }

  /* ─────────────────────────────────────────────
     技術的なポイント（カード形式）
     ───────────────────────────────────────────── */
  .case-tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: clamp(16px, 3vw, 24px);
  }

  .case-tech-card {
    background: var(--case-surface);
    border-radius: var(--case-radius-md);
    border: 1px solid var(--case-border);
    padding: clamp(20px, 4vw, 32px);
    box-shadow: var(--case-shadow-sm);
    transition: all var(--case-transition-smooth);
    position: relative;
    overflow: hidden;
  }

  .case-tech-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--case-accent), var(--case-accent-hover));
  }

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

  .case-tech-card__title {
    margin: 0 0 clamp(8px, 1.5vw, 12px);
    font-size: clamp(1rem, 1.5vw, 1.1rem);
    font-weight: 700;
    color: var(--case-accent);
  }

  .case-tech-card__desc {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--case-text-secondary);
  }

  /* ─────────────────────────────────────────────
     Facts Section - 加工情報サマリー
     ───────────────────────────────────────────── */
  .case-facts {
    position: relative;
  }

  .case-facts .container {
    position: relative;
    background: var(--case-surface);
    padding: clamp(32px, 5vw, 48px);
    border-radius: var(--case-radius-lg);
    border: 1px solid var(--case-border);
    box-shadow: var(--case-shadow-md);
    overflow: hidden;
    transition: all var(--case-transition-smooth);
  }

  .case-facts .container:hover {
    box-shadow: var(--case-shadow-lg);
  }

  /* Animated top accent bar */
  .case-facts .container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--case-accent), var(--case-accent-hover), var(--case-accent));
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
  }

  @keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }

  /* Facts Table */
  .case-facts__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 2px;
    font-size: 0.9rem;
    color: var(--case-text);
  }

  .case-facts__table tr {
    background: var(--case-bg);
    transition: all var(--case-transition-fast);
  }

  .case-facts__table tr:hover {
    background: var(--case-accent-subtle);
  }

  .case-facts__table tr:first-child td:first-child,
  .case-facts__table tr:first-child th:first-child {
    border-top-left-radius: var(--case-radius-sm);
  }

  .case-facts__table tr:first-child td:last-child,
  .case-facts__table tr:first-child th:last-child {
    border-top-right-radius: var(--case-radius-sm);
  }

  .case-facts__table tr:last-child td:first-child,
  .case-facts__table tr:last-child th:first-child {
    border-bottom-left-radius: var(--case-radius-sm);
  }

  .case-facts__table tr:last-child td:last-child,
  .case-facts__table tr:last-child th:last-child {
    border-bottom-right-radius: var(--case-radius-sm);
  }

  .case-facts__table th,
  .case-facts__table td {
    padding: clamp(14px, 2.5vw, 20px) clamp(16px, 2.5vw, 24px);
    vertical-align: top;
    text-align: left;
  }

  .case-facts__table th {
    width: clamp(100px, 22vw, 160px);
    font-family: "DM Sans", var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--case-text-secondary);
    border-right: 2px solid var(--case-accent);
    text-align: left;
    white-space: nowrap;
  }

  .case-facts__table td {
    color: var(--case-text);
    font-weight: 500;
    line-height: 1.7;
  }

  .case-facts__table td p {
    margin: 0 0 8px;
  }

  .case-facts__table td p:last-child {
    margin-bottom: 0;
  }

  /* ─────────────────────────────────────────────
     Case Body - Content Area (エディタコンテンツ)
     ───────────────────────────────────────────── */
  .case-body .entry-content {
    background: var(--case-surface);
    padding: clamp(32px, 6vw, 56px);
    border-radius: var(--case-radius-lg);
    border: 1px solid var(--case-border);
    box-shadow: var(--case-shadow-md);
    position: relative;
    overflow: hidden;
    transition: all var(--case-transition-smooth);
  }

  .case-body .entry-content:hover {
    box-shadow: var(--case-shadow-lg);
  }

  .case-body .entry-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--case-accent), var(--case-accent-hover), var(--case-accent));
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
  }

  .case-body .entry-content > *:first-child {
    margin-top: 0;
  }

  .case-body .entry-content p {
    font-size: 1rem;
    line-height: 2;
    color: var(--case-text);
    margin-bottom: 1.5em;
  }

  .case-body .entry-content h2 {
    margin-top: clamp(48px, 7vw, 64px);
    margin-bottom: clamp(16px, 3vw, 24px);
    font-family: var(--font-serif);
    font-size: clamp(1.3rem, 2.5vw, 1.6rem);
    font-weight: 700;
    line-height: 1.4;
    color: var(--case-text);
    position: relative;
    padding-left: clamp(20px, 3vw, 28px);
  }

  .case-body .entry-content h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    bottom: 0.15em;
    width: 4px;
    background: linear-gradient(180deg, var(--case-accent), var(--case-accent-hover));
    border-radius: 2px;
  }

  .case-body .entry-content h3 {
    margin-top: clamp(36px, 5vw, 48px);
    margin-bottom: clamp(12px, 2vw, 18px);
    font-family: var(--font-serif);
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    font-weight: 600;
    line-height: 1.45;
    color: var(--case-text);
  }

  .case-body .entry-content figure {
    margin: clamp(32px, 5vw, 48px) 0;
  }

  .case-body .entry-content figure img {
    border-radius: var(--case-radius-md);
    box-shadow: var(--case-shadow-md);
    transition: all var(--case-transition-smooth);
  }

  .case-body .entry-content figure:hover img {
    box-shadow: var(--case-shadow-lg);
    transform: translateY(-2px);
  }

  .case-body .entry-content figcaption {
    margin-top: clamp(12px, 2vw, 16px);
    font-size: 0.85rem;
    color: var(--case-text-muted);
    text-align: center;
    font-weight: 400;
  }

  .case-body .wp-block-gallery {
    margin: clamp(32px, 5vw, 48px) 0;
    gap: clamp(16px, 3vw, 24px);
  }

  .case-body .wp-block-gallery .wp-block-image {
    border-radius: var(--case-radius-md);
    box-shadow: var(--case-shadow-md);
    overflow: hidden;
    transition: all var(--case-transition-smooth);
  }

  .case-body .wp-block-gallery .wp-block-image:hover {
    box-shadow: var(--case-shadow-lg);
    transform: translateY(-2px);
  }

  .case-body .entry-content ul,
  .case-body .entry-content ol {
    margin: clamp(20px, 3vw, 28px) 0;
    padding-left: 0;
    list-style: none;
  }

  .case-body .entry-content ul li,
  .case-body .entry-content ol li {
    position: relative;
    padding-left: clamp(28px, 4vw, 36px);
    margin-bottom: 0.75em;
    line-height: 1.85;
  }

  .case-body .entry-content ul li::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0.65em;
    width: 8px;
    height: 8px;
    background: var(--case-accent);
    border-radius: 50%;
    opacity: 0.7;
  }

  .case-body .entry-content ol {
    counter-reset: case-counter;
  }

  .case-body .entry-content ol li {
    counter-increment: case-counter;
  }

  .case-body .entry-content ol li::before {
    content: counter(case-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 24px;
    height: 24px;
    background: var(--case-accent-subtle);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: "DM Sans", var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--case-accent);
  }

  .case-body .entry-content blockquote {
    margin: clamp(32px, 5vw, 48px) 0;
    padding: clamp(24px, 4vw, 36px);
    background: linear-gradient(135deg, var(--case-accent-subtle), transparent);
    border-left: 4px solid var(--case-accent);
    border-radius: 0 var(--case-radius-md) var(--case-radius-md) 0;
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--case-text);
    font-style: italic;
  }

  .case-body .entry-content blockquote p {
    margin-bottom: 0;
    color: inherit;
  }

  .case-body .entry-content table {
    width: 100%;
    margin: clamp(28px, 4vw, 40px) 0;
    border-collapse: separate;
    border-spacing: 0 2px;
    font-size: 0.92rem;
  }

  .case-body .entry-content th,
  .case-body .entry-content td {
    padding: clamp(14px, 2vw, 18px);
    text-align: left;
  }

  .case-body .entry-content th {
    background: var(--case-bg);
    font-family: "DM Sans", var(--font-sans);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--case-text);
    border-radius: var(--case-radius-sm) var(--case-radius-sm) 0 0;
  }

  .case-body .entry-content td {
    background: var(--case-surface);
    color: var(--case-text-secondary);
    border-bottom: 1px solid var(--case-border);
  }

  .case-body .entry-content tr:hover td {
    background: var(--case-accent-subtle);
  }

  .case-body .entry-content strong {
    color: var(--case-text);
    font-weight: 600;
  }

  .case-body .entry-content a {
    color: var(--case-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: all var(--case-transition-fast);
  }

  .case-body .entry-content a:hover {
    color: var(--case-accent-hover);
    text-underline-offset: 5px;
  }

  /* ─────────────────────────────────────────────
     Responsive
     ───────────────────────────────────────────── */
  @media (max-width: 880px) {
    .case-facts .container {
      padding: clamp(24px, 6vw, 40px);
      border-radius: var(--case-radius-md);
    }

    .case-facts__table th,
    .case-facts__table td {
      display: block;
      width: 100%;
      padding: clamp(10px, 2.5vw, 14px) 0;
    }

    .case-facts__table th {
      padding-bottom: 8px;
      border-right: none;
      border-bottom: 2px solid var(--case-accent);
    }

    .case-facts__table tr {
      padding: clamp(12px, 3vw, 16px);
      border-radius: var(--case-radius-sm);
    }

    .case-step {
      flex-direction: column;
      gap: clamp(12px, 2vw, 16px);
    }

    .case-step__number {
      width: 36px;
      height: 36px;
    }

    .case-results__item {
      flex-wrap: wrap;
    }
  }

  @media (max-width: 680px) {
    .case-section {
      margin-top: clamp(36px, 7vw, 56px);
    }

    .case-section__title {
      padding-left: 16px;
    }

    .case-section__title::before {
      width: 3px;
    }

    .case-body .entry-content {
      padding: clamp(24px, 6vw, 40px);
      border-radius: var(--case-radius-md);
    }

    .case-body .entry-content h2 {
      padding-left: 16px;
    }

    .case-body .entry-content h2::before {
      width: 3px;
    }

    .case-before-after__grid {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 480px) {
    .case-facts .container {
      padding: 20px;
      border-radius: var(--case-radius-sm);
    }

    .case-item,
    .case-step,
    .case-tech-card {
      padding: 16px;
    }

    .case-results__item {
      padding: 12px 16px;
    }

    .case-body .entry-content {
      padding: 20px;
      border-radius: var(--case-radius-sm);
    }

    .case-body .entry-content blockquote {
      padding: 16px;
      padding-left: 20px;
    }
  }

  /* Reduced motion */
  @media (prefers-reduced-motion: reduce) {
    .case-facts .container::before,
    .case-body .entry-content::before {
      animation: none;
    }

    *,
    *::before,
    *::after {
      transition-duration: 0.01ms !important;
    }
  }

  /* Focus states */
  body.single-case_study :focus-visible {
    outline: 2px solid var(--case-accent);
    outline-offset: 2px;
  }
}
