/* Besoje site styles. Tokens and rules: see DESIGN.md.
   Spacing scale: 4, 8, 16, 24, 32, 48, 64. Radius: 8 controls, 12 panels. */

:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --soft: #EDEDE8;
  --text: #1C1C1A;
  --muted: #5E5D58;
  --border: #8E8D87;
  --line: #E2E1DB;
  --accent: #0E7C5A;
  --accent-hover: #0B6B4D;
  --accent-pressed: #095C42;
  --accent-soft: #E3F1EB;
  --star: #B7770B;
  --star-empty: #D6D4CC;
  --error: #B42318;
  --error-soft: #FBEAE8;
  --info-soft: #EDEDE8;

  --s4: 4px;
  --s8: 8px;
  --s16: 16px;
  --s24: 24px;
  --s32: 32px;
  --s48: 48px;
  --s64: 64px;

  --r8: 8px;
  --r12: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; display: block; }

h1 { font-size: clamp(28px, 2vw + 20px, 44px); line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; text-wrap: balance; }
h2 { font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; font-weight: 700; }
h3 { font-size: 18px; line-height: 1.3; font-weight: 600; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--s24); }
.main { flex: 1; padding-top: var(--s32); padding-bottom: var(--s64); }
.narrow { max-width: 680px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.lead { font-size: 18px; color: var(--muted); margin-top: var(--s8); max-width: 680px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.section { margin-top: var(--s48); }
.section > h2 { margin-bottom: var(--s16); }
.stack { display: grid; gap: var(--s16); }
.page-head { margin-bottom: var(--s24); }
.page-head h1 { margin-top: var(--s4); }

.skip-link { position: absolute; left: var(--s16); top: -64px; padding: var(--s8) var(--s16); background: var(--surface); border-radius: var(--r8); z-index: 20; }
.skip-link:focus { top: var(--s16); }

.preview-bar { background: var(--text); color: #FFFFFF; font-size: 14px; text-align: center; padding: var(--s8) var(--s16); }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; gap: var(--s24); padding-top: var(--s16); padding-bottom: var(--s16); }
.brand { display: inline-flex; align-items: center; gap: var(--s8); min-height: 44px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { color: var(--accent); flex: none; }
.brand-name { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.brand-small .brand-name { font-size: 18px; }
.header-search { flex: 1; display: flex; gap: var(--s8); max-width: 560px; }
.header-search .input { flex: 1; min-width: 0; }
.header-nav { display: flex; gap: var(--s8); margin-left: auto; }
.header-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s8); color: var(--text); text-decoration: none; font-weight: 600; border-radius: var(--r8); }
.header-nav a:hover { background: var(--soft); color: var(--text); }

/* Buttons */
.button-primary, .button-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s8);
  min-height: 44px; padding: 0 var(--s24); border-radius: var(--r8);
  font: inherit; font-size: 16px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.button-primary { border: 0; background: var(--accent); color: #FFFFFF; }
.button-primary:hover { background: var(--accent-hover); color: #FFFFFF; }
.button-primary:active { background: var(--accent-pressed); }
.button-secondary { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover { border-color: var(--text); color: var(--text); }
.button-secondary:active { background: var(--soft); }
.button-primary:disabled, .button-secondary:disabled { cursor: progress; opacity: 0.8; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--s8); margin-top: var(--s16); }
.spinner { display: none; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #FFFFFF; border-radius: 50%; animation: spin 700ms linear infinite; }
.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-quiet { color: var(--muted); }

/* Forms */
.field { display: grid; gap: var(--s8); margin: 0; padding: 0; border: 0; min-width: 0; }
legend.field-label { padding: 0; margin-bottom: var(--s8); }
.field-label { font-weight: 600; }
.field-help { color: var(--muted); font-size: 14px; }
.field-error { color: var(--error); font-size: 14px; font-weight: 600; }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s16); }
.input {
  width: 100%; min-height: 44px; padding: var(--s8) var(--s16);
  border: 1px solid var(--border); border-radius: var(--r8); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px;
}
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: var(--s48); }
textarea.input { min-height: 96px; resize: vertical; }
.input:hover { border-color: var(--text); }
.input:focus-visible { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--error); }
.input-short { max-width: 240px; }
.check { display: flex; gap: var(--s8); align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }

.rating-input { display: inline-flex; flex-direction: row-reverse; gap: var(--s4); justify-self: start; }
.rating-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating-input label { width: 44px; height: 44px; cursor: pointer; background: no-repeat center / 32px 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23D6D4CC' d='M10 1.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L10 14.8l-5.2 2.8 1-5.8L1.5 7.7l5.9-.8z'/%3E%3C/svg%3E"); border-radius: var(--r8); }
.rating-input input:checked ~ label,
.rating-input label:hover,
.rating-input label:hover ~ label { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23B7770B' d='M10 1.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L10 14.8l-5.2 2.8 1-5.8L1.5 7.7l5.9-.8z'/%3E%3C/svg%3E"); }
.rating-input input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Notices */
.notice { padding: var(--s16); border-radius: var(--r8); margin-bottom: var(--s24); }
.notice-info { background: var(--info-soft); }
.notice-success { background: var(--accent-soft); color: var(--text); }
.notice-error { background: var(--error-soft); color: var(--error); font-weight: 600; }

/* Cards and lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r12); padding: var(--s24); }
.empty-state { display: grid; gap: var(--s16); }
.biz-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s16); }
.biz-card { display: grid; gap: var(--s8); align-content: start; }
.biz-name { font-size: 18px; }
.biz-name a { color: var(--text); text-decoration: none; }
.biz-name a:hover { color: var(--accent); text-decoration: underline; }
.biz-meta { font-size: 14px; }
.biz-rating { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s8); }
.ranked { counter-reset: rank; }
.ranked > li { counter-increment: rank; position: relative; }
.ranked > li .biz-name::before { content: counter(rank) ". "; color: var(--muted); }

.rating { display: inline-flex; align-items: center; gap: var(--s8); }
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.star .s-bg { fill: var(--star-empty); }
.star .s-fg { fill: var(--star); }
.star-empty .s-fg { display: none; }
.star-half .s-fg { clip-path: inset(0 50% 0 0); }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 var(--s8); border-radius: var(--r8); font-size: 14px; font-weight: 600; }
.badge-verified { background: var(--accent-soft); color: var(--accent-pressed); }

.tile-grid > li { display: flex; }
.tile-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s16); }
.tile { flex: 1; display: grid; gap: var(--s4); min-height: 88px; align-content: center; padding: var(--s16) var(--s24); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r12); color: var(--text); text-decoration: none; transition: border-color 150ms var(--ease); }
.tile:hover { border-color: var(--text); color: var(--text); }
.tile-title { font-weight: 600; font-size: 18px; }
.tile-hint { font-size: 14px; }
.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s8); }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s16); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--text); text-decoration: none; }
.chip:hover { border-color: var(--text); color: var(--text); }
.more-towns { margin-top: var(--s16); }
.more-towns summary { cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; color: var(--accent); }
.more-towns .chip-list { margin-top: var(--s8); }

/* Home */
.hero { padding: var(--s32) 0 var(--s16); }
.hero h1 { max-width: 760px; }
.search-panel { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: var(--s16); align-items: end; margin-top: var(--s32); padding: var(--s24); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r12); }
.how-list { display: grid; gap: var(--s16); padding-left: var(--s24); max-width: 680px; margin-bottom: var(--s16); }

/* Breadcrumbs */
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s8); font-size: 14px; color: var(--muted); margin-bottom: var(--s16); }
.breadcrumbs li + li::before { content: "/"; margin-right: var(--s8); color: var(--muted); }
.breadcrumbs a { color: var(--muted); }

