/*
  antoniocoppola.org: a hand-built replica of the Squarespace 7.1 site.

  Layout numbers come from measuring the live Squarespace pages:
  - 24-column grid (8 on mobile) inside 3vw side gutters (6vw on mobile)
  - type sizes scale with the viewport: 1rem + (size - 1) * 1.2vw (2.6vw on mobile)
  - "row" is one Squarespace Fluid Engine grid row: 2.15% of the container width
*/

/* ---------- Fonts ---------- */

/* The site font is Aktiv Grotesk, served by the Adobe Fonts web project
   "antoniocoppola.org" (the <link> to use.typekit.net in each page's <head>).
   Instrument Sans (SIL Open Font License) is self-hosted as a fallback: its
   widths and vertical metrics are close enough that the layout holds if
   Adobe's servers are unreachable or the Adobe plan lapses. */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/InstrumentSans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/InstrumentSans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/InstrumentSans-Italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/InstrumentSans-Italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */

:root {
  --font: "aktiv-grotesk", "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ink: #000;
  --link: #253551;
  --navy: #253551;
  --rule-light: #ccc;
  --footer-bg: #2a2829;

  --gutter: 3vw;
  --gap: 11px;
  --row: 2.021vw;              /* 0.0215 x 94vw */
  --bar: 20px;
  --header-pad: 2.2vw;
  /* Squarespace section padding scales with the larger window side (vmax) */
  --wrap-pad: 1vmax;           /* most sections */
  --wrap-pad-lg: 6.6vmax;      /* Teaching / Data sections */

  --fs-body: calc(1rem + 0.12vw);
  --fs-h4: calc(1rem + 0.48vw);
  --fs-h2: calc(1rem + 1.92vw);
  --fs-title: calc(1rem + 1.2vw);
  --lh-title: calc(var(--fs-title) * 1.3);
  --header-h: calc(2 * var(--header-pad) + 2 * var(--lh-title));

  --cols: 24;
  --max: 2517px;
}

/* Squarespace switches the header to its mobile form below 800px,
   but keeps the desktop page grid down to 768px. */
@media (max-width: 799px) {
  :root { --header-pad: 6vw; --header-side: 6vw; }
}

@media (max-width: 767px) {
  :root {
    --gutter: 6vw;
    --row: 24px;                 /* mobile grid rows are a fixed 24px */
    /* mobile type scales with 2.6vw but stops growing at ~415px wide */
    --mfac: min(2.6vw, 10.8px);
    --fs-body: calc(1rem + 0.1 * var(--mfac));
    --fs-h4: calc(1rem + 0.4 * var(--mfac));
    --fs-h2: calc(1rem + 1.6 * var(--mfac));
    --fs-title: calc(1rem + var(--mfac));
    --cols: 8;
  }
}

@media (max-width: 640px) {
  :root { --bar: 15px; }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--ink);
  background: #fff;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }

p { margin: 16px 0; }
p:first-child { margin-top: 0; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; }

/* Squarespace heading styles, decoupled from the HTML level so the
   document outline can be correct without changing how anything looks. */
.h2 { font-size: var(--fs-h2); line-height: 1.2168; }
.h4 { font-size: var(--fs-h4); line-height: 1.2792; }

.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: var(--gutter); top: -100px; z-index: 10;
  background: #fff; color: var(--ink); padding: 8px 12px;
}
.skip-link:focus { top: 8px; }

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

/* ---------- Header ---------- */

.site-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--bar);
  background: url("/assets/img/header-bar.png") 0 0 / cover no-repeat;
  pointer-events: none;
}

.site-header {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--header-pad) var(--header-side, var(--gutter));
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
}

.site-title {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: var(--lh-title);
}
.site-title a { color: inherit; text-decoration: none; }

.site-tagline {
  margin: 0;
  font-size: 17px;
  font-weight: 400;
  line-height: var(--lh-title);
}

.site-nav ul {
  display: flex;
  margin: 0;
  padding: 0 0 0 20px;
  list-style: none;
}
.site-nav li + li { margin-left: 1.4vw; }
.site-nav a {
  display: block;
  padding: 0.1em 0;
  color: var(--ink);
  text-decoration: none;
  font-size: var(--fs-body);
  line-height: 1.7;
}
.site-nav a[aria-current="page"] {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: repeat-x;
  background-size: 1px 1px;
  background-position: 0 calc(100% - 0.1em);
}

.menu-toggle { display: none; }

/* Navy header variant (the Complementarity page uses a different color theme) */
.theme-navy .site-title,
.theme-navy .site-tagline { color: var(--navy); }

/* ---------- Mobile header + overlay menu ---------- */

