@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Oswald:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #0c0b0a;
  --paper: #f5f0e8;
  --accent: #8b2500;
  --accent-glow: #c0392b;
  --gold: #b8860b;
  --muted: #6b6356;
  --card-bg: rgba(245, 240, 232, 0.04);
  --card-border: rgba(245, 240, 232, 0.08);
}

body {
  font-family: 'EB Garamond', Georgia, serif;
  line-height: 1.7;
  color: var(--paper);
  background: var(--bg);
  min-height: 100vh;
}

/* Subtle noise texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

header {
  position: relative;
  z-index: 1;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--card-border);
}

header nav a {
  text-decoration: none;
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s;
}

header nav a:hover { color: var(--paper); }

main {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

/* --- Index page --- */

.index-header {
  text-align: center;
  margin-bottom: 3rem;
}

.index-header h1 {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.category { margin-bottom: 3rem; }

.category h2 {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.survey-grid {
  display: grid;
  gap: 1rem;
}

.survey-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 2px;
  padding: 1.75rem 2rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.3s, background 0.3s;
}

.survey-card:hover {
  border-color: rgba(245, 240, 232, 0.15);
  background: rgba(245, 240, 232, 0.06);
}

.survey-card h3 {
  font-family: 'EB Garamond', serif;
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.survey-card p {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.meta {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Survey page --- */

#survey-app {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Intro */
#intro {
  text-align: center;
  animation: fadeUp 0.6s ease-out;
}

#intro .eyebrow {
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

#intro h1 {
  font-family: 'EB Garamond', serif;
  font-size: 2.5rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

#intro .subtitle {
  font-style: italic;
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

#intro .description {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 480px;
  margin: 0 auto 2rem;
  white-space: pre-line;
}

#intro .description a {
  color: var(--paper);
  text-decoration-color: var(--muted);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.3s;
}

#intro .description a:hover {
  text-decoration-color: var(--paper);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.8rem 2rem;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--paper);
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s;
}

.btn:hover {
  border-color: var(--paper);
}

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

.btn.primary:hover {
  background: var(--accent);
  color: var(--paper);
}

.btn.last-result {
  display: block;
  margin: 1rem auto 0;
  padding: 0.6rem 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-color: var(--card-border);
}

.btn.last-result:hover {
  color: var(--paper);
  border-color: var(--paper);
}

/* Progress bar */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--accent-glow);
  transition: width 0.4s ease;
  z-index: 100;
}

/* Question area */
#question-area {
  text-align: center;
  animation: fadeUp 0.4s ease-out;
}

.question-counter {
  font-family: 'Oswald', sans-serif;
  font-size: 4rem;
  font-weight: 700;
  color: rgba(245, 240, 232, 0.06);
  line-height: 1;
  margin-bottom: 1rem;
}

.question-meta {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

#question-text {
  font-family: 'EB Garamond', serif;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.5;
  margin-bottom: 2.5rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

#options {
  display: flex;
  justify-content: center;
  gap: 1rem;
}


.btn.option {
  min-width: 140px;
  border-color: var(--card-border);
  transition: all 0.3s;
}

.btn.option.agree:hover {
  border-color: var(--accent-glow);
  color: var(--accent-glow);
}

.btn.option.disagree:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn.option.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

.btn.option:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn.back {
  margin-top: 2rem;
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-color: transparent;
}

.btn.back:hover {
  color: var(--paper);
  border-color: var(--card-border);
}

/* Image questions */
.image-question {
  position: relative;
  display: inline-block;
  user-select: none;
}

.question-image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 4px;
  display: block;
}

.image-region {
  position: absolute;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 3px;
  transition: border-color 0.2s, background 0.2s;
}

.image-region:hover {
  border-color: var(--accent-glow);
  background: rgba(192, 57, 43, 0.15);
}

.image-region.selected {
  border-color: var(--accent-glow);
  background: rgba(192, 57, 43, 0.25);
}

.image-region.disabled {
  pointer-events: none;
}

