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

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────── */
.container       { max-width: 1280px; margin: 0 auto; padding: 0 32px; }
main.container   { flex: 1; padding-top: 48px; padding-bottom: 72px; }

/* ── Header / Footer ───────────────────────────────────── */
.site-header {
  background: var(--color-navy);
  padding: 16px 0;
}
.header-inner {
  display: flex;
  align-items: center;
  position: relative;
}
.header-logo { display: flex; align-items: center; }
.logo-img    { height: 32px; filter: brightness(0) invert(1); }
.logo-text   { font-size: 19px; font-weight: 600; color: #fff; }
.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  letter-spacing: .01em;
  pointer-events: none;
}

.site-footer {
  background: var(--color-navy);
  padding: 20px 0;
  margin-top: 48px;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
}

/* ── Poll header ───────────────────────────────────────── */
.poll-header {
  background: #f0f2f4;
  background: color-mix(in srgb, var(--color-navy) 6%, #fff);
  border: 1px solid #d4d9de;
  border: 1px solid color-mix(in srgb, var(--color-navy) 15%, #fff);
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 36px;
}
.poll-title    { font-size: 28px; font-weight: 600; margin-bottom: 8px; color: var(--color-navy); }
.poll-description { color: var(--color-muted); max-width: 640px; margin-bottom: 10px; font-size: 16px; }
.poll-deadline { font-size: 14px; color: var(--color-muted); margin-top: 8px; }

.badge         { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; margin-bottom: 8px; }
.badge-closed  { background: #f0f0f0; color: var(--color-muted); }

/* ── Hints ──────────────────────────────────────────────── */
.hint-single-select,
.hint-already-voted {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  border-radius: var(--radius);
  padding: 6px 12px;
  margin-bottom: 12px;
}
.hint-single-select {
  color: #7a5800;
  background: #fef9ec;
  border: 1px solid #f5e0a0;
}
.hint-single-select::before { content: 'ℹ️'; font-size: 14px; }
.hint-already-voted {
  color: var(--color-navy);
  background: #f0f2f4;
  background: color-mix(in srgb, var(--color-navy) 6%, #fff);
  border: 1px solid #ccd2d8;
  border: 1px solid color-mix(in srgb, var(--color-navy) 20%, #fff);
  margin-bottom: 16px;
}
.hint-already-voted::before { content: '✓'; font-weight: 700; }

/* ── Form errors ───────────────────────────────────────── */
.form-errors {
  background: #fef0f0;
  border: 1px solid #f5c6c6;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #c0392b;
}

/* ── Table ─────────────────────────────────────────────── */
.table-scroll {
  overflow: hidden;         /* clip border-radius */
  overflow-x: auto;         /* must come after shorthand to override x-axis */
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  -webkit-mask-image: -webkit-radial-gradient(white, black); /* Safari border-radius clip fix */
  transform: translateZ(0);
}

.results-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  border-radius: 12px;
  overflow: hidden;
}

.results-table th,
.results-table td {
  padding: 0;
  border: 1px solid var(--color-border);
  text-align: center;
  vertical-align: middle;
}

/* Name column */
.col-name,
.results-table td.cell-name,
.results-table th.col-name {
  text-align: left;
  min-width: 200px;
  padding: 12px 16px;
  font-weight: 500;
  white-space: nowrap;
}

/* Option header */
.col-option {
  min-width: 140px;
  padding: 12px 14px;
  background: #f8f8f8;
  font-weight: 500;
}
.opt-day  { display: block; font-weight: 600; font-size: 14px; }
.opt-date { display: block; font-weight: 600; font-size: 14px; }

/* Winner column highlight */
.col-winner {
  background: rgba(232, 80, 10, 0.08) !important;
  background: color-mix(in srgb, var(--color-primary) 8%, transparent) !important;
  border-color: rgba(232, 80, 10, 0.25) !important;
  border-color: color-mix(in srgb, var(--color-primary) 25%, transparent) !important;
}
thead .col-winner { color: var(--color-primary); }

/* Best column (most yes votes) */
.col-best {
  background: #edf7ed !important;
  border-color: #b6ddb6 !important;
}
thead .col-best { color: #237523; }

/* Vote cell */
.cell-vote { width: 140px; }

/* Own row */
.row-own td { background: #fafaf8; }
.row-own td:first-child { border-left: 3px solid var(--color-primary); }

.name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-edit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-muted);
  background: #fff;
  text-decoration: none;
  transition: border-color .12s, color .12s, background .12s;
}
.btn-edit:hover {
  border-color: var(--color-navy);
  color: var(--color-navy);
  background: color-mix(in srgb, var(--color-navy) 5%, #fff);
  text-decoration: none;
}

/* ── Vote chips (display) ───────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
}
.chip-yes   { background: #d6f0d6; color: #237523; }
.chip-maybe { background: #fef0d4; color: #c97a10; }
.chip-no    { background: #fde8e8; color: #c0392b; }

.participant-comment {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 400;
  margin-top: 2px;
  max-width: 200px;
}

/* ── Tally rows ─────────────────────────────────────────── */
.tally-row td         { border-top: 3px solid var(--color-border); background: #fafafa; padding: 12px 8px; }
.tally-row:first-of-type td { border-top: 3px solid #d0d0d0; }
.tally-label          { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); padding: 12px 16px; }
.tally-yes            { font-size: 22px; font-weight: 700; color: #237523; }
.tally-maybe          { font-size: 22px; font-weight: 700; color: var(--color-muted); }

/* ── Input row ──────────────────────────────────────────── */
.input-row td         { border-top: 2px solid var(--color-primary); background: #fff; }
.results-table td.input-row .cell-name,
.input-row td.cell-name { padding: 10px 12px; }

.name-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  transition: border-color .15s;
}
.name-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}
.name-input[aria-invalid] { border-color: #c0392b; }
.field-error { display: block; color: #c0392b; font-size: 12px; margin-top: 3px; }

.cell-input { padding: 8px 4px; }

/* ── Vote toggle (3 icons per cell) ─────────────────────── */
.vote-toggle {
  display: flex;
  gap: 3px;
  justify-content: center;
  align-items: center;
}

.vt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  background: #f0f0f0;
  color: #bbb;
  transition: background .12s, color .12s, transform .1s;
  user-select: none;
}
.vt input[type="radio"] { display: none; }

.vt:hover { transform: scale(1.15); }

/* Selected states via :has() */
.vt-yes:has(input:checked)   { background: #d6f0d6; color: #237523; }
.vt-maybe:has(input:checked) { background: #fef0d4; color: #c97a10; }
.vt-no:has(input:checked)    { background: #fde8e8; color: #c0392b; }

/* ── Form footer ────────────────────────────────────────── */
.comment-input {
  width: 100%;
  margin-top: 6px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--color-text);
  background: #f8f8f8;
  resize: vertical;
  transition: border-color .15s, background .15s;
  display: block;
}
.comment-input:focus {
  outline: none;
  border-color: var(--color-navy);
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-navy) 10%, transparent);
}

.form-footer {
  margin-top: 0;
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

.btn-submit {
  display: block;
  width: 100%;
  text-align: center;
  border-radius: 0;
  padding: 13px;
  font-size: 15px;
}

/* ── Button ─────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 24px;
  border: none;
  border-radius: 3px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: .02em;
  transition: background .15s, box-shadow .15s;
}
.btn-primary {
  background: var(--color-navy);
  color: #fff;
}
.btn-primary:hover {
  background: #0f1f2e;
  background: color-mix(in srgb, var(--color-navy) 85%, black);
  box-shadow: 0 2px 8px rgba(31, 48, 65, 0.3);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--color-navy) 30%, transparent);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  .container     { padding: 0 16px; }
  main.container { padding-top: 28px; padding-bottom: 48px; }
  .poll-title    { font-size: 22px; }
  .comment-input { max-width: 100%; }
  .col-option, .cell-vote { min-width: 80px; width: 80px; }
  .tally-yes, .tally-maybe { font-size: 18px; }
  .col-name,
  .results-table td.cell-name,
  .results-table th.col-name { min-width: 110px; padding: 10px 12px; }
  .form-footer   { flex-direction: column; }
  .btn           { width: 100%; text-align: center; }

  /* iOS: prevent auto-zoom on input focus (requires font-size >= 16px) */
  .name-input    { font-size: 16px; }
  .comment-input { font-size: 16px; }

  /* Larger touch targets for vote toggles */
  .vt {
    width: 36px; height: 36px;
    font-size: 15px;
  }
  .chip { width: 30px; height: 30px; font-size: 13px; }
  .vote-toggle { gap: 4px; }
}


/* Info Page */
.info-page {
  max-width: 480px;
  margin: 80px auto;
  text-align: center;
}
.info-page h1 { margin-bottom: 16px; }
.info-page p { color: var(--color-muted); margin-bottom: 8px; }
