/* Glizzy Guide app styles. System fonts only; light and dark follow the OS. */

:root {
  --cream: #fff4dc;
  --cream-2: #ffe8bd;
  --ketchup: #c8261c;
  --ketchup-dark: #9e1c14;
  --orange: #f08a24;
  --mustard: #f2b705;
  --brown: #4a2511;
  --navy: #1f3b73;

  --bg: var(--cream);
  --surface: #fffaf0;
  --surface-2: #fdebc8;
  --text: #2b1a10;
  --muted: #1f3b73;
  --border: #e3c58e;
  --primary: #c8261c;
  --primary-hover: #9e1c14;
  --on-primary: #ffffff;
  --accent: #f2b705;
  --on-accent: #2b1a10;
  --danger: #a3160d;
  --focus: #1f3b73;
  --shadow: 0 2px 0 rgba(74, 37, 17, 0.18), 0 6px 18px rgba(74, 37, 17, 0.1);
  --radius: 18px;
  --tabbar-height: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c120d;
    --surface: #2a1c15;
    --surface-2: #36251b;
    --text: #fff4dc;
    --muted: #b5cbf2;
    --border: #5a4030;
    --primary: #f2b705;
    --primary-hover: #ffcd3c;
    --on-primary: #1c120d;
    --accent: #f2b705;
    --on-accent: #1c120d;
    --danger: #ff8a7a;
    --focus: #ffcd3c;
    --shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

main {
  display: block;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--tabbar-height) + 28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
}

