:root {
  --bg: #f5f6f6;
  --surface: #ffffff;
  --ink: #0a1f29;
  --muted: #43545c;
  --line: #d9dfe1;
  --accent: #d20a11;
  --shadow: 0 8px 24px rgba(10, 31, 41, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  border-top: 5px solid var(--accent);
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button, input { font: inherit; }
.site-brand { display: inline-block; }
.site-brand img { display: block; width: 160px; height: auto; }
.site-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.page-shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 48px 0 64px; }
.hero { margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: .13em; font-size: clamp(1rem, 1.6vw, 1.25rem); font-weight: 750; color: var(--accent); }
.hero-row { display: flex; gap: 40px; align-items: end; justify-content: space-between; }
.hero-aside { display: flex; flex-direction: column; align-items: flex-end; gap: 16px; }
.hero h1 { font-size: clamp(2.4rem, 5vw, 5.4rem); letter-spacing: -.045em; line-height: .98; margin: 0; max-width: 850px; }
.intro { max-width: 780px; color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.2rem); line-height: 1.6; margin: 18px 0 0; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(90px, 1fr)); gap: 10px; min-width: 330px; }
.stats div { background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 4px; padding: 16px; }
.stats strong { display: block; font-size: 1.65rem; }
.stats span { color: var(--muted); font-size: .86rem; }

