/* ==================================================
   Yuibi Repo Prototype — css/style.css
   Chapter Guide
     [CH1] Design tokens / globals
     [CH2] Layout primitives
     [CH3] Components
     [CH4] Page-specific
     [CH5] Responsive
   ================================================== */

/* [CH1] Design tokens — Sage × Warm Grey */
:root {
  --bg: #FAFAF8;
  --bg-surface: #F3F2EE;
  --fg: #4A4A47;
  --fg-secondary: #6B6B66;
  --fg-hint: #9A9A94;
  --accent: #7A8C73;
  --accent-hover: #6A7C63;
  --accent-light: #D5DDD1;
  --accent-bg: #EDF0EB;
  --border: #E0DED8;
  --border-light: #ECEAE4;
  --card-bg: #fff;
  --danger: #C53030;
  --danger-bg: #FFF5F5;
  --warn: #B7791F;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 99px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}


/* [CH2] Base elements */
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--fg);
  background-color: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  opacity: 0.8;
  text-decoration: none;
}


/* [CH3] Header */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  height: 48px;
  border-bottom: 1px solid var(--border-light);
  background-color: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2000;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
}

.brand-title:hover {
  opacity: 1;
  text-decoration: none;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--fg-secondary);
}

.site-nav a {
  margin-left: 1.2rem;
  font-size: 0.9rem;
  color: var(--fg-secondary);
  transition: color 0.15s;
}
.site-nav a:hover {
  color: var(--accent);
  opacity: 1;
}


/* [CH4] Main layout */

main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.hero {
  margin-bottom: 1.5rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
}


/* [CH4] Search area */

.search-area {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr);
  grid-template-rows: auto auto;
  gap: 1rem;
  margin-bottom: 2rem;
}

#search-map {
  grid-column: 1 / 3;
}

.search-panel {
  background-color: var(--card-bg);
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

.search-panel h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.map-placeholder {
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  background-color: #fafafa;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input[type="text"],
select {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: var(--card-bg);
  color: var(--fg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

button {
  align-self: flex-start;
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-sm);
  border: none;
  background-color: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.15s;
}

button:hover {
  background-color: var(--accent-hover);
}


/* [CH4] Route cards */

.route-list {
  margin-top: 2rem;
}

.route-card {
  background-color: var(--card-bg);
  padding: 1.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  margin-bottom: 1rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.route-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.route-card h3 {
  margin-top: 0;
  margin-bottom: 0.3rem;
}

.route-meta {
  font-size: 0.85rem;
  color: var(--fg-secondary);
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.route-summary {
  font-size: 0.95rem;
}


/* [CH4] Route detail page */

.route-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.route-article {
  background-color: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.route-header h1 {
  margin-top: 0;
  margin-bottom: 0.3rem;
  font-size: 1.4rem;
}

.route-overview,
.route-meta-info,
.route-map-section,
.spot-list,
.references {
  margin-top: 1.5rem;
}

.route-meta-info dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 0.25rem 1rem;
  font-size: 0.95rem;
}

.route-meta-info dt {
  font-weight: 600;
}

.route-meta-info dd {
  margin: 0;
}

.route-map-section {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1rem;
}

.route-files ul {
  padding-left: 1.2rem;
}


/* [CH4] Spot blocks */

.spot-list .spot {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.spot-header h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.spot-coords {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-secondary);
}

.spot-caption {
  margin-top: 0.5rem;
}

.spot-notes {
  font-size: 0.9rem;
  color: var(--fg-secondary);
}


/* [CH3] Footer */

.site-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.8rem;
  color: var(--fg-hint);
  background-color: var(--card-bg);
}


/* [CH5] Responsive */

@media (max-width: 768px) {
  .search-area {
    grid-template-columns: 1fr;
  }

  #search-map {
    grid-column: 1 / 2;
  }

  .route-map-section {
    grid-template-columns: 1fr;
  }
}


/* [CH3] Small UI helpers */
.ref-list-container {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}
.ref-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-light);
  padding: 0.4rem 0;
  font-size: 0.9rem;
}
.ref-item:last-child { border-bottom: none; }
.ref-item button {
  font-size: 0.75rem; padding: 2px 6px; margin-left: 5px;
  background-color: var(--danger);
}

/* [CH4] Profile Page */

.profile-container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* プロフィールカード */
.profile-card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ヘッダー画像エリア (将来的に画像を入れる場所) */
.profile-cover {
  height: 120px;
  background-color: var(--accent-light);
  border-bottom: 1px solid var(--border-light);
}

.profile-body {
  padding: 1.5rem 2rem;
  position: relative;
}

/* アイコンとアクションボタンの配置 */
.profile-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: -3.5rem; /* カバー画像に食い込ませる */
  margin-bottom: 1rem;
}

