/* Custom styles on top of Bulma, adapted from nerfies.github.io.
   Mobile-first: base rules target phones, desktop overrides at >= 769px. */

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

body {
  font-family: 'Noto Sans', sans-serif;
  overflow-x: hidden;
}

img,
video {
  max-width: 100%;
  height: auto;
}

/* ---------- Hero ---------- */

.publication-title,
.publication-venue,
.publication-authors {
  font-family: 'Google Sans', 'Noto Sans', sans-serif;
}

.publication-title.is-1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin-bottom: 0.5rem !important;
  overflow-wrap: anywhere;
}

/* Deliberately not a Bulma .subtitle: that class pulls itself up under the
   title by 1.25rem and overlaps a wrapped title on phones. */
.publication-venue {
  display: block;
  color: #4a4a4a;
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.3;
  margin: 0.25rem 0 1rem;
}

.publication-venue a {
  color: inherit;
  border-bottom: 1px solid #c8c8c8;
}

.publication-venue a:hover {
  color: hsl(204, 86%, 53%);
  border-bottom-color: currentColor;
}

.author-email {
  font-size: 0.75em;
  margin-left: 0.2em;
  color: #7a7a7a !important;
  vertical-align: baseline;
}

.publication-authors {
  font-size: 1rem !important;
  line-height: 1.6;
}

.publication-authors a {
  color: hsl(204, 86%, 53%) !important;
}

.publication-authors a:hover {
  text-decoration: underline;
}

.author-block {
  display: inline-block;
}

.publication-note {
  margin-top: 0.5rem;
}

.publication-links {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.link-block a {
  font-size: 0.9rem;
  min-height: 44px; /* comfortable tap target */
}

.hero .hero-body {
  padding: 2rem 1rem 1.5rem;
}

.hero .hero-body .column.has-text-centered .column {
  padding: 0.5rem 0 0;
}

/* ---------- Teaser ---------- */

.hero.teaser .hero-body {
  padding-top: 0;
  padding-bottom: 2rem;
}

.teaser-block {
  margin: 0.75rem 0 1.25rem;
}

/* Inside the hero on phones: bleed edge to edge so the video is as large as
   the screen allows. */
.hero .teaser-block {
  margin-left: -1rem;
  margin-right: -1rem;
}

.hero .teaser-block .publication-video,
.hero .teaser-block video,
.hero .teaser-block img {
  border-radius: 0 !important;
}

.teaser-block video,
.teaser-block img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #f5f5f5;
}

.teaser-caption {
  margin-top: 0.6rem;
  padding: 0 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #4a4a4a;
  text-align: center;
}

.teaser-sound {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.85rem;
  color: #7a7a7a;
  white-space: nowrap;
}

.teaser-sound:hover {
  color: hsl(204, 86%, 53%);
}

.hero .publication-authors {
  margin-top: 0.5rem;
}

/* Still figure under the teaser video. The scroll wrap handles its own bleed,
   so undo the hero bleed on this block. */
.hero .teaser-block.teaser-figure-block {
  margin: 0.25rem 0 1rem;
}

.teaser-figure-block .section-media {
  margin-top: 0;
  border-radius: 0;
}

.teaser-figure-block .results-table-hint {
  margin-top: 0.1rem;
}

/* ---------- Sections ---------- */

.section {
  padding: 2rem 1rem;
}

.section .title.is-3 {
  font-size: 1.5rem;
}

/* Justified text produces rivers on narrow screens. */
.content.has-text-justified {
  text-align: left !important;
}

.paper-section + .paper-section {
  margin-top: 2.5rem;
}

.section-media {
  display: block;
  width: 100%;
  height: auto;
  margin: 0.75rem auto 1rem auto;
  border-radius: 6px;
}

/* Wide diagrams: on phones, scroll sideways at a readable size instead of
   shrinking to a thumbnail. Desktop shows them at natural width. */
.section-media-wrap.is-scrollable {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -1rem;
  padding: 0 1rem;
  scrollbar-width: thin;
}

.section-media-wrap.is-scrollable .section-media {
  width: var(--minw, 720px);
  max-width: none;
  margin-bottom: 0.25rem;
}

