/* Page styles: study-hub. Scoped under <main class="page">. */
.page {
  --bg: #0E1320;
  --panel: #171E2E;
  --panel-2: #1B2335;
  --edge: #232C40;
  --text: #E6EAF2;
  --body: #B4BDCD;
  --muted: #8D97AB;
  --t: #4FC3F7;   /* people */
  --e: #FFC247;   /* Education color, events */
  --m: #B794FF;   /* ideas & movements */
  --ok: #5BD69A;  /* studied */
  --radius: 12px;
}
.page {
  background: var(--bg);
  color: var(--body);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
:where(.page) a { color: inherit; }
:where(.page) :focus-visible { outline: 2px solid var(--e); outline-offset: 2px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px 20px 20px; }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; gap: 12px 24px; margin-bottom: 14px; flex-wrap: wrap; }
.title { display: flex; align-items: center; gap: 12px; }
.flap {
  position: relative; width: 40px; height: 48px; border-radius: 8px;
  background: linear-gradient(180deg, #1B2335 0%, var(--panel) 50%, #141A28 50%, #121827 100%);
  border: 1px solid var(--edge); display: grid; place-items: center;
}
.flap::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0,0,0,0.6); }
.flap span { color: var(--e); font-weight: 900; font-size: 34px; line-height: 1; }
.crumb { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 2px; }
.title h1 { color: var(--text); font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }

.progress { margin-left: auto; min-width: 220px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.progress-label strong { color: var(--text); font-weight: 600; }
.progress-bar { height: 6px; background: var(--panel); border: 1px solid var(--edge); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .3s ease; }

/* ---------- Filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius);
}
.search { position: relative; flex: 1 1 220px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
input[type="search"], select {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--edge); border-radius: 8px;
  height: 34px;
}
input[type="search"] { width: 100%; padding: 0 10px 0 32px; }
input[type="search"]::placeholder { color: var(--muted); }
select {
  padding: 0 30px 0 10px; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
input[type="search"]:hover, select:hover { border-color: #33405C; }
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg); border: 1px solid var(--edge); border-radius: 8px; height: 34px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  background: transparent; border: 0; border-radius: 6px; padding: 0 10px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.seg button[data-cat="people"][aria-pressed="true"] { color: var(--t); }
.seg button[data-cat="events"][aria-pressed="true"] { color: var(--e); }
.seg button[data-cat="ideas & movements"][aria-pressed="true"] { color: var(--m); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.range { color: var(--muted); }
.range strong { color: var(--text); font-weight: 600; }
.spacer { flex: 1; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); background: transparent;
  border: 1px solid var(--edge); border-radius: 8px;
  height: 30px; padding: 0 12px; cursor: pointer; white-space: nowrap;
  transition: border-color .2s ease;
}
.btn:hover:not(:disabled) { border-color: var(--e); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.link { border-color: transparent; color: var(--muted); }
.btn.link:hover { color: var(--text); border-color: transparent; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; align-items: start; }
.card {
  --c: var(--muted);
  position: relative;
  display: flex; flex-direction: column;
  min-height: 118px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-top: 3px solid var(--c);
  border-radius: 10px;
  padding: 12px 14px 10px;
  cursor: pointer;
  transition: border-color .2s ease, transform .2s ease, background-color .2s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 50%, var(--edge)); border-top-color: var(--c); }
.card.people { --c: var(--t); }
.card.events { --c: var(--e); }
.card.ideas { --c: var(--m); }
.card.studied { background: color-mix(in srgb, var(--ok) 5%, var(--panel)); }
.card h3 { color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; text-decoration-color: var(--c); }
.meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 999px;
  color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.back { display: none; font-size: 13px; }
.card.flipped .back { display: block; }
.card.flipped .front-hint { display: none; }
.back p { margin-bottom: 6px; }
.back .label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-right: 4px; }
.back a { color: var(--text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--c) 60%, transparent); text-underline-offset: 2px; }
.back a:hover { color: var(--c); }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 6px; }
.front-hint { color: var(--muted); font-size: 11px; }
.study {
  font: inherit; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted); background: transparent;
  border: 1px solid var(--edge); border-radius: 999px;
  padding: 2px 9px 2px 7px; cursor: pointer; margin-left: auto;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.study:hover { border-color: var(--ok); color: var(--text); }
.study .box {
  width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid currentColor;
  display: inline-grid; place-items: center;
}
.study[aria-pressed="true"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.study[aria-pressed="true"] .box { background: var(--ok); border-color: var(--ok); }
.study[aria-pressed="true"] .box::after { content: ""; width: 6px; height: 3px; border-left: 1.5px solid var(--bg); border-bottom: 1.5px solid var(--bg); transform: rotate(-45deg) translate(1px, -1px); }

.empty { grid-column: 1 / -1; text-align: center; padding: 40px 10px; color: var(--muted); border: 1px dashed var(--edge); border-radius: var(--radius); }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.foot a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--edge); }
.foot a:hover { border-color: var(--e); }

@media (prefers-reduced-motion: reduce) {
  .card, .btn, .study, .progress-bar span { transition: none; }
}
@media (max-width: 760px) {
  .progress { margin-left: 0; width: 100%; }
  .filters select { flex: 1 1 140px; }
  .seg { flex: 1 1 100%; }
  .seg button { flex: 1; }
  .hint { display: none; }
  .toolbar { flex-wrap: wrap; row-gap: 6px; }
  .range { flex-basis: 100%; }
  .toolbar .spacer { display: none; }
  .toolbar #reset-btn { margin-right: auto; padding-left: 0; }
}
