/*
 * Text.vote styles. Plain CSS, no framework, modern browsers only.
 *
 * The palette and metrics intentionally match the Bootstrap 3 defaults the
 * app used to ship, so this is a like-for-like replacement ahead of a redesign.
 *
 * Class vocabulary (everything else is styled by element):
 *   .container                      centered content column
 *   .site-header / .site-footer     chrome around <main>
 *   .flash                          flash message box
 *   .page-header, .actions          page title row with buttons on the right
 *   .section-header                 sub-heading row with something on the right
 *   .panel*, .badge                 boxed sections, small pill label
 *   .table, .number                 data tables, right-aligned numeric cells
 *   .field, .error-message          one labelled form control (+ its error)
 *   .option, .datetime, .auth-form  radio/checkbox row, datetime_select row, narrow auth forms
 *   .form-actions, .form-errors     submit row, error summary
 *   .add-choice                     inline "add a choice" form under the choices table
 *   .results*, .chart*             results bars (HTML) and the votes-over-time line (inline SVG)
 *   .button_to                      Rails button_to form, kept inline
 *   .btn, .btn-{primary,success,warning,danger}
 */

:root {
  --text: #333;
  --muted: #777;
  --link: #428bca;
  --link-hover: #2a6496;
  --border: #ddd;
  --border-light: #eee;
  --surface: #f5f5f5;
  --danger-text: #a94442;
  --danger-bg: #f2dede;
  --danger-border: #ebccd1;
  --info-text: #31708f;
  --info-bg: #d9edf7;
  --info-border: #bce8f1;
  --chart: #428bca;
  --chart-track: #e3eef8;
  --radius: 4px;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.42857;
  color: var(--text);
  background: #fff;
}

a { color: var(--link); text-decoration: none; }
a:hover, a:focus { color: var(--link-hover); text-decoration: underline; }

img { vertical-align: middle; border: 0; }

h1, h2, h3, h4, h5, h6 { font-weight: 500; line-height: 1.1; }
h1, h2, h3 { margin: 20px 0 10px; }
h4, h5, h6 { margin: 10px 0; }
h1 { font-size: 36px; }
h2 { font-size: 30px; }
h3 { font-size: 24px; }
h4 { font-size: 18px; }

p { margin: 0 0 10px; }

button, input, select, textarea { font: inherit; margin: 0; }

label {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 5px;
  font-weight: bold;
}

input[type="radio"], input[type="checkbox"] {
  margin: 4px 0 0;
  line-height: normal;
}

/* Layout ----------------------------------------------------------------- */

.container {
  max-width: 1170px;
  margin-inline: auto;
  padding-inline: 15px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-bottom: 20px;
  background: #f8f8f8;
  border-bottom: 1px solid #e7e7e7;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 50px;
  padding-inline: 0;
}

