/* ===== Custom Properties ===== */
:root {
  --bg: #f4f1eb;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --text-secondary: #6b6459;
  --accent: #c0713a;
  --exit-color: #3a7a8c;
  --voice-color: #8c3a3a;
  --border: #e0dbd3;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ===== Nav ===== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }

/* Hamburger (CSS-only) */
.nav-toggle { display: none; }
.nav-toggle-label {
  display: none;
  cursor: pointer;
  width: 28px;
  height: 20px;
  position: relative;
}
.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  position: absolute;
  transition: transform 0.2s;
}
.nav-toggle-label span { top: 9px; }
.nav-toggle-label span::before { content: ''; top: -7px; }
.nav-toggle-label span::after { content: ''; top: 7px; }
.nav-toggle:checked + .nav-toggle-label span { background: transparent; }
.nav-toggle:checked + .nav-toggle-label span::before { top: 0; transform: rotate(45deg); }
.nav-toggle:checked + .nav-toggle-label span::after { top: 0; transform: rotate(-45deg); }

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }

/* Dropdown */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 160px;
  padding: 0.5rem 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  z-index: 10;
}
.nav-dropdown:hover .nav-dropdown-content { display: block; }
.nav-dropdown-content a {
  display: block;
  padding: 0.4rem 1rem;
  color: var(--text);
  font-size: 0.85rem;
}
.nav-dropdown-content a:hover { background: var(--bg); }