.section-media-wrap.is-scrollable + .results-table-hint {
  margin-bottom: 0.75rem;
}

.publication-video {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  overflow: hidden;
  border-radius: 10px !important;
}

.publication-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ---------- Results galleries (native scroll-snap) ---------- */

.gallery-section .hero-body {
  padding: 1.5rem 0;
}

/* Alternate background so two adjacent galleries read as separate blocks. */
.gallery-section + .gallery-section {
  background-color: #fff;
}

.gallery-section.gallery-accent {
  background: linear-gradient(180deg, #f3f6fb 0%, #e9eef7 100%);
}

.gallery-header {
  padding: 0 1rem 0.75rem;
}

.gallery-header .title.is-3 {
  margin-bottom: 0.5rem;
}

.gallery-badge {
  display: inline-block;
  margin-bottom: 0.5rem;
  background: #363636;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.gallery-accent .gallery-badge {
  background: hsl(204, 86%, 45%);
}

.gallery-description {
  max-width: 44rem;
  margin: 0 auto;
  font-size: 0.95rem;
  color: #4a4a4a;
}

.gallery-description p:last-child {
  margin-bottom: 0;
}

.gallery-label {
  display: block;
  font-weight: 600;
  color: #363636;
}

.gallery-accent .gallery-label {
  color: hsl(204, 86%, 40%);
}

.gallery-caption-text {
  display: block;
}

.gallery-wrap {
  position: relative;
}

.gallery {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 1rem 0.5rem;
  scroll-padding: 0 1rem;
  scrollbar-width: none;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.gallery:focus-visible {
  outline: 2px solid hsl(204, 86%, 53%);
  outline-offset: 2px;
}

.gallery-item {
  flex: 0 0 86%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  margin: 0;
  border: 1px solid #ddd;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  font-size: 0;
}

.gallery-item video,
.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}

.gallery-caption {
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.5rem 0.75rem;
  color: #4a4a4a;
  text-align: center;
}

.gallery-nav {
  display: none; /* touch devices swipe; buttons shown on desktop below */
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: rgba(255, 255, 255, 0.95);
  color: #363636;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.gallery-nav:hover {
  background: #fff;
}

.gallery-prev { left: -8px; }
.gallery-next { right: -8px; }

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 0.25rem;
}

.gallery-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c8c8c8;
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
}

.gallery-dot.is-active {
  background: #363636;
  transform: scale(1.25);
}

/* ---------- Results table ---------- */

.results-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem -1rem 0.5rem; /* bleed to the phone edge so it hints scrollability */
  padding: 0 1rem;
  scrollbar-width: thin;
}

.results-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 30rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  background: #fff;
}

.results-table th,
.results-table td {
  padding: 0.6rem 0.85rem;
  text-align: center !important;
  vertical-align: middle;
  white-space: nowrap;
}

.results-table td:not(.row-label),
.results-table thead th:not(.row-label) {
  min-width: 5.5rem;
}

.results-table thead th {
  border-top: 2px solid #363636;
  border-bottom: 1px solid #363636;
  font-weight: 600;
  color: #363636;
}

.results-table tbody tr:last-child td,
.results-table tbody tr:last-child th {
  border-bottom: 2px solid #363636;
}

.results-table .row-label {
  text-align: left !important;
  font-weight: 500;
  color: #363636;
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 1;
  box-shadow: 2px 0 0 rgba(0, 0, 0, 0.04);
}

.results-table thead .row-label {
  background: #fff;
}

.results-table tbody tr {
  background: #fff;
}

.results-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.results-table tbody tr.is-highlight {
  background: #fff7cc;
}

.results-table tbody tr.is-highlight .row-label {
  font-weight: 700;
}

.results-table .dir {
  color: #9a9a9a;
  font-size: 0.85em;
  margin-left: 0.15em;
}

