@tailwind base;
@tailwind components;
@tailwind utilities;

.leaflet-attribution-flag {
  visibility: hidden;
}

.quick-start-trigger,
.guide-topic-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  font: inherit;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.quick-start-trigger {
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.quick-start-trigger:hover,
.guide-topic-button:hover {
  border-color: #475569;
  color: #0f172a;
  background: #f8fafc;
}

.quick-start-trigger:focus-visible,
.guide-topic-button:focus-visible,
.guide-dialog__close:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}

.quick-start-trigger svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.about-guide {
  margin-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1.25rem;
}

.about-guide-trigger {
  margin-top: 0.75rem;
}

.guide-topic-button {
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.guide-dialog {
  width: min(100% - 2rem, 42rem);
  max-width: 42rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: #0f172a;
}

.guide-dialog::backdrop {
  background: rgb(15 23 42 / 0.42);
}

.guide-dialog__surface {
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 1.5rem;
  box-shadow: 0 24px 56px rgb(15 23 42 / 0.24);
}

.guide-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.guide-dialog__eyebrow {
  margin: 0;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guide-dialog__title {
  margin: 0.3rem 0 0;
  font-size: 1.25rem;
  line-height: 1.35;
}

.guide-dialog__close {
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 1.75rem;
  line-height: 1;
}

.guide-dialog__close:hover {
  color: #0f172a;
}

.guide-dialog__intro {
  margin: 1rem 0 0;
  color: #475569;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.guide-dialog__steps {
  display: grid;
  gap: 0.875rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: guide-step;
}

.guide-dialog__steps li {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  column-gap: 0.75rem;
  color: #475569;
  font-size: 0.875rem;
  line-height: 1.45;
}

.guide-dialog__steps li::before {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  background: #f1f5f9;
  color: #334155;
  content: counter(guide-step);
  counter-increment: guide-step;
  font-size: 0.75rem;
  font-weight: 700;
}

.guide-dialog__steps strong,
.guide-dialog__steps span {
  grid-column: 2;
}

.guide-dialog__steps strong {
  color: #0f172a;
}

.guide-dialog__steps span {
  margin-top: 0.125rem;
}

.plasma-ace-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.plasma-ace-legend i {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
}

.plasma-ace-bar:focus {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}

.epitope-bar:focus {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}

.protein-camera-reset {
  position: absolute;
  z-index: 20;
  top: 1rem;
  right: 13.5rem;
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  background: rgb(255 255 255 / 0.9);
  color: #334155;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.08);
  backdrop-filter: blur(4px);
}

.protein-camera-reset:hover {
  border-color: #64748b;
  color: #0f172a;
}

.protein-camera-reset:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}

.protein-camera-reset svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

#epitopeChart {
  padding: 1.25rem;
}

main table th,
main table td {
  text-align: center;
}

main table th.text-left,
main table td.text-left {
  text-align: left;
}

main table th.text-right,
main table td.text-right {
  text-align: right;
}

.blood-ace-value {
  color: #0f172a;
}

.blood-ace-layout {
  display: inline-grid;
  grid-template-columns: 3ch 4.5rem;
  width: 7.5rem;
  align-items: baseline;
  text-align: initial;
}

.blood-ace-layout--right {
  display: grid;
  margin-left: auto;
}

.blood-ace-layout--inline {
  display: inline-flex;
  width: auto;
}

.blood-ace-layout--inline .blood-ace-number,
.blood-ace-layout--inline .blood-ace-references {
  min-width: 0;
}

.blood-ace-layout--inline .blood-ace-number {
  text-align: left;
}

.blood-ace-layout--inline .blood-ace-references {
  padding-left: 0.25rem;
}

.blood-ace-number {
  min-width: 3ch;
  text-align: right;
}

.blood-ace-references {
  min-width: 4.5rem;
  padding-left: 0.25rem;
  text-align: left;
}

.rsid-reference-layout {
  display: inline-grid;
  grid-template-columns: 13ch 4.5rem;
  align-items: baseline;
}

.rsid-reference-value {
  min-width: 13ch;
}

.rsid-reference-links {
  min-width: 4.5rem;
  padding-left: 0.25rem;
  text-align: left;
}

.blood-ace-value-low {
  background: #00ffff;
}

.blood-ace-value-yellow {
  background: #ffff00;
}

.blood-ace-value-orange {
  background: #ffc000;
}

.blood-ace-value-red {
  background: #ff0000;
}

#tableHead th,
#structuralTable thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f8fafc;
  box-shadow: inset 0 -1px 0 #e2e8f0;
}

