/* ==========================================================
   Pujan Pant: personal site
   All colours and fonts are set once here under :root.
   ========================================================== */

/* Fonts live in /fonts (SIL Open Font License), so nothing loads from other servers */
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("../fonts/source-serif-4.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/hanken-grotesk.woff2") format("woff2");
}

:root {
  --paper: #f4f4f2;      /* soft off-white page */
  --card: #ffffff;       /* panels and boxes */
  --ink: #18213a;        /* deep navy: headings and body */
  --slate: #5a6478;      /* secondary text */
  --faint: #9aa1b0;      /* map lines, quiet labels */
  --hairline: #dcdfe5;   /* dividers and borders */
  --cobalt: #2448c9;     /* the one accent: links, focus, calibrated line */
  --mist: #e8ecf5;       /* quiet tinted surfaces */

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --wrap: 75rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --section-space: clamp(4rem, 8vw, 6.5rem);

  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }

a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip {
  position: absolute; left: -999px; top: 0.75rem; z-index: 20;
  background: var(--ink); color: var(--card); padding: 0.5rem 0.9rem; border-radius: 6px;
}
.skip:focus { left: 0.75rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: rgba(244, 244, 242, 0.9);
  -webkit-backdrop-filter: saturate(1.3) blur(10px);
  backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.site-header.scrolled { border-bottom-color: var(--hairline); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.25rem;
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.wordmark:hover { text-decoration: none; }

.nav-cv {
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hairline);
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
}
.nav-cv:hover { border-color: var(--ink); text-decoration: none; }

/* ==========================================================
   Network map (first screen)
   ========================================================== */
.map-hero {
  background:
    radial-gradient(ellipse 70% 60% at 38% 48%, #fbfbfa 0%, rgba(251, 251, 250, 0) 70%),
    linear-gradient(180deg, #f4f4f2 0%, #ececea 78%, var(--paper) 100%);
  min-height: calc(100vh - 4.25rem);
  padding-top: clamp(1.5rem, 3vw, 2.5rem);
  padding-bottom: clamp(2rem, 4vw, 3.5rem);
}

.map-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem 2rem;
  flex-wrap: wrap;
}
.person { display: flex; align-items: center; gap: 0.9rem; }
.avatar {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 30%;
  background: var(--mist);
}
h1 {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.role { color: var(--slate); font-size: 0.9375rem; line-height: 1.4; }
.map-hint { color: var(--slate); font-size: 0.9375rem; max-width: 26rem; }

.map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 23rem;
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: start;
  margin-top: clamp(0.5rem, 2vw, 1.25rem);
}
html:not(.has-map) .map-grid,
html:not(.has-map) .map-hint { display: none; }

.map-stage { position: relative; }
#map-svg {
  width: 100%;
  height: auto;
  max-height: min(42rem, calc(100vh - 9rem));
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}

/* Map lines */
.edge { stroke: var(--faint); stroke-width: 1; }
.edge.dotted { stroke-dasharray: 1.5 4; stroke-linecap: round; stroke-width: 1.25; }
.edge.is-focus-edge { stroke: var(--ink); }

/* Map nodes: shape tells you the type */
.node { cursor: pointer; outline: none; }
.node.is-hidden { pointer-events: none; }
.node .hit { fill: transparent; }
.node .halo { fill: none; stroke: none; }
.node .sym { fill: var(--card); stroke: var(--ink); stroke-width: 1.5; transition: fill 0.15s ease, stroke 0.15s ease; }
.node.t-theme .sym { fill: var(--paper); stroke: var(--slate); }
.node.t-interest .sym { fill: var(--paper); stroke: var(--faint); stroke-dasharray: 2 2; }
.node.t-person .sym { fill: var(--ink); stroke: none; }

.node .label {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  fill: var(--ink);
  paint-order: stroke;
  stroke: #f2f2f0;
  stroke-width: 4px;
  stroke-linejoin: round;
}
.node .label .sub { font-size: 11.5px; font-weight: 400; fill: var(--slate); }
.node.is-far .label { font-weight: 400; fill: var(--slate); }
.node.t-person .label { font-family: var(--serif); font-size: 15px; font-weight: 600; }

.node:hover .sym { stroke: var(--cobalt); }
.node.is-focus .sym { fill: var(--cobalt); stroke: var(--cobalt); }
.node.is-focus .halo { fill: var(--cobalt); opacity: 0.12; }
.node.is-focus .label { font-weight: 600; }
.node:focus-visible .halo { fill: none; stroke: var(--cobalt); stroke-width: 2; opacity: 1; }

/* Details panel */
.map-panel {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(24, 33, 58, 0.04), 0 12px 32px -12px rgba(24, 33, 58, 0.14);
  padding: 1.5rem 1.5rem 1.6rem;
  max-height: min(40rem, calc(100vh - 9rem));
  overflow-y: auto;
  font-size: 0.96875rem;
}
.p-back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--slate);
  cursor: pointer;
}
.p-back:hover { color: var(--ink); border-color: var(--slate); }

.p-type {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--slate);
  font-size: 0.875rem;
  font-weight: 500;
}
.p-title {
  margin-top: 0.4rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1.22;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.p-meta { margin-top: 0.35rem; color: var(--slate); font-size: 0.9375rem; line-height: 1.45; }
.p-body { margin-top: 1rem; }
.p-body p + p { margin-top: 0.75rem; }
.p-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-top: 1rem; font-weight: 600; }

.p-section { margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--hairline); }
.p-section h3 { font-size: 0.875rem; font-weight: 600; color: var(--slate); margin-bottom: 0.7rem; }

.p-groups li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--hairline);
}
.p-groups li:first-child { border-top: 0; padding-top: 0; }
.g-name {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  color: var(--slate);
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.875rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.chip:hover { border-color: var(--cobalt); color: var(--cobalt); }

.shape { flex: none; }
.shape * { fill: var(--card); stroke: var(--ink); stroke-width: 1.4; }
.shape.t-person * { fill: var(--ink); stroke: none; }
.shape.t-theme * { fill: var(--paper); stroke: var(--slate); }
.shape.t-interest * { fill: var(--paper); stroke: var(--faint); stroke-dasharray: 2 1.6; }

.p-hint { margin-top: 1.2rem; font-size: 0.875rem; color: var(--slate); }

/* ---------- Tablet ---------- */
@media (max-width: 960px) {
  .map-grid { grid-template-columns: 1fr; }
  #map-svg { max-height: none; }
  .map-panel { max-height: none; }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  body { font-size: 1rem; }
  .header-inner { height: 3.75rem; }
  .map-stage { margin-inline: calc(var(--gutter) * -0.5); }
  #map-svg { overflow: hidden; }
  .node .label { font-size: 17px; }
  .node .label .sub { font-size: 14px; }
  .node.is-far .label { display: none; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .skip { display: none; }
}
