/* fonts: /assets/fonts.css (self-hosted), linked from each page's <head> */

/* ==========================================================
   kianshah.in - subpage design system
   Palette = the strip's wireframe gradient (see script.js)
   ========================================================== */

:root {
  --ink:    #001219;
  --panel:  #04202a;
  --line:   #14333d;
  --wheat:  #e9d8a6;
  --aqua:   #94d2bd;
  --teal:   #0a9396;
  --amber:  #ee9b00;
  --rust:   #ca6702;
  --text:   #d3dcdf;   /* body copy      ~11:1 on ink */
  --muted:  #8fa0a6;   /* metadata       ~7:1 on ink  */
  --serif:  'Cormorant Garamond', Georgia, serif;
  --sans:   'Inter', system-ui, sans-serif;
  --mono:   'JetBrains Mono', ui-monospace, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;             /* ≥16px everywhere */
  line-height: 1.7;
  letter-spacing: 0.01em;
}

::selection { background: var(--teal); color: var(--ink); }

/* ------------------ LINKS: must look like links ------------------ */
a {
  color: var(--aqua);
  text-decoration: underline;
  text-decoration-color: rgba(148, 210, 189, 0.45);
  text-underline-offset: 3px;
  transition: color 0.25s ease, text-decoration-color 0.25s ease;
}

a:hover {
  color: var(--amber);
  text-decoration-color: var(--amber);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ------------------ LAYOUT ------------------ */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(96px, 16vh, 140px) 20px 60px;
}

section { margin-bottom: clamp(72px, 12vh, 120px); }

/* ------------------ NAV ------------------ */
nav {
  position: fixed;
  top: 0;
  z-index: 50;
  width: 100%;
  padding: 14px clamp(16px, 3vw, 40px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(8px);
  background: rgba(0, 18, 25, 0.72);
  border-bottom: 1px solid rgba(148, 210, 189, 0.09);
}

nav .nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  column-gap: 4px;
}

nav .nav-links a {
  font-size: 14px;
  text-decoration: none;
  color: #a9b6bb;
  padding: 10px 12px;          /* ≥44px tap target incl. line-height */
  transition: color 0.25s ease;
}

nav .nav-links a:hover,
nav .nav-links a[aria-current="page"] {
  color: var(--wheat);
  text-decoration: underline;
  text-decoration-color: rgba(233, 216, 166, 0.5);
  text-underline-offset: 4px;
}

.strip-back {
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
  color: var(--wheat);
  text-decoration: none;
  border-bottom: 1px dashed rgba(233, 216, 166, 0.4);
  padding: 10px 0 6px;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.strip-back:hover { color: var(--aqua); border-color: var(--aqua); }

@media (max-width: 720px) {
  nav { position: static; flex-direction: column; align-items: flex-start; gap: 2px; }
  .container { padding-top: 40px; }
  .sb-long { display: none; }  /* "↩ strip" on small screens */
}

/* ------------------ TYPOGRAPHY ------------------ */
h1, h2 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #f2ede0;
  text-wrap: balance;
}

h1 { font-size: clamp(40px, 7vw, 64px); margin-bottom: 20px; }
h2 { font-size: clamp(30px, 5vw, 38px); margin-bottom: 8px; }

h3 {
  font-family: var(--serif);
  font-size: clamp(23px, 3.5vw, 27px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #eee9da;
  margin-bottom: 10px;
}

.subtitle {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 44px;
}

p { margin-bottom: 20px; max-width: 68ch; }

.mono {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ------------------ STRIP ECHO: section divider ------------------ */
.strip-divider {
  margin: clamp(48px, 8vh, 80px) auto;
  max-width: 520px;
  opacity: 0.75;
}

.strip-divider svg { display: block; width: 100%; height: 28px; overflow: visible; }

.strip-divider path {
  fill: none;
  stroke: url(#stripGrad);
  stroke-width: 1;
  stroke-dasharray: 5 7;
  animation: strip-drift 26s linear infinite;
}

@keyframes strip-drift { to { stroke-dashoffset: -240; } }

/* ------------------ CARDS ------------------ */
.card {
  border: 1px solid var(--line);
  padding: clamp(24px, 4.5vw, 40px);
  margin-bottom: 24px;
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.card:hover { border-color: var(--teal); transform: translateY(-4px); }

@media (prefers-reduced-motion: reduce) {
  .card:hover { transform: none; }
}

.card-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  margin: 10px 8px 0 0;
  color: var(--muted);
}

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border: 1px solid var(--amber);
  border-radius: 999px;
  color: var(--amber);
  margin-left: 8px;
  vertical-align: 2px;
  white-space: nowrap;
}

.pill.teal { border-color: var(--teal); color: var(--aqua); }

/* ------------------ BUTTONS ------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--aqua);
  background: transparent;
  border: 1px solid var(--aqua);
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.btn:hover {
  background: var(--aqua);
  color: var(--ink);
  transform: translateY(-2px);
}

.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { border-color: var(--aqua); color: var(--aqua); background: transparent; }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

@media (prefers-reduced-motion: reduce) {
  .btn:hover { transform: none; }
}

/* ------------------ PAPER CARD (research) ------------------ */
.paper-card { border-color: rgba(148, 210, 189, 0.28); }

.paper-card .authors { color: var(--text); margin-bottom: 4px; }
.paper-card .authors .me { color: var(--wheat); }

details.abstract { margin: 16px 0 4px; max-width: 68ch; }

details.abstract summary {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--aqua);
  cursor: pointer;
  padding: 8px 0;              /* comfortable target */
}

details.abstract[open] summary { color: var(--amber); }

details.abstract p { margin-top: 10px; color: var(--text); }

/* ------------------ const(p) values table (research) ------------------ */
details.values { max-width: none; }

.values-note { margin-top: 10px; font-size: 15px; color: var(--muted); }

.values-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.values-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.08em;
  white-space: nowrap;
  padding: 6px 16px 6px 0;
  border-bottom: 1px solid var(--line);
}