#referencesList li {
  transition: background-color 180ms ease, box-shadow 180ms ease;
}

#referencesList .reference-details--compact {
  font-size: 0.8125rem;
  letter-spacing: -0.01em;
  line-height: 1.25rem;
}

#referencesList li.reference-highlight {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 #2563eb;
}

body[data-active-page="all"] main {
  display: grid;
  height: auto;
  min-height: 0;
  grid-template-columns: minmax(420px, 1.05fr) minmax(420px, 0.95fr);
  grid-template-rows: 380px 560px 560px 620px;
  gap: 1rem;
  align-items: stretch;
  overflow: visible;
}

body[data-active-page="all"] [data-all-area="variant-distribution"] {
  display: block;
  grid-column: 1 / -1;
  grid-row: 1;
}

.variant-distribution-content {
  display: grid;
  height: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.variant-distribution-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 1.5rem 1.75rem;
}

.variant-distribution-card > h2,
.low-ace-summary h2 {
  text-align: center;
  font-size: 1.25rem;
  line-height: 1.5rem;
}

.variant-distribution-chart {
  position: relative;
  width: 168px;
  height: 168px;
  flex: 0 0 168px;
  border-radius: 50%;
  background: conic-gradient(
    #a89acb 0deg 296.6deg,
    #f7bd62 296.6deg 341.5deg,
    #70c6ae 341.5deg 360deg
  );
}

.variant-distribution-chart::after {
  position: absolute;
  inset: 35px;
  border-radius: 50%;
  background: #ffffff;
  content: "";
}

.variant-distribution-chart__center {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.1;
  color: #0f172a;
  text-align: center;
}

.variant-distribution-chart__center small,
.variant-distribution-legend small {
  font-size: 0.75em;
  font-weight: 400;
  color: #64748b;
}

.variant-distribution-legend {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #334155;
  font-size: 0.875rem;
}

.variant-distribution-legend li {
  display: grid;
  grid-template-columns: 0.875rem minmax(220px, 1fr) auto;
  align-items: center;
  gap: 0.625rem;
}