.profile-avatar {
  width: 100px; height: 100px;
  background: #fff;
  border: 4px solid #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: #ccc;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 編集ボタン */
.btn-edit-profile {
  margin-top: 2.5rem; /* 位置調整 */
  background: #fff;
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: bold;
  padding: 0.5rem 1rem;
  border-radius: 999px; /* 角丸 */
  cursor: pointer;
  transition: background 0.2s;
}
.btn-edit-profile:hover {
  background: #f0f0f0;
}

/* テキスト情報 */
.profile-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
}
.profile-bio {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--fg);
  white-space: pre-wrap;
  margin-bottom: 1rem;
}
.profile-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--fg-secondary);
}
.profile-meta a {
  color: var(--accent);
  text-decoration: none;
  display: flex; align-items: center; gap: 4px;
}
.profile-meta a:hover { text-decoration: underline; }

/* 編集フォームモード */
.edit-form-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
.edit-form-grid label {
  font-weight: 600; font-size: 0.9rem;
}
.edit-form-grid input, 
.edit-form-grid textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
}
.form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--border-light);
}
.btn-save {
  background: var(--accent); color: #fff; border: none; padding: 0.6rem 1.5rem; border-radius: var(--radius-pill); font-weight: 600; cursor: pointer;
}
.btn-cancel {
  background: transparent; border: 1px solid var(--border); padding: 0.6rem 1.5rem; border-radius: var(--radius-pill); cursor: pointer; color: var(--fg-secondary);
}

.section-title {
  font-size: 1.2rem; font-weight: bold; border-bottom: 2px solid var(--border-light); padding-bottom: 0.5rem; margin-bottom: 1rem;
}

.edit-form-grid {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-top: 1rem;
}

.edit-form-grid label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg-secondary);
  margin-bottom: 0.4rem;
}

.edit-form-grid input,
.edit-form-grid textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg);
}

.edit-form-grid input:focus,
.edit-form-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.btn-save {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-cancel {
  background: transparent;
  color: var(--fg-secondary);
  border: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-cancel:hover {
  background: var(--bg-surface);
}

/* Dashboard Action Buttons */
.btn-text-danger {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--danger); font-size: 0.85rem; text-decoration: underline;
}
.btn-text-danger:hover { color: #9B2C2C; }

.btn-text-warn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--warn); font-size: 0.85rem; text-decoration: underline;
}
.btn-text-warn:hover { color: #975A16; }

/* Follow UI (Profile) */
.follow-row {
  display: flex;
  justify-content:flex-start !important;
  align-items: center;
  margin: 0.6rem 0 0.8rem;
  gap:12px;
}

.follow-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--fg-secondary);
}