.site-header ul {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header .account { margin-left: auto; }

.button_to { display: inline-block; }

.site-header :is(a, button) {
  display: block;
  padding: 15px;
  line-height: 20px;
  color: var(--muted);
}

.site-header button {
  background: none;
  border: 0;
  cursor: pointer;
}

.site-header :is(a, button):hover, .site-header :is(a, button):focus {
  color: var(--text);
  text-decoration: none;
}

.site-header .brand { font-size: 18px; }

.site-footer {
  margin-top: .5em;
  text-align: center;
  font-size: smaller;
  font-family: Futura, "Trebuchet MS", Arial, sans-serif;
}

.site-footer img {
  background-color: #313C66;
  vertical-align: top;
  margin-top: .5em;
}

.site-footer span {
  display: inline-block;
  margin-left: 10px;
  text-align: left;
  vertical-align: top;
}

.flash {
  padding: 15px;
  margin-bottom: 20px;
  color: var(--info-text);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 40px 0 9px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.page-header h1, .page-header h2 { margin: 0; }

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Panels & badges -------------------------------------------------------- */

.panel {
  margin-bottom: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
}

.panel-heading {
  padding: 10px 15px;
  color: var(--text);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: 3px 3px 0 0;
}

.panel-title { margin: 0; font-size: 16px; }

.panel-body { padding: 15px; }

.panel-footer {
  padding: 10px 15px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 3px 3px;
}

.panel > .table, .panel > form > .table { margin-bottom: 0; }
.panel .table tr:first-child > * { border-top: 0; }

.panel-danger { border-color: var(--danger-border); }
.panel-danger > .panel-heading {
  color: var(--danger-text);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.badge {
  display: inline-block;
  padding: .2em .6em .3em;
  font-size: 75%;
  font-weight: bold;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
  background: #5bc0de;
  border-radius: .25em;
}

/* Tables ----------------------------------------------------------------- */

.table {
  width: 100%;
  margin-bottom: 20px;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 8px;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--border);
}

.table thead th { vertical-align: bottom; border-bottom: 2px solid var(--border); }
.table thead:first-child tr:first-child > * { border-top: 0; }

.table .number { text-align: right; }

/* Forms ------------------------------------------------------------------ */

.field { margin-bottom: 15px; }

.field > input:not([type="checkbox"], [type="radio"]),
.field > textarea,
.field > select {
  display: block;
  width: 100%;
  padding: 6px 12px;
  color: #555;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.field > input:focus, .field > textarea:focus, .field > select:focus {
  border-color: #66afe9;
  outline: 0;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
}

.field.error .error-message { display: block; color: var(--danger-text); }

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  margin-bottom: 5px;
  font-weight: bold;
}

.option {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  font-weight: normal;
  cursor: pointer;
}

.option input { margin: 0; }

.datetime {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.auth-form { max-width: 420px; }

.form-actions { margin-top: 15px; }

.add-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 20px;
}

.add-choice .field { flex: 1 1 200px; margin-bottom: 0; }

.table .delete {
  padding: 0;
  color: var(--link);
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.table .delete:hover, .table .delete:focus { color: var(--link-hover); text-decoration: underline; }

.form-errors { text-align: center; color: var(--danger-text); }

/* Charts ----------------------------------------------------------------- */

.results {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.results li {
  display: grid;
  grid-template-columns: minmax(8em, 1fr) 4fr auto;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
}

.results-label { overflow-wrap: anywhere; }

/* <progress> keeps the bar width out of inline styles, so the CSP needs no
   style-src exception. The vendor pseudo-elements are how it is styled. */
.results-bar {
  display: block;
  width: 100%;
  height: 20px;
  appearance: none;
  border: 0;
  background: var(--chart-track);
}

.results-bar::-webkit-progress-bar { background: var(--chart-track); }
.results-bar::-webkit-progress-value { background: var(--chart); border-radius: 0 4px 4px 0; }
.results-bar::-moz-progress-bar { background: var(--chart); border-radius: 0 4px 4px 0; }

.results-value {
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart {
  display: block;
  width: 100%;
  max-width: 640px;
  margin-bottom: 20px;
  overflow: visible;
}

.chart-grid { stroke: var(--border-light); stroke-width: 1; }
.chart-area { fill: var(--chart); fill-opacity: .1; }
.chart-line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--chart); stroke: #fff; stroke-width: 2; }
.chart-label { font-size: 11px; fill: var(--muted); }
.chart-label-y, .chart-label-end { text-anchor: end; }

/* Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 6px 12px;
  font-weight: normal;
  line-height: 1.42857;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.btn:hover, .btn:focus { text-decoration: none; }

.btn-primary { color: #fff; background: #428bca; border-color: #357ebd; }
.btn-primary:hover, .btn-primary:focus { color: #fff; background: #3071a9; border-color: #285e8e; }

.btn-success { color: #fff; background: #5cb85c; border-color: #4cae4c; }
.btn-success:hover, .btn-success:focus { color: #fff; background: #449d44; border-color: #398439; }

.btn-warning { color: #fff; background: #f0ad4e; border-color: #eea236; }
.btn-warning:hover, .btn-warning:focus { color: #fff; background: #ec971f; border-color: #d58512; }

.btn-danger { color: #fff; background: #d9534f; border-color: #d43f3a; }
.btn-danger:hover, .btn-danger:focus { color: #fff; background: #c9302c; border-color: #ac2925; }