.variant-distribution-legend strong {
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.variant-distribution-swatch {
  width: 0.875rem;
  height: 0.875rem;
}

.variant-distribution-swatch--missense { background: #a89acb; }
.variant-distribution-swatch--loss { background: #f7bd62; }
.variant-distribution-swatch--signal { background: #70c6ae; }

.variant-distribution-note {
  max-width: 700px;
  margin-top: 0.75rem;
  color: #475569;
  font-size: 0.875rem;
  line-height: 1.5;
  text-align: center;
}

.low-ace-summary {
  min-width: 0;
  text-align: center;
  color: #0f172a;
}

.low-ace-summary h2 {
  margin: 0;
  color: #0f172a;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.low-ace-summary__subtitle {
  margin-top: 0.75rem;
  color: #475569;
  font-size: 0.8125rem;
  font-weight: 600;
}

.low-ace-summary__value {
  margin-top: 0.875rem;
  color: #1d4ed8;
  font-size: 2.75rem;
  font-weight: 600;
  line-height: 1;
}

.low-ace-summary__ratio {
  margin-top: 0.5rem;
  color: #334155;
  font-size: 1rem;
  font-weight: 600;
}

.low-ace-summary__people {
  display: grid;
  width: min(100%, 220px);
  margin: 0.875rem auto 0;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 0.25rem;
}

.low-ace-summary__people span {
  position: relative;
  display: block;
  height: 1.625rem;
  border-radius: 999px 999px 0.375rem 0.375rem;
  background: #dbeafe;
}

.low-ace-summary__people span::before {
  position: absolute;
  top: -0.35rem;
  left: 50%;
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 999px;
  background: inherit;
  content: "";
  transform: translateX(-50%);
}

.low-ace-summary__people .is-highlighted,
.low-ace-summary__people .is-highlighted::before {
  background: #1d4ed8;
}

.low-ace-summary__text {
  margin: 0.75rem auto 0;
  max-width: 300px;
  color: #475569;
  font-size: 0.75rem;
  line-height: 1.45;
}

body[data-active-page="all"] div[data-page-panel="all"] {
  display: flex;
  min-height: 0;
  grid-column: 1;
  grid-row: 2;
  flex-direction: column;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

body[data-active-page="all"] [data-all-area="filters"] {
  flex: 0 0 auto;
  padding: 1rem;
}

body[data-active-page="all"] [data-all-area="filters"] > div:first-child {
  grid-template-columns: minmax(0, 1fr);
}

body[data-active-page="all"] [data-all-area="filters"] .text-sm.text-slate-500 {
  display: none;
}

body[data-active-page="all"] [data-all-area="table"] {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 1rem;
  padding-top: 0.875rem;
}

body[data-active-page="all"] [data-all-area="table"] > .overflow-x-auto {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

body[data-active-page="all"] [data-all-area="table"] > .mt-4 {
  flex: 0 0 auto;
}

body[data-active-page="all"] [data-all-area="map"] {
  min-height: 0;
  grid-column: 1 / -1;
  grid-row: 3;
  /* Keep geographic context prominent without letting the map dominate the
     overview. The extra room also makes the selected-variant details easier
     to scan alongside it. */
  grid-template-columns: minmax(0, 1fr) 440px;
  border-bottom: 0;
  padding: 0;
}

body[data-active-page="all"] [data-frequency-map-pane] {
  height: 100%;
  min-height: 0;
}

body[data-active-page="all"] [data-frequency-side-pane] {
  min-height: 0;
  height: 100%;
}

body[data-active-page="all"] [data-all-area="protein"] {
  min-height: 0;
  grid-column: 2;
  grid-row: 2;
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 0;
  padding: 0;
}

body[data-active-page="all"] [data-all-area="protein"] > div {
  height: 100%;
  min-height: 0;
}

body[data-active-page="all"] [data-all-area="protein"] > aside {
  display: none;
}

body[data-active-page="all"] #proteinViewerStatus {
  display: none;
}

body[data-active-page="all"] [data-all-area="genome"] {
  display: flex;
  min-height: 0;
  grid-column: 1 / -1;
  grid-row: 4;
  flex-direction: column;
  border-bottom: 0;
  padding: 0;
}

body[data-active-page="all"] [data-all-area="genome"] > .mb-3 {
  flex: 0 0 auto;
  margin-bottom: 0.75rem;
}

body[data-active-page="all"] [data-all-area="genome"] > .relative {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
}

body[data-active-page="all"] #genomeBrowserSvg {
  min-width: 980px;
}

body[data-active-page="structural"] main {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.05fr);
  align-items: stretch;
  gap: 1rem;
}

body[data-active-page="structural"] [data-all-area="protein"] {
  order: 1;
  grid-column: 1;
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 0;
  padding: 0;
}

body[data-active-page="structural"] [data-all-area="protein"] > div {
  height: 560px;
}

body[data-active-page="structural"] [data-all-area="protein"] > aside {
  display: none;
}

body[data-active-page="structural"] #proteinClassFilter,
body[data-active-page="structural"] label:has(#proteinClassFilter) {
  display: none;
}

body[data-active-page="structural"] .protein-camera-reset,
body[data-active-page="epitope"] .protein-camera-reset {
  right: 1rem;
}

body[data-active-page="structural"] [data-page-panel="structural"] {
  order: 2;
  grid-column: 2;
  display: flex;
  min-height: 0;
  height: 560px;
  flex-direction: column;
  border-bottom: 0;
  padding: 0;
}

body[data-active-page="structural"] #structuralTable {
  min-height: 0;
  flex: 1 1 0;
}

body[data-active-page="structural"] [data-all-area="genome"] {
  order: 3;
  grid-column: 1 / -1;
}

body[data-active-page="most-frequent"] [data-all-area="map"] {
  grid-template-columns: minmax(0, 1.08fr) minmax(560px, 1fr);
  align-items: stretch;
}

body[data-active-page="most-frequent"] [data-frequency-map-pane],
body[data-active-page="most-frequent"] [data-frequency-side-pane] {
  height: 720px;
  min-height: 720px;
}

body[data-active-page="most-frequent"] [data-frequency-side-pane] {
  gap: 0.875rem;
}

body[data-active-page="most-frequent"] [data-frequency-summary] {
  order: 2;
}

body[data-active-page="most-frequent"] [data-frequency-dataset],
body[data-active-page="most-frequent"] [data-frequency-map-mode],
body[data-active-page="most-frequent"] [data-frequency-metrics] {
  order: 3;
}

body[data-active-page="most-frequent"] [data-frequency-tables] {
  order: 1;
  min-height: 0;
  flex: 1 1 0;
}

body[data-active-page="most-frequent"] [data-most-frequent-table] {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

body[data-active-page="most-frequent"] #mostFrequentList {
  max-height: 100%;
  flex: 1 1 0;
  overflow-y: auto;
}

body[data-active-page="most-frequent"] [data-population-table-title],
body[data-active-page="most-frequent"] #populationTable {
  display: none;
}

body[data-active-page="epitope"] [data-all-area="protein"] {
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 0;
  padding: 0;
}

body[data-active-page="epitope"] [data-all-area="protein"] > div {
  height: 700px;
}

body[data-active-page="epitope"] [data-all-area="protein"] > aside,
body[data-active-page="epitope"] label:has(#proteinClassFilter) {
  display: none;
}

body[data-active-page="epitope"] #proteinViewerStatus {
  display: block;
}

