/* ============================================================================
   Tonal Research Lab — homepage styles
   Design tokens blend OpenAI (near-black bg, off-white text), Google Research
   (rounded hover tiles), and the Tonal brand (dark grey + teal accent).
   ========================================================================= */

/* GT America (Grilli Type) — self-hosted, licensed. Two cuts:
   "GT America" (Standard) is the body/UI font; "GT America Expanded" is the
   wider display cut used for the brand wordmark. Only the weights whose .woff2
   files exist in assets/fonts/ are declared. */
@font-face {
  font-family: "GT America";
  src: url("assets/fonts/GT-America-Standard-Light.otf") format("opentype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America";
  src: url("assets/fonts/GT-America-Standard-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America";
  src: url("assets/fonts/GT-America-Standard-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America";
  src: url("assets/fonts/GT-America-Standard-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America Expanded";
  src: url("assets/fonts/GT-America-Expanded-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America Expanded";
  src: url("assets/fonts/GT-America-Expanded-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #000000;            /* page background (OpenAI black) */
  --surface: #1b1e1f;       /* tile / card dark grey (Tonal primary) */
  --surface-2: #26292b;     /* hover / raised surface */
  --border: #2c2f31;        /* hairline borders */
  --text: #f2f2ec;          /* off-white primary text (Tonal secondary) */
  --text-dim: #9aa0a0;      /* meta text: dates, authors */
  --accent: rgb(17, 221, 196);       /* #11ddc4 teal */
  --accent-soft: rgba(17, 221, 196, 0.14);
  --radius: 16px;
  --control-h: 32px;        /* shared height for the nav controls */
  --max-width: 1400px;
  --font: "GT America", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must win over author display rules (e.g. .grid) so
   hiding the empty list / empty-state actually works. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ===== Top hero (full-width animated background) ========================= */
.hero {
  position: relative;
  width: 100%;
  height: 384px;
  overflow: hidden;
  background: var(--bg);
}

.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Header ============================================================ */
.site-header {
  position: relative;   /* sit above the canvas */
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 1.5rem;
}

.brand {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.brand__logo {
  height: 1.1rem;
  width: auto;
  display: block;
  margin-left: 4px; /* nudge the logo right to align with "Research" */
}

.brand__text {
  font-size: 3.5rem;
  font-weight: 300; /* GT America Standard Light — narrower than Expanded */
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 2;
}

/* ===== View / filter controls =========================================== */
/* One right-aligned row: view toggle, category, About link. Sits low in the
   band under the hero so it reads with the list it controls. */
.controls {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* List-view column headings, sharing the controls row with the widgets. The
   grid tracks match .row, and taking the free space (flex: 1) keeps each
   heading over its column while the widgets stay pinned right. */
.list-head {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: 9rem 8rem 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0 0.9rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-about {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-about:hover {
  color: var(--text);
  background: var(--surface);
}

/* Segmented list / tile switch. */
.viewtoggle {
  display: inline-flex;
  height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 2px;
}

.viewtoggle__btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 0 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.viewtoggle__btn svg {
  fill: currentColor;
}

.viewtoggle__btn:hover {
  color: var(--text);
}

.viewtoggle__btn.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.viewtoggle__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Category filter: a fixed "Filter" button that opens a radio menu, so the
   label never changes to the chosen value the way a native select does. */
.filter {
  position: relative;
}

.filter__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: var(--control-h);   /* match the view toggle */
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.filter__btn svg {
  color: var(--text-dim);
}

.filter__btn:hover,
.filter__btn[aria-expanded="true"] {
  border-color: var(--text-dim);
}

.filter__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Shown only while a category other than "All" is active. */
.filter__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.filter__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  min-width: 160px;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}

.filter__option {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.filter__option:hover {
  color: var(--text);
  background: var(--surface-2);
}

.filter__option[aria-checked="true"] {
  color: var(--text);
}

.filter__option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Radio mark: an outlined circle that fills teal when checked. */
.filter__radio {
  flex: none;
  width: 13px;
  height: 13px;
  border: 1px solid var(--text-dim);
  border-radius: 50%;
}

.filter__option[aria-checked="true"] .filter__radio {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 2.5px var(--surface);
}

/* ===== Main / About ===================================================== */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.25rem 1.5rem 3rem;
}

/* About: spans the same width as the publications list above it. */
.about {
  margin: 2.5rem 0 0;
  color: var(--text);
  scroll-margin-top: 1.5rem;
}

.about__title {
  font-size: 2.25rem;
  font-weight: 300;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

.about__lead {
  font-size: 1.2rem;
  color: var(--text);
  margin: 0 0 2rem;
}

.about h2 {
  font-size: 1.4rem;
  font-weight: 500;
  margin: 2.5rem 0 0.75rem;
}

.about p {
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1.7;
  margin: 0 0 1rem;
}

/* Media stays at a sane size even though the section is now full width. */
.about__figure {
  max-width: 760px;
  margin: 2rem auto;
}

.about__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 120% at 30% 15%, var(--accent-soft), transparent 55%),
    linear-gradient(135deg, var(--surface-2), var(--surface));
}

.about__video,
.about__img {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

.about__video {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background: none;
}

.about__video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  /* Decorative loop — block interaction so hover/tap never re-shows controls. */
  pointer-events: none;
}

.about__figure figcaption {
  margin-top: 0.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
}

/* Team: small round portraits, at most 3 per row. Flex (not grid) so a short
   final row centers on its own midpoint instead of left-aligning to columns;
   the max-width is what caps the row at three. */
.team {
  list-style: none;
  margin: 1.5rem auto 0;
  padding: 0;
  max-width: 700px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem 1.25rem;
}

.team__member {
  margin: 0;
  flex: 0 1 200px;
  text-align: center;
}

.team__portrait {
  display: block;
  width: 104px;
  height: 104px;
  margin: 0 auto;
  object-fit: cover;
  /* border: 1px solid var(--border); */
  border-radius: 50%;
  background: var(--surface);
}

.team__name {
  font-size: 1rem;
  font-weight: 500;
  margin: 0.75rem 0 0.25rem;
}

.team__bio {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

/* Careers call-to-action closing the Team section. */
.join {
  margin: 3rem 0 0;
  text-align: center;
}

.join__link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--accent);
  font-size: 1.05rem;
  padding: 0.55rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.join__link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.join__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== List view (default) ============================================== */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: grid;
  grid-template-columns: 9rem 8rem 1fr;
  align-items: baseline;
  gap: 1rem;
  padding: 0.95rem 0.9rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.row:hover {
  background: var(--surface);
}

.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.row__date {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.row__category {
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.row__title {
  margin: 0;
  font-size: 1.0rem;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.row:hover .row__title {
  color: var(--accent);
}

/* ===== Tile view ======================================================== */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  column-gap: 1.5rem;   /* ~20% more horizontal spacing */
  row-gap: 2.5rem;      /* ~20% more vertical spacing */
}

.tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);      /* blends into the page until hovered */
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem;
  transition: transform 0.18s ease, background 0.18s ease;
}

.tile:hover {
  transform: translateY(-4px);
  background: var(--accent);  /* card lights up teal on hover */
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Picture on top (Google-Research style); text sits below it. */
.tile__thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);   /* very thin outline */
  border-radius: 12px;
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Placeholder art until a real `image` is supplied per article. */
  background-image:
    radial-gradient(120% 120% at 30% 15%, var(--accent-soft), transparent 55%),
    linear-gradient(135deg, var(--surface-2), var(--surface));
}

.tile:hover .tile__thumb {
  border-color: rgba(0, 0, 0, 0.4);
}

.tile__title {
  margin: 0.9rem 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.tile__desc {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.tile__meta {
  margin-top: auto;
  padding-top: 1rem;
  display: flex;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.tile__meta-dot {
  opacity: 0.6;
}

/* On the teal hover state, flip text to dark for contrast. */
.tile:hover .tile__title {
  color: #06201d;
}

.tile:hover .tile__desc,
.tile:hover .tile__meta {
  color: rgba(6, 32, 29, 0.82);
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 3rem 1rem;
}

/* ===== Footer =========================================================== */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer__about {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.site-footer__links {
  display: flex;
  gap: 1.25rem;
}

.site-footer__links a {
  color: var(--accent);
  font-size: 0.9rem;
}

.site-footer__links a:hover {
  text-decoration: underline;
}

/* ===== Responsive ======================================================= */
@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }

  /* The stacked rows below no longer line up with column headings. */
  .list-head {
    display: none;
  }

  /* Stack the row: date + category on one line, title beneath. */
  .row {
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
  }

  .row__title {
    grid-column: 1 / -1;
  }

  /* Two per row on narrow screens. */
  .team__member {
    flex-basis: 140px;
  }

  .controls {
    justify-content: flex-start;
  }
}
