/*
 * Retro app styles: neutral pastel look, day (light) and night (dark) theme.
 *
 * Theme: without a choice the system setting (prefers-color-scheme) applies;
 * the day/night toggle sets <html data-theme="light|dark"> (theme.js, app.js).
 * All colours are CSS variables defined below; components only use those.
 */

/* ---------- Colours ---------- */

:root {
  color-scheme: light;
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f0eef8;
  --text: #2b2a35;
  --muted: #6a6779;
  --border: #e3e0ee;
  --shadow: 0 1px 2px rgb(43 42 53 / 6%), 0 4px 14px rgb(43 42 53 / 5%);

  --primary: #5b61c4;
  --primary-hover: #4b51b0;
  --primary-soft: #e7e8fb;
  --on-primary: #ffffff;
  --focus: #8b90e8;

  --good: #2e7556;
  --good-soft: #dcf2e7;
  --bad: #a9473f;
  --bad-soft: #fbe2de;
  --idea: #6d4fae;
  --idea-soft: #ece4fa;
  --warn: #8a6214;
  --warn-soft: #fbf0d4;
  --neutral-soft: #ecebf2;

  --theme-icon: "🌙";
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17161e;
  --surface: #211f2b;
  --surface-2: #292734;
  --text: #ebe9f3;
  --muted: #a7a3b8;
  --border: #383547;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);

  --primary: #a2a7f3;
  --primary-hover: #b8bcf7;
  --primary-soft: #2e3055;
  --on-primary: #17182c;
  --focus: #a2a7f3;

  --good: #93dbb9;
  --good-soft: #1e3a2f;
  --bad: #f2aaa0;
  --bad-soft: #452a2a;
  --idea: #c9b5f4;
  --idea-soft: #342b4b;
  --warn: #ecc979;
  --warn-soft: #3d3220;
  --neutral-soft: #2d2b38;

  --theme-icon: "☀️";
}

/* Same dark colours when the system prefers dark and no choice was made. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17161e;
    --surface: #211f2b;
    --surface-2: #292734;
    --text: #ebe9f3;
    --muted: #a7a3b8;
    --border: #383547;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);

    --primary: #a2a7f3;
    --primary-hover: #b8bcf7;
    --primary-soft: #2e3055;
    --on-primary: #17182c;
    --focus: #a2a7f3;

    --good: #93dbb9;
    --good-soft: #1e3a2f;
    --bad: #f2aaa0;
    --bad-soft: #452a2a;
    --idea: #c9b5f4;
    --idea-soft: #342b4b;
    --warn: #ecc979;
    --warn-soft: #3d3220;
    --neutral-soft: #2d2b38;

    --theme-icon: "☀️";
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: var(--primary);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--primary-hover);
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

h2 {
  font-size: 1.25rem;
  font-weight: 650;
  margin-top: 0.25rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 650;
}

p {
  margin: 0 0 0.75rem;
}

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

.container {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem;
}

main.container {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

.muted {
  color: var(--muted);
}

.error {
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-weight: 550;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  text-decoration: none;
  font-size: 0.95rem;
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.page-title h1 {
  margin: 0;
}

/* ---------- Header ---------- */

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

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 750;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--good-soft), var(--idea-soft) 55%, var(--bad-soft));
  color: var(--primary);
  font-size: 1rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
}

.nav-user {
  color: var(--muted);
  font-size: 0.95rem;
}

.theme-toggle {
  min-width: 2.5rem;
  padding: 0.35rem 0.6rem;
}

.theme-toggle::before {
  content: var(--theme-icon);
}

/* ---------- Cards and layout ---------- */

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

.card > :last-child {
  margin-bottom: 0;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

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

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

.list-links li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.list-links li:last-child {
  border-bottom: 0;
}

.list-links a {
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Buttons and forms ---------- */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.55rem 1rem;
  min-height: 2.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button:hover {
  border-color: var(--primary);
  color: var(--text);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: var(--border);
}

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);
  color: var(--on-primary);
}

button.danger {
  background: transparent;
  border-color: var(--bad-soft);
  color: var(--bad);
}

button.danger:hover {
  background: var(--bad-soft);
  border-color: var(--bad);
}

button.small,
.button.small {
  font-size: 0.85rem;
  padding: 0.3rem 0.65rem;
  min-height: 2rem;
}

form.inline {
  display: inline;
}

.form-stack {
  display: grid;
  gap: 0.85rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.95rem;
}

