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

@layer pages {
  /* Type-level CSS for post type: case（加工事例） */

  /* Archive page - Angular rich design with light background */
  .post-type-archive-case .section {
    position: relative;
    background: #ffffff;
    padding: clamp(60px, 8vw, 100px) 0 clamp(80px, 10vw, 120px);
  }

  .post-type-archive-case .section__head {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto clamp(48px, 6vw, 72px);
    padding: 0 clamp(32px, 5vw, 80px);
  }

  .post-type-archive-case .section__title {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    color: #0f172a;
    margin: 0;
    position: relative;
    display: inline-block;
  }

  .post-type-archive-case .section__title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100px;
    height: 4px;
    background: #0f172a;
    clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
  }

  /* Filters - Angular design */
  .post-type-archive-case .filters {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto clamp(40px, 5vw, 60px);
    padding: clamp(28px, 4vw, 40px);
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  }

  .post-type-archive-case .filters__group {
    gap: 0.75rem;
  }

  .post-type-archive-case .filters__label {
    color: #374151;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
  }

  .post-type-archive-case .filters select,
  .post-type-archive-case .filters input[type="search"] {
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #1f2937;
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
  }

  .post-type-archive-case .filters select:hover,
  .post-type-archive-case .filters input[type="search"]:hover {
    border-color: #9ca3af;
  }

  .post-type-archive-case .filters select:focus-visible,
  .post-type-archive-case .filters input[type="search"]:focus-visible {
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
  }

  .post-type-archive-case .filters .chip {
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #374151;
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
  }

  .post-type-archive-case .filters .chip:has(input:checked) {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
  }

  .post-type-archive-case .filters__actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
  }

  .post-type-archive-case .filters__actions .btn {
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
    font-weight: 700;
    padding: 14px 32px;
    font-size: 0.875rem;
  }

  .post-type-archive-case .filters__actions .btn--primary {
    background: #0f172a;
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
  }

  .post-type-archive-case .filters__actions .btn--primary:hover {
    background: #1e293b;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.4);
  }

  .post-type-archive-case .filters__actions .btn:not(.btn--primary) {
    background: #ffffff;
    border: 2px solid #d1d5db;
    color: #374151;
  }

  .post-type-archive-case .filters__actions .btn:not(.btn--primary):hover {
    border-color: #9ca3af;
    background: #f9fafb;
  }

  /* Card grid */
  .post-type-archive-case .card-list {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(32px, 5vw, 80px);
  }

  /* Cards - Simple angular design */
  .post-type-archive-case .card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
    min-height: auto;
    align-items: stretch;
  }

  .post-type-archive-case .card::before {
    display: none;
  }

  .post-type-archive-case .card::after {
    display: none;
  }

  .post-type-archive-case .card:hover {
    border-color: #0f172a;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
  }

  .post-type-archive-case .card__media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #f3f4f6;
    overflow: hidden;
  }

  .post-type-archive-case .card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: none;
  }

  .post-type-archive-case .card__media.is-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
  }

  .post-type-archive-case .card__media.is-logo img {
    width: 70%;
    height: auto;
    object-fit: contain;
    max-height: 70%;
  }

  .post-type-archive-case .card:hover .card__media img {
    transform: scale(1.05);
  }

  .post-type-archive-case .card:hover .card__media.is-logo img {
    transform: scale(1.02);
  }

  .post-type-archive-case .card__body {
    position: static;
    padding: clamp(20px, 3vw, 28px);
    gap: 10px;
    display: flex;
    flex-direction: column;
    color: inherit;
  }

  .post-type-archive-case .card__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
  }

  .post-type-archive-case .card__category {
    display: inline-block;
    padding: 4px 12px;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 0 100%);
  }

  .post-type-archive-case .card__date {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .post-type-archive-case .card__title {
    color: #0f172a;
    font-size: clamp(1.1rem, 2vw, 1.25rem);
    font-weight: 700;
    line-height: 1.5;
    text-shadow: none;
  }

  .post-type-archive-case .card__excerpt {
    display: none;
  }

  .post-type-archive-case .card__meta {
    display: none;
  }

  /* Pagination */
  .post-type-archive-case .pagination {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: clamp(48px, 6vw, 72px) auto 0;
    padding: 0 clamp(32px, 5vw, 80px);
  }

  .post-type-archive-case .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 16px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    color: #374151;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
  }

  .post-type-archive-case .page-numbers:hover {
    background: #f9fafb;
    border-color: #9ca3af;
  }

  .post-type-archive-case .page-numbers.current {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
  }

  /* Single page styles - Angular rich design */
  .single-case .section {
    background: #ffffff;
    padding: clamp(60px, 8vw, 100px) 0;
  }

  .single-case .section__head {
    max-width: 1400px;
    margin: 0 auto clamp(32px, 4vw, 48px);
    padding: 0 clamp(32px, 5vw, 80px);
  }

  .single-case .section__title {
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #0f172a;
    line-height: 1.3;
    margin: 0 0 clamp(16px, 2vw, 24px);
    position: relative;
    display: inline-block;
  }

  .single-case .section__title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 80px;
    height: 4px;
    background: #0f172a;
    clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
  }

  .single-case .term-badges {
    max-width: 1400px;
    margin: 0 auto clamp(16px, 2vw, 24px);
    padding: 0 clamp(32px, 5vw, 80px);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .single-case .term-badge {
    display: inline-block;
    padding: 6px 16px;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
    transition: all 0.3s ease;
  }

  .single-case .term-badge:hover {
    background: #1e293b;
    transform: translateY(-2px);
  }

  .single-case .case-header {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
    gap: clamp(32px, 5vw, 56px);
    align-items: start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(32px, 5vw, 80px);
  }

  .single-case .case-header__media {
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 24px), calc(100% - 24px) 100%, 0 100%);
    border: 3px solid #0f172a;
    display: block;
    aspect-ratio: 4 / 3;
  }

  .single-case .case-header__media::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
  }

  .single-case .case-header__media img {
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
    object-position: center;
  }

  .single-case .case-header__media--wide {
    display: block;
    padding: 0;
    background: #ffffff;
  }

  .single-case .case-header__media--wide img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: auto;
    object-fit: contain;
    object-position: center;
    transform: none;
  }

  .single-case .case-header__media--wide:hover img {
    transform: none;
  }

  .single-case .case-header__media:not(.case-header__media--wide):hover img {
    transform: scale(1.05);
  }

  .single-case .case-header__meta {
    position: relative;
  }

  .table--case {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%);
  }

  .table--case th,
  .table--case td {
    border-bottom: 1px solid #e5e7eb;
    padding: 16px 20px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
  }

  .table--case tr:last-child th,
  .table--case tr:last-child td {
    border-bottom: none;
  }

  .table--case th {
    width: 38%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.03em;
    position: relative;
  }

  .table--case th::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: rgba(255, 255, 255, 0.2);
  }

  .table--case td {
    background: #ffffff;
    font-size: 0.9375rem;
    color: #1f2937;
    font-weight: 500;
  }

  .single-case .entry-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(32px, 5vw, 80px);
    font-size: 1rem;
    line-height: 1.8;
    color: #374151;
  }

  .single-case .entry-content h2 {
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    font-weight: 800;
    color: #0f172a;
    margin: clamp(48px, 6vw, 72px) 0 clamp(24px, 3vw, 32px);
    position: relative;
    padding-left: 20px;
  }

  .single-case .entry-content h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: #0f172a;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
  }

  .single-case .entry-content h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    font-weight: 700;
    color: #1f2937;
    margin: clamp(32px, 4vw, 48px) 0 clamp(16px, 2vw, 24px);
    padding-left: 16px;
    border-left: 4px solid #0f172a;
  }

  .single-case .entry-content p {
    margin: 0 0 1.5em;
  }

  .single-case .entry-content ul,
  .single-case .entry-content ol {
    margin: 1.5em 0;
    padding-left: 2em;
  }

  .single-case .entry-content li {
    margin-bottom: 0.75em;
  }

  .single-case .entry-content img {
    max-width: 100%;
    height: auto;
    border: 2px solid #e5e7eb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  }

  /* Share tools - Compact angular design */
  .single-case .section--share {
    margin: clamp(32px, 4vw, 48px) 0;
    background: transparent;
    padding: 0;
  }

  .single-case .share-tools {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(16px, 2vw, 20px) clamp(32px, 5vw, 80px);
    border: 1px solid #d1d5db;
    border-radius: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: clamp(16px, 2vw, 24px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }

  .single-case .share-tools__label {
    margin: 0;
    font-weight: 700;
    font-size: 0.875rem;
    color: #1f2937;
    flex-shrink: 0;
  }

  .single-case .share-tools__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
  }

  .single-case .share-tools__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 0;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
  }

  .single-case .share-tools__btn:hover {
    border-color: #0f172a;
    background: #f9fafb;
    color: #0f172a;
  }

  .single-case .share-tools__btn:focus-visible {
    outline: 2px solid #0f172a;
    outline-offset: 2px;
  }

  .single-case .share-tools__btn--x {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
  }

  .single-case .share-tools__btn--x:hover {
    background: #1e293b;
    border-color: #1e293b;
    color: #ffffff;
  }

  .single-case .share-tools__feedback {
    min-height: 0;
    margin: 0;
    font-size: 0.8125rem;
    color: #0f172a;
    font-weight: 500;
  }

  .single-case .share-tools__feedback.is-error {
    color: #dc2626;
  }

  /* Related content section - User-friendly compact design */
  .single-case .section--related {
    background: #f9fafb;
    padding: clamp(48px, 6vw, 72px) 0;
    border-top: 1px solid #e5e7eb;
  }

  .single-case .section--related .section__head {
    max-width: 1200px;
    margin: 0 auto clamp(24px, 3vw, 36px);
    padding: 0 clamp(20px, 4vw, 40px);
  }

  .single-case .section--related .section__title {
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    font-weight: 700;
    color: #0f172a;
    margin: 0;
  }

  .single-case .related-group {
    max-width: 1200px;
    margin: 0 auto clamp(32px, 4vw, 48px);
    padding: 0 clamp(20px, 4vw, 40px);
  }

  .single-case .related-group:last-of-type {
    margin-bottom: 0;
  }

  .single-case .related-group__head {
    margin-bottom: clamp(16px, 2vw, 20px);
    padding-bottom: 12px;
    border-bottom: 2px solid #0f172a;
  }

  .single-case .related-group__title {
    font-size: clamp(1.125rem, 2vw, 1.25rem);
    font-weight: 700;
    color: #0f172a;
    margin: 0;
  }

  /* Q&A list - Compact list style */
  .single-case .qa-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .single-case .qa-accordion {
    background: #ffffff;
    border: 1px solid #d1d5db;
    transition: border-color 0.2s ease;
  }

  .single-case .qa-accordion:hover {
    border-color: #0f172a;
  }

  .single-case .qa-q {
    padding: 12px 40px 12px 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.5;
  }

  .single-case .qa-q__label {
    font-weight: 900;
    font-size: 0.875rem;
    color: #0f172a;
    flex-shrink: 0;
  }

  .single-case .qa-q__text {
    line-height: 1.5;
  }

  .single-case .qa-accordion > .qa-q::after {
    font-size: 1.125rem;
    color: #0f172a;
    right: 12px;
  }

  .single-case .qa-a {
    padding: 12px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
  }

  .single-case .qa-a__label {
    font-weight: 900;
    font-size: 0.875rem;
    color: #0f172a;
  }

  .single-case .qa-a__body {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #374151;
  }

  .single-case .qa-a__body p {
    margin: 0;
  }

  /* Card list - Compact vertical list style */
  .single-case .related-group .card-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    grid-template-columns: none !important;
  }

  .single-case .related-group .card-list__item {
    list-style: none;
    width: 100%;
  }

  .single-case .related-group .card-list .card {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0;
    transition: all 0.2s ease;
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 16px;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    width: 100%;
    min-height: auto;
    box-shadow: none;
    clip-path: none;
  }

  .single-case .related-group .card-list .card::before,
  .single-case .related-group .card-list .card::after {
    display: none;
  }

  .single-case .related-group .card-list .card:hover {
    border-color: #0f172a;
    background: #fafbfc;
    transform: none;
  }

  .single-case .related-group .card-list .card__media {
    width: 80px !important;
    height: 80px !important;
    min-width: 80px;
    flex-shrink: 0;
    background: #f3f4f6;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    position: static;
    margin: 0 !important;
  }

  .single-case .related-group .card-list figure,
  .single-case .related-group .card-list figure.card__media {
    margin: 0 !important;
  }

  .single-case .related-group .card-list .card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: none;
    transform: none !important;
    display: block;
    vertical-align: top;
  }

  .single-case .related-group .card-list .card__media.is-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
  }

  .single-case .related-group .card-list .card__media.is-logo img {
    width: 70%;
    height: auto;
    max-height: 70%;
    object-fit: contain;
    display: block;
  }

  .single-case .related-group .card-list .card:hover .card__media img {
    transform: none !important;
  }

  .single-case .related-group .card-list .card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    position: static;
    color: inherit;
  }

  .single-case .related-group .card-list .card__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 2px;
  }

  .single-case .related-group .card-list .card__category {
    padding: 2px 8px;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.4;
  }

  .single-case .related-group .card-list .card__date {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 500;
  }

  .single-case .related-group .card-list .card__title {
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.4;
    color: #0f172a;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-shadow: none;
  }

  .single-case .related-group .card-list .card__excerpt {
    display: none !important;
  }

  .single-case .related-group .card-list .card__meta {
    display: none !important;
  }

  /* More link - Simple text link */
  .single-case .related-group__more {
    margin-top: 16px;
    text-align: right;
  }

  .single-case .section__more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #0f172a;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.2s ease;
  }

  .single-case .section__more:hover {
    color: #1e293b;
    text-decoration: underline;
  }

  .single-case .section__more::after {
    content: '→';
    font-size: 1em;
    transition: transform 0.2s ease;
  }

  .single-case .section__more:hover::after {
    transform: translateX(4px);
  }

  @media (max-width: 900px) {
    .single-case .case-header {
      grid-template-columns: 1fr;
    }

    .single-case .case-header__media {
      max-width: 720px;
    }

    .single-case .case-header__media img {
      aspect-ratio: auto;
    }

    .post-type-archive-case .filters {
      margin-left: clamp(24px, 4vw, 32px);
      margin-right: clamp(24px, 4vw, 32px);
    }
  }

  @media (max-width: 640px) {
    .post-type-archive-case .section__title {
      font-size: clamp(2.5rem, 8vw, 3rem);
    }

    .post-type-archive-case .filters__actions {
      flex-direction: column;
    }

    .post-type-archive-case .filters__actions .btn {
      width: 100%;
    }

    .post-type-archive-case .card {
      min-height: 400px;
    }

    /* Mobile: Share tools stack */
    .single-case .share-tools {
      flex-direction: column;
      align-items: stretch;
      gap: 12px;
      padding: 16px clamp(20px, 4vw, 32px);
    }

    .single-case .share-tools__label {
      text-align: center;
    }

    .single-case .share-tools__actions {
      flex-direction: column;
      gap: 8px;
    }

    .single-case .share-tools__btn {
      width: 100%;
    }

    /* Mobile: Stack card vertically */
    .single-case .related-group .card-list .card {
      flex-direction: column !important;
      align-items: stretch;
    }

    .single-case .related-group .card-list .card__media {
      width: 100% !important;
      height: 140px !important;
      min-width: 100%;
    }

    .single-case .related-group__more {
      text-align: center;
    }
  }
}