body.no-tabs main { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 800; }
p { margin: 0 0 0.8em; }
a { color: var(--muted); font-weight: 600; }
img { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
}
.skip-link:focus { top: calc(8px + env(safe-area-inset-top)); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.loading, .muted { color: var(--muted); }
.noscript { padding: 16px; text-align: center; }

/* --- banners --------------------------------------------------------------- */
.banners {
  max-width: 480px;
  margin: 0 auto;
}
.banner {
  margin: 0;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  font-size: 0.95rem;
  font-weight: 600;
}
.banner.offline { background: var(--navy); color: #ffffff; text-align: center; }
.install-hint {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface-2);
  color: var(--text);
  border-bottom: 2px solid var(--border);
}
.install-hint p { margin: 0; flex: 1; }

/* --- buttons and forms ----------------------------------------------------- */
.button, button {
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 48px;
  padding: 10px 20px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.button.primary, button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.button.primary:hover, button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.danger, button.danger { color: var(--danger); border-color: currentColor; background: transparent; }
.button.small, button.small { min-height: 44px; padding: 6px 14px; font-size: 0.95rem; }
.button.block, button.block { width: 100%; }
button:disabled, .button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.link-button {
  background: none;
  border: 0;
  padding: 10px 4px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: underline;
  font-weight: 600;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

form { margin: 0; }
.field { margin: 0 0 16px; }
.field > label, .field > .label, fieldset > legend {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.hint { font-size: 0.9rem; color: var(--muted); margin: 4px 0 0; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  font: inherit;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
textarea { min-height: 110px; resize: vertical; }
input:focus-visible, textarea:focus-visible { border-color: var(--focus); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.92rem; font-weight: 600; margin: 6px 0 0; }
.form-error {
  background: var(--surface-2);
  border-left: 5px solid var(--danger);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
}
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }

/* --- brand ----------------------------------------------------------------- */
.logo-panel {
  display: block;
  background: var(--cream);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 4px 0 18px;
  text-align: center;
}
.logo-panel img { display: block; width: 100%; height: auto; margin: 0 auto; }
.wordmark-panel {
  display: inline-block;
  background: var(--cream);
  border-radius: 14px;
  padding: 6px 10px;
}
.wordmark-panel img { display: block; width: 150px; height: auto; }
@media (prefers-color-scheme: light) {
  .logo-panel, .wordmark-panel { padding-left: 0; padding-right: 0; background: transparent; }
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.page-head h1 { margin: 0; }

/* --- auth pages ------------------------------------------------------------ */
.auth .intro { color: var(--muted); font-weight: 600; }
.auth .switch { text-align: center; margin-top: 20px; }

/* --- feed ------------------------------------------------------------------ */
.segmented {
  display: flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  margin: 0 0 16px;
  gap: 4px;
}
.segmented a {
  flex: 1;
  text-align: center;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
}
.segmented a[aria-current="page"] { background: var(--primary); color: var(--on-primary); }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card > a { display: block; color: inherit; text-decoration: none; font-weight: inherit; }
.card .thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-2);
}
.card .card-body { padding: 12px 14px 14px; }
.card h2 { font-size: 1.15rem; margin: 0 0 2px; overflow-wrap: anywhere; }
.card .place { color: var(--muted); margin: 0 0 6px; overflow-wrap: anywhere; }
.card .meta { font-size: 0.92rem; color: var(--muted); margin: 6px 0 0; }
.sentinel { height: 1px; }
.feed-end { text-align: center; color: var(--muted); margin: 18px 0; }

.empty {
  text-align: center;
  padding: 24px 8px;
}
.empty img { width: 200px; height: auto; margin: 0 auto 10px; display: block; border-radius: 24px; }
@media (prefers-color-scheme: dark) {
  /* Derek's mascots sit on a cream panel in dark mode, like the logo. */
  .empty img { background: var(--cream); padding: 8px; }
}
.wordmark-panel img, .preview, .review-photo { height: auto; }

/* --- scores ---------------------------------------------------------------- */
.dogs { display: inline-flex; gap: 3px; vertical-align: middle; }
.dogs img { width: 26px; height: 17px; }
.dogs img.off { opacity: 0.22; filter: grayscale(1); }
.score-line { display: flex; align-items: center; gap: 8px; margin: 0; }
.score-line .num { font-weight: 800; }
.scores { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; margin: 12px 0; }
.scores dt { font-weight: 700; }
.scores dd { margin: 0; }
.scores dt.overall, .scores dd.overall .num { font-size: 1.1rem; }

.rating { margin: 0 0 16px; }
.rating .choices { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.rating label.dog {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  cursor: pointer;
}
.rating label.dog img { width: 38px; height: 25px; opacity: 0.25; filter: grayscale(1); }
.rating label.dog.on img { opacity: 1; filter: none; }
.rating input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.rating input:focus-visible + img { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.rating label.clear { font-size: 0.92rem; color: var(--muted); padding: 10px; min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; }
.rating label.clear input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* --- post ------------------------------------------------------------------ */
.photo-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.photo-pick label { width: 100%; }
.photo-pick input[type="file"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-pick label:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.preview {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin: 0 0 16px;
}
.counter { float: right; font-size: 0.85rem; color: var(--muted); font-weight: 600; }

/* --- review ---------------------------------------------------------------- */
.review-photo { display: block; width: 100%; border-radius: var(--radius); background: var(--surface-2); margin-bottom: 12px; }
.review-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.byline { color: var(--muted); font-size: 0.95rem; }
.review h1, .review .place { overflow-wrap: anywhere; }
.comments { margin-top: 24px; }
.comment-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.comment {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.comment .comment-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 0.92rem; }
.comment .comment-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .comment-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* --- profile --------------------------------------------------------------- */
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.avatar {
  flex: none;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  border: 3px solid var(--brown);
}
.avatar.small { width: 40px; height: 40px; font-size: 1.1rem; border-width: 2px; }
.profile-head h1 { overflow-wrap: anywhere; margin: 0 0 2px; }
.bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.stats { display: flex; gap: 12px; margin: 12px 0 16px; }
.stat {
  flex: 1;
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat .value { display: block; font-size: 1.5rem; font-weight: 800; }
.stat .label { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid a { display: block; position: relative; border-radius: 10px; overflow: hidden; }
.grid img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.grid .badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  background: var(--brown);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 7px;
}
.settings { display: grid; gap: 10px; margin-top: 24px; }

/* --- rules page ------------------------------------------------------------ */
.rules ul { padding-left: 1.2em; }
.rules li { margin-bottom: 0.4em; }

/* --- dialogs --------------------------------------------------------------- */
dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(28, 18, 13, 0.55); }
dialog h2 { margin-top: 0; }
.radio-list { display: grid; gap: 6px; margin: 0 0 12px; }
.radio-list label { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.radio-list input { width: 22px; height: 22px; accent-color: var(--primary); }

/* --- tab bar --------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  max-width: 480px;
  margin: 0 auto;
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  background: var(--surface);
  border-top: 2px solid var(--border);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tabbar-height);
  color: var(--text);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
}
.tab[aria-current="page"] { color: var(--primary); }
.tab.post { position: relative; justify-content: flex-end; padding-bottom: 6px; }
.post-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-top: -26px;
  border-radius: 50%;
  background: var(--ketchup);
  color: #ffffff;
  border: 4px solid var(--bg);
  box-shadow: var(--shadow);
}
.tab.post[aria-current="page"] .post-button { background: var(--ketchup-dark); }

/* --- toast ----------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-height) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(440px, calc(100vw - 32px));
  background: var(--brown);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