.explorer-card { background: var(--surface); border: 1px solid #e6e9ee; border-radius: 4px; box-shadow: var(--shadow); overflow: hidden; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 24px 18px; border-bottom: 1px solid var(--line); }
.toolbar h2 { margin: 0; font-size: 1.2rem; }
.toolbar p { margin: 5px 0 0; color: var(--muted); font-size: .92rem; }

.view-switcher { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: #f5f7f9; }
.view-button { border: 0; background: transparent; color: #55616e; border-radius: 999px; padding: 9px 14px; cursor: pointer; font-weight: 650; transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.view-button:hover { color: var(--ink); }
.view-button.is-active { background: var(--ink); color: #fff; }

.legend { display: flex; gap: 12px 18px; flex-wrap: wrap; padding: 14px 24px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.legend-item { display: inline-flex; gap: 7px; align-items: center; }
.legend-swatch { width: 11px; height: 11px; border-radius: 50%; }

.visual-layout {
  position: relative;
  min-height: 760px;
  overflow: hidden;
}
.visualisation {
  min-width: 0;
  min-height: 760px;
  position: relative;
  margin-right: 370px;
  background: linear-gradient(#fff, #f5f6f6);
  transition: margin-right .42s cubic-bezier(.2,.75,.25,1), opacity .25s ease;
}
.visualisation svg { display: block; width: 100%; min-height: 760px; height: 100%; }

.details-panel {
  position: absolute;
  inset: 0 0 0 auto;
  width: 370px;
  z-index: 4;
  border-left: 1px solid var(--line);
  padding: 26px;
  overflow: auto;
  background: #fafbfb;
  transition: width .42s cubic-bezier(.2,.75,.25,1), box-shadow .42s ease, background .25s ease;
}
.details-panel.has-project:not(.is-expanded) { cursor: e-resize; }
.details-panel.is-expanded {
  width: calc(100% - 96px);
  cursor: default;
  background: #fff;
  box-shadow: -22px 0 48px rgba(31,48,68,.14);
}
.visual-layout.is-details-expanded .visualisation {
  margin-right: 0;
  cursor: w-resize;
}
.visual-layout.is-details-expanded .visualisation::after {
  content: "←";
  position: absolute;
  left: 28px;
  top: 28px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 5px 16px rgba(31,48,68,.10);
  pointer-events: none;
}
.details-toggle {
  min-height: 44px;
  margin-bottom: 18px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.details-toggle:hover { background: #a6080d; }
.details-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.details-content {
  width: 100%;
  transition: max-width .42s ease;
}
.details-panel.is-expanded .details-content {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 42px 56px;
}
.details-placeholder { color: var(--muted); margin-top: 80px; }
.placeholder-mark { font-size: 2.4rem; color: #b6c0cb; }
.details-panel h3 { margin: 16px 0 16px; font-size: 1.38rem; line-height: 1.22; }
.details-panel p { color: var(--muted); line-height: 1.58; }
.details-identity { display: flex; gap: 13px; align-items: center; }
.student-photo { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; border: 3px solid white; box-shadow: 0 0 0 2px #ccd5df; }
.details-identity > div { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.student-label { font-size: .82rem; font-weight: 750; color: #526171; }
.theme-pill { display: inline-block; border-radius: 999px; padding: 5px 9px; background: #edf1f5; color: #334456; font-size: .76rem; font-weight: 700; }
.partner-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); background: white; border-radius: 13px; }
.partner-card img { width: 70px; height: 42px; object-fit: contain; }
.partner-card div { min-width: 0; }
.partner-card span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 2px; }
.partner-card strong { display: block; font-size: .88rem; overflow-wrap: anywhere; }
.meta-list { display: grid; gap: 12px; margin: 20px 0 24px; }
.meta-row { display: grid; grid-template-columns: 100px 1fr; gap: 10px; }
.meta-row dt { color: var(--muted); }
.meta-row dd { margin: 0; font-weight: 650; }
.description-title { font-size: .88rem; letter-spacing: .04em; text-transform: uppercase; color: #687584; margin: 0 0 8px; }

.cluster-label { font-size: 13px; font-weight: 750; fill: #39495a; pointer-events: none; text-anchor: middle; }
.project-node { cursor: pointer; outline: none; transition: filter .15s ease; }
.node-ring { stroke: white; stroke-width: 3px; transition: stroke-width .14s ease, stroke .14s ease; }
.project-node.is-hovered .node-ring { stroke: #182534; stroke-width: 4px; }
.project-node.is-hovered { filter: drop-shadow(0 6px 8px rgba(25,38,53,.25)); }
.project-node.is-selected .node-ring { stroke: #0f1720; stroke-width: 5px; }
.project-node:focus-visible .node-ring { stroke: #0f1720; stroke-width: 5px; }
.partner-anchor rect { fill: white; stroke: #d7dee6; stroke-width: 1.5; }
.partner-anchor { pointer-events: none; }

.tooltip { position: fixed; pointer-events: none; max-width: 340px; background: rgba(20,27,35,.96); color: white; padding: 10px 12px; border-radius: 10px; font-size: .84rem; line-height: 1.35; opacity: 0; transform: translate(12px, 12px); transition: opacity .12s ease; z-index: 30; box-shadow: 0 10px 25px rgba(0,0,0,.2); }
.tooltip strong { display: block; font-size: .86rem; margin-bottom: 4px; }
.tooltip span { display: block; color: #ccd5df; }
.error { padding: 32px; color: #8b1f1f; font-weight: 650; }

@media (max-width: 1050px) {
  .hero-row { align-items: start; flex-direction: column; }
  .hero-aside, .stats { min-width: 0; width: 100%; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .visual-layout { overflow: visible; }
  .visualisation { margin-right: 0; }
  .details-panel {
    position: relative;
    width: 100%;
    min-height: 300px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .details-panel.is-expanded { width: 100%; box-shadow: none; }
  .details-panel.is-expanded .details-content { padding: 8px 0 28px; }
  .details-panel.is-expanded .student-photo { width: 88px; height: 88px; }
  .details-panel.is-expanded .meta-list { grid-template-columns: 1fr; }
  .visual-layout.is-details-expanded .visualisation::after { display: none; }
  .details-placeholder { margin-top: 10px; }
}

@media (max-width: 650px) {
  .page-shell { width: min(100% - 16px, 1440px); padding-top: 24px; }
  .stats { grid-template-columns: 1fr; }
  .view-switcher { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); border-radius: 14px; }
  .view-button { border-radius: 10px; }
  .visualisation { min-height: 720px; }
  .visual-layout { min-height: 0; }
  .meta-row { grid-template-columns: 1fr; gap: 2px; }
}

/* TF-IDF project relationship graph */
.similarity-link {
  stroke: #8d99a6;
  stroke-linecap: round;
  pointer-events: none;
}
.similarity-link.is-moderate {
  stroke-width: 1.35px;
  stroke-opacity: .32;
}
.similarity-link.is-strong {
  stroke-width: 3.25px;
  stroke-opacity: .62;
}


/* Expanded project drawer */
.details-panel.is-expanded .details-identity { gap: 22px; }
.details-panel.is-expanded .student-photo {
  width: 116px;
  height: 116px;
  border-width: 5px;
  box-shadow: 0 0 0 2px #ccd5df;
}
.details-panel.is-expanded .student-label { font-size: 1rem; }
.details-panel.is-expanded .theme-pill { font-size: .86rem; padding: 7px 11px; }
.details-panel.is-expanded h3 {
  margin: 28px 0 24px;
  font-size: clamp(2rem, 3.1vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -.025em;
  max-width: 850px;
}
.details-panel.is-expanded .partner-card {
  width: min(460px, 100%);
  padding: 16px;
}
.details-panel.is-expanded .partner-card img { width: 96px; height: 56px; }
.details-panel.is-expanded .partner-card span { font-size: .8rem; }
.details-panel.is-expanded .partner-card strong { font-size: 1rem; }
.details-panel.is-expanded .meta-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 30px 0 38px;
}
.details-panel.is-expanded .meta-row {
  display: block;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.details-panel.is-expanded .meta-row dt { margin-bottom: 4px; font-size: .82rem; }
.details-panel.is-expanded .meta-row dd { font-size: 1rem; }
.details-panel.is-expanded .description-title { margin-top: 8px; }
.project-description { white-space: pre-line; }
.details-panel.is-expanded .project-description {
  max-width: 780px;
  font-size: 1.08rem;
  line-height: 1.75;
  color: #465361;
}

/* Official links remain readable and keyboard-visible in both drawer states. */
.details-panel a { color: var(--accent); text-decoration: underline; text-underline-offset: .16em; }
.details-panel a:hover { color: #a6080d; }
.details-panel a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