@media (max-width: 767px) {
  [data-frequency-legend] {
    right: 0.5rem !important;
    bottom: 0.5rem !important;
    width: 8.25rem !important;
    padding: 0.5rem !important;
  }

  [data-frequency-legend] > div:first-child {
    font-size: 0.75rem;
  }

  [data-frequency-legend] > div:last-child {
    gap: 0.5rem;
    margin-top: 0.5rem;
  }

  #frequencyLegendGradient {
    width: 1rem !important;
    height: 6rem !important;
  }

  #frequencyLegendTicks {
    height: 6rem !important;
    font-size: 0.75rem;
    line-height: 1;
  }

  header > div {
    align-items: stretch !important;
    flex-direction: column;
    gap: 0.875rem !important;
  }

  header > div > div:first-child {
    align-items: stretch;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
  }

  #mainNav {
    display: flex;
    width: 100%;
    max-width: 100%;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.125rem;
    -webkit-overflow-scrolling: touch;
  }

  #mainNav button {
    flex: 0 0 auto;
  }

  header > div > .ml-auto {
    align-self: flex-start;
    margin-left: 0 !important;
    text-align: left;
  }
}

@media (max-width: 1023px) {
  body[data-active-page="structural"] main {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-active-page="structural"] [data-all-area="protein"],
  body[data-active-page="structural"] [data-page-panel="structural"],
  body[data-active-page="structural"] [data-all-area="genome"] {
    grid-column: 1;
  }

  body[data-active-page="structural"] [data-all-area="protein"] > div,
  body[data-active-page="structural"] [data-page-panel="structural"] {
    height: 520px;
  }

  body[data-active-page="most-frequent"] [data-all-area="map"] {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-active-page="most-frequent"] [data-frequency-map-pane],
  body[data-active-page="most-frequent"] [data-frequency-side-pane] {
    height: 560px;
    min-height: 560px;
  }

  body[data-active-page="all"] main {
    height: auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    overflow: visible;
  }

  body[data-active-page="all"] div[data-page-panel="all"],
  body[data-active-page="all"] [data-all-area="variant-distribution"],
  body[data-active-page="all"] [data-all-area="map"],
  body[data-active-page="all"] [data-all-area="protein"],
  body[data-active-page="all"] [data-all-area="genome"] {
    grid-column: 1;
    grid-row: auto;
  }

  /* The desktop All layout reserves a fixed side column.  Below lg that
     column left the map with virtually no usable width. */
  body[data-active-page="all"] [data-all-area="map"] {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-active-page="all"] div[data-page-panel="all"] {
    min-height: 720px;
  }

  body[data-active-page="all"] [data-all-area="variant-distribution"] {
    min-height: 0;
  }

  .variant-distribution-content {
    max-width: none;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.75rem;
  }

  .variant-distribution-card {
    padding: 1.25rem;
  }

  .variant-distribution-legend li {
    grid-template-columns: 0.875rem minmax(0, 1fr);
  }

  .variant-distribution-legend strong {
    grid-column: 2;
  }

  body[data-active-page="all"] [data-frequency-map-pane],
  body[data-active-page="all"] [data-all-area="protein"] > div,
  body[data-active-page="all"] [data-all-area="genome"] {
    height: 620px;
  }
}

@media (max-width: 767px) {
  /* Keep geographic context visible without making the map dominate the page. */
  body[data-active-page="all"] [data-frequency-map-pane],
  body[data-active-page="most-frequent"] [data-frequency-map-pane] {
    height: 280px;
    min-height: 280px;
  }

  body[data-active-page="all"] [data-frequency-side-pane],
  body[data-active-page="most-frequent"] [data-frequency-side-pane] {
    height: auto;
    min-height: 0;
  }
}

#genomeBrowserSvg {
  -webkit-user-select: none;
  user-select: none;
  /* Let a finger scroll the page vertically or the track horizontally.
     Mouse users retain drag-to-pan; touch no longer gets trapped by SVG zoom. */
  touch-action: pan-x pan-y;
}

#genomeBrowserSvg text {
  -webkit-user-select: none;
  user-select: none;
}