/* Demographics area */
#demographics-area {
  text-align: center;
  animation: fadeUp 0.6s ease-out;
}

#demographics-area h2 {
  font-family: 'EB Garamond', serif;
  font-size: 1.8rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.demo-subtitle {
  color: var(--muted);
  font-size: 1rem;
  max-width: 420px;
  margin: 0 auto 2rem;
}

.demo-fields {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.demo-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.demo-field label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.demo-field input,
.demo-field select {
  background: rgba(245, 240, 232, 0.04);
  border: 1px solid var(--card-border);
  color: var(--paper);
  font-family: 'EB Garamond', serif;
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 2px;
  min-width: 140px;
}

.demo-field input:focus,
.demo-field select:focus {
  outline: none;
  border-color: var(--muted);
}

.demo-field select option {
  background: var(--bg);
  color: var(--paper);
}

.demo-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* Results area */
#results-area {
  text-align: center;
  animation: fadeUp 0.6s ease-out;
}

.score-ring {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 2rem;
}

.score-ring svg {
  transform: rotate(-90deg);
  width: 180px;
  height: 180px;
}

.score-ring .track {
  fill: none;
  stroke: rgba(245, 240, 232, 0.06);
  stroke-width: 4;
}

.score-ring .fill {
  fill: none;
  stroke: var(--accent-glow);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 502;
  stroke-dashoffset: 502;
  transition: stroke-dashoffset 1.5s ease-out;
}

.score-ring .pct-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: 2.5rem;
  font-weight: 600;
}

.result-label {
  font-family: 'EB Garamond', serif;
  font-size: 1.8rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.result-description {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.result-stat {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2rem;
}

.result-attribution {
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 2.5rem;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Aggregates */
#aggregates {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--card-border);
}

#aggregates h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.bar-label {
  min-width: 140px;
  font-size: 0.9rem;
  text-align: right;
  color: var(--muted);
}

.bar-track {
  flex: 1;
  height: 6px;
  background: rgba(245, 240, 232, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent-glow);
  border-radius: 3px;
  transition: width 0.8s ease-out;
}

.bar-pct {
  min-width: 40px;
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Histogram */
.histogram {
  position: relative;
  margin-top: 1rem;
}

.hist-bars {
  position: relative;
  height: 140px;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--card-border);
}

.hist-bar {
  position: absolute;
  bottom: 0;
  border-radius: 2px 2px 0 0;
  transition: height 0.8s ease-out;
  /* small gap between bars */
  box-sizing: border-box;
  border-left: 1px solid var(--bg);
  border-right: 1px solid var(--bg);
}

.hist-axis {
  position: relative;
  height: 1.5rem;
  margin-top: 0.25rem;
}

.hist-label {
  position: absolute;
  transform: translateX(-50%);
  font-family: 'Oswald', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.hist-marker {
  position: absolute;
  bottom: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
}

.hist-marker-line {
  position: absolute;
  top: 0;
  bottom: 1.75rem;
  width: 2px;
  background: var(--paper);
  transform: translateX(-1px);
}

.hist-marker-label {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  font-family: 'Oswald', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper);
}

/* Stats table */
.stats-table {
  margin: 2rem auto 0;
  border-collapse: collapse;
  font-size: 0.9rem;
  color: var(--muted);
}

.stats-table td {
  padding: 0.3rem 1rem;
  border-bottom: 1px solid var(--card-border);
}

.stats-table td:first-child {
  text-align: right;
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stats-table td:last-child {
  text-align: left;
  font-family: 'EB Garamond', serif;
}

/* Visitor history */
.visitor-history {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--card-border);
}

.visitor-history h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  color: var(--muted);
}

.history-table th {
  font-family: 'Oswald', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--card-border);
}

.history-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--card-border);
  font-family: 'EB Garamond', serif;
}

/* Footer / Visitor ID */
footer {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 3rem auto 1rem;
  padding: 0 2rem 1rem;
  text-align: center;
}

.visitor-id-section {
  display: inline-block;
}

.visitor-id-label {
  display: block;
  font-family: 'Oswald', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.2);
  margin-bottom: 0.3rem;
}

