/* Design tokens and type match agarwal-labs.com so the subdomain feels like the same site. */
:root {
  color-scheme: light;
  --paper: #fdfdfc;
  --ink: #272b29;
  --muted: #656c68;
  --link: #285b4c;
  --line: #dfe3df;
  --positive: #237448;
  --negative: #af3f42;
  --tint: #f1f4f1;
  --mark: #e3ece6;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
a:hover { color: var(--ink); }

:focus-visible { outline: 2px solid var(--link); outline-offset: 5px; }

h1, h2, h3 { font-weight: 500; margin: 0; }
h2 { font-size: 25px; line-height: 1.3; }
h3 { font-size: 19px; line-height: 1.35; }
p { margin: 0; }

button { font: inherit; color: inherit; }

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

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 10;
  padding: 4px 12px;
  background: var(--paper); color: var(--link);
  border: 1px solid var(--link); border-radius: 4px;
}
.skip-link:focus { top: 12px; }

/* Page column */
.journal {
  width: min(700px, calc(100% - 48px));
  margin: 76px auto 0;
  padding-bottom: 100px;
}

/* Masthead */
.masthead {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.masthead h1 { font-size: 40px; line-height: 1.2; }
.masthead__name { color: var(--ink); text-decoration: none; }
.masthead__name:hover { color: var(--link); }
.masthead__role { margin-top: 8px; font-size: 17px; line-height: 1.55; }

.masthead__bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px;
  margin-top: 18px;
  font-size: 16px;
}
.site-links { display: flex; flex-wrap: wrap; gap: 28px; }
.site-links a, .text-button {
  color: var(--ink);
  text-decoration: none;
}
.site-links a:hover, .text-button:hover {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.text-button {
  padding: 0; border: 0; background: none; cursor: pointer;
  line-height: inherit;
}

.badge {
  font-size: 14px;
  color: var(--muted);
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

/* Search */
.page { margin-top: 40px; }

.search {
  display: flex; gap: 10px; align-items: stretch;
}
.search input {
  flex: 1; min-width: 0;
  padding: 9px 14px;
  font: inherit; font-size: 18px; color: var(--ink);
  background: var(--paper);
  border: 1px solid #b9c0bb;
  border-radius: 4px;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:hover { border-color: var(--muted); }
.search input:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.search-submit {
  padding: 2px 18px;
  font-size: 17px;
  color: var(--link);
  background: transparent;
  border: 1px solid var(--link);
  border-radius: 4px;
  cursor: pointer;
}
.search-submit:hover { background: var(--link); color: var(--paper); }
.search-submit:disabled { opacity: .6; cursor: progress; }

.examples {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px;
  margin-top: 12px;
  font-size: 15px;
}
.examples-label { color: var(--muted); }
.chip {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  text-decoration-color: var(--line);
}
.chip:hover { color: var(--ink); text-decoration-color: currentColor; }

/* Index limitations notice */
.notice {
  margin-top: 28px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 15px; line-height: 1.6;
  color: var(--muted);
}
.notice summary {
  cursor: pointer;
  list-style: none;
}
.notice summary::-webkit-details-marker { display: none; }
.notice-more {
  margin-left: 6px;
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  white-space: nowrap;
}
.notice-more::after { content: " +"; }
.notice[open] .notice-more::after { content: " −"; }
.notice summary:hover .notice-more { color: var(--ink); }
.notice ul { margin: 12px 0 0; padding-left: 20px; }
.notice li { margin-bottom: 8px; }
.notice strong { color: var(--ink); font-weight: 600; }
.notice-extra { margin-top: 8px; }

/* Results view */
.results-view { margin-top: 49px; }

.wake {
  display: flex; gap: 14px; align-items: flex-start;
  margin-bottom: 32px;
  font-size: 16px;
}
.wake strong { font-weight: 500; }
.wake p { color: var(--muted); font-size: 15px; }
.wake .spinner { margin-top: 6px; }

.summary {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.summary-head, .results-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px;
  margin-bottom: 14px;
}
.summary-meta, .results-meta { font-size: 14px; color: var(--muted); }
.summary-meta .spinner, .results-meta .spinner { margin-right: 8px; vertical-align: -2px; }
.summary-body { font-size: 18px; line-height: 1.7; }
.summary-body p + p { margin-top: 12px; }
.summary-foot { margin-top: 14px; font-size: 14px; color: var(--muted); font-style: italic; }
.summary-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 16px; margin-bottom: 12px; }
.summary-error { color: var(--negative); font-size: 16px; }
.summary-empty { color: var(--muted); font-style: italic; }

/* Citation markers: [1] style links */
.cite {
  display: inline;
  padding: 0 1px;
  border: 0; background: none; cursor: pointer;
  font-size: .78em;
  vertical-align: super;
  line-height: 0;
  color: var(--link);
}
.cite::before { content: "["; }
.cite::after { content: "]"; }
.cite:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

.results-head { margin-top: 40px; margin-bottom: 4px; }

.inline-note {
  margin: 4px 0 8px;
  font-size: 15px; color: var(--muted); font-style: italic;
}

/* Result list: rows separated by hairlines, like the writing list */
.results { list-style: none; margin: 0; padding: 0; }

.result {
  display: grid; grid-template-columns: 30px 1fr; gap: 0 10px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 24px;
  transition: background-color .6s ease;
}
.result-rank {
  font-size: 15px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
}
.result-main { min-width: 0; }
.result-title { font-size: 19px; line-height: 1.4; }
.result-title a { overflow-wrap: anywhere; }
.result-byline { margin-top: 4px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.result-abstract {
  margin-top: 8px;
  font-size: 16px; line-height: 1.65; color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result.expanded .result-abstract { display: block; -webkit-line-clamp: unset; line-clamp: unset; }
mark { background: var(--mark); color: var(--ink); padding: 0 1px; }

.result-footer {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px;
  margin-top: 8px;
  font-size: 14px;
}
.result-tags { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--muted); }
.tag { font-variant-numeric: tabular-nums; }
.tag-primary { color: var(--ink); }
.result-actions { display: flex; gap: 18px; }
.link-btn {
  padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 14px;
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.link-btn:hover { color: var(--ink); }

.result.flash { background-color: var(--tint); }

.more { margin-top: 24px; }
.more-btn {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 16px;
}
.more-btn::after { content: " +"; }
.more-btn[aria-expanded="true"]::after { content: " −"; }
.more-btn:hover { color: var(--ink); }
.more-head { margin-top: 24px; }

/* Loading */
.spinner {
  display: inline-block; flex: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--line);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { display: grid; gap: 10px; }
.skeleton span {
  display: block; height: 12px; border-radius: 2px;
  background: linear-gradient(90deg, var(--tint), #e8ece8, var(--tint));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton span:nth-child(1) { width: 92%; }
.skeleton span:nth-child(2) { width: 100%; }
.skeleton span:nth-child(3) { width: 64%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.result-skeleton { display: block; padding: 22px 0; border-bottom: 1px solid var(--line); }

/* Empty and error states */
.state {
  margin-top: 28px;
  font-size: 16px;
  color: var(--muted);
}
.state h3 { color: var(--ink); margin-bottom: 4px; }
.state.error h3 { color: var(--negative); }
.state .retry {
  margin-top: 14px;
  padding: 2px 13px;
  font-size: 16px;
  color: var(--link);
  background: transparent;
  border: 1px solid var(--link);
  border-radius: 4px;
  cursor: pointer;
}
.state .retry:hover { background: var(--link); color: var(--paper); }

/* About dialog */
.about {
  width: min(620px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(39, 43, 41, .12);
}
.about::backdrop { background: rgba(39, 43, 41, .28); }
.about-inner { padding: 28px 32px 30px; font-size: 16px; line-height: 1.65; }
.about-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 14px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover { color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin-bottom: 12px; color: var(--muted); }
.steps strong { color: var(--ink); font-weight: 600; }
.about h3 { margin: 22px 0 6px; }
.about p { color: var(--muted); }
.about-links { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 18px; }

/* Footer */
.site-footer {
  display: grid; gap: 4px;
  margin-top: 52px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

@media (max-width: 600px) {
  .journal { width: calc(100% - 40px); margin-top: 38px; }
  .masthead h1 { font-size: 34px; }
  h2 { font-size: 23px; }
  .masthead__bar, .site-links { gap: 10px 22px; font-size: 15px; }
  .search input { font-size: 17px; }
  .search-submit { padding: 2px 13px; }
  .result { grid-template-columns: 24px 1fr; gap: 0 6px; }
  .about-inner { padding: 22px 20px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .spinner { animation: none; border-top-color: var(--muted); }
}
