/* 이음 공통 스타일: 값은 모두 tokens.css에서 가져온다 (HTML에서 tokens.css를 먼저 불러온다) */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; background: var(--surface); }
body {
  font-family: var(--font-family);
  font-size: var(--font-body-medium);
  line-height: var(--line-height);
  color: var(--text-body);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.4; font-weight: var(--font-weight-bold); }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--text-link); }
a:hover { color: var(--text-link-hover); }

/* 키보드로 이동할 때 지금 위치가 잘 보이게 (가이드라인: 초점 표시는 인접 배경과 3:1 이상) */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* 본문 바로가기: 평소엔 숨어 있다가 Tab을 누르면 화면 왼쪽 위에 나타난다 */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--text-body);
  color: var(--surface);
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-medium);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-2); color: var(--surface); }

/* 화면에는 안 보이지만 화면 읽기 프로그램은 읽는 글자 */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 배지 ---------- */
.badge-type, .badge-unverified, .badge-category {
  display: inline-block;
  font-size: var(--font-body-xsmall);
  font-weight: var(--font-weight-bold);
  line-height: 1.5;
  padding: 1px var(--space-2);
  border-radius: var(--radius-small);
  vertical-align: middle;
}
/* UI-04: 색 바탕 배지를 회색 테두리 하나로 통일. 뜻이 있는 배지(미확인·진행 중 등)만 앞에 작은 점 색 */
.badge-type { border: 1px solid var(--border-light); background: var(--surface); color: var(--text-body); }
.badge-category { background: var(--surface-subtle); color: var(--text-subtle); font-weight: var(--font-weight-medium); border: 1px solid transparent; }
.badge-unverified { border: 1px solid var(--border-light); background: var(--surface); color: var(--text-body); --dot: var(--color-warning-60); font-weight: var(--font-weight-medium); }
/* 전통시장: 가게 배지와 같은 회색 테두리 (UI-04: 진한 청록 꽉 찬 바탕을 뺌) */
.badge-market {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--font-body-xsmall);
  font-weight: var(--font-weight-bold);
  line-height: 1.5;
  padding: 2px var(--space-2);
  border-radius: var(--radius-small);
  border: 1px solid var(--border-light); background: var(--surface); color: var(--text-body);
  vertical-align: middle;
}

/* ---------- 버튼 ---------- */
/* 한 화면에서 가장 중요한 동작 하나만 button-primary로 */
.button-primary, .button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-5);
  border-radius: var(--radius-medium);
  font-size: var(--font-body-medium);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
  border: 1px solid var(--action-primary);
}
.button-primary { background: var(--action-primary); color: var(--text-on-primary); }
.button-primary:hover { background: var(--action-primary-hover); border-color: var(--action-primary-hover); color: var(--text-on-primary); }
.button-primary:active { background: var(--action-primary-pressed); }
.button-secondary { background: var(--action-secondary-bg); color: var(--text-link); }
.button-secondary:hover { background: var(--action-secondary-hover); color: var(--text-link-hover); }
/* 사용할 수 없는 상태: 투명도 대신 정해진 회색을 쓴다 (가이드라인) */
.button-primary:disabled, .button-secondary:disabled,
.button-primary[aria-disabled="true"], .button-secondary[aria-disabled="true"] {
  background: var(--action-disabled-bg);
  border-color: var(--action-disabled-bg);
  color: var(--action-disabled-text);
  cursor: not-allowed;
}
.wide { width: 100%; }

.icon { width: 24px; height: 24px; flex: none; }
.icon-small { width: 20px; height: 20px; flex: none; }

/* ---------- 공통 상단 바: 로고 + (왼쪽 돌아가기) + 계정 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 56px;
  padding: var(--space-1) var(--screen-margin);
  background: var(--surface);
  border-bottom: 1px solid var(--border-divider);
}
.logo {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  font-size: 1.25rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 1px;
  color: var(--color-primary-70);
  text-decoration: none;
  margin-right: auto;
}
/* 심볼 마크: 오래된 가게의 처마 아래로 골목길이 이어지는 모양. 글자 '이음'은 그대로 두고 앞에 그림만 붙인다.
   mask 로 그려서 글자색(currentColor)을 따라간다. 화면 낭독기는 링크 글자 '이음'만 읽는다 */
.logo::before {
  content: "";
  flex: none;
  width: 1.25em;
  height: 1.25em;
  margin-right: 0.3em;
  background-color: currentColor;
  /* 작게 쓰는 곳이라 선을 굵게 한 판 (큰 크기는 ieum-symbol.svg) */
  -webkit-mask: url("/images/ieum-symbol-small.svg") center / contain no-repeat;
  mask: url("/images/ieum-symbol-small.svg") center / contain no-repeat;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--touch-min);
  padding: 0 var(--space-2) 0 0;
  font-weight: var(--font-weight-medium);
  color: var(--text-body);
  text-decoration: none;
}
.back-link:hover { color: var(--text-link); }

/* 계정 영역 (header.js가 채움): 로그인 링크 또는 닉네임 버튼 + 메뉴 */
.account { position: relative; flex: none; }
.account-link, .account-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  max-width: 112px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-medium);
  font-size: var(--font-body-small);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-link { border: 1px solid var(--action-primary); color: var(--text-link); background: var(--surface); }
