/* Perse Learning Interactives — site styles
   Palette taken from The Perse School brand purple (#5C338E). */

:root {
  --purple: #5c338e;
  --purple-deep: #3d2160;
  --purple-ink: #2a1a40;
  --purple-soft: #efe9f6;
  --purple-line: #ddd2ea;
  --paper: #faf8f5;
  --card: #ffffff;
  --ink: #23202a;
  --muted: #6d6878;
  --line: #e8e4ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 26, 64, .05), 0 8px 24px rgba(42, 26, 64, .06);
  --shadow-hover: 0 2px 4px rgba(42, 26, 64, .06), 0 14px 34px rgba(42, 26, 64, .12);
  --serif: "Cormorant Garamond", "Garamond", "Georgia", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; border-radius: 4px; }

.wrap { width: min(1120px, 100% - 48px); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.site-header::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: linear-gradient(90deg, var(--purple-deep), var(--purple) 55%, #8a63b8);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px 0 24px;
}
.brand { display: flex; flex-direction: column; color: var(--purple-ink); }
.brand:hover { text-decoration: none; }
.brand-kicker {
  font-size: 12px; letter-spacing: .28em; text-transform: uppercase;
  color: var(--purple); font-weight: 600;
}
.brand-title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(30px, 4.4vw, 46px); line-height: 1.05; letter-spacing: .005em;
}
.crest img { width: 74px; height: auto; }
.crest:hover { text-decoration: none; }