.vid-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

#vid-input {
  background: rgba(245, 240, 232, 0.04);
  border: 1px solid rgba(245, 240, 232, 0.08);
  color: rgba(245, 240, 232, 0.3);
  font-family: monospace;
  font-size: 0.7rem;
  padding: 0.3rem 0.5rem;
  border-radius: 2px;
  width: 280px;
}

#vid-input:focus {
  outline: none;
  border-color: var(--muted);
  color: var(--paper);
}

.btn.vid-save {
  padding: 0.3rem 0.75rem;
  font-size: 0.6rem;
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s ease-in;
}

/* Big Five results */
.big5-results {
  text-align: left;
  max-width: 520px;
  margin: 2rem auto;
}

.big5-domain {
  margin-bottom: 1.75rem;
}

.big5-domain-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}

.big5-domain-name {
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.big5-domain-pct {
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
}

.big5-bar-track {
  height: 8px;
  background: rgba(245, 240, 232, 0.06);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.big5-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 1.2s ease-out;
}

.big5-bar-fill.big5-high { background: var(--accent-glow); }
.big5-bar-fill.big5-low { background: var(--gold); }
.big5-bar-fill.big5-avg { background: var(--muted); }

.big5-facets {
  padding-left: 0.5rem;
  border-left: 1px solid var(--card-border);
  margin-left: 0.25rem;
}

.big5-facet {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.big5-facet-name {
  min-width: 140px;
  font-size: 0.85rem;
  color: var(--muted);
}

.big5-facet-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(245, 240, 232, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.big5-facet-bar-fill {
  height: 100%;
  width: 0%;
  background: rgba(245, 240, 232, 0.3);
  border-radius: 2px;
  transition: width 1.2s ease-out;
}

.norm-pctile {
  display: inline-block;
  border-radius: 2px;
  padding: 0.1rem 0.4rem;
  font-family: 'Oswald', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-left: 0.3rem;
  cursor: help;
}

.norm-ref {
  background: rgba(245, 240, 232, 0.08);
  border: 1px solid var(--card-border);
}

.norm-site {
  background: rgba(139, 35, 0, 0.15);
  border: 1px solid rgba(192, 57, 43, 0.3);
}

.big5-section-title {
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.big5-facet-pct {
  min-width: 32px;
  text-align: right;
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  color: var(--muted);
}

/* Likert scale — ordered gradient buttons */
.likert-options {
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 420px;
  margin: 0 auto;
}

.likert-options .btn.option {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: auto;
  padding: 0.7rem 1rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  border-radius: 0;
  border-bottom: none;
  text-align: left;
  justify-content: flex-start;
  gap: 0.75rem;
}

.likert-options .btn.option:first-child {
  border-radius: 3px 3px 0 0;
}

.likert-options .btn.option:last-child {
  border-radius: 0 0 3px 3px;
  border-bottom: 1px solid var(--card-border);
}

.likert-options .btn.option .likert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.likert-options .btn.option:hover {
  background: rgba(245, 240, 232, 0.06);
}

.likert-options .btn.option.selected {
  background: rgba(245, 240, 232, 0.1);
  border-color: var(--paper);
}

/* Likert color scale: red (disagree) → neutral → green (agree) */
.likert-dot.l-1 { background: #c0392b; }
.likert-dot.l-2 { background: #b8640b; }
.likert-dot.l-3 { background: #8b7355; }
.likert-dot.l-4 { background: #6b8b55; }
.likert-dot.l-5 { background: #4a8b3b; }
.likert-dot.l-6 { background: #2d8b2d; }

/* Responsive */
@media (max-width: 480px) {
  main { padding: 2rem 1.25rem; }
  #intro h1 { font-size: 2rem; }
  #question-text { font-size: 1.25rem; }
  .question-counter { font-size: 3rem; }
  #options { flex-direction: column; align-items: center; }
  .btn.option { width: 100%; max-width: 280px; }
  .bar-label { min-width: 100px; font-size: 0.8rem; }
}
