/* ---------------------------------------------------------------
   The Trolley Index
   --------------------------------------------------------------- */

:root {
  --bg:        #0e1014;
  --bg-2:      #151920;
  --bg-3:      #1c2129;
  --line:      #272d37;
  --line-2:    #343c48;
  --fg:        #e8eaed;
  --fg-2:      #a3abb8;
  --fg-3:      #6d7784;

  --accent:    #f0a840;
  --accent-dk: #c2822a;
  --stay:      #5b9dd9;
  --swerve:    #e0794f;
  --agree:     #4fb87a;
  --disagree:  #d96a6a;

  --radius:    14px;
  --radius-sm: 9px;
  --sidebar-w: 310px;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", monospace;
}

:root[data-theme="light"] {
  --bg:        #faf9f7;
  --bg-2:      #ffffff;
  --bg-3:      #f0eeea;
  --line:      #e0ddd6;
  --line-2:    #cfcbc2;
  --fg:        #1a1d22;
  --fg-2:      #555d68;
  --fg-3:      #868e99;
  --accent:    #b8791a;
  --accent-dk: #8f5d12;
  --stay:      #2f6ea8;
  --swerve:    #c05627;
  --agree:     #2e8355;
  --disagree:  #b34545;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

/* ---------------- layout ---------------- */

#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

#sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

#main {
  padding: 46px 40px 80px;
  display: flex;
  justify-content: center;
}

.view { width: 100%; max-width: 940px; }

/* ---------------- sidebar ---------------- */

.side-head { padding: 26px 22px 18px; border-bottom: 1px solid var(--line); }

.side-head h1 {
  margin: 0;
  font-size: 1.14rem;
  letter-spacing: -0.015em;
  font-weight: 650;
}

.tagline {
  margin: 6px 0 0;
  font-size: 0.79rem;
  color: var(--fg-3);
  line-height: 1.45;
}

.whoami {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.whoami .label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
}

.whoami strong {
  font-family: var(--mono);
  font-size: 0.93rem;
  color: var(--accent);
  font-weight: 600;
}

.side-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.stat {
  padding: 15px 22px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat + .stat { border-left: 1px solid var(--line); }

.stat-val {
  font-family: var(--mono);
  font-size: 1.22rem;
  font-weight: 600;
  line-height: 1;
}

.stat-lab {
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-3);
}

.side-hist {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 0 0;
}

.hist-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 22px 10px;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
}

.linkish {
  background: none;
  border: 0;
  color: var(--fg-3);
  cursor: pointer;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkish:hover { color: var(--fg); }

#history {
  list-style: none;
  margin: 0;
  padding: 0 12px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hist-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  border: 1px solid transparent;
  font-size: 0.78rem;
  animation: slideIn 0.22s ease both;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: none; }
}

.hist-num {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--fg-3);
}

.hist-body { min-width: 0; }

.hist-choice {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}

.hist-sub {
  display: block;
  font-size: 0.68rem;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-mark { font-size: 0.82rem; font-weight: 700; }
.hist-mark.ok  { color: var(--agree); }
.hist-mark.no  { color: var(--disagree); }

#hist-empty { padding: 0 22px; }

/* ---------------- typography ---------------- */

.prose { max-width: 660px; }

.eyebrow {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin: 0 0 12px;
  font-weight: 600;
}

h2 {
  font-size: 1.85rem;
  line-height: 1.22;
  letter-spacing: -0.022em;
  margin: 0 0 20px;
  font-weight: 650;
}

.prose p {
  line-height: 1.66;
  color: var(--fg-2);
  margin: 0 0 16px;
  font-size: 0.97rem;
}

.prose strong { color: var(--fg); font-weight: 600; }

.aside-note {
  border-left: 2px solid var(--line-2);
  padding-left: 16px;
  font-size: 0.87rem !important;
  color: var(--fg-3) !important;
}

.muted { color: var(--fg-3); }
.small { font-size: 0.8rem; line-height: 1.5; }
.privacy { margin-top: 22px; max-width: 480px; }

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

.btn {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.btn:hover { border-color: var(--fg-3); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #15120c;
  font-weight: 650;
}
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }

.cta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
  flex-wrap: wrap;
}

#theme-toggle {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 20;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--fg-2);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
#theme-toggle:hover { color: var(--fg); border-color: var(--fg-3); }

/* ---------------- play view ---------------- */

.play-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.counter {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  white-space: nowrap;
}

.pips { display: flex; gap: 4px; flex-wrap: wrap; }

