/* @link https://utopia.fyi/type/calculator?c=360,16,1.2,1440,20,1.25,5,2,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */
:root {
  --step--2: clamp(0.7813rem, 0.775rem + 0.0278vw, 0.8rem);
  --step--1: clamp(0.9375rem, 0.9167rem + 0.0926vw, 1rem);
  --step-0: clamp(1.125rem, 1.0833rem + 0.1852vw, 1.25rem);
  --step-1: clamp(1.35rem, 1.2792rem + 0.3148vw, 1.5625rem);
  --step-2: clamp(1.62rem, 1.509rem + 0.4935vw, 1.9531rem);
  --step-3: clamp(1.944rem, 1.7782rem + 0.7369vw, 2.4414rem);
  --step-4: clamp(2.3328rem, 2.0931rem + 1.0651vw, 3.0518rem);
  --step-5: clamp(2.7994rem, 2.4609rem + 1.5042vw, 3.8147rem);
}

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

/* Крошечный сброс всего мешающего */
h1,
h2,
h3,
h6,
p,
ul,
li {
  margin: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

header {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 0.6em 1em;
  padding: 1em 1em 0.5em 1em;
  background: #000000;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 13%);;
}

.header-title {
  display: inline-flex;
  gap: 0.4em;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  margin: 0 0 0 0;
  font-size: var(--step--1) !important;
  font-weight: 600;

  span {
    display: inline-block;
    margin: 0;
    padding: 0;
  }

  .header-group {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 0.4em;
    white-space: nowrap;
  }

  .tabs {
    display: inline-flex;
  }
}

a {
  color: inherit;
  font-size: inherit;
  opacity: 1;
  transition: ease-in 0.15s;
}

p {
  margin: 0;
  font-size: var(--step--1) !important;
  line-height: 1.1;
}

a:hover {
  opacity: 0.7;
  transition: ease-in 0s;
}

.lede {
  margin: 0;
  color: #c8c8c8;
  font-size: 0.95rem;
  line-height: 1.45;
}

.tabs {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 0.4em;
}

.tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  appearance: none;
  font-size: inherit;
  font-weight: normal;
  margin: 0;
  padding: 0.2em 0.3em;
  line-height: 1;
  background: transparent;
  color: var(--color-text);
  border: 1px solid #888;
  border-radius: 4px;
  corner-shape: squircle;
  cursor: pointer;
  opacity: 0.5;
}

.tab::after {
  content: attr(data-label);
  height: 0;
  visibility: hidden;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
  font-weight: bold;
}

.tab:hover {
  color: var(--color-text);
  opacity: 1;
}

.tab.is-active {
  color: var(--color-text);
  opacity: 1;
  font-weight: bold;
}

.tab:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 3px;
}

.sort-control {
  display: inline-flex;
  flex-direction: row;
  align-items: baseline;
  gap: 0.5em;
  font-size: var(--step--1);
}

.sort-label {
  opacity: 0.65;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ddd;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 18px;
  height: 6px;
  border-radius: 99px;
}

#h-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

#events-dock,
#sheet,
#axis-dock {
  width: max-content;
}

#events-dock {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: stretch;
  background: #000;
  background: linear-gradient(180deg, rgba(0, 0, 0, 1) 88%, rgba(0, 0, 0, 0) 100%);
}

#events-dock[hidden] {
  display: none;
}

#events-name {
  position: sticky;
  left: 0;
  z-index: 4;
  flex: 0 0 auto;
  background: #000;
}

#sheet {
  display: flex;
  align-items: flex-start;
}

#names {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: 0 0 auto;
  background: #000;
}

#axis-dock {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: stretch;
  background: #000000;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 13%);
  padding-bottom: 10px;
}

#axis-pad {
  position: sticky;
  left: 0;
  z-index: 4;
  flex: 0 0 auto;
}

#events-name,
#events,
#names,
#timeline,
#axis {
  display: block;
}

.axis-line {
  stroke: #fff;
  stroke-width: 1.5;
}

.axis-tick {
  stroke: #fff;
  stroke-width: 1;
}

.axis-label {
  fill: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.name-label {
  fill: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
}

.event-label {
  fill: #c8c8c8;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.event-hit {
  fill: transparent;
}

.event-bar {
  pointer-events: all;
}

.event-point {
  stroke: #000;
  stroke-width: 1.5;
  pointer-events: all;
}

.period-bar {
  stroke-linecap: butt;
  stroke-width: 3;
  pointer-events: none;
}

.guide {
  stroke: #3a3a3a;
  stroke-width: 0.5;
}

.period-link {
  stroke: #777;
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.row-bg {
  fill: transparent;
}

.name.is-hot .row-bg,
.book.is-hot .row-bg,
.name.is-selected .row-bg,
.book.is-selected .row-bg {
  fill: #1c1c1c;
}

.event.is-hot .event-bar,
.event.is-hot .event-point,
.event.is-selected .event-bar,
.event.is-selected .event-point {
  fill: #fff;
}

.event.is-hot .period-bar,
.event.is-selected .period-bar {
  stroke: #fff;
}

.event.is-hot .event-label,
.event.is-selected .event-label {
  fill: #fff;
}

.bar {
  stroke-linecap: square;
  stroke-width: 3;
}

.book.is-hot .bar {
}

.name.is-hot .name-label,
.name.is-selected .name-label {
  fill: #fff;
}

.name.is-hot .name-label {
  text-decoration: underline;
}

.book,
.name,
.event {
  cursor: pointer;
}

.book:focus,
.name:focus,
.event:focus {
  outline: none;
}

.book:focus-visible .row-bg,
.name:focus-visible .row-bg {
  fill: #1c1c1c;
}

#note-popup {
  position: fixed;
  top: 3.75rem;
  right: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(26rem, calc(100vw - 32px));
  max-height: calc(100dvh - 4.75rem);
  padding: 16px 18px;
  background: #141414;
  color: #f0f0f0;
  border-radius: 8px;
  corner-shape: squircle;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: var(--step--1);
  line-height: 1.55;
  pointer-events: auto;
}

#note-popup[hidden] {
  display: none;
}

.note-popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  margin-bottom: 10px;
}

.note-popup-meta {
  min-width: 0;
}

#note-popup-title {
  margin: 0 0 4px;
  font-size: var(--step--1);
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
}

#note-popup .tip-cat {
  display: block;
  color: #9a9a9a;
  font-size: var(--step--2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.note-popup-close {
  appearance: none;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: -4px -6px 0 0;
  padding: 0;
  border-radius: 6px;
  border: none;
  corner-shape: squircle;
  background: transparent;
  color: #aaa;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.note-popup-close:hover {
  color: #fff;
  background: #242424;
}

.note-popup-close:focus-visible {
}

.note-popup-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  color: #dcdcdc;
  padding-right: 4px;
}

#note-popup .note-popup-source {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #2a2a2a;
  color: #9a9a9a;
  font-size: 12px !important;
  line-height: 1.45;
}

#note-popup .note-popup-source a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 768px) {
  .header-title {
    flex-direction: column;
    align-items: flex-start;
  }

  #note-popup {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: #0e0e0e;
    padding: max(20px, env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left));
    font-size: 15px;
    line-height: 1.6;
  }

  .note-popup-close {
    width: 40px;
    height: 40px;
    margin: -6px -6px 0 0;
    font-size: 26px;
  }
}