.account-link:hover { background: var(--action-secondary-hover); }
.account-button { display: inline-block; line-height: var(--touch-min); border: none; background: var(--action-primary); color: var(--text-on-primary); }
.account-button:hover { background: var(--action-primary-hover); }
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-large);
  padding: var(--space-2);
  z-index: 30;
}
.account-menu a, .account-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--touch-min);
  padding: 0 var(--space-3);
  border: none;
  background: none;
  border-radius: var(--radius-medium);
  font-size: var(--font-body-medium);
  color: var(--text-body);
  text-align: left;
  text-decoration: none;
}
.account-menu a:hover, .account-menu button:hover { background: var(--surface-subtle); color: var(--text-body); }
.account-menu .menu-name {
  padding: var(--space-1) var(--space-3) var(--space-2);
  margin-bottom: var(--space-1);
  font-size: var(--font-body-small);
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border-divider);
}

@media (max-width: 380px) {
  .account-link, .account-button { max-width: 84px; padding: 0 var(--space-2); }
}

/* 화면에는 안 보이고 화면 낭독기만 읽는 글자 (UI-03) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 로컬크리에이터 (LOC-01) */
.badge-field { display: inline-flex; align-items: center; padding: 2px var(--space-2); border-radius: var(--radius-small); border: 1px solid var(--border-light); background: var(--surface); color: var(--text-body); font-size: var(--font-body-xsmall); font-weight: var(--font-weight-medium); }
.creator-box .creator-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--border-light); border-radius: var(--radius-large); background: var(--surface); overflow: hidden; }
.creator-box .creator-list > li { padding: var(--space-3) var(--space-4); }
.creator-box .creator-list > li + li { border-top: 1px solid var(--border-divider); }
.creator-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-1); }
.creator-item { margin: 0; overflow-wrap: anywhere; }
.creator-meta { margin: var(--space-1) 0 0; font-size: var(--font-body-small); color: var(--text-subtle); }

/* 가게·시장·축제 화면의 '방문 이야기' (COM-01) */
.place-stories { display: flex; flex-direction: column; gap: var(--space-2); }
.place-stories h2 { margin: 0; }
.place-stories-status, .place-stories-meta { margin: 0; color: var(--text-subtle); font-size: var(--font-body-small); }
.place-stories-status[hidden] { display: none; }
.place-stories-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.place-stories-list > li { padding: var(--space-3) 0; border-bottom: 1px solid var(--border-divider); display: flex; flex-direction: column; gap: var(--space-1); }
.place-stories-head { margin: 0; display: flex; align-items: baseline; gap: var(--space-2); }
.place-stories-head a { font-weight: var(--font-weight-bold); color: var(--text-body); overflow-wrap: anywhere; }
.place-stories-links { margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.place-stories-links a { display: inline-flex; align-items: center; min-height: var(--touch-min); font-weight: var(--font-weight-bold); }
.place-stories .cat-badge { display: inline-flex; flex: none; padding: 2px var(--space-2); border-radius: var(--radius-small); font-size: var(--font-body-xsmall); font-weight: var(--font-weight-bold); background: var(--color-primary-5); color: var(--color-primary-70); border: 1px solid var(--color-primary-10); }

/* UI-04: 상태 배지 앞의 작은 점. 배지마다 --dot 으로 색만 정한다 */
.badge-unverified::before, .status-now::before, .status-soon::before, .status-ended::before, .rec-badge::before, .state-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--dot, var(--color-gray-40));
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* 상세 화면(가게·시장·축제)에서 그 항목이 없거나 못 불러왔을 때 (ERR-01, not-found.js) */
.not-found-block { padding: var(--space-10) 0 var(--space-8); word-break: keep-all; }
.not-found-block .not-found-title { margin: 0 0 var(--space-3); font-size: var(--font-heading-xlarge); font-weight: 650; letter-spacing: -0.01em; line-height: 1.3; }
.not-found-block .not-found-lead { margin: 0 0 var(--space-6); color: var(--text-body); line-height: 1.6; }
.not-found-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.not-found-actions > * { flex: 1 1 140px; cursor: pointer; font: inherit; font-weight: var(--font-weight-bold); }

/* 찜하기 버튼 (FAV-01, favorite.js): 가게·시장 제목 아래 */
.favorite { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.favorite-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-input);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-body);
  font: inherit;
  font-size: var(--font-body-small);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
}
.favorite-button:hover { background: var(--surface-subtle); }
.favorite-button.saved { border-color: var(--color-primary-60); color: var(--color-primary-70); background: var(--color-primary-5, #eef7f4); }
.favorite-button:disabled { cursor: progress; }
.favorite-status { margin: 0; font-size: var(--font-body-small); color: var(--text-subtle); }
.favorite-status:empty { display: none; }
.favorite-status.error { color: var(--color-danger-70); }

/* 알림 종 (NOTI-01, header.js): 닉네임 버튼 왼쪽 */
.account { display: inline-flex; align-items: center; gap: var(--space-1); }
.noti-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: 999px;
  color: var(--text-body);
}
.noti-link:hover { background: var(--surface-subtle); }
.noti-link .icon { width: 24px; height: 24px; }
.noti-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--color-danger-70);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.noti-badge[hidden] { display: none; }
.noti-link[hidden] { display: none; }
.header-end { display: flex; justify-content: flex-end; }
/* 안 읽은 알림 점 (닉네임 버튼). 종이 보일 때는 감춘다 */
.account-button.has-unread { position: relative; }
.account-button.has-unread::after { content: ''; display: none; position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--color-danger-70); border: 2px solid var(--surface); }
/* 지도 위쪽 바는 칸이 많아 좁은 화면에서는 종을 감추고 닉네임 버튼의 점·메뉴로 알린다 */
@media (max-width: 400px) {
  .topbar .noti-link { display: none; }
  .topbar .account-button.has-unread::after { display: block; }
}

/* ROUTE-01: 길찾기 버튼 아래 안내 */
.actions .route-note { grid-column: 1 / -1; }
.route-note { margin: calc(-1 * var(--space-1)) 0 var(--space-1); font-size: var(--font-body-xsmall); color: var(--text-subtle); }