.dropdown-exit, .dropdown-voice {
  padding: 0.3rem 1rem 0.15rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dropdown-exit { color: var(--exit-color); }
.dropdown-voice { color: var(--voice-color); }

/* ===== Main Content ===== */
.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

/* ===== Typography ===== */
h1 { font-size: 2rem; line-height: 1.2; margin-bottom: 0.5rem; }
h2 { font-size: 1.4rem; line-height: 1.3; margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  font-family: var(--font);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #a8622f; color: #fff; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; font-weight: 500; }

.intro-subtext { font-size: 1.1rem; color: var(--secondary-text); margin: 0.5rem 0 1.5rem; }

.intro-primary { margin-bottom: 2rem; }

.btn-large { padding: 1rem 2.5rem; font-size: 1.1rem; }

.intro-name-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.name-input {
  flex: 1 1 200px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
}
.name-input:focus { border-color: var(--accent); }

/* Access status on returning-user intro */
.intro-access-status { margin-bottom: 1.25rem; }
.access-ok  { font-size: 0.9rem; color: #3a7a5a; }
.access-warn { font-size: 0.9rem; color: #8c5a3a; }

/* Notice on first-visit intro */
.access-notice {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: #f0ece4;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Paywall */
.paywall-inner { max-width: 480px; }
.paywall-subtext { color: var(--text-secondary); margin: 0.4rem 0 1.25rem; }
.paywall-error {
  padding: 0.6rem 1rem;
  background: #fdf0ec;
  border-left: 3px solid #c0513a;
  border-radius: 4px;
  font-size: 0.9rem;
  color: #c0513a;
  margin-bottom: 1rem;
}
.paywall-label { font-weight: 600; font-size: 0.9rem; display: block; margin-bottom: 0.25rem; }
.paywall-hint  { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.6rem; }
.paywall-input-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.paywall-input-row .name-input { flex: 1 1 200px; }
.paywall-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.paywall-divider::before,
.paywall-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.paywall-buy-btn { width: 100%; text-align: center; }
.paywall-fine { font-size: 0.82rem; color: var(--text-secondary); margin-top: 1rem; }

.result-access-notice {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: #f0ece4;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.result-access-notice p { margin-bottom: 0.5rem; }
.result-access-notice p:last-child { margin-bottom: 0; }

.history-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.history-count { font-size: 0.9rem; color: var(--secondary-text); flex: 1 1 auto; }

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 2rem 0 1.5rem;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.hero .subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

/* ===== Archetype Card Grid ===== */
.archetype-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}
.archetype-section-title.exit { color: var(--exit-color); border-color: var(--exit-color); }
.archetype-section-title.voice { color: var(--voice-color); border-color: var(--voice-color); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1rem;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card a { color: var(--text); font-weight: 600; font-size: 0.95rem; }
.card a:hover { color: var(--accent); text-decoration: none; }
.card img {
  width: 80px;
  height: auto;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
}

/* ===== Diagram Image ===== */
.diagram {
  max-width: 500px;
  margin: 1.5rem auto;
}

/* ===== Archetype Profile Pages ===== */
.archetype-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.archetype-header h1 { margin-bottom: 0; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
}
.badge-exit { background: var(--exit-color); color: #fff; }
.badge-voice { background: var(--voice-color); color: #fff; }

.archetype-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.archetype-images img {
  width: 100%;
  border-radius: 8px;
}

.archetype-meta {
  list-style: none;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  padding-top: 1rem;
}
.archetype-meta li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.archetype-meta li strong {
  color: var(--text);
  font-weight: 600;
}

.archetype-cta {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ===== Test Page ===== */
.test-container {
  max-width: 600px;
  margin: 0 auto;
}

.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.question-prompt {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.choice-btn {
  display: block;
  width: 100%;
  padding: 1rem 1.25rem;
  margin: 0.5rem 0;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  line-height: 1.5;
  font-family: var(--font);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.choice-btn:hover {
  border-color: var(--accent);
  background: #fdf9f5;
}
.choice-btn:active {
  background: #f5ede4;
}

.back-btn {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: var(--font);
  transition: border-color 0.15s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Results ===== */
.results-section { text-align: center; }
.results-section h2 { margin-top: 0; }

.result-archetype-icon {
  width: 120px;
  height: auto;
  border-radius: 50%;
  display: inline-block;
}
#result-icon { margin-bottom: 0.5rem; }
#result-icon .result-archetype-icon + .result-archetype-icon { margin-left: 1rem; }

.archetype-result-name {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0.5rem 0;
}

.ev-bias-text {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0.75rem 0;
}
.ev-bias-text .badge {
  vertical-align: middle;
  margin-right: 0.4rem;
}

.result-links {
  margin: 1rem 0 2rem;
}
.result-links a {
  font-weight: 600;
}

.score-bars {
  text-align: left;
  margin: 1.5rem 0;
}
.score-bar-row {
  margin-bottom: 0.75rem;
}
.score-bar-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: space-between;
}
.score-bar-track {
  background: var(--border);
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
}
.score-bar-value {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.score-bar-value.exit-bar { background: var(--exit-color); }
.score-bar-value.voice-bar { background: var(--voice-color); }
.score-bar-value.ethics-bar { background: var(--accent); }

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

/* ===== History Page ===== */
.history-page { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem; }

.history-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.history-page-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 0.25rem; }
.history-page-actions { display: flex; gap: 0.5rem; align-items: center; padding-top: 0.25rem; }

.history-empty { text-align: center; padding: 3rem 0; color: var(--text-secondary); }

.history-entry {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.history-entry-header { margin-bottom: 1rem; }
.history-entry-meta {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.4rem;
}
.history-entry-num { font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); }
.history-entry-date { font-size: 0.85rem; color: var(--text-secondary); }
.history-entry-archetype { font-size: 1.1rem; font-weight: 600; }
.history-archetype-name { margin-right: 0.4rem; }

.history-score-bars { display: flex; flex-direction: column; gap: 0.35rem; }
.history-score-row {
  display: grid;
  grid-template-columns: 140px 1fr 2rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}
.history-score-label { color: var(--text-secondary); }
.history-score-track {
  background: var(--bg);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
}
.history-score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.history-score-val { color: var(--text-secondary); text-align: right; }

/* Continuous position display in history entries */
.history-position {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}
.history-pos-label { color: var(--text-secondary); }
.history-pos-track { background: var(--bg); border-radius: 3px; height: 8px; overflow: hidden; position: relative; }
.history-pos-fill { height: 100%; background: linear-gradient(to right, var(--voice-color), var(--exit-color)); border-radius: 3px; }
.history-pos-labels { display: flex; justify-content: space-between; font-size: 0.75rem; width: 2.5rem; }
.voice-label { color: var(--voice-color); }
.exit-label  { color: var(--exit-color); }

.history-ethics-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}
.history-ethics-seg { height: 100%; }
.ethics-virtue { background: #5a8a6a; }
.ethics-conseq { background: #8a6a3a; }
.ethics-deont  { background: #3a6a8a; }

.history-ethics-legend {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.ethics-virtue-dot { color: #5a8a6a; }
.ethics-conseq-dot { color: #8a6a3a; }
.ethics-deont-dot  { color: #3a6a8a; }
.version-tag { font-size: 0.75rem; color: var(--text-secondary); opacity: 0.6; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 44, 44, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1.5rem;
}
.modal-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 2rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-question {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}
.modal-actions { display: flex; flex-direction: column; gap: 0.6rem; }
.modal-actions .btn { text-align: center; }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  max-width: 720px;
  margin: 0 auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav-toggle-label { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem 1.5rem;
    gap: 0;
  }
  .nav-links li { padding: 0.5rem 0; }
  .nav-toggle:checked ~ .nav-links { display: flex; }
  .nav-dropdown-content {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: 1rem;
  }
  .nav-dropdown:hover .nav-dropdown-content { display: none; }
  .nav-dropdown.open .nav-dropdown-content { display: block; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 2rem; }
}

/* ===== Model Grid (understand.html) ===== */
.model-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.model-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.model-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.model-table td {
  border: 1px solid var(--border);
  padding: 0.6rem;
  text-align: center;
  vertical-align: top;
  font-size: 0.85rem;
  line-height: 1.4;
}

.model-table td em {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.model-table td.q1 { background: #eef6f0; }
.model-table td.q2 { background: #f0f4f8; }
.model-table td.q3 { background: #f5f2ed; }
.model-table td.q4 { background: #fdf5ee; }

@media (max-width: 768px) {
  .model-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .content { padding: 1.5rem 1rem 2rem; }
  .card-grid { grid-template-columns: 1fr; }
  .archetype-images { grid-template-columns: 1fr; }
  .archetype-images img { max-width: 250px; margin: 0 auto; }
  h1 { font-size: 1.6rem; }
  .hero h1 { font-size: 1.8rem; }
  .archetype-result-name { font-size: 1.4rem; }
}
