/* ---------------------------------------------------------------
   Itamar J. Allali — personal site
   Colours come from one palette file in css/palettes/ (imported
   below). The hero rule under the homepage intro is the single
   gradient motif; don't repeat it elsewhere.
   --------------------------------------------------------------- */

/* Colour palette: exactly one file from css/palettes/ is active. To switch
   schemes, change this line (see css/palettes/README.md). */
@import url("palettes/stone-and-blue.css");

:root {

  --serif: "Newsreader", Georgia, "Iowan Old Style", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --max: 920px; /* content width; matches the header */
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ink);
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

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

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

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.15;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); font-weight: 460; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

p { max-width: 62ch; color: var(--ink); }
p.lede { font-size: 1.15rem; color: var(--muted); max-width: 56ch; }

.muted { color: var(--muted); }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.wrap--wide { max-width: 920px; }

/* ---------- header ---------- */

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 560;
  text-decoration: none;
  white-space: nowrap;
}

/* |IJA> logo before the name; decorative (alt=""), the name is the link text */
.site-logo {
  display: block;
  height: 30px;
  width: auto;
  flex-shrink: 0;
}

nav.primary {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

nav.primary a {
  font-size: 0.94rem;
  text-decoration: none;
  color: var(--muted);
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}

nav.primary a:hover { color: var(--ink); }

nav.primary a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
}

/* collapse to the Menu button before the 7 links would wrap onto a second
   row (they fit on one line from ~860px) */
@media (max-width: 820px) {
  .nav-toggle { display: inline-block; }
  nav.primary {
    display: none;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding-top: 12px;
  }
  nav.primary.open { display: flex; }
  .site-header-inner { flex-wrap: wrap; }
}

/* ---------- hero (home only) ---------- */

.hero {
  /* keep .wrap's 24px side gutters; a bare `0` here overrode them, which put
     the intro text flush against the screen edge on phones */
  padding: 72px 24px 40px;
}

.hero .eyebrow {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 20px;
}

.hero-actions {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 28px 0 44px;
  font-size: 0.98rem;
}

.hero-actions a {
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

.hero-actions a:hover { border-bottom-color: var(--accent-hover); }

.hero-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: start;
}

@media (max-width: 640px) {
  .hero-grid { grid-template-columns: 1fr; }
  .headshot-wrap { order: -1; width: 152px; height: 182px; }
  .headshot { width: 152px !important; height: 182px !important; }
}

.headshot-wrap {
  width: 240px;
  flex-shrink: 0;
}

