/* =====================================================================
   Suara - public participation system
   One stylesheet for the whole app.
   ===================================================================== */

:root {
  --ink:      #17242f;
  --ink-soft: #5a6b78;
  --paper:    #f4f2ec;
  --surface:  #ffffff;
  --line:     #ded8cc;
  --support:  #1f6f5c;
  --oppose:   #b0472f;
  --accent:   #24506b;
  --radius:   6px;
}

* { box-sizing: border-box; }

/* Base size for the whole app. Every other size in this file is in rem,
   so changing this one number scales the entire interface.
   100% = 16px (browser default), 112.5% = 18px, 125% = 20px. */
html { font-size: 112.5%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

h1, h2, h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 .5rem;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

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

/* Page width. Raise this number for a wider layout, lower it for narrower. */
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 1.75rem; }
.page { padding-top: 2.5rem; padding-bottom: 4rem; }
.narrow { max-width: 34rem; margin: 0 auto; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; padding-top: .8rem; padding-bottom: .8rem;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: Georgia, serif; font-size: 1.1rem;
}
.brand-text { font-family: Georgia, serif; font-size: 1.15rem; line-height: 1.1; }
.brand-text em {
  display: block; font-size: .68rem; font-style: normal;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft);
}

.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: .95rem; }
.nav a { text-decoration: none; }
.who { color: var(--ink-soft); font-size: .85rem; line-height: 1.2; text-align: right; }
.who em {
  display: block; font-style: normal; font-size: .68rem;
  text-transform: uppercase; letter-spacing: .07em;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: .45rem .9rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9rem; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; padding: .6rem; }
.btn-primary:hover { background: var(--ink); color: #fff; }
.btn-support { background: var(--support); border-color: var(--support); color: #fff; }
.btn-oppose  { background: var(--oppose);  border-color: var(--oppose);  color: #fff; }
.btn-quiet   { background: transparent; }

/* ---------- cards, forms ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  margin-bottom: 1.5rem;
}

.form label { display: block; margin-bottom: 1rem; font-size: .88rem; color: var(--ink-soft); }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input[type=number], .form input[type=date],
.form select, .form textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .65rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit; font-size: .95rem;
}
.form textarea { min-height: 140px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.opt { font-size: .78rem; color: var(--ink-soft); font-weight: normal; }

.choice { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: 1rem; }
.choice legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); padding: 0 .3rem; }
.radio { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: .6rem; color: var(--ink); }
.radio input { margin-top: .35rem; }
.radio span { font-size: .85rem; color: var(--ink-soft); }
.radio strong { display: block; color: var(--ink); font-size: .95rem; }

/* ---------- messages ---------- */
.flash {
  padding: .7rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  margin-bottom: 1.25rem; font-size: .9rem;
  border-left: 4px solid var(--support);
}
.flash-error { border-left-color: var(--oppose); }

.note { font-size: .88rem; color: var(--ink-soft); }
.lede { color: var(--ink-soft); margin-top: 0; }
.meta { font-size: .85rem; color: var(--ink-soft); margin: .3rem 0; }

/* ---------- listing ---------- */
.hero { margin-bottom: 1.5rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.filters input, .filters select {
  padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: var(--radius); font: inherit; font-size: .9rem; background: #fff;
}
.filters input { flex: 1 1 200px; }

.grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.project h2 { margin: .4rem 0; font-size: 1.15rem; }
.project h2 a { text-decoration: none; }

.tags { display: flex; gap: .4rem; flex-wrap: wrap; }
.tag {
  font-size: .74rem; letter-spacing: .05em; text-transform: uppercase;
  padding: .18rem .45rem; border-radius: 3px;
  background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line);
}
.tag-project    { background: var(--accent);  color: #fff; border-color: var(--accent); }
.tag-initiative { background: var(--support); color: #fff; border-color: var(--support); }

.votes { margin-top: .8rem; }
.bar { height: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--support); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-soft); }

.demo-box { background: #fffdf5; }
.demo-box ul { padding-left: 1.1rem; font-size: .85rem; }
.demo-box code { background: var(--paper); padding: .1rem .3rem; border-radius: 3px; }

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 1.25rem 0; font-size: .82rem; color: var(--ink-soft);
}

@media (max-width: 560px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .who { text-align: left; }
}

/* ---------- submissions table (my_projects.php) ---------- */
.head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.head-row h1 { margin: 0; }

.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; font-size: .95rem;
}
.table th {
  text-align: left; font-size: .76rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-soft);
  padding: .7rem .8rem; border-bottom: 1px solid var(--line); background: var(--paper);
}
.table td { padding: 1rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.meta { white-space: nowrap; }

.row-actions { display: flex; gap: .4rem; align-items: center; white-space: nowrap; }
.row-actions form { margin: 0; }
.btn.danger { color: var(--oppose); }
.btn.danger:hover { border-color: var(--oppose); }
.btn.inline { width: auto; display: inline-block; }

.reject-note {
  margin-top: .35rem; padding-left: .6rem;
  border-left: 3px solid var(--oppose); color: var(--ink-soft);
}

.thumb {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem;
}

.tag-status { background: var(--paper); }

@media (max-width: 640px) {
  .table, .table thead, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .table td { border: 0; padding: .25rem .8rem; }
  .table td.meta { white-space: normal; }
  .row-actions { padding-top: .5rem; }
}

/* ---------- admin ---------- */
.stats {
  display: grid; gap: 1rem; margin-bottom: 2rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem;
}
.stat strong {
  display: block; font-family: Georgia, serif;
  font-size: 2.4rem; line-height: 1.1; color: var(--accent);
}
.stat span { font-size: .82rem; color: var(--ink-soft); }
.stat-link { display: block; margin-top: .4rem; font-size: .8rem; }

.review .desc { white-space: normal; margin: .6rem 0; }
.review-actions {
  border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem;
  display: grid; gap: .8rem;
}
.approve-form, .reject-form {
  display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap;
}
.inline-field { font-size: .78rem; color: var(--ink-soft); margin: 0; }
.inline-field.grow { flex: 1 1 260px; }
.inline-field input {
  display: block; margin-top: .25rem; padding: .45rem .6rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: .9rem; background: #fff; width: 100%;
}

.pills { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.pill {
  padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-soft);
  font-size: .85rem; text-decoration: none;
}
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill-n { opacity: .7; margin-left: .2rem; }

.two-col { display: grid; gap: 1.5rem; grid-template-columns: 1.6fr 1fr; align-items: start; }
.two-col .card h3 { margin-top: 0; }

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
  .approve-form, .reject-form { flex-direction: column; align-items: stretch; }
}

/* ---------- role selector in the users table ---------- */
.role-form { display: flex; gap: .35rem; align-items: center; }
.role-form select {
  padding: .3rem .4rem; border: 1px solid var(--line);
  border-radius: var(--radius); font: inherit; font-size: .85rem; background: #fff;
}

/* ---------- project detail ---------- */
.detail h1 { margin: .5rem 0; }
.detail .desc { white-space: normal; margin: 1rem 0; }
.hero-img {
  display: block; width: 100%; height: auto; max-height: 460px; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--radius); margin: 1rem 0;
}