/* ---------- Generic ---------- */
.section { padding: 44px 0 8px; }
.section:last-of-type { padding-bottom: 64px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  margin-bottom: 18px;
}
h1, h2, h3 { font-family: var(--serif); color: var(--purple-ink); font-weight: 600; margin: 0; }
h2 { font-size: 32px; line-height: 1.15; }
h2 .ellipsis { color: var(--purple); }
.lede { max-width: 720px; color: var(--muted); font-size: 18px; margin: 28px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.tag {
  display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 10px; border-radius: 999px;
  background: var(--purple-soft); color: var(--purple-deep);
  white-space: nowrap;
}
.tag.level { background: transparent; border: 1px solid var(--purple-line); color: var(--purple); }
.tag.subtle { background: #f3f1f5; color: var(--muted); font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.empty, .error {
  padding: 28px; border: 1px dashed var(--purple-line); border-radius: var(--radius);
  color: var(--muted); text-align: center; background: var(--card);
}
.error { border-color: #e2b3b3; color: #8a3030; }

/* ---------- Latest list ---------- */
.latest {
  list-style: none; margin: 0; padding: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.latest li + li { border-top: 1px solid var(--line); }
.latest a {
  display: grid; grid-template-columns: 110px 130px minmax(0, 1fr) 24px;
  align-items: center; gap: 16px; padding: 15px 22px; color: inherit;
  transition: background .15s;
}
.latest a:hover { background: #fbf9fd; text-decoration: none; }
.latest .date { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.latest .subject { font-weight: 600; color: var(--purple-deep); }
.latest .title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.latest .name { font-weight: 600; font-size: 17.5px; margin-right: 4px; }
.latest .arrow { color: var(--purple); font-size: 20px; transition: transform .15s; }
.latest a:hover .arrow { transform: translateX(3px); }

.pager { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.pager button {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--purple-line); background: var(--card); color: var(--purple);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.pager button:hover:not(:disabled) { background: var(--purple-soft); }
.pager button:disabled { opacity: .35; cursor: default; }

/* ---------- Subject tiles ---------- */
.tiles {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 150px; padding: 22px 22px 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: inherit; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.tile::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent, var(--purple));
}
.tile::after {
  content: attr(data-initial);
  position: absolute; right: 14px; bottom: -26px;
  font-family: var(--serif); font-size: 120px; font-weight: 600; line-height: 1;
  color: var(--accent, var(--purple)); opacity: .08; pointer-events: none;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); text-decoration: none; }
.tile h3 { font-size: 28px; }
.tile .count { color: var(--muted); font-size: 14.5px; margin-top: 2px; }
.tile .tags { margin-top: 18px; }

/* ---------- Subject page ---------- */
.crumbs { font-size: 14px; color: var(--muted); padding-top: 26px; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 8px; opacity: .6; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.page-title h1 { font-size: clamp(36px, 5vw, 52px); line-height: 1.05; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  margin: 26px 0 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line);
}
.seg { display: inline-flex; background: #f1edf5; border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--purple-deep); box-shadow: 0 1px 3px rgba(42,26,64,.12); }
.toolbar label { font-size: 14px; color: var(--muted); margin-right: 6px; }
.toolbar select {
  font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--purple-line); background: var(--card); color: var(--ink);
}

.topic-group + .topic-group { margin-top: 34px; }
.topic-group > h2 {
  font-size: 26px; margin-bottom: 12px; display: flex; align-items: baseline; gap: 10px;
}
.topic-group > h2 small { font-family: var(--sans); font-size: 13px; color: var(--muted); font-weight: 500; }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card {
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: start;
  padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: inherit; transition: transform .18s, box-shadow .18s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); text-decoration: none; }
.card .thumb { aspect-ratio: 16 / 10; border-radius: 9px; overflow: hidden; background: var(--purple-soft); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card h3 { font-family: var(--sans); font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.card .by { font-size: 13.5px; color: var(--muted); margin: 2px 0 8px; }

/* placeholder thumbnail when no preview image exists */
.ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent, var(--purple)) 0%, var(--purple-deep) 100%);
  color: rgba(255,255,255,.92); font-family: var(--serif); font-weight: 600; font-size: 34px;
}

/* ---------- Interactive detail ---------- */
.detail {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 44px; align-items: start;
  margin-top: 22px; padding: 30px; background: var(--card);
  border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px); box-shadow: var(--shadow);
}
.detail .shot {
  display: block; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 10;
  border: 1px solid var(--line); background: var(--purple-soft); position: relative;
}
.detail .shot img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.detail .shot:hover img { transform: scale(1.02); }
.detail .shot .ph { font-size: 72px; }
.detail .kicker { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--purple); font-weight: 700; }
.detail h1 { font-size: clamp(34px, 4vw, 46px); line-height: 1.05; margin: 6px 0 4px; }
.detail .author { font-family: var(--serif); font-style: italic; font-size: 21px; color: var(--muted); }
.detail .tags { margin: 18px 0 4px; }
.detail .intro p { margin: 14px 0 0; }
.detail h4 { margin: 22px 0 4px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--purple-deep); }
.detail .instructions { white-space: pre-line; color: #45404f; font-size: 16px; }
.detail .meta { margin-top: 22px; font-size: 14px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 26px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--purple); color: #fff; font-weight: 700; font-size: 16.5px; letter-spacing: .01em;
  box-shadow: 0 6px 18px rgba(92, 51, 142, .28);
  transition: background .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: var(--purple-deep); text-decoration: none; transform: translateY(-1px); box-shadow: 0 10px 24px rgba(92, 51, 142, .32); }
.btn.secondary { background: var(--card); color: var(--purple); border: 1px solid var(--purple-line); box-shadow: none; }
.btn.secondary:hover { background: var(--purple-soft); }
.btn.danger { background: #fff; color: #9b2c2c; border: 1px solid #efcaca; box-shadow: none; }
.btn.danger:hover { background: #fdf2f2; }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.open-row { margin-top: 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--purple-ink); color: #cfc4df; margin-top: 40px; }
.site-footer .wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 30px 0; flex-wrap: wrap; }
.site-footer img { height: 64px; width: auto; opacity: .9; }
.site-footer p { margin: 0; font-size: 14px; max-width: 620px; }
.site-footer a { color: #e7defa; }
.site-footer .manage { font-size: 13px; opacity: .55; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .detail { grid-template-columns: 1fr; padding: 20px; gap: 24px; }
  .latest a { grid-template-columns: 1fr 24px; gap: 4px 12px; }
  .latest .date, .latest .subject { grid-column: 1; font-size: 13px; }
  .latest .date { order: -1; }
  .latest .title-line { grid-column: 1; }
  .latest .arrow { grid-column: 2; grid-row: 1 / span 3; }
  .crest img { width: 58px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