.results-table .stat {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.results-table .sd {
  font-size: 0.75em;
  color: #8a8a8a;
  margin-top: 0.1em;
}

.results-table .is-best .v {
  font-weight: 800;
  color: #000;
}

.results-table .is-best .sd {
  font-weight: 600;
  color: #555;
}

.results-table-hint {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: #9a9a9a;
  margin-top: 0.35rem;
}

.results-table-note {
  font-size: 0.85rem;
  color: #6a6a6a;
  margin-top: 0.5rem;
}

.results-table-note p:last-child {
  margin-bottom: 0;
}

/* ---------- BibTeX ---------- */

.bibtex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bibtex-header .title {
  margin-bottom: 0;
  font-size: 1.5rem;
}

#BibTeX pre {
  margin-top: 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.footer {
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.footer .icon-link {
  font-size: 25px;
  color: #000;
  margin: 0 0.5rem;
}

/* ---------- Tablet / desktop overrides ---------- */

@media screen and (min-width: 769px) {
  .publication-title.is-1 {
    font-size: 3rem;
  }

  .publication-venue {
    font-size: 1.5rem;
    margin-top: 0.5rem;
  }

  .publication-authors {
    font-size: 1.25rem !important;
  }

  .link-block a {
    font-size: 1rem;
  }

  .hero .hero-body {
    padding: 3rem 1.5rem 1.5rem;
  }

  .hero.teaser .hero-body {
    padding-bottom: 3rem;
  }

  .teaser-block {
    margin: 1.25rem 0 1.5rem;
  }

  .hero .teaser-block {
    margin-left: 0;
    margin-right: 0;
  }

  .hero .teaser-block .publication-video,
  .hero .teaser-block video,
  .hero .teaser-block img {
    border-radius: 8px !important;
  }

  .teaser-caption {
    font-size: 1.05rem;
    padding: 0;
  }

  .hero .teaser-block.teaser-figure-block {
    margin: 0.5rem 0 1.25rem;
  }

  .teaser-figure-block .section-media {
    border-radius: 6px;
  }

  .section {
    padding: 3rem 1.5rem;
  }

  .section .title.is-3,
  .bibtex-header .title {
    font-size: 2rem;
  }

  .content.has-text-justified {
    text-align: justify !important;
  }

  .paper-section + .paper-section {
    margin-top: 3rem;
  }

  .gallery-section .hero-body {
    padding: 2rem 1.5rem;
  }

  .gallery-header {
    padding: 0 0 1rem;
  }

  .gallery {
    padding: 0.25rem 0 0.5rem;
    scroll-padding: 0;
  }

  .gallery-item {
    flex-basis: calc((100% - 1.5rem) / 3);
    scroll-snap-align: start;
  }

  .gallery-caption {
    font-size: 0.9rem;
  }

  #BibTeX pre {
    font-size: 0.875rem;
  }

  .results-table-wrap {
    margin: 1.25rem 0 0.5rem;
    padding: 0;
  }

  .results-table {
    font-size: 0.95rem;
    min-width: 0;
  }

  .results-table {
    font-size: 1rem;
    table-layout: fixed;
  }

  .results-table th,
  .results-table td {
    padding: 0.75rem 1rem;
  }

  .results-table .row-label {
    width: 22%;
  }

  .results-table td:not(.row-label),
  .results-table thead th:not(.row-label) {
    min-width: 0;
  }

  /* Wide screens: mean and ± std on one line, like the paper. */
  .results-table .stat {
    flex-direction: row;
    align-items: baseline;
  }

  .results-table .sd {
    font-size: 0.85em;
    margin-top: 0;
    margin-left: 0.5em;
  }

  .section-media-wrap.is-scrollable {
    overflow: visible;
    margin: 0;
    padding: 0;
  }

  .section-media-wrap.is-scrollable .section-media {
    width: 100%;
    max-width: 100%;
  }

  .results-table-note {
    font-size: 0.9rem;
  }

  .results-table-hint {
    display: none;
  }

  .footer {
    padding: 3rem 1.5rem;
  }
}

/* Prev/next buttons on wide screens; hidden again on touch-only devices. */
@media screen and (min-width: 769px) {
  .gallery-nav {
    display: flex;
  }
}

@media (hover: none) and (pointer: coarse) {
  .gallery-nav {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
