/* styles/components.css — 가맹점숲 공통 컴포넌트
   의존: styles/tokens.css 가 먼저 로드되어 있어야 함. */

/* ========== Layout helpers ========== */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
}
@media (max-width: 720px) {
  .container { padding-inline: 16px; }
}

.section {
  padding-block: var(--space-8);
}
@media (max-width: 720px) {
  .section { padding-block: 40px; }
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin-block: var(--space-5);
}

/* ========== Buttons ========== */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 40px;
  font: var(--fw-500) var(--fs-15)/1.2 var(--font);
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: transform var(--dur-1) var(--ease),
              background-color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              opacity var(--dur-2) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--primary-ink);
  --btn-bd: transparent;
  box-shadow: 0 6px 18px -8px var(--primary);
}
.btn-primary:hover { --btn-bg: var(--primary-2); }

.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: var(--border);
}
.btn-ghost:hover { --btn-bg: var(--surface-2); }

.btn-danger {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  --btn-bd: transparent;
}
.btn-danger:hover { filter: brightness(1.08); }

.btn-sm { min-height: 32px; padding: 6px 12px; font-size: var(--fs-14); }
.btn-lg { min-height: 52px; padding: 14px 22px; font-size: var(--fs-17); border-radius: var(--radius); }

.btn .icon { width: 18px; height: 18px; flex: 0 0 18px; }

