/* ------------------------------------------------------------------ *
 * Design tokens.
 *
 * Every colour, radius and shadow in the app is defined once, here, and
 * referenced by name everywhere else. When you want to restyle the app you
 * change these eight lines instead of hunting through the file. This is the
 * single highest-value CSS habit to pick up early.
 * ------------------------------------------------------------------ */
:root {
  --bg:        #12100e;
  --surface:   #1c1917;
  --surface-2: #262220;
  --line:      #37312d;
  --text:      #f5f1ec;
  --muted:     #a89f96;
  --accent:    #d98c3f;   /* warm amber, like a well-lit bar */
  --accent-dim:#7a4f22;
  --good:      #6fbf73;
  --radius:    14px;
  --shadow:    0 8px 28px rgba(0,0,0,.4);
  --font:      ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f7f4ef;
    --surface:   #ffffff;
    --surface-2: #f2ede5;
    --line:      #e2d9cc;
    --text:      #1f1a16;
    --muted:     #6f665c;
    --accent:    #a8621b;
    --accent-dim:#e8d3b8;
    --shadow:    0 6px 20px rgba(60,40,20,.10);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); }

/* ---------------- Header ---------------- */

.site-header {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  padding: 26px 0 22px;
  margin-bottom: 26px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 40px; line-height: 1; }
.site-header h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------------- Controls ---------------- */

.controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 22px;
}
.control-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.control-row + .control-row { margin-top: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 170px; }
.field.grow { flex: 1 1 260px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

input[type="text"], input[type="search"], input[type="date"], select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.postcode-group { display: flex; gap: 8px; }
/* Scoped to #postcode only. The same .postcode-group wrapper is reused by
   the token and Gist ID fields, and those are case-sensitive — uppercasing
   them on screen makes a correct value look wrong. */
#postcode { text-transform: uppercase; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 15px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #17120d; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-quiet { background: none; color: var(--muted); font-weight: 500; }

/* Filter chips: a styled checkbox. The real input stays in the DOM for
   keyboard and screen-reader users, it's just visually hidden. */
.filters { align-items: center; }
.chip { position: relative; cursor: pointer; user-select: none; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span {
  display: inline-block;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  background: var(--surface-2);
  transition: background .12s, border-color .12s;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #17120d; font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-divider { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }

.origin-note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.origin-note .warn { color: var(--accent); }

.result-count { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

/* ---------------- Pub cards ---------------- */

.pub-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }

.pub {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.pub:hover { transform: translateY(-2px); border-color: var(--accent-dim); box-shadow: var(--shadow); }

.pub-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.pub h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.pub .where { margin: 3px 0 0; font-size: 13px; color: var(--muted); }

.score { text-align: right; flex-shrink: 0; }
.score .stars { color: var(--accent); font-size: 14px; letter-spacing: 1px; }
.score .num { font-size: 19px; font-weight: 700; }
.score .count { display: block; font-size: 11px; color: var(--muted); }
.score .none { font-size: 12px; color: var(--muted); }

.blurb {
  margin: 0; font-size: 14px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.badge.on { color: var(--text); border-color: var(--accent-dim); }
.badge.unverified { opacity: .65; font-style: italic; }

.pub-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; margin-top: auto; padding-top: 3px; }
.distance { color: var(--accent); font-weight: 600; }
.mine { color: var(--good); font-weight: 600; }
.mine small { display: block; color: var(--muted); font-weight: 400; }

/* ---------------- Detail dialog ---------------- */

.detail {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 620px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
.detail::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(3px); }
.detail-inner { padding: 24px; position: relative; }
.detail-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 30px; line-height: 1; cursor: pointer; padding: 4px 8px;
}
.detail-close:hover { color: var(--text); }

.detail h2 { margin: 0 0 4px; font-size: 22px; padding-right: 34px; }
.detail .where { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.detail h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 9px; }

.links { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  padding: 8px 12px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.link-btn:hover { border-color: var(--accent); }
.link-btn.wa:hover  { border-color: #25d366; }
.link-btn.fb:hover  { border-color: #4267b2; }

.review { border-top: 1px solid var(--line); padding: 11px 0; }
.review:first-of-type { border-top: none; }
.review-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.review-head strong { font-weight: 600; }
.review-head .when { color: var(--muted); }
.review p { margin: 5px 0 0; font-size: 14px; }
.review .stars { color: var(--accent); }

.form-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
textarea { resize: vertical; min-height: 62px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.err { color: #e2725b; font-size: 13px; margin: 8px 0 0; }

.facility-toggles { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- Misc ---------------- */

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.site-footer {
  margin-top: 50px; padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
.site-footer p { margin: 0 0 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--accent); color: #17120d;
  padding: 11px 20px; border-radius: 999px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
  z-index: 50;
}

@media (max-width: 560px) {
  .pub-list { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field, .field.grow { min-width: 100%; flex-basis: 100%; }
}

/* Respect users who've asked their OS to reduce motion. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------------ *
 * Static-version additions: sync button and settings dialog
 * ------------------------------------------------------------------ */

.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.sync-btn { display: inline-flex; align-items: center; gap: 8px; }

.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.sync-dot.ok    { background: var(--good); }
.sync-dot.dirty { background: var(--accent); }
.sync-dot.off   { background: var(--muted); opacity: .5; }

.sync-status {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 16px 0 4px;
  font-size: 14px;
}
.sync-status p { margin: 0 0 4px; }
.sync-status p:last-child { margin-bottom: 0; }
.sync-status .warn { color: var(--accent); font-weight: 600; }

.hint { font-size: 13px; color: var(--muted); margin: 8px 0 10px; }
.hint code {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; font-size: 12px;
}

input[type="password"] {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 10px 12px; font: inherit; font-size: 15px; width: 100%;
}

.form-actions { flex-wrap: wrap; }

.link-del {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; margin-left: 6px;
}
.link-del:hover { color: #e2725b; }

@media (max-width: 560px) {
  .header-inner { flex-wrap: wrap; }
}