.pip {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--line-2);
}
.pip.done-ok { background: var(--agree); }
.pip.done-no { background: var(--disagree); }
.pip.current { background: var(--accent); }

.question {
  font-size: 1.5rem;
  margin-bottom: 26px;
}

.options {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: stretch;
}

.versus {
  align-self: center;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-3);
}

.option {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.option:hover:not(:disabled) {
  border-color: var(--fg-3);
  transform: translateY(-2px);
}

#opt-stay:hover:not(:disabled)   { border-color: var(--stay); }
#opt-swerve:hover:not(:disabled) { border-color: var(--swerve); }

.option:disabled { cursor: default; opacity: 0.55; }

.option.picked {
  opacity: 1;
  border-width: 2px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
#opt-stay.picked   { border-color: var(--stay); }
#opt-swerve.picked { border-color: var(--swerve); }

.option.jev-picked::after {
  content: "Jev's choice";
  position: absolute;
}

.opt-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 650;
  color: var(--fg-3);
}
#opt-stay .opt-label   { color: var(--stay); }
#opt-swerve .opt-label { color: var(--swerve); }

.scene {
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scene svg { max-width: 100%; height: auto; display: block; }

.opt-desc {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--fg-2);
}

.tag {
  display: inline-block;
  font-size: 0.66rem;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  color: var(--fg-3);
  margin-top: 6px;
  letter-spacing: 0.03em;
}
.tag.illegal { color: var(--swerve); border-color: color-mix(in srgb, var(--swerve) 45%, transparent); }
.tag.legal   { color: var(--agree);  border-color: color-mix(in srgb, var(--agree) 45%, transparent); }
.tag.inside  { color: var(--stay);   border-color: color-mix(in srgb, var(--stay) 45%, transparent); }

/* ---------------- reveal ---------------- */

.reveal {
  margin-top: 26px;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  animation: rise 0.26s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.reveal-verdict {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 5px 11px;
  border-radius: 20px;
}
.badge.ok { background: color-mix(in srgb, var(--agree) 18%, transparent); color: var(--agree); }
.badge.no { background: color-mix(in srgb, var(--disagree) 18%, transparent); color: var(--disagree); }

.reveal-verdict p { margin: 0; font-size: 0.93rem; color: var(--fg-2); }

.reveal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.rev-cell {
  background: var(--bg-2);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rev-lab {
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-3);
}

.rev-cell strong { font-size: 1rem; font-weight: 600; }

.bar-wrap { margin-bottom: 16px; }

.bar {
  height: 9px;
  border-radius: 6px;
  background: var(--stay);
  overflow: hidden;
  display: flex;
  justify-content: flex-end;
}

.bar-fill {
  height: 100%;
  background: var(--swerve);
  transition: width 0.5s cubic-bezier(.3,.9,.3,1);
}

.bar-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.67rem;
  color: var(--fg-3);
  margin-top: 5px;
  font-family: var(--mono);
}

.rev-note {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--fg-3);
  margin: 0 0 18px;
  padding-left: 14px;
  border-left: 2px solid var(--line-2);
}

/* ---------------- summary ---------------- */

.sum-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 30px;
}

.sum-stat {
  background: var(--bg-2);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sum-stat .v {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
}

.sum-stat .k {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-3);
}

h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-3);
  margin: 30px 0 14px;
  font-weight: 650;
}

.block-row {
  display: grid;
  grid-template-columns: 120px 1fr 44px;
  gap: 12px;
  align-items: center;
  padding: 7px 0;
  font-size: 0.85rem;
}

.block-name { color: var(--fg-2); text-transform: capitalize; }

.block-bar {
  height: 7px;
  border-radius: 5px;
  background: var(--bg-3);
  overflow: hidden;
}

.block-bar span {
  display: block;
  height: 100%;
  background: var(--agree);
  border-radius: 5px;
}

.block-pct { font-family: var(--mono); font-size: 0.78rem; color: var(--fg-2); text-align: right; }

.diverge {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  margin-bottom: 9px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.diverge .d-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  color: var(--fg-3);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.diverge .d-body { color: var(--fg-2); }
.diverge em { color: var(--fg); font-style: normal; font-weight: 600; }

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }

  #sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-hist { max-height: 260px; }
  #main { padding: 30px 16px 60px; }

  .options { grid-template-columns: 1fr; }
  .versus { justify-self: center; padding: 2px 0; }
  h2 { font-size: 1.5rem; }
  .question { font-size: 1.25rem; }
}