@media (max-width: 799px) {
  .site-nav { display: none; }

  .menu-toggle {
    display: block;
    position: relative;
    width: 47px;
    height: 37px;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    color: var(--ink);
    cursor: pointer;
  }
  .menu-toggle span {
    position: absolute;
    left: 6px;
    width: 35px;
    height: 1px;
    background: currentColor;
    transition: transform 0.25s ease;
  }
  .menu-toggle span:first-child { top: calc(50% - 6px); }
  .menu-toggle span:last-child { top: calc(50% + 5px); }
  .menu-open .menu-toggle span:first-child { transform: translateY(5.5px) rotate(45deg); }
  .menu-open .menu-toggle span:last-child { transform: translateY(-5.5px) rotate(-45deg); }

  .menu-open { overflow: hidden; }
  .menu-open .site-nav {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: -1;
    align-items: center;
    justify-content: center;
    padding-top: calc(var(--header-h) + 11vw);
    background: #fff;
  }
  .menu-open .site-nav ul { flex-direction: column; align-items: center; padding: 0; }
  .menu-open .site-nav li + li { margin-left: 0; margin-top: 0.87em; }
  .menu-open .site-nav li { font-size: 8.5vw; line-height: 1; }
  .menu-open .site-nav a { font-size: inherit; line-height: 1; padding: 0; }
  .menu-open .site-nav a[aria-current="page"] { background: none; }
}

@media (max-width: 640px) {
  .site-tagline { font-size: 15px; }
  /* The original forces paragraph text to .99rem on phones; paper titles and
     abstract toggles were paragraphs there, so they shrink too. */
  main p,
  .paper-title,
  .abstract summary { font-size: 0.99rem; }
}

/* ---------- Main + grid ---------- */

main {
  flex: 1 0 auto;
  width: 100%;
}

.page {
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: calc(var(--bar) + var(--wrap-pad)) var(--gutter) var(--wrap-pad);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--gap);
}
.grid > * { grid-column: 1 / -1; min-width: 0; }

/* Teaching and Data sections carry larger vertical padding on the original */
.page--padded {
  padding-top: calc(var(--bar) + var(--wrap-pad-lg));
  padding-bottom: var(--wrap-pad-lg);
}

/* Thin black rule (Squarespace line block): one grid row, line centered.
   The cell never shrinks below the rule plus its .5em margins. */
.rule {
  height: max(var(--row), calc(1em + 1px));
  display: flex;
  align-items: center;
}
.rule::before {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ink);
}

/* ---------- Home ---------- */

.home {
  row-gap: var(--gap);
  grid-template-rows: calc(2 * var(--row) + var(--gap)) auto auto;
}
.home__photo {
  grid-column: 5 / 8;
  grid-row: 1 / 4;
  align-self: start;
  width: 100%;
  /* six grid rows; the rule's row can grow past one row (see .rule) */
  height: calc(5 * var(--row) + 5 * var(--gap) + max(var(--row), calc(1em + 1px)));
  object-fit: cover;
  object-position: 46.5% 34.4%;
}
.home__logo {
  grid-column: 9 / 15;
  grid-row: 1;
  align-self: stretch;
  display: flex;
  align-items: center;
}
/* fit the logo inside its cell (Squarespace "contain"), left-aligned */
.home__logo img { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.home__rule { grid-column: 9 / 21; grid-row: 2; }
.home__text { grid-column: 9 / 21; grid-row: 3; }

.home__text hr {
  margin: 33.333px 0;
  height: 0;
  border: 0;
  border-bottom: 1px solid var(--rule-light);
}

/* The original's custom CSS nudges three home blocks at tablet widths */
@media (min-width: 768px) and (max-width: 991px) {
  .home__photo { position: relative; left: -50px; width: 143%; max-width: none; }
  .home__logo,
  .home__rule { position: relative; left: 50px; }
}

@media (max-width: 767px) {
  .home {
    grid-template-rows: calc(2 * var(--row) + var(--gap)) calc(2 * var(--row) + var(--gap)) var(--row) auto;
    margin-bottom: calc(var(--row) + var(--gap));
  }
  .home__photo { grid-column: 1 / 4; grid-row: 1 / 3; height: calc(4 * var(--row) + 3 * var(--gap)); }
  .home__logo { grid-column: 4 / 9; grid-row: 2; align-items: flex-end; }
  /* on phones this rule sits .5em below the top of its row, not centered */
  .home__rule { grid-column: 1 / -1; grid-row: 3; align-items: flex-start; padding-top: 0.5em; }
  .home__text { grid-column: 1 / -1; grid-row: 4; }
}

/* ---------- Research ---------- */

.grid--flush { column-gap: 0; }
.research { grid-column: 5 / 21; }
/* a heading cell is at least one grid row tall (matters on wide screens) */
.research h2 { min-height: var(--row); }

.paper-title {
  font-size: inherit;
  line-height: inherit;
  font-weight: 700;
  font-style: italic;
}
.paper-title + p { margin-top: 0; }

/* Squarespace blocks span a fixed number of grid rows (set per block in the
   editor, separately for desktop and mobile) and grow only if the text needs
   more. --rows / --m-rows on each block carry those counts. */
.paper-info,
.dataset,
.data-note,
.page-body { --n: var(--rows, 0); }
.paper-info { min-height: calc(var(--n) * var(--row)); }
.dataset,
.data-note,
.page-body { min-height: max(0px, calc(var(--n) * var(--row) + (var(--n) - 1) * var(--gap))); }
@media (max-width: 767px) {
  .paper-info,
  .dataset,
  .data-note,
  .page-body { --n: var(--m-rows, 0); }
}

.abstract summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30px 0;
  list-style: none;
  cursor: pointer;
  line-height: normal;
}
.abstract summary::-webkit-details-marker { display: none; }
.abstract__label {
  flex: 1;
  padding-right: 14px;
  text-align: right;
}
.abstract__icon {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  transition: transform 0.25s;
}
.abstract__icon::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 9.9px;
  height: 9.9px;
  margin: -4.95px 0 0 -4.95px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2.475px) rotate(45deg);
}
.abstract[open] .abstract__icon { transform: rotate(180deg); }
.abstract__body {
  width: 90%;
  margin: 0 auto;
  padding-bottom: 30px;
}
.abstract { margin-bottom: var(--row); }

