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

/* Type-level CSS for post type: download（技術ガイド） */

@layer pages {
  /* Archive page - Card grid (3 columns) */
  .post-type-archive-download .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: clamp(20px, 3vw, 32px);
  }

  /* Angular card design */
  .post-type-archive-download .content-card {
    border-radius: 0;
    border: 2px solid #e5e7eb;
    box-shadow: none;
  }

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

  .post-type-archive-download .content-card:hover {
    border-color: #0f172a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }

  /* Archive page - A4 portrait eyecatch (compact) */
  .post-type-archive-download .content-card__media {
    height: auto;
    aspect-ratio: 210 / 297; /* A4 portrait ratio */
    background: #f8fafc;
  }

  .post-type-archive-download .content-card__media::before {
    display: none;
  }

  /* Card body */
  .post-type-archive-download .content-card__content {
    padding: clamp(16px, 2.5vw, 24px);
    gap: 12px;
  }

  .post-type-archive-download .content-card__title {
    font-size: clamp(1rem, 2vw, 1.125rem);
    line-height: 1.4;
  }

  .post-type-archive-download .content-card__text {
    font-size: 0.875rem;
    line-height: 1.5;
    -webkit-line-clamp: 2;
  }

  /* Download button - angular with file size */
  .post-type-archive-download .content-card__download-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.875rem;
    flex-wrap: wrap;
    border-radius: 0;
    background: #0f172a;
  }

  .post-type-archive-download .content-card__download-btn:hover {
    background: #1e293b;
  }

  .post-type-archive-download .content-card__download-label {
    flex-shrink: 0;
  }

  .post-type-archive-download .content-card__file-size {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    margin-left: auto;
  }

  .post-type-archive-download .content-card__download-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }

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

  .post-type-archive-download .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-download .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-download .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-download .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-download .filters__group {
    gap: 0.75rem;
  }

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

  .post-type-archive-download .filters select,
  .post-type-archive-download .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-download .filters select:hover,
  .post-type-archive-download .filters input[type="search"]:hover {
    border-color: #9ca3af;
  }

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

  .post-type-archive-download .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-download .filters .chip:has(input:checked) {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
  }

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

  .post-type-archive-download .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-download .filters__actions .btn--primary {
    background: #0f172a;
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
  }

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

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

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

  /* Card grid */
  .post-type-archive-download .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-download .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-download .card::before {
    display: none;
  }

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

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

  .post-type-archive-download .card__media {
    position: relative;
    width: 100%;
    aspect-ratio: 210 / 297; /* A4 portrait ratio */
    background: #f3f4f6;
    overflow: hidden;
  }

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

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

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

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

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

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

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

  .post-type-archive-download .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-download .card__date {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .post-type-archive-download .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-download .card__excerpt {
    display: none;
  }

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

  /* Pagination */
  .post-type-archive-download .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-download .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-download .page-numbers:hover {
    background: #f9fafb;
    border-color: #9ca3af;
  }

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

  @media (max-width: 900px) {
    .post-type-archive-download .filters {
      margin-left: clamp(24px, 4vw, 32px);
      margin-right: clamp(24px, 4vw, 32px);
    }
  }

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

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

    .post-type-archive-download .filters__actions .btn {
      width: 100%;
    }
  }
}
  /* Single download page - matching case/lp/guide style */
  .single-download h1 { 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-download h1::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-download .term-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: clamp(24px, 3vw, 32px); }
  .single-download .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%); }
  .single-download .entry-content img { 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%); }
  .single-download .section--share { margin: clamp(32px, 4vw, 48px) 0; }
  .single-download .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); }
  .single-download .share-tools__label { font-weight: 700; font-size: 0.875rem; color: #1f2937; }
  .single-download .share-tools__btn { padding: 8px 16px; border-radius: 0; border: 1px solid #d1d5db; background: #ffffff; color: #374151; font-size: 0.875rem; font-weight: 600; }
  .single-download .share-tools__btn:hover { border-color: #0f172a; background: #f9fafb; }
  .single-download .share-tools__btn--x { background: #0f172a; border-color: #0f172a; color: #ffffff; }
  .single-download .section--related { background: #f9fafb; padding: clamp(48px, 6vw, 72px) 0; border-top: 1px solid #e5e7eb; }
  .single-download .section--related .section__title { font-size: clamp(1.5rem, 3vw, 1.875rem); font-weight: 700; color: #0f172a; }
  .single-download .related-group__head { padding-bottom: 12px; border-bottom: 2px solid #0f172a; }
  .single-download .related-group .card-list { display: flex !important; flex-direction: column !important; gap: 8px !important; }
  .single-download .related-group .card-list figure { margin: 0 !important; }
  .single-download .related-group .card-list .card { background: #ffffff; border: 1px solid #d1d5db; display: flex !important; flex-direction: row !important; align-items: center; gap: 16px; padding: 12px; clip-path: none; box-shadow: none; }
  .single-download .related-group .card-list .card:hover { border-color: #0f172a; transform: none; }
  .single-download .related-group .card-list .card__media { width: 80px !important; height: 80px !important; min-width: 80px; margin: 0 !important; }
  .single-download .related-group .card-list .card__media img { display: block; transform: none !important; }
  .single-download .related-group .card-list .card__title { font-size: 0.9375rem; font-weight: 700; color: #0f172a; text-shadow: none; }
  .single-download .related-group .card-list .card__excerpt { display: none !important; }
  @media (max-width: 640px) {
    .single-download .share-tools { flex-direction: column; }
    .single-download .related-group .card-list .card { flex-direction: column !important; }
    .single-download .related-group .card-list .card__media { width: 100% !important; height: 140px !important; }
  }

  /* Download Modal */
  .download-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .download-modal.is-open {
    opacity: 1;
    visibility: visible;
  }

  .download-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    cursor: pointer;
  }

  .download-modal__content {
    position: relative;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    padding: clamp(24px, 4vw, 40px);
    transform: translateY(20px);
    transition: transform 0.3s ease;
  }

  .download-modal.is-open .download-modal__content {
    transform: translateY(0);
  }

  .download-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
  }

  .download-modal__close:hover {
    background: #f9fafb;
    border-color: #0f172a;
    color: #0f172a;
  }

  .download-modal__title {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px;
  }

  .download-modal__desc {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0 16px;
  }

  .download-modal__file-name {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    padding: 12px 16px;
    background: #f8fafc;
    border-left: 4px solid #0f172a;
    margin: 0 0 24px;
  }

  .download-modal__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .download-modal__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .download-modal__label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
  }

  .download-modal__label .required {
    color: #dc2626;
  }

  .download-modal__input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    background: #ffffff;
    color: #0f172a;
    transition: border-color 0.2s ease;
  }

  .download-modal__input:focus {
    outline: none;
    border-color: #0f172a;
  }

  .download-modal__error {
    font-size: 0.875rem;
    color: #dc2626;
    margin: 0;
    min-height: 1.25em;
  }

  .download-modal__submit {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    background: #0f172a;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
  }

  .download-modal__submit:hover {
    background: #1e293b;
  }

  .download-modal__submit:disabled {
    background: #9ca3af;
    cursor: not-allowed;
  }

  @media (max-width: 640px) {
    .download-modal__content {
      width: 95%;
      padding: 20px;
    }
  }
}