/* Business page */
.biz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "head side" "reviews side"; grid-template-rows: auto 1fr; gap: var(--s24) var(--s48); align-items: start; }
.biz-head { grid-area: head; margin-bottom: 0; }
.biz-reviews { grid-area: reviews; margin-top: var(--s24); }
.biz-reviews > h2 { margin-bottom: var(--s16); }
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s8); margin-top: var(--s16); }
.big-rating { font-size: 32px; font-weight: 700; line-height: 1; }
.biz-side { grid-area: side; display: grid; gap: var(--s16); position: sticky; top: var(--s24); }
.side-title { font-size: 18px; }
.biz-side .button-row { margin-top: 0; }
.details { display: grid; grid-template-columns: auto 1fr; gap: var(--s8) var(--s16); }
.details dt { color: var(--muted); }
.review-list { list-style: none; display: grid; gap: var(--s24); }
.review { display: grid; gap: var(--s8); padding-bottom: var(--s24); border-bottom: 1px solid var(--line); }
.review-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s8); }
.review-author { font-weight: 600; }
.review-body { display: grid; gap: var(--s8); max-width: 680px; }
.owner-reply { margin-top: var(--s8); padding: var(--s16); background: var(--soft); border-radius: var(--r8); }
.owner-reply-title { font-weight: 600; margin-bottom: var(--s4); }
.reply-box summary { cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--r12); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r12); overflow: hidden; }
.table th, .table td { text-align: left; padding: var(--s8) var(--s16); border-bottom: 1px solid var(--line); height: 44px; vertical-align: middle; }
.table th { font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Legal */
.prose { display: grid; gap: var(--s16); }
.prose h2 { margin-top: var(--s24); }
.prose ul { padding-left: var(--s24); display: grid; gap: var(--s8); }

/* Sign-in */
.auth .stack { max-width: 420px; }
.button-google { width: 100%; }
.divider { display: flex; align-items: center; gap: var(--s16); color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.dev-login { margin-top: var(--s32); max-width: 420px; }
.dev-login + p { margin-top: var(--s16); }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s32); }
.admin-nav ul { list-style: none; display: grid; gap: var(--s4); position: sticky; top: var(--s24); }
.admin-nav a { display: flex; align-items: center; min-height: 44px; padding: 0 var(--s16); border-radius: var(--r8); color: var(--text); text-decoration: none; }
.admin-nav a:hover { background: var(--soft); color: var(--text); }
.admin-nav a[aria-current="page"] { background: var(--surface); border: 1px solid var(--line); font-weight: 600; }
.admin-main { display: grid; gap: var(--s24); align-content: start; }
.queue { list-style: none; display: grid; gap: var(--s16); }
.queue-item { display: grid; gap: var(--s8); }
.queue-title { font-size: 18px; }
.queue-actions { display: flex; flex-wrap: wrap; gap: var(--s16); align-items: center; margin-top: var(--s8); }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--s8); align-items: center; }
.inline-form .input { width: auto; }
.proof { max-width: 320px; max-height: 320px; border: 1px solid var(--line); border-radius: var(--r8); }
.stat-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s16); }
.stat { display: grid; gap: var(--s4); }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: var(--s48) 0 var(--s24); }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: var(--s32); }
.footer-grid ul { list-style: none; display: grid; gap: var(--s8); }
.footer-grid a { color: var(--text); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }
.footer-title { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: var(--s8); }
.footer-bottom { margin-top: var(--s32); font-size: 14px; }

@media (max-width: 960px) {
  .biz-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "side" "reviews"; grid-template-rows: auto; gap: var(--s32); }
  .biz-side { position: static; }
  .biz-reviews { margin-top: 0; }
  .search-panel { grid-template-columns: 1fr 1fr; }
  .search-panel .field:first-child { grid-column: 1 / -1; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .admin-nav ul { position: static; display: flex; flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .container { padding-left: var(--s16); padding-right: var(--s16); }
  .main { padding-top: var(--s24); }
  .header-row { flex-wrap: wrap; gap: var(--s8) var(--s16); }
  .header-search { order: 3; flex-basis: 100%; max-width: none; }
  .header-nav { margin-left: auto; }
  .search-panel { grid-template-columns: 1fr; padding: var(--s16); }
  .field-row-2 { grid-template-columns: 1fr; }
  .biz-list { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .button-row .button-primary, .button-row .button-secondary { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
  .spinner { animation-duration: 1500ms; }
}
