/* ── Morningtide — mobile-first styles ─────────────────────── */
:root {
  --bg:         #f4f3ef;
  --surface:    #ffffff;
  --border:     #e0ddd5;
  --text:       #1a1a1a;
  --muted:      #6b6860;
  --primary:    #2c5f2e;
  --primary-fg: #ffffff;
  --accent:     #d4a017;
  --danger:     #c0392b;
  --open:       #2980b9;
  --completed:  #27ae60;
  --needs-work: #e67e22;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1);
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Nav ─────────────────────────────────────────── */
.nav {
  background: var(--primary);
  color: var(--primary-fg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-title { font-size: 1.1rem; font-weight: 700; letter-spacing: .02em; }
.nav-sub   { font-size: .8rem; opacity: .8; }
.nav-actions { display: flex; gap: .75rem; align-items: center; }
.nav a { color: var(--primary-fg); text-decoration: none; font-size: .9rem; opacity: .9; }
.nav a:hover { opacity: 1; }

/* ── Container ───────────────────────────────────── */
.container { max-width: 640px; margin: 0 auto; padding: .75rem 1rem 4rem; }

/* ── Flash messages ──────────────────────────────── */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .75rem; font-size: .9rem; }
.flash.success { background: #d4edda; color: #155724; }
.flash.error   { background: #f8d7da; color: #721c24; }
.flash.warning { background: #fff3cd; color: #856404; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  min-height: 44px;
  text-decoration: none;
}
.btn-primary  { background: var(--primary); color: var(--primary-fg); }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-sm       { padding: .4rem .75rem; font-size: .85rem; min-height: 36px; }
.btn:hover    { filter: brightness(1.08); }

/* ── Status badge ────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-open       { background: #d6eaf8; color: var(--open); }
.badge-completed  { background: #d5f5e3; color: var(--completed); }
.badge-needs-work { background: #fdebd0; color: var(--needs-work); }

/* ── Sort tabs ───────────────────────────────────── */
.sort-bar {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem;
}
.sort-tab {
  flex: 1;
  text-align: center;
  padding: .5rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.sort-tab.active { background: var(--primary); color: var(--primary-fg); }

/* ── Item card ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: .75rem;
}
.card-link { text-decoration: none; color: inherit; display: block; }
.card-body { padding: .85rem 1rem; }
.card-desc { font-size: 1rem; font-weight: 600; margin-bottom: .3rem; }
.card-meta { font-size: .8rem; color: var(--muted); display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .4rem; }
.card-thumb { width: 100%; height: 160px; object-fit: cover; display: block; }

/* ── Stars ───────────────────────────────────────── */
.stars { display: inline-flex; gap: 2px; }
.star-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: .1rem;
  line-height: 1;
  min-height: 0;
  filter: grayscale(1);          /* dim un-selected thumbs (emoji ignores color) */
  opacity: .4;
}
.star-btn.filled { filter: none; opacity: 1; }
.star-btn:hover  { filter: none; opacity: 1; transform: scale(1.15); }
.star-display    { font-size: 1rem; }
.star-empty      { filter: grayscale(1); opacity: .4; font-size: 1rem; }

/* ── Votes list (Strava style) ───────────────────── */
.votes-list { list-style: none; margin-top: .5rem; }
.votes-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.votes-list li:last-child { border-bottom: none; }
.vote-name { font-weight: 600; min-width: 6rem; }

/* ── Thread (updates) ────────────────────────────── */
.thread { margin-top: 1rem; }
.thread-item {
  background: var(--surface);
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .75rem 1rem;
  margin-bottom: .5rem;
}
.thread-item.completed  { border-left-color: var(--completed); }
.thread-item.needs-work { border-left-color: var(--needs-work); }
.thread-meta { font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.thread-note { font-size: .95rem; }
.thread-thumb { width: 100%; max-height: 200px; object-fit: cover; border-radius: 4px; margin-top: .5rem; }

/* ── Forms ───────────────────────────────────────── */
.form-group  { margin-bottom: 1rem; }
label        { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--muted); }
textarea, input[type=text], input[type=password], select {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  appearance: none;
  min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input[type=file] { font-size: .9rem; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* ── Login page ──────────────────────────────────── */
.login-wrap { max-width: 400px; margin: 2rem auto; padding: 0 1rem; }
.login-title { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin-bottom: .25rem; }
.login-sub   { color: var(--muted); font-size: .95rem; margin-bottom: 1.5rem; }
.login-intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin: .75rem 0 1.5rem;
  font-size: .9rem;
  color: var(--text);
  box-shadow: var(--shadow);
}
.login-intro p { margin-bottom: .5rem; }
.login-intro ul { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.login-intro li { line-height: 1.35; }
.user-grid   { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; margin-bottom: 1.5rem; }
.user-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  min-height: 60px;
  transition: border-color .15s, background .15s;
}
.user-btn:hover, .user-btn.selected { border-color: var(--primary); background: #eef5ee; }
.pin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.pin-for { font-weight: 700; font-size: 1.05rem; margin-bottom: 1rem; }
.pin-input {
  font-size: 1.6rem;
  letter-spacing: .4rem;
  text-align: center;
  width: 100%;
  padding: .75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

/* ── Admin table ─────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background: #f0ede6; font-weight: 700; }

/* ── Empty state ─────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-icon { font-size: 3rem; margin-bottom: .75rem; }

/* ── FAB (floating action button) ───────────────── */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
}
.fab:hover { filter: brightness(1.1); }

/* ── Detail header ───────────────────────────────── */
.detail-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;            /* show the whole photo, never crop */
  background: #ece9e1;            /* neutral letterbox behind the image */
  display: block;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Rotate controls under the detail photo */
.rotate-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .9rem;
  padding: .55rem;
  background: #ece9e1;
  border-bottom: 1px solid var(--border);
}
.rotate-btn {
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.rotate-btn:active { background: var(--bg); }
.rotate-label { font-size: .8rem; color: var(--muted); }

/* Upload progress overlay */
.upload-overlay[hidden] { display: none; }   /* attribute must win over display:flex */
.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.upload-box {
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem 2rem;
  border-radius: var(--radius);
  text-align: center;
  font-size: .95rem;
}
.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto .75rem;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.detail-body { padding: 1rem; }
.detail-desc { font-size: 1.15rem; font-weight: 700; margin-bottom: .5rem; }
.detail-meta { font-size: .82rem; color: var(--muted); margin-bottom: .75rem; }

/* ── Section headings ────────────────────────────── */
.section-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.25rem 0 .5rem; }

/* ── Collapsible votes ───────────────────────────── */
.votes-toggle { font-size: .85rem; color: var(--primary); cursor: pointer; background: none; border: none; padding: 0; }

/* ── Vote form ───────────────────────────────────── */
.vote-form { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.vote-form .star-btn { font-size: 2rem; }

/* ── Action section ──────────────────────────────── */
.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: .75rem;
}
.action-title { font-size: .85rem; font-weight: 700; margin-bottom: .75rem; color: var(--muted); text-transform: uppercase; }