input[type="text"],
input[type="date"],
input[type="number"],
input:not([type]),
select,
textarea {
  font: inherit;
  font-weight: 400;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

input[type="number"] {
  max-width: 7rem;
}

input[type="date"] {
  max-width: 12rem;
}

textarea {
  resize: vertical;
}

.form-row label {
  flex: 0 1 auto;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  font-weight: 650;
  margin-bottom: 0.5rem;
  padding: 0;
}

/* Category choice as pastel "chips". */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.chip input {
  accent-color: var(--primary);
  margin: 0;
}

.chip.good {
  background: var(--good-soft);
  color: var(--good);
}

.chip.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.chip.idea {
  background: var(--idea-soft);
  color: var(--idea);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  background: var(--neutral-soft);
  color: var(--muted);
  white-space: nowrap;
}

.badge strong {
  font-weight: inherit;
}

.badge.collecting,
.badge.open {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.voting,
.badge.in_progress {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.closed,
.badge.done {
  background: var(--good-soft);
  color: var(--good);
}

.badge.cancelled {
  background: var(--neutral-soft);
  color: var(--muted);
  text-decoration: line-through;
}

.badge.good {
  background: var(--good-soft);
  color: var(--good);
}

.badge.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.badge.idea {
  background: var(--idea-soft);
  color: var(--idea);
}

/* ---------- Topics ---------- */

.category {
  border-radius: 14px;
  padding: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.category h3 {
  display: inline-block;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
}

.category.good h3 {
  background: var(--good-soft);
  color: var(--good);
}

.category.bad h3 {
  background: var(--bad-soft);
  color: var(--bad);
}

.category.idea h3 {
  background: var(--idea-soft);
  color: var(--idea);
}

.topics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.topic {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  border-left: 4px solid var(--border);
}

.category.good .topic {
  border-left-color: var(--good);
}

.category.bad .topic {
  border-left-color: var(--bad);
}

.category.idea .topic {
  border-left-color: var(--idea);
}

.topic-text,
.topic-proposal {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.topic-proposal {
  margin-top: 0.35rem;
  font-size: 0.92rem;
}

.topic-actions {
  margin-top: 0.4rem;
}

/* Voting: the whole topic is the click target. */
.vote-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 400;
  cursor: pointer;
}

.vote-option input {
  width: 1.35rem;
  height: 1.35rem;
  margin: 0.1rem 0 0;
  flex: none;
  accent-color: var(--primary);
}

.vote-submit {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
  background: var(--bg);
}

/* Results after the voting. */
.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.result {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.75rem;
}

.result-rank {
  grid-row: span 3;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 750;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
}

.votes-bar {
  appearance: none;
  width: 100%;
  height: 0.55rem;
  border: 0;
  border-radius: 999px;
  background: var(--neutral-soft);
  overflow: hidden;
}

.votes-bar::-webkit-progress-bar {
  background: var(--neutral-soft);
  border-radius: 999px;
}

.votes-bar::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

.votes-bar::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

/* ---------- Status panel on the retro page ---------- */

.status-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.92rem;
}

.notice {
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  background: var(--primary-soft);
  color: var(--text);
}

.notice.good {
  background: var(--good-soft);
}

/* ---------- Tables (cards on narrow screens) ---------- */

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 650;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.cell-actions {
  white-space: nowrap;
}

.cell-actions > * {
  margin: 0.1rem 0.15rem;
}

.status-form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.status-form select {
  width: auto;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
}

/* ---------- Login ---------- */

.hero {
  max-width: 32rem;
  margin: 3rem auto;
  text-align: center;
}

.hero .brand-mark {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.75rem;
  border-radius: 16px;
  margin-bottom: 1rem;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 720px) {
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  h1 {
    font-size: 1.45rem;
  }

  /* Header: brand on the first row, links and the toggle on the second. */
  .nav-user {
    display: none;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
  }

  .card {
    padding: 0.95rem 1rem;
    border-radius: 12px;
  }

  /* Tables become one card per row; td[data-label] names the value. */
  .responsive-table thead {
    display: none;
  }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--surface-2);
  }

  .responsive-table td {
    border: 0;
    padding: 0.3rem 0;
  }

  .responsive-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 650;
  }

  .cell-actions {
    white-space: normal;
  }

  button,
  .button {
    min-height: 2.75rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  .button,
  a {
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  }
}