/* ========== Card ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease);
}
.card-hover:hover,
.card.card-hover:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
}
.card-list {
  display: grid;
  gap: var(--space-4);
}
@media (min-width: 720px) {
  .card-list.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .card-list.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ========== Chip ========== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font: var(--fw-500) var(--fs-12)/1 var(--font);
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}
.chip-primary {
  color: var(--primary-2);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-color: color-mix(in srgb, var(--primary) 36%, transparent);
}
.chip-outline {
  background: transparent;
  color: var(--text);
}

/* ========== Badge ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font: var(--fw-700) var(--fs-12)/1.4 var(--font);
  color: #fff;
  background: var(--muted);
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-danger { background: var(--danger); }
.badge-warn   { background: var(--warn); color: #0b1020; }
.badge-ok     { background: var(--ok); }

/* ========== Table ========== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-15);
  color: var(--text);
}
.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table thead th {
  font-weight: var(--fw-700);
  color: var(--muted);
  text-transform: uppercase;
  font-size: var(--fs-12);
  letter-spacing: .04em;
  background: var(--surface-2);
}
.table tbody tr:nth-child(odd) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.table tbody tr:hover td { background: var(--surface-2); }
.table.sticky thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 1;
}

/* ========== List Item (블라인드 게시판 느낌) ========== */
.list-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px dashed var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background-color var(--dur-2) var(--ease);
}
.list-item:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.list-item .li-title {
  font-weight: var(--fw-500);
  font-size: var(--fs-17);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item .li-cat { flex: 0 0 auto; }
.list-item .li-date { color: var(--muted); font-size: var(--fs-14); }
.list-item .li-views { color: var(--muted); font-size: var(--fs-14); }
@media (max-width: 640px) {
  .list-item { grid-template-columns: 1fr auto; row-gap: 4px; }
  .list-item .li-cat { grid-column: 1; grid-row: 2; }
  .list-item .li-title { grid-column: 1 / -1; grid-row: 1; }
  .list-item .li-date { grid-column: 2; grid-row: 2; }
  .list-item .li-views { display: none; }
}

/* ========== Hero ========== */
.hero {
  position: relative;
  padding: 96px 24px 80px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(1200px 500px at 10% -10%, color-mix(in srgb, var(--primary) 32%, transparent), transparent 60%),
    radial-gradient(900px 420px at 90% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.6), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow {
  display: inline-block;
  color: var(--primary-2);
  font-size: var(--fs-14);
  font-weight: var(--fw-700);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.hero h1 {
  font-size: clamp(28px, 5vw, var(--fs-44));
  line-height: 1.15;
  font-weight: var(--fw-700);
  color: var(--text-strong);
  margin: 0 0 16px;
  letter-spacing: -.02em;
}
.hero p.lead {
  font-size: var(--fs-17);
  color: var(--muted);
  max-width: 680px;
  line-height: var(--lh-base);
  margin: 0 0 28px;
}
.hero .hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; }

/* ========== Prose (글 본문) ========== */
.prose {
  max-width: 720px;
  margin-inline: auto;
  color: var(--text);
  font-size: var(--fs-17);
  line-height: var(--lh-prose);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.prose > * + * { margin-top: 1.2em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--text-strong);
  font-weight: var(--fw-700);
  line-height: 1.3;
  letter-spacing: -.01em;
  margin-top: 2em;
}
.prose h1 { font-size: var(--fs-32); }
.prose h2 { font-size: var(--fs-24); padding-bottom: .4em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: var(--fs-20); }
.prose h4 { font-size: var(--fs-17); }
.prose p { margin: 0; }
.prose a {
  color: var(--primary-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .4em; }
.prose blockquote {
  margin: 0;
  padding: 12px 18px;
  border-left: 3px solid var(--primary);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
}
.prose code {
  font-family: var(--font-mono);
  font-size: .92em;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}
.prose pre {
  font-family: var(--font-mono);
  font-size: var(--fs-14);
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  line-height: 1.6;
}
.prose pre code { background: none; border: 0; padding: 0; }
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-15);
}
.prose table th, .prose table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.prose table thead th { background: var(--surface-2); color: var(--muted); }

/* ========== Forms ========== */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label {
  font-size: var(--fs-14);
  font-weight: var(--fw-500);
  color: var(--muted);
}
.form-help { font-size: var(--fs-12); color: var(--muted); }
.form-error { font-size: var(--fs-12); color: var(--danger); }

.input, .textarea, .select {
  width: 100%;
  font: var(--fw-400) var(--fs-15)/1.5 var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}
.textarea { min-height: 120px; resize: vertical; }
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* ========== Search bar ========== */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.search-bar .input { padding-left: 40px; }
.search-bar .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  display: inline-flex;
  align-items: center;
  padding: 12px 16px;
  font: var(--fw-500) var(--fs-15)/1 var(--font);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text-strong);
  border-bottom-color: var(--primary);
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: var(--space-6);
}
.pagination a, .pagination button, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: var(--fs-14);
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
}
.pagination a:hover, .pagination button:hover { color: var(--text); background: var(--surface-2); }
.pagination .active, .pagination [aria-current="page"] {
  color: var(--primary-ink);
  background: var(--primary);
  border-color: transparent;
}

/* ========== Skeleton ========== */
.skeleton {
  display: block;
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    var(--surface-3) 40%,
    var(--surface-2) 80%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-shimmer 1.4s linear infinite;
  min-height: 14px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== Toast ========== */
.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 12px 16px;
  font-size: var(--fs-14);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(8px);
  animation: toast-in var(--dur-3) var(--ease) forwards;
}
.toast.leaving { animation: toast-out var(--dur-3) var(--ease) forwards; }
.toast-success { border-left-color: var(--ok); }
.toast-error   { border-left-color: var(--danger); }
@keyframes toast-in  { to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ========== Modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  animation: modal-fade var(--dur-2) var(--ease) forwards;
}
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  transform: translateY(8px);
  opacity: 0;
  animation: modal-in var(--dur-3) var(--ease) forwards;
}
.modal-body { padding: 24px; }
@keyframes modal-fade { to { opacity: 1; } }
@keyframes modal-in   { to { opacity: 1; transform: translateY(0); } }

/* ========== kbd ========== */
.kbd {
  display: inline-block;
  padding: 2px 6px;
  font: var(--fw-500) var(--fs-12)/1 var(--font-mono);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
}
