/* ---------------------------------------------------------------------------
   Pollke - one small stylesheet, mobile first, no framework, no trackers.
   Layout rules start at phone width; media queries only ever add breathing room.
   --------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f0f2f5;
  --border: #dfe3e8;
  --text: #1b1f24;
  --text-soft: #5b6673;
  --accent: #2f6f62;
  --accent-hover: #24564b;
  --accent-text: #ffffff;
  --accent-soft: #e4efec;
  --yes: #2e7d4f;
  --yes-soft: #e3f3e9;
  --maybe: #a97400;
  --maybe-soft: #fbf0d9;
  --no: #b03b3b;
  --no-soft: #f8e5e5;
  --danger: #b03b3b;
  --heart: #d6334a;
  --best: #2e7d4f;
  --best-text: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1d2126;
    --surface-alt: #262b31;
    --border: #343a42;
    --text: #e8eaed;
    --text-soft: #a3acb7;
    --accent: #6bbfa8;
    --accent-hover: #86d3bd;
    --accent-text: #11201c;
    --accent-soft: #223029;
    --yes: #78c99a;
    --yes-soft: #1f2f26;
    --maybe: #d8b05a;
    --maybe-soft: #312a1b;
    --no: #e08585;
    --no-soft: #342122;
    --danger: #e08585;
    --heart: #f0607a;
    --best: #4fa877;
    --best-text: #0f1f16;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .25rem; }
h2 { font-size: 1.125rem; margin: 2rem 0 .75rem; }
p { margin: 0 0 1rem; }

.muted { color: var(--text-soft); }
.small { font-size: .875rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* --- chrome ---------------------------------------------------------------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.brand {
  font-weight: 650;
  font-size: 1.125rem;
  letter-spacing: -.01em;
  color: var(--text);
  text-decoration: none;
}

.brand span { color: var(--accent); }

.topbar nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .9375rem;
}

main {
  flex: 1;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

main.wide { max-width: 64rem; }

footer {
  border-top: 1px solid var(--border);
  padding: 1rem;
  text-align: center;
  font-size: .8125rem;
  color: var(--text-soft);
}

footer .tagline { margin-top: .5rem; }
footer .credits { margin-top: .25rem; }
footer .heart { color: var(--heart); }

/* --- language switcher ----------------------------------------------------- */

.lang {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .25rem;
}

.lang-label { margin-right: .25rem; }

.lang-btn,
.lang-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 34px;
  padding: 0 .4rem;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  letter-spacing: .02em;
}

.lang-btn {
  border: 1px solid transparent;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.lang-btn:hover { background: var(--surface-alt); border-color: var(--border); }

.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lang-current {
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--accent);
}

/* --- surfaces -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 1rem; }

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-soft);
}

/* --- buttons --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--surface-alt); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/*
  Must restate background and colour: `.btn:hover` above is a two-class selector and therefore
  outranks the one-class `.btn-primary`, so a hover rule that only tweaks a filter would leave the
  button with the plain surface background and unreadable accent-coloured text.
*/
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}

.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--no-soft); }

.btn-small { min-height: 36px; padding: .25rem .625rem; font-size: .875rem; font-weight: 500; }

.btn-block { width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* --- forms ----------------------------------------------------------------- */

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-weight: 550;
  font-size: .9375rem;
  margin-bottom: .3rem;
}

input[type="text"],
input[type="date"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: .5rem .625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea { min-height: 5.5rem; resize: vertical; }

input:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint { font-size: .8125rem; color: var(--text-soft); margin-top: .25rem; }

.validation { color: var(--danger); font-size: .875rem; }

.validation-summary ul { margin: 0; padding-left: 1.1rem; }

.alert {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}

.alert-error { border-left-color: var(--danger); background: var(--no-soft); }

/* --- date list in the create/edit form ------------------------------------- */

.date-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.date-row input { flex: 1; }

.date-remove {
  flex: none;
  min-height: 44px;
  width: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 1.125rem;
  cursor: pointer;
}

.date-remove:hover { background: var(--no-soft); color: var(--danger); }

/* --- the poll grid --------------------------------------------------------- */

.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.grid {
  border-collapse: collapse;
  width: 100%;
  font-size: .9375rem;
}

table.grid th,
table.grid td {
  border-bottom: 1px solid var(--border);
  padding: .5rem .5rem;
  text-align: center;
  white-space: nowrap;
}

table.grid thead th {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: .8125rem;
  line-height: 1.2;
  padding-top: .6rem;
  padding-bottom: .6rem;
}

table.grid th.name-col,
table.grid td.name-col {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 9rem;
  max-width: 12rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

table.grid thead th.name-col { background: var(--surface-alt); z-index: 2; }

table.grid tbody tr:last-child td { border-bottom: none; }

.date-head .dow { display: block; color: var(--text-soft); font-weight: 500; }
.date-head .day { display: block; font-size: 1.0625rem; }
.date-head .mon { display: block; color: var(--text-soft); font-weight: 500; }

.mark { display: inline-block; width: 1.5rem; height: 1.5rem; line-height: 1.5rem; border-radius: 50%; font-size: .875rem; }
.mark-yes { background: var(--yes-soft); color: var(--yes); }
.mark-no { background: var(--no-soft); color: var(--no); }
.mark-maybe { background: var(--maybe-soft); color: var(--maybe); }
.mark-none { color: var(--border); }

.totals td { font-weight: 600; background: var(--surface-alt); }
.totals .count-yes { color: var(--yes); }
.totals .count-maybe { color: var(--maybe); font-weight: 500; font-size: .8125rem; }

/* The date with the most yes answers: the whole header cell turns green, and the total under
   it gets the soft green so the column reads as one. */
table.grid thead th.best { background: var(--best); color: var(--best-text); }
table.grid thead th.best .dow,
table.grid thead th.best .mon { color: inherit; }
.totals td.best { background: var(--yes-soft); }

.you { font-size: .75rem; color: var(--text-soft); font-weight: 500; }

.row-actions { display: block; margin-top: .15rem; }
.row-actions a { font-size: .8125rem; margin-right: .5rem; }

/* --- the vote form --------------------------------------------------------- */

.vote-date {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: .75rem;
  margin-bottom: .625rem;
}

.vote-date-label { font-weight: 600; margin-bottom: .5rem; }
.vote-date-label .muted { font-weight: 450; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: .375rem; }

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  font-size: .9375rem;
  font-weight: 550;
  cursor: pointer;
  user-select: none;
}

.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented input:checked + label.opt-yes { background: var(--yes-soft); border-color: var(--yes); color: var(--yes); }
.segmented input:checked + label.opt-no { background: var(--no-soft); border-color: var(--no); color: var(--no); }
.segmented input:checked + label.opt-maybe { background: var(--maybe-soft); border-color: var(--maybe); color: var(--maybe); }

/* --- share link ------------------------------------------------------------ */

.share { display: flex; gap: .5rem; align-items: stretch; }
.share input { font-size: .875rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* --- lists ----------------------------------------------------------------- */

.poll-list { list-style: none; margin: 0; padding: 0; }

.poll-list li + li { margin-top: .5rem; }

.poll-list a.poll-link {
  display: block;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}

.poll-list a.poll-link:hover { border-color: var(--accent); }

.poll-list .title { font-weight: 600; }

.tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}

@media (min-width: 40rem) {
  h1 { font-size: 1.875rem; }
  main { padding: 2rem 1.5rem 4rem; }
  .segmented { grid-template-columns: repeat(3, minmax(7rem, 1fr)); justify-content: start; }
}
