/* 本・読書フリー素材サイト - from-books.jp */
:root {
  --color-bg: #faf8f5;
  --color-surface: #fff;
  --color-text: #2c2c2c;
  --color-text-muted: #666;
  --color-accent: #8b6914;
  --color-accent-hover: #6b5010;
  --color-border: #e5e0d8;
  --color-badge: #2d8a3e;
  --font-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* アクセシビリティ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ヘッダー */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 700;
  color: var(--color-accent);
  text-decoration: none;
  font-size: 1.1rem;
}

.logo:hover {
  color: var(--color-accent-hover);
}

.nav a {
  margin-left: 1.5rem;
  color: var(--color-text);
  text-decoration: none;
}

.nav a:hover {
  color: var(--color-accent);
}

/* メイン */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* ヒーロー */
.hero {
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--color-text);
}

.hero-desc {
  color: var(--color-text-muted);
  margin: 0;
  font-size: 0.95rem;
}

.hero-features {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--color-accent);
  font-weight: 500;
}

/* 検索 */
.search-section {
  margin-bottom: 2rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  max-width: 500px;
  margin: 0 auto 0.5rem;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.search-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-color: transparent;
}

.search-btn {
  padding: 0.75rem 1.25rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
}

.search-btn:hover {
  background: var(--color-accent-hover);
}

.search-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0;
  text-align: center;
}

/* フィルター・ソート */
.filter-section {
  margin-bottom: 1.5rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}

.filter-label {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.filter-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--color-surface);
}

.filter-select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* 検索0件 */
.search-zero {
  text-align: center;
  padding: 3rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-zero.hidden {
  display: none;
}

.search-suggestion {
  margin-top: 1rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ページネーション */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 1rem 0;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  min-width: 2.5rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

.pagination-pages {
  display: flex;
  gap: 0.25rem;
}

.pagination-pages .pagination-btn {
  padding: 0.5rem 0.75rem;
}

/* 素材グリッド */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.material-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.material-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.material-card:focus-within {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.material-thumb-wrap {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--color-border);
  overflow: hidden;
}

.material-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge-commercial {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--color-badge);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

/* PCではカードの商用OKバッジを非表示（見やすさ重視） */
@media (min-width: 769px) {
  .material-card .badge-commercial {
    display: none;
  }
}

.badge-license {
  font-size: 0.85rem;
  color: var(--color-badge);
  font-weight: 500;
}

.material-body {
  padding: 1rem;
}

.material-title {
  font-weight: 600;
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.material-category {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

.material-source {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  font-size: 1.5rem;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-preview {
  margin-bottom: 1.5rem;
}

.modal-img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

.modal-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.modal-source {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.modal-download h3 {
  font-size: 1rem;
  margin: 0 0 1rem;
}

.download-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.option-group.hidden {
  display: none;
}

.option-label {
  font-size: 0.9rem;
  font-weight: 500;
}

.select,
.color-input {
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 1rem;
}

.download-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.btn-secondary:hover {
  background: rgba(139, 105, 20, 0.08);
}

/* サンクスオーバーレイ */
.thanks-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.thanks-overlay.hidden {
  display: none;
}

.thanks-content {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  max-width: 400px;
  text-align: center;
}

.thanks-message {
  font-weight: 600;
  margin: 0 0 1rem;
}

.thanks-donation {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 1.5rem 0 0;
  line-height: 1.6;
}

.thanks-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-donation {
  display: block;
  padding: 0.75rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
}

.btn-donation:hover {
  background: var(--color-accent-hover);
}

.btn-close-thanks {
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

/* フッター */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer-donation {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
}

.footer-donation a {
  color: var(--color-accent);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* レスポンシブ */
@media (max-width: 600px) {
  .search-form {
    flex-direction: column;
  }

  .materials-grid {
    grid-template-columns: 1fr;
  }
}
