@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=DM+Sans:wght@400;500;600&display=swap");

:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --text: #1a1208;
  --text-muted: #6b6355;
  --above-bg: #fff4ec;
  --above-border: #c45c00;
  --above-text: #7a3800;
  --above-badge: #c41e3a;
  --below-bg: #eef4fb;
  --below-border: #1a5fa8;
  --below-text: #0d3d6e;
  --below-badge: #1a5fa8;
  --accent: #c45c00;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.14);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* Header */
h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 16px;
}

h1 span {
  color: var(--accent);
}

.intro {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 36px;
  max-width: 560px;
}

/* Explainer sections */
h2 {
  font-family: "Playfair Display", serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 28px;
  margin-bottom: 8px;
  color: var(--text);
}

p {
  color: var(--text-muted);
  margin-bottom: 12px;
  font-size: 0.97rem;
}

strong {
  color: var(--text);
  font-weight: 600;
}

#explainer {
  display: none;
}

#explainer.expanded {
  display: block;
}

#toggle-explainer {
  background: none;
  border: none;
  font-family: "DM Sans", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  margin-bottom: 8px;
}

#toggle-explainer:hover {
  opacity: 0.75;
}

.byline {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.byline a {
  color: var(--accent);
  text-decoration: none;
}

.byline a:hover {
  text-decoration: underline;
}

.controls {
  display: flex;
  gap: 12px;
  margin: 16px 0 20px;
  align-items: center;
}

/* Search */
#search {
  display: block;
  flex: 1;
  padding: 14px 18px;
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  border: 2px solid #e0d9d0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#search:focus {
  border-color: var(--accent);
}

#search::placeholder {
  color: #b0a898;
}

#sort {
  padding: 14px 18px;
  flex: 0 0 180px;
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  border: 2px solid #e0d9d0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  color: #b0a898;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b0a898' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* List */
ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Cards */
li {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 5px solid transparent;
  transition:
    box-shadow 0.2s,
    transform 0.15s;
  overflow: hidden;
  user-select: none;
}

li:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

li:active {
  transform: translateY(0);
}

li.above-average {
  background: var(--above-bg);
  border-left-color: var(--above-border);
}

li.below-average {
  background: var(--below-bg);
  border-left-color: var(--below-border);
}

/* Card summary row */
li span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 1rem;
}

li.above-average span {
  color: var(--above-text);
}

li.below-average span {
  color: var(--below-text);
}

li span::after {
  content: "▸";
  font-size: 0.85rem;
  opacity: 0.6;
  transition: transform 0.2s;
}

li.expanded span::after {
  transform: rotate(90deg);
}

/* Expanded content */
li div {
  display: none;
  padding: 0 20px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

li.expanded div {
  display: block;
}

li div p {
  font-size: 0.9rem;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  margin: 0;
}

li div p:last-child {
  border-bottom: none;
}

li.above-average div p {
  color: var(--above-text);
}

li.below-average div p {
  color: var(--below-text);
}

/* Legend */
.legend {
  display: flex;
  gap: 20px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.above {
  background: var(--above-border);
}

.legend-dot.below {
  background: var(--below-border);
}

/* Footer */
footer {
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid #e0d9d0;
}

footer p {
  font-size: 0.78rem;
  color: #a09888;
  margin-bottom: 8px;
  line-height: 1.5;
}

/* Mobile */
@media (max-width: 480px) {
  .container {
    padding: 28px 16px 60px;
  }

  li span {
    padding: 14px 16px;
    font-size: 0.95rem;
  }

  li div {
    padding: 0 16px 14px;
  }
}