.tally { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .8rem; }
.bar.big { height: 14px; border-radius: 7px; }
.bar .fill-accent { background: var(--accent); }
.tally-nums { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: baseline; font-size: .9rem; }
.tally-nums strong { font-family: Georgia, serif; font-size: 1.3rem; }

.vote-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.vote-row form { margin: 0; }
.btn.chosen { box-shadow: inset 0 0 0 2px var(--ink); }

/* ---------- progress timeline ---------- */
.timeline { list-style: none; margin: 1rem 0 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.2rem 1rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot {
  position: absolute; left: -1.6rem; top: .35rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}
.timeline p { margin: .3rem 0; }
.update-form { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1.2rem; }
.update-form h3 { margin-top: 0; }

/* ---------- comments ---------- */
.comments { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.comments li {
  border-bottom: 1px solid var(--line); padding: .9rem 0;
}
.comments li:last-child { border-bottom: 0; }
.comments p { margin: .2rem 0; }
.comments form { margin-top: .4rem; }
.hidden-comment { opacity: .55; }

/* ---------- statistics dashboard ---------- */
.chart-grid {
  display: grid; gap: 1.5rem; margin-bottom: 2rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.chart-card { margin-bottom: 0; display: flex; flex-direction: column; }
.chart-card h2 { font-size: 1.05rem; margin-bottom: .2rem; }
.chart-card .note { margin-top: 0; margin-bottom: .8rem; min-height: 2.6em; }
.chart-card.wide { grid-column: 1 / -1; }
/* flex: 1 lets the canvas absorb any leftover card height, so cards in the
   same row stay level without a gap under the shorter chart. */
.chart-box { position: relative; flex: 1 1 auto; min-height: 320px; }
.chart-box.tall { min-height: 400px; }

/* Two columns stay side by side on tablets and phones. Below 480px a chart
   would be too narrow to read its own labels, so it drops to one column. */
@media (max-width: 700px) {
  .chart-box { min-height: 220px; }
  .chart-box.tall { min-height: 260px; }
  .chart-card h2 { font-size: .95rem; }
}
@media (max-width: 480px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-box, .chart-box.tall { min-height: 240px; }
}

/* Ease the base size down on small screens so tables and charts still fit. */
@media (max-width: 560px) {
  html { font-size: 106.25%; }
}