.values-table td {
  vertical-align: top;
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid rgba(20, 51, 61, 0.6);
  color: var(--text);
}

.values-table td:last-child { word-break: break-all; padding-right: 0; }
.values-table td:first-child, .values-table th:first-child { color: var(--wheat); }

@media (max-width: 560px) {
  .values-table .col-d { display: none; }
}

/* ------------------ growth chart (research) ------------------ */
.growth-fig {
  position: relative;
  border: 1px solid var(--line);
  padding: clamp(18px, 3.5vw, 28px);
  margin-top: 44px;
}

.growth-fig figcaption { margin-bottom: 18px; }

.fig-title {
  display: block;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
}

.fig-sub {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  color: var(--muted);
  max-width: 62ch;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.chart-legend .lg { display: inline-flex; align-items: center; gap: 8px; }

.k-dot { width: 9px; height: 9px; border-radius: 50%; background: #bd8500; flex: none; }
.k-line { width: 18px; height: 2px; border-radius: 1px; flex: none; }

#growth-chart svg { display: block; }
#growth-chart svg:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.chart-tip {
  position: absolute;
  z-index: 5;
  display: none;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.chart-tip.shown { display: block; }
.chart-tip .tt-head { color: var(--wheat); }
.chart-tip .tt-sub { margin-bottom: 4px; white-space: nowrap; }
.chart-tip .tt-row { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.chart-tip .tt-row strong { color: var(--text); font-weight: 600; }
.chart-tip .tt-key { flex: none; align-self: center; }
.chart-tip .tt-key.dot { width: 8px; height: 8px; border-radius: 50%; }
.chart-tip .tt-key.line { width: 14px; height: 2px; }

.fit-models {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: grid;
  gap: 10px;
}

.fit-model {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 15px;
}

.fit-model .fit-params {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.bibtex { display: none; margin-top: 16px; }
.bibtex.shown { display: block; }

.bibtex pre {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
}

/* ------------------ MATH ------------------ */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 2px;
}

.math-anchor {
  border-block: 1px solid var(--line);
  padding: 18px 0 6px;
  margin: 34px 0;
}

.math-anchor .mono { display: block; margin-bottom: 4px; }

/* ------------------ LISTS (results, talks) ------------------ */
ul.linked {
  list-style: none;
  display: grid;
  gap: 18px;
  max-width: 72ch;
}

ul.linked li { padding-left: 26px; position: relative; }

ul.linked li::before {
  content: "▸";
  position: absolute;
  left: 2px;
  color: var(--teal);
  font-family: var(--mono);
}

/* ------------------ TIMELINE (CV) ------------------ */
.timeline { border-left: 1px solid var(--line); display: grid; gap: 44px; padding-left: 28px; }

.timeline-item { position: relative; }

.timeline-item::before {
  content: "";
  position: absolute;
  left: -32.5px;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  border: 1.5px solid var(--aqua);
}

.timeline-period {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}

.timeline-item h3 { font-size: 21px; font-family: var(--sans); font-weight: 600; color: #e8e4d8; }
.timeline-item p { margin-bottom: 6px; }
.timeline-item .note { font-size: 15px; color: var(--muted); }

.cv-skills { display: flex; flex-wrap: wrap; gap: 0 4px; }

/* ------------------ TEACHING / PROJECT GRIDS ------------------ */
.card-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.card-grid .card { margin-bottom: 0; }

/* ------------------ ABOUT ------------------ */
.about-container {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.about-photo {
  flex: 0 0 250px;
  overflow: hidden;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.about-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.about-photo:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(10, 147, 150, 0.35);
}

.about-text { flex: 1 1 320px; }

@media (max-width: 560px) {
  .about-photo { flex-basis: 100%; max-width: 320px; }
}

/* ------------------ FILM SHELF (about) ------------------ */
.shelf-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  vertical-align: 6px;
  margin-left: 12px;
}

.film-shelf {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
}

/* 15 films · 3 fixed columns on desktop = 5 clean rows */
@media (min-width: 640px) {
  .film-shelf { grid-template-columns: repeat(3, 1fr); }
}

.film-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  text-decoration: none;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.film-card:nth-child(3n + 2) { border-top-color: var(--amber); }
.film-card:nth-child(3n)     { border-top-color: #ae2012; }

.film-card:hover { border-color: var(--aqua); transform: translateY(-3px); }

.film-card .f-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--wheat);
  line-height: 1.4;
}

.film-card .f-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .film-card:hover { transform: none; }
}

/* ------------------ BOOK SHELF (about) ------------------ */
.book-shelf {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  margin-top: 26px;
  padding: 0 16px;
  border-bottom: 3px solid var(--teal);
  border-image: linear-gradient(90deg, var(--teal), var(--amber), #ae2012) 1;
  overflow-x: auto;
}

.book {
  flex: none;
  writing-mode: vertical-rl;
  height: var(--h, 180px);
  padding: 12px 6px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0.28) 94%),
    var(--spine, var(--teal));
  color: var(--on, var(--ink));
  border: 1px solid rgba(148, 210, 189, 0.14);
  border-bottom: none;
  border-radius: 2px 2px 0 0;
}

.book .b-title {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  line-height: 1.05;
  margin-block-end: 2px;
}

.book .b-author {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* one book left leaning against its neighbour, as shelves go */
.book.lean {
  transform: rotate(-8deg);
  transform-origin: bottom left;
  margin-left: 14px;
  margin-right: 6px;
}

@media (max-width: 480px) {
  .book-shelf { gap: 4px; padding: 0 8px; }
  .book { height: calc(var(--h, 180px) * 0.82); padding: 10px 4px; }
  .book .b-title { font-size: 12px; }
  .book .b-author { font-size: 7.5px; }
  .book.lean { margin-left: 10px; margin-right: 2px; }
}

/* ------------------ SKILL ROWS (cv) ------------------ */
.skill-rows { display: grid; gap: 12px; max-width: 62ch; }

.skill-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  align-items: baseline;
}

.skill-row .k {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 480px) {
  .skill-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ------------------ CONTACT ------------------ */
.contact-links { display: grid; gap: 14px; max-width: 46ch; margin-top: 8px; }

.contact-links a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.25s ease, color 0.25s ease;
}

.contact-links a:hover { border-color: var(--aqua); color: var(--aqua); }

.contact-links .k {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 74px;
}

/* ------------------ CV PDF ------------------ */
.cv-embed-wrapper {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.cv-embed-wrapper iframe { width: 100%; height: 70vh; border: none; display: block; }

@media (max-width: 720px) {
  .cv-embed-wrapper { display: none; }  /* download button instead */
}

/* ------------------ FOOTER ------------------ */
footer {
  padding: 48px 20px 56px;
  text-align: center;
  border-top: 1px solid rgba(148, 210, 189, 0.09);
  font-size: 14px;
  color: var(--muted);
}

footer .foot-links { margin-top: 8px; font-family: var(--mono); font-size: 12.5px; }
footer .foot-links a { color: var(--muted); margin: 0 8px; }
footer .foot-links a:hover { color: var(--aqua); }

/* contact links as icons - injected by page.js on every page */
footer .foot-social {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 4px;
  margin-bottom: 12px;
}

footer .foot-social a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: none;
  border-radius: 4px;
  transition: color 0.2s ease, transform 0.2s ease;
}

footer .foot-social a:hover,
footer .foot-social a:focus-visible { color: var(--aqua); transform: translateY(-2px); }

footer .foot-social svg { width: 21px; height: 21px; display: block; }

@media (prefers-reduced-motion: reduce) {
  footer .foot-social a:hover,
  footer .foot-social a:focus-visible { transform: none; }
}

/* ------------------ PAGE ENTER / EXIT ------------------ */
@media (prefers-reduced-motion: no-preference) {
  .page-enter .container {
    animation: page-unfold 480ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
  }

  @keyframes page-unfold {
    from { opacity: 0; transform: translateY(18px) scale(0.985); }
    to   { opacity: 1; transform: none; }
  }

  .page-exit .container,
  .page-exit footer {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 240ms ease, transform 240ms ease;
  }
}
