/* =========================================
   diary.css — Life with Paws 日記ページ
   ========================================= */

/* ---- ページヘッダー ---- */
.diary-page-header {
  background: var(--bg-alt, #f5f2ee);
  padding: 80px 0 40px;
  border-bottom: 1px solid var(--border, #e8e3dc);
}
.diary-page-title {
  font-family: 'Shippori Mincho', serif;
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--text, #1a1a1a);
  margin: 0 0 8px;
}
.diary-page-lead {
  font-size: 1rem;
  color: var(--text-muted, #777);
  margin: 0;
}

/* ---- レイアウト ---- */
.diary-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 48px;
  align-items: start;
  padding-top: 48px;
  padding-bottom: 80px;
}
@media (max-width: 900px) {
  .diary-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

/* ---- 日記一覧 ---- */
.diary-list-section h2,
.diary-form-section h2 {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.3rem;
  color: var(--text, #1a1a1a);
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--brand, #8b6f5e);
}
.diary-list-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.diary-list-header h2 { margin: 0; border: none; padding: 0; }
.diary-count {
  font-size: 0.8rem;
  color: var(--text-muted, #999);
  background: var(--bg-alt, #f5f2ee);
  padding: 2px 8px;
  border-radius: 20px;
}
.diary-empty {
  color: var(--text-muted, #999);
  font-size: 0.95rem;
  padding: 32px;
  text-align: center;
  background: var(--bg-alt, #f5f2ee);
  border-radius: 12px;
}

/* ---- 日記カード ---- */
.diary-card {
  background: #fff;
  border: 1px solid var(--border, #e8e3dc);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  transition: box-shadow 0.2s;
  position: relative;
}
.diary-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }

/* トップ画像に使われているカードのマーク */
.diary-card.is-hero {
  border-color: var(--brand, #8b6f5e);
  box-shadow: 0 0 0 2px var(--brand, #8b6f5e);
}
.diary-card-hero-badge {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--brand, #8b6f5e);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  gap: 4px;
  align-items: center;
  z-index: 2;
}
.diary-card.is-hero .diary-card-hero-badge { display: flex; }

.diary-card-img-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--bg-alt, #f5f2ee);
  position: relative;
}
.diary-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s;
}
.diary-card:hover .diary-card-img-wrap img { transform: scale(1.03); }
.diary-card-no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: 2rem;
}

.diary-card-body {
  padding: 16px 20px 12px;
}
.diary-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted, #999);
  margin-bottom: 6px;
}
.diary-card-title {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  margin: 0 0 6px;
  line-break: strict;
}
.diary-card-excerpt {
  font-size: 0.88rem;
  color: var(--text-muted, #666);
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.diary-card-footer {
  padding: 10px 20px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--border, #f0ebe4);
}
.btn-set-hero {
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--brand, #8b6f5e);
  background: transparent;
  color: var(--brand, #8b6f5e);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-set-hero:hover,
.btn-set-hero.active {
  background: var(--brand, #8b6f5e);
  color: #fff;
}
.btn-set-hero svg { flex-shrink: 0; }

.btn-delete-card {
  margin-left: auto;
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid #e0d5cc;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-delete-card:hover {
  border-color: #e55;
  color: #e55;
  background: #fff5f5;
}

/* ---- フォームエリア ---- */
.diary-form-section {
  position: sticky;
  top: 80px;
}
.drop-zone {
  border: 2px dashed var(--border, #d5ccc3);
  border-radius: 12px;
  background: var(--bg-alt, #f9f7f4);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 20px;
  min-height: 160px;
  position: relative;
  overflow: hidden;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--brand, #8b6f5e);
  background: #f3ede7;
}
.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  text-align: center;
  gap: 8px;
}
.drop-icon {
  width: 40px;
  height: 40px;
  color: var(--brand, #8b6f5e);
  opacity: 0.6;
}
.drop-label {
  font-size: 0.95rem;
  color: var(--text, #444);
  margin: 0;
  line-height: 1.6;
}
.drop-label span {
  font-size: 0.82rem;
  color: var(--text-muted, #999);
}
.drop-hint {
  font-size: 0.75rem;
  color: var(--text-muted, #bbb);
  margin: 0;
}

/* プレビュー表示 */
.drop-preview {
  position: relative;
  width: 100%;
  height: 200px;
}
.drop-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.drop-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  z-index: 3;
}
.drop-remove:hover { background: rgba(220,50,50,0.85); }

/* トップ画像チェック */
.hero-flag-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  z-index: 3;
}
.hero-flag-label:has(input:checked) {
  background: var(--brand, #8b6f5e);
}
.hero-flag-label input { display: none; }

/* フォーム部品 */
.diary-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text, #444);
}
.form-group input[type="date"],
.form-group input[type="text"],
.form-group textarea {
  border: 1px solid var(--border, #d5ccc3);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text, #1a1a1a);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand, #8b6f5e);
  box-shadow: 0 0 0 3px rgba(139,111,94,0.15);
}
.form-group textarea { resize: vertical; line-height: 1.7; }

.btn-diary-submit {
  background: var(--brand, #8b6f5e);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 24px;
  font-size: 1rem;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-diary-submit:hover { background: #7a5f4f; }
.btn-diary-submit:active { transform: scale(0.98); }

/* ---- トースト通知 ---- */
.diary-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  white-space: nowrap;
}
.diary-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================
   認証UI（管理者バー・ログインモーダル）
   ========================================= */

/* ---- 管理者バー ---- */
.owner-auth-bar {
  background: var(--bg-alt, #f5f2ee);
  border-bottom: 1px solid var(--border, #e8e3dc);
  padding: 8px 0;
}
.auth-bar-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 36px;
}
.auth-status {
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  letter-spacing: 0.02em;
}
.btn-auth {
  font-size: 0.78rem;
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid var(--border, #d8d3cc);
  background: transparent;
  color: var(--text-muted, #888);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.4;
}
.btn-auth:hover {
  background: var(--bg, #fff);
  color: var(--text, #1a1a1a);
  border-color: var(--text-muted, #aaa);
}
.btn-auth.is-owner {
  color: var(--brand, #7c6a50);
  border-color: var(--brand, #7c6a50);
}
.btn-auth.is-owner:hover {
  background: color-mix(in srgb, var(--brand, #7c6a50) 8%, transparent);
}

/* ---- ログインモーダル ---- */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.auth-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.auth-modal {
  background: var(--bg, #fff);
  border-radius: 16px;
  padding: 40px 36px 32px;
  width: min(380px, 90vw);
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  transform: translateY(12px);
  transition: transform 0.2s;
}
.auth-modal-overlay.is-open .auth-modal {
  transform: translateY(0);
}
.auth-modal-title {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.3rem;
  margin: 0 0 6px;
  color: var(--text, #1a1a1a);
}
.auth-modal-lead {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  margin: 0 0 24px;
}
.auth-error {
  font-size: 0.82rem;
  color: #c0392b;
  margin: 4px 0 8px;
  min-height: 1.2em;
}
.auth-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted, #aaa);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}
.auth-modal-close:hover { color: var(--text, #1a1a1a); }

/* ---- 日記ヒーロー画像（トップに設定された日記の画像） ---- */
.diary-hero {
  width: 100%;
  height: 60vh; /* スマホでビューポートの60%の高さ */
  max-height: 400px; /* PCでの最大高さを維持 */
  background-color: #f0f0f0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover; /* 画像がコンテナを覆うように調整 */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2em;
  font-weight: bold;
  overflow: hidden;
  position: relative;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.4);
}
.diary-hero.has-image .diary-page-title,
.diary-hero.has-image .diary-page-lead {
  /* 画像がある場合はテキストを白く、影を付けて読みやすく */
  color: #fff;
}

@media (max-width: 900px) {
  .diary-hero {
    height: 45vh; /* スマホでは少し高さを抑える */
    min-height: 250px; /* 最小高さを設定 */
  }
}