.btn-follow {
  margin-top: 2.5rem;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: bold;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-follow:hover {
  background: var(--bg-surface);
}

.btn-follow.is-following {
  background: var(--accent-bg);
  border-color: var(--accent-light);
}

.btn-follow:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary, .btn-muted {
  padding: 0.3rem 0.8rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-muted { background: var(--fg-secondary); color: #fff; }

.profile-cover {
  position: relative;
  height: 160px;
  background: var(--accent-light);
  background-size: cover;
  background-position: center;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.avatar-wrapper {
  position: relative;
  width: 104px;
  height: 104px;
}
.avatar-img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 4px solid #fff;
  object-fit: cover;
  background: #ddd;
}

.profile-actions {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.btn-pill{
  background:#111 !important;
  color:#fff !important;
  border:1px solid #111 !important;
}
.btn-pill:hover{
  background:#000 !important;
}
.btn-pill.is-following{
  background:#fff !important;
  color:#111 !important;
  border:1px solid #111 !important;
}
  
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.92);
  color:#111;
  border-radius: 999px;
  cursor: pointer;
}
.icon-btn:hover { background: #fff; }
.icon-btn svg {
  display: block;
  flex-shrink: 0;
}

#btn-cover-edit{
  position:absolute;
  top:12px;
  left:12px;
}

.avatar-edit {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 32px;
  height: 32px;
}

.icon-20 { width: 20px; height: 20px; }
.icon-18 { width: 18px; height: 18px; }

.follow-row {
  display: flex;
  gap: 1rem;
  margin: 0.5rem 0 0.8rem;
  color: var(--fg);
  font-size: 0.95rem;
}
.stat-link {
  cursor: pointer;
  user-select: none;
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.stat-link:hover { text-decoration: underline; }

.sns-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.sns-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  text-decoration: none;
  color: var(--fg);
  background: #fff;
  font-size: 0.9rem;
}
.sns-link:hover { background: var(--bg-surface); }
.sns-icon { width: 16px; height: 16px; display: inline-block; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.modal-card {
  position: relative;
  width: min(520px, calc(100vw - 24px));
  max-height: min(70vh, 720px);
  margin: 8vh auto 0;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
}
.modal-title { font-weight: 800; }
.modal-list {
  overflow: auto;
  padding: 6px 0;
}
.modal-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: center;
}

.user-row {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
}
.user-row:hover { background: #f8fafc; }
.user-row-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  background: #ddd;
}
.user-row-main { display: flex; flex-direction: column; min-width: 0; }
.user-row-top { display: flex; gap: 8px; align-items: center; }
.user-row-name { font-weight: 800; }
.user-row-sub { color: var(--fg-secondary); font-size: 0.9rem; }
.mutual-badge {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: #111;
}

.section-subtitle { margin: 0 0 0.6rem; font-size: 1.1rem; }
.req { color: red; }
.hint { color: var(--fg-secondary); font-size: 0.85rem; }
.at-input { display: flex; gap: 0.5rem; align-items: center; }
.at { padding: 0.6rem; background:#eee; border:1px solid #ddd; border-radius:4px; color:#666; }
.hintline { font-size:0.85rem; margin-top:0.3rem; min-height:1.2em; color:#666; }
.links-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
@media (max-width: 720px) {
  .links-grid { grid-template-columns: 1fr; }
}

/* ★ ヘッダー ユーザーメニュー (ドロップダウン) */
.user-menu-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  background: none;
  color: inherit;
  font-size: 0.9rem;
}
.user-menu-trigger:hover {
  background: var(--bg-surface);
  border-color: var(--border);
}
.user-menu-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #ddd;
}
.user-menu-name {
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-caret {
  font-size: 0.6rem;
  color: var(--fg-hint);
  transition: transform 0.2s;
}
.user-menu-container.open .user-menu-caret {
  transform: rotate(180deg);
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 3000;
  padding: 4px 0;
  animation: dropdownFadeIn 0.15s ease;
}
.user-menu-container.open .user-dropdown {
  display: block;
}
@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.1s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.user-dropdown-item:hover {
  background: var(--accent-bg);
  text-decoration: none;
}
.user-dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}
.user-dropdown-item.danger {
  color: var(--danger);
}
.user-dropdown-item.danger:hover {
  background: var(--danger-bg);
}

/* 未ログイン時のボタン */
.header-login-btn {
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
}
.header-login-btn:hover {
  background: var(--accent-hover);
}