@media (max-width: 767px) {
  .research { grid-column: 1 / -1; }
  /* mobile: heading spans two rows and the rule sits in the second */
  .research h2 { height: var(--row); min-height: 0; }
  /* a closed abstract toggle occupies exactly four 24px grid rows */
  .abstract { margin-bottom: 0; min-height: calc(4 * var(--row)); }
  /* the mobile grid ends with two empty rows */
  .research { padding-bottom: calc(2 * var(--row)); }
}

@media (max-width: 640px) {
  .paper-title { font-size: 0.99rem; }
}

/* ---------- Teaching + Data ---------- */

.page-heading { grid-column: 3 / 8; }
.page-body { grid-column: 8 / 23; }

.page-body h2 + p { margin-top: 32px; }

.course + .course { margin-top: calc(48px + 1.7 * var(--fs-body)); }
@media (max-width: 640px) {
  /* the original's empty spacer paragraph between courses shrinks too */
  .course + .course { margin-top: calc(48px + 1.7 * 0.99rem); }
}

.dataset + .dataset { margin-top: calc(var(--row) + 2 * var(--gap)); }

.data-note {
  grid-column: 6 / 20;
  margin-top: calc(var(--row) + 2 * var(--gap));
  text-align: center;
}

@media (max-width: 767px) {
  .page-heading,
  .page-body,
  .data-note { grid-column: 1 / -1; }
  .page-heading { min-height: calc(2 * var(--row) + var(--gap)); margin-bottom: var(--gap); }
}

/* ---------- Complementarity ---------- */

.page--flush { padding-top: var(--bar); padding-bottom: 0; }
.viz-title { color: var(--navy); text-align: center; min-height: var(--row); }
.viz {
  display: block;
  width: 1200px;
  max-width: 100%;
  height: 800px;
  margin: calc(var(--gap) + 16px) auto 25.3px;
  border: 0;
}

@media (max-width: 767px) {
  .viz-title { min-height: calc(2 * var(--row) + var(--gap)); }
}

/* ---------- 404 ---------- */

.not-found { grid-column: 3 / 23; }
.not-found h1 { margin-bottom: 32px; }

@media (max-width: 767px) {
  .not-found { grid-column: 1 / -1; }
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: auto;
  background: var(--footer-bg);
  color: #fff;
}
/* Footer section: at least 10% of the window tall, content centered */
.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: calc(var(--max) + 2 * var(--gutter));
  min-height: max(10vh, calc(var(--row) + 2 * var(--wrap-pad)));
  margin: 0 auto;
  padding: var(--wrap-pad) var(--gutter);
}
.site-footer__logo { display: block; }
.site-footer__logo img {
  width: calc(7.8333vw - 10.083px);
  height: auto;
}
.site-footer__social {
  display: block;
  width: 40px;
  height: 40px;
  margin-right: -10px;
  color: #fff;
}
.site-footer__social svg { display: block; width: 40px; height: 40px; fill: currentColor; }

@media (max-width: 767px) {
  .site-footer__inner {
    min-height: max(10vh, calc(3 * var(--row) + 2 * var(--gap) + 2 * var(--wrap-pad)));
  }
  .site-footer__logo img { width: calc(44vw - 5.5px); }
  .site-footer__social {
    align-self: flex-end;
    margin-bottom: calc(var(--wrap-pad) + var(--row) + var(--gap) / 2 - 20px);
  }
}
