/* ============================================================================
   House voting page — stylesheet. Beach colours.
   Phone first: one column under ~700px, the Compare table scrolls sideways.
   ============================================================================ */

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

:root {
  --bg: #f6f2ea;            /* sand */
  --bg-card: #ffffff;
  --bg-soft: #efe9dd;
  --bg-header: #0b4f6c;     /* deep water */
  --bg-nav: #093f57;
  --text: #1d2a30;
  --text-muted: #5b6b72;
  --border: #e2dacb;
  --accent: #0f8b8d;        /* teal */
  --accent-hover: #0b6e70;
  --up: #2a9d8f;
  --maybe: #e9a23b;
  --down: #8d99ae;
  --heart: #e63946;
  --over: #d9622b;
  --success: #2a9d8f;
  --error: #c1121f;
  --info: #0b4f6c;
  --shadow: 0 2px 8px rgba(0,0,0,0.07);
  --shadow-hover: 0 6px 18px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

body.dark-mode {
  --bg: #0e1a20;
  --bg-card: #16262e;
  --bg-soft: #1c3039;
  --text: #e3ecef;
  --text-muted: #9fb1b8;
  --border: #29404a;
  --accent: #34b3b5;
  --accent-hover: #4cc6c8;
  --over: #f08a5d;
  --shadow: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-hover: 0 6px 18px rgba(0,0,0,0.5);
}

body.modal-open { overflow: hidden; }

button { font-family: inherit; }
a { color: var(--accent); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-header);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.header-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
}
.header-btn:hover { background: rgba(255,255,255,0.22); }
.voter-btn { font-weight: 600; }
.voter-btn.voter-unset { background: #f4a261; border-color: #f4a261; color: #1d2a30; }

.voter-wrapper { position: relative; }
.voter-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  z-index: 200;
  min-width: 170px;
  margin-top: 6px;
  overflow: hidden;
}
.voter-menu.active { display: block; }
.voter-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
}
.voter-menu button:hover { background: var(--bg-soft); }
.voter-menu-note { padding: 8px 14px 10px; font-size: 0.8rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* --- Navigation --- */
.app-nav {
  display: flex;
  background: var(--bg-nav);
  padding: 0 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-tab {
  padding: 12px 14px;
  color: rgba(255,255,255,0.7);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav-tab:hover { color: #fff; }
.nav-tab.active { color: #fff; border-bottom-color: #f4a261; }

/* --- Main --- */
.app-main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.view { min-height: 300px; }
.empty { color: var(--text-muted); padding: 24px 0; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin: 6px 0 10px; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }

/* --- Panels (The basics, Results) --- */
.hero {
  background: linear-gradient(135deg, #0b4f6c, #0f8b8d);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.hero h2 { font-size: 1.35rem; margin-bottom: 8px; }
.hero p { font-size: 0.95rem; opacity: 0.95; }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.panel h3 { font-size: 1.05rem; margin-bottom: 8px; }
.panel p { margin-bottom: 8px; }
.panel ul { padding-left: 20px; }
.panel li { margin-bottom: 6px; }
.plain-list { list-style: none; padding-left: 0 !important; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-big { margin-top: 6px; padding: 12px 20px; font-size: 1rem; width: 100%; max-width: 320px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Houses --- */
.house-group { margin-bottom: 28px; }
.group-title { font-size: 1.2rem; margin-bottom: 2px; }
.group-blurb { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 12px; }

.house-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.house-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
}
.house-card.clickable { cursor: pointer; }
.house-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.house-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.house-card-title { font-size: 1.15rem; font-weight: 700; line-height: 1.25; }
.house-card-name { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.house-card-town { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }

.card-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 12px;
  white-space: nowrap;
}
.card-badge.hearts { background: #fdecee; color: var(--heart); }
.card-badge.everyone { background: #e3f4f1; color: #1c7a6e; }
body.dark-mode .card-badge.hearts { background: #3a1a1e; }
body.dark-mode .card-badge.everyone { background: #173a35; color: #6fd3c4; }

.house-card-price { font-size: 0.95rem; margin-bottom: 8px; }
.house-card-price strong { font-size: 1.2rem; }
.house-card-price.price-over strong { color: var(--over); }
.seen { display: block; font-size: 0.78rem; color: var(--text-muted); }

.house-card-facts { list-style: none; font-size: 0.88rem; margin-bottom: 12px; flex: 1; }
.house-card-facts li { padding: 2px 0; }

.house-card-votes, .modal-votes { display: flex; gap: 8px; margin-bottom: 8px; }

.vote-btn {
  flex: 1;
  min-height: 44px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.vote-btn:hover { border-color: var(--accent); }
.vote-count { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); min-width: 0.5em; }
.vote-btn.voted[data-vote="up"]    { background: #e3f4f1; border-color: var(--up); border-width: 2px; }
.vote-btn.voted[data-vote="maybe"] { background: #fdf3e2; border-color: var(--maybe); border-width: 2px; }
.vote-btn.voted[data-vote="down"]  { background: #eceff3; border-color: var(--down); border-width: 2px; }
body.dark-mode .vote-btn.voted[data-vote="up"]    { background: #173a35; }
body.dark-mode .vote-btn.voted[data-vote="maybe"] { background: #3a2e18; }
body.dark-mode .vote-btn.voted[data-vote="down"]  { background: #2a313a; }
.vote-btn.big { font-size: 1.4rem; min-height: 52px; }

.house-card-actions { display: flex; gap: 8px; }
.heart-btn, .details-btn {
  flex: 1;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.heart-btn:hover, .details-btn:hover { border-color: var(--accent); }
.heart-btn.mine { background: #fdecee; border-color: var(--heart); color: var(--heart); }
body.dark-mode .heart-btn.mine { background: #3a1a1e; }

/* --- Compare --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
}
table.compare { border-collapse: collapse; font-size: 0.85rem; min-width: 1050px; width: 100%; }
.compare th, .compare td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.compare thead th { background: var(--bg-soft); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); white-space: nowrap; }
.compare tbody th { position: sticky; left: 0; background: var(--bg-card); z-index: 1; min-width: 120px; box-shadow: 1px 0 0 var(--border); }
.compare thead th:first-child { position: sticky; left: 0; z-index: 2; }
.compare td { min-width: 9.5em; }
.compare .num { text-align: right; white-space: nowrap; min-width: 0; }
.compare .group-row td { background: var(--bg-soft); font-weight: 700; color: var(--text); }
.over { color: var(--over); font-weight: 600; }

/* --- Results --- */
ol.results { list-style: none; padding: 0 !important; }
.result-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: none; }
.result-rank {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.result-body { flex: 1; min-width: 0; }
.result-name { font-size: 1.05rem; }
.result-price { color: var(--text-muted); font-size: 0.85rem; margin-left: 6px; }
.result-line { font-size: 0.9rem; margin-top: 2px; }

/* --- Comments --- */
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-meta { font-size: 0.82rem; color: var(--text-muted); }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.delete-btn { color: var(--error); font-weight: 500; font-size: 0.82rem; margin-left: 6px; }

.composer { margin-top: 10px; }
.composer textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;           /* 16px+: stops iPhone zooming into the box */
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* --- Modal --- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  overflow-y: auto;
  padding: 24px 12px;
}
.modal.active { display: flex; align-items: flex-start; justify-content: center; }
.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  position: relative;
}
.modal-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 44px; height: 44px;
  background: none;
  border: none;
  font-size: 1.9rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-header { padding: 20px 52px 8px 20px; }
.modal-kicker { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); font-weight: 700; }
.modal-header h2 { font-size: 1.45rem; line-height: 1.2; }
.modal-name, .modal-town { color: var(--text-muted); font-size: 0.9rem; }
.modal-body { padding: 0 20px 20px; }
.modal-price { background: var(--bg-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0 14px; }
.modal-price strong { font-size: 1.25rem; }
.modal-section { padding: 12px 0; border-top: 1px solid var(--border); }
.modal-section h3 { font-size: 0.95rem; margin-bottom: 8px; }
.modal-section ul { padding-left: 20px; }
.modal-section li { margin-bottom: 4px; font-size: 0.92rem; }
.modal-section.good h3 { color: var(--up); }
.modal-section.catches h3 { color: var(--over); }
.modal-heart { display: flex; margin-bottom: 8px; }
.who-voted { font-size: 0.9rem; }
.who-voted li { margin-bottom: 2px; }

.facts .fact { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 6px 0; font-size: 0.92rem; }
.facts dt { font-weight: 600; }
.fact-note { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.link-chip:hover { background: var(--accent); color: #fff; }

/* Name picker */
#select-user-modal { z-index: 600; align-items: center; }
.select-user-content { max-width: 400px; text-align: center; }
.select-user-body { padding: 28px 20px 22px; }
.select-user-icon { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }
.select-user-body h2 { font-size: 1.3rem; margin-bottom: 6px; }
.select-user-body p { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 16px; }
.select-user-picks { display: flex; flex-direction: column; gap: 10px; }
.select-user-pick {
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.select-user-pick:hover, .select-user-pick:focus { background: var(--accent); color: #fff; border-color: var(--accent); }
.select-user-note { margin: 14px 0 0 !important; font-size: 0.82rem !important; }

/* --- Closed (a house is booked) --- */
.site-closed .app-nav, .site-closed .voter-wrapper { display: none; }
.closed-panel { text-align: center; padding: 40px 20px; font-size: 1.15rem; }
.closed-icon { font-size: 3rem; margin-bottom: 8px; }

/* --- Toasts + confetti --- */
.toast-container {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.92rem;
  box-shadow: var(--shadow-hover);
  animation: toastIn 0.3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-info { background: var(--info); }
.toast-exit { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

.confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 800; overflow: hidden; }
.confetti {
  position: absolute;
  top: -10px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confettiFall 2.5s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .house-card, .house-card:hover { transition: none; transform: none; }
  .confetti { display: none; }
}

/* --- Phones --- */
@media (max-width: 700px) {
  .app-main { padding: 12px; }
  .house-grid { grid-template-columns: 1fr; gap: 12px; }
  .facts .fact { grid-template-columns: 1fr; gap: 0; }
  .modal { padding: 0; }
  .modal-content { border-radius: 0; min-height: 100%; }
}

@media (max-width: 480px) {
  .app-title { font-size: 1rem; }
}

@media (max-width: 380px) {
  .header-btn { padding: 6px 9px; font-size: 0.82rem; }
}