.headshot {
  display: block;
  width: 240px;
  height: 288px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.headshot-placeholder-text {
  display: none;
}

.headshot-wrap.missing {
  width: 240px;
  height: 288px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.headshot-wrap.missing .headshot-placeholder-text {
  display: block;
}

.headshot-wrap.missing .headshot-placeholder-text code {
  font-family: var(--mono);
  font-size: 0.78rem;
}

section.block h3 {
  margin-top: 28px;
}

section.block h3 + ul {
  margin-top: 6px;
}

section.block ul + p.muted {
  margin-top: -8px;
  margin-bottom: 20px;
}

.figure-wrap {
  margin: 28px 0;
}

.figure-wrap img {
  display: block;
  width: 100%;
  max-width: 560px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.figure-wrap .photo-slot {
  display: none;
}

.figure-wrap.missing img {
  display: none;
}

.figure-wrap.missing .photo-slot {
  display: flex;
  flex-direction: column; /* stack the label above the filename (<br> is ignored in a flex row) */
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  height: 260px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 14px;
}

.figure-wrap .photo-slot code {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.figure-wrap figcaption {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* centred figure: image, placeholder and caption centred in the column */
.figure-wrap.figure-center img,
.figure-wrap.figure-center.missing .photo-slot { margin-left: auto; margin-right: auto; }
.figure-wrap.figure-center figcaption { text-align: center; }

.figure-wrap.float-left,
.figure-wrap.float-right {
  width: 260px;
  margin-top: 6px;
  margin-bottom: 24px;
}

.figure-wrap.float-right { float: right; margin-left: 32px; }
.figure-wrap.float-left { float: left; margin-right: 32px; }

.figure-wrap.float-left img,
.figure-wrap.float-right img {
  width: 100%;
  max-width: 100%;
}

.figure-wrap.float-left.missing .photo-slot,
.figure-wrap.float-right.missing .photo-slot {
  width: 100%;
  max-width: 100%;
  height: 200px;
}

/* Figure rail: photos stack down the right-hand side of a wide page while
   paragraphs keep their 62ch reading measure on the left. clear:right
   keeps consecutive photos from colliding. */
.figure-rail .figure-wrap.float-right {
  clear: right;
  width: clamp(220px, 32%, 300px);
  margin: 6px 0 32px 40px;
}

/* larger rail photo for landscape shots that read poorly at 300px */
.figure-rail .figure-wrap.float-right.rail-large {
  width: clamp(240px, 46%, 420px);
}

.figure-rail h2 { margin-top: 1.4em; }
.figure-rail h1 + .figure-wrap + h2,
.figure-rail h1 + h2 { margin-top: 0.6em; }

/* Research plot within the text column: as wide as the paragraphs, below any
   floated photo. Missing file -> dashed placeholder like other photo spots. */
.figure-wrap.figure-plot {
  clear: both;
  max-width: 62ch;
  margin: 8px 0 32px;
}

.figure-wrap.figure-plot img,
.figure-wrap.figure-plot.missing .photo-slot {
  width: 100%;
  max-width: 100%;
  background: var(--paper-raised);
}

.figure-wrap.figure-plot.missing .photo-slot {
  height: auto;
  aspect-ratio: 16 / 9;
}

/* captions under research plots: same text width as the plot, comfortable measure */
.figure-wrap.figure-plot figcaption {
  line-height: 1.5;
}

/* plots sit centred under the text column, narrower than the
   paragraphs (75%); captions match the plot width but stay left-aligned.
   Full width on phones so plot detail stays legible. */
.figure-wrap.figure-plot img,
.figure-wrap.figure-plot.missing .photo-slot,
.figure-wrap.figure-plot figcaption {
  max-width: 75%;
  margin-left: auto;
  margin-right: auto;
}


@media (max-width: 640px) {
  .figure-wrap.figure-plot img,
  .figure-wrap.figure-plot figcaption { max-width: 100%; }
}

/* KaTeX defaults to 1.21em; keep caption math the same size as the surrounding text */
.figure-wrap figcaption .katex { font-size: 1em; }

/* Full-width decorative banner at the end of a page: clears any floats and
   spans the whole content column, cropped to a wide strip. */
.figure-wrap.figure-banner {
  clear: both;
  margin: 48px 0 0;
}

.figure-wrap.figure-banner img,
.figure-wrap.figure-banner.missing .photo-slot {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 1;
  height: auto;
  object-fit: cover;
}

@media (max-width: 640px) {
  .figure-wrap.figure-banner img,
  .figure-wrap.figure-banner.missing .photo-slot { aspect-ratio: 2 / 1; }
}

@media (max-width: 640px) {
  .figure-wrap.float-left,
  .figure-wrap.float-right,
  .figure-rail .figure-wrap.float-right,
  .figure-rail .figure-wrap.float-right.rail-large {
    float: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

.dawn-line {
  height: 3px;
  border: none;
  margin: 0 0 48px;
  background: linear-gradient(90deg, var(--rule-from) 0%, var(--rule-to) 100%);
}

/* ---------- sections ---------- */

section.block {
  padding: 8px 0 48px;
  display: flow-root;
}

section.block + section.block {
  border-top: 1px solid var(--line);
  padding-top: 48px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
}

@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
}

/* latest-paper callout card, kept quiet: a rule + text, no shadow/gradient box */
.latest-paper {
  border-left: 3px solid var(--accent);
  padding-left: 20px;
}

.latest-paper .kicker {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

/* research areas */
dl.areas {
  margin: 0;
  display: grid;
  gap: 20px;
}

dl.areas dt {
  font-family: var(--serif);
  font-size: 1.08rem;
  margin-bottom: 2px;
}

dl.areas dd {
  margin: 0;
  color: var(--muted);
  max-width: 58ch;
}

/* ---------- link rows (find my research / connect) ---------- */

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 6px;
  padding: 0;
  list-style: none;
}

.link-row a {
  text-decoration: none;
  font-size: 0.96rem;
  border-bottom: 1px solid var(--line);
}

.link-row a:hover { border-bottom-color: var(--accent-hover); }

/* link with a leading service logo (icons live in assets/icons.svg);
   ink by default, the service's own brand colour (--brand) on hover */
.link-row a.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-bottom: none;
}

/* underline the label only, not the icon */
.icon-link span { border-bottom: 1px solid var(--line); }
.icon-link:hover span { border-bottom-color: var(--accent-hover); }

.icon-link .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--ink);
  transition: color 0.15s;
}

.icon-link:hover .icon { color: var(--brand, var(--accent-hover)); }

/* ---------- publications ---------- */

.pub-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0 28px;
  font-size: 0.92rem;
  color: var(--muted);
}

.pub-controls button {
  font-family: var(--sans);
  font-size: 0.88rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  color: var(--ink);
}

.pub-controls button[aria-pressed="true"] {
  border-color: var(--accent-hover);
  background: var(--accent-tint);
}

.pub-year {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 32px 0 10px;
  letter-spacing: 0.02em;
}

ol.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub-entry {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.pub-entry:first-of-type { border-top: none; }

.pub-entry .title a {
  font-family: var(--serif);
  font-size: 1.08rem;
  text-decoration: none;
}

.pub-entry .title a:hover { color: var(--accent-hover); }

.pub-entry .meta {
  margin-top: 4px;
  font-size: 0.92rem;
  color: var(--muted);
}

.pub-entry .meta .arxiv {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.pub-entry .stats {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.pub-note {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: -6px;
}

/* ---------- talks ---------- */

.talk-list .title {
  font-family: var(--serif);
  font-size: 1.08rem;
}

.talk-list .venue-group {
  margin-top: 4px;
}

.talk-list .venue-group + .venue-group {
  margin-top: 10px;
}

.talk-list .meta {
  font-size: 0.92rem;
  color: var(--muted);
}

.talk-list .stats {
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--muted);
}

.talk-list .stats a {
  color: var(--muted);
  text-decoration-color: var(--line);
}

.talk-list .stats a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
}

/* ---------- footer ---------- */

footer.site {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 28px 0 48px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* match the header's 920px width so footer text lines up with the site name */
footer.site .wrap { max-width: 920px; }

/* three link columns (Contact / Research / Connect), stacking on phones */
.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px 48px;
}

.footer-heading {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 8px;
}

footer.site .link-row { margin: 0; }
footer.site .link-row a { font-size: 0.92rem; color: var(--ink); }

.footer-copy { margin: 32px 0 0; }

.placeholder-note {
  font-size: 0.88rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 18px 0;
}

/* ---------- CV page ---------- */

.cv-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.cv-embed {
  display: block;
  width: 100%;
  height: 85vh;
  min-height: 520px;
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-raised);
}

@media (max-width: 640px) {
  .cv-embed { height: 70vh; min-height: 0; }
}

/* ---------- publications page ---------- */

/* title + intro text with a photo across from it; the photo stacks below
   the text on narrow screens */
section.block.page-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(220px, 32%, 300px);
  gap: 40px;
  align-items: center;
}

.page-intro .figure-wrap { margin: 0; }

.page-intro .figure-wrap img,
.page-intro .figure-wrap.missing .photo-slot { max-width: 100%; }

@media (max-width: 720px) {
  section.block.page-intro { grid-template-columns: 1fr; gap: 24px; }
}

/* a standalone photo centred in the full column (68% of its width) */
/* margins balance the gap above (list section's 48px bottom padding) with
   the gap below (next section's 8px top padding) */
.figure-wrap.figure-feature { margin: 8px 0 48px; }

.figure-wrap.figure-feature img,
.figure-wrap.figure-feature.missing .photo-slot {
  width: 68%;
  max-width: 68%;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 640px) {
  .figure-wrap.figure-feature img,
  .figure-wrap.figure-feature.missing .photo-slot { width: 100%; max-width: 100%; }
}

/* lake photo is 4:3 with the sun near the top; a 3:1 strip can't hold both
   sun and shore, so keep the horizon, glittering water and shoreline */
.figure-wrap.figure-banner--lake img { object-position: 50% 72%; }

/* ---------- latest Substack post (reading.html) ---------- */
/* Same quiet treatment as .latest-paper: a gold rule, no card or shadow. */

.substack-preview {
  border-left: 3px solid var(--accent);
  padding-left: 20px;
  margin: 28px 0 32px;
  max-width: 640px;
}

.substack-link {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  text-decoration: none;
  color: var(--ink);
}

.substack-cover {
  width: 120px;
  height: 120px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.substack-text { display: flex; flex-direction: column; gap: 4px; }

.substack-text .kicker { font-size: 0.85rem; color: var(--muted); }

.substack-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.2;
}

.substack-sub { color: var(--muted); font-size: 0.96rem; }

.substack-cta {
  margin-top: 6px;
  font-size: 0.92rem;
  align-self: flex-start;
  border-bottom: 1px solid var(--line);
}

.substack-link:hover .substack-title { color: var(--accent-hover); }
.substack-link:hover .substack-cta { border-bottom-color: var(--accent-hover); }

@media (max-width: 480px) {
  .substack-cover { width: 84px; height: 84px; }
  .substack-link { gap: 14px; }
}
