/* A unit's page, as Explore and the photo page show it: a side panel, a
   bottom sheet on a phone. Each page sets the tokens it reads (--ink,
   --edge, --fill-strong, --accent, --gap) and may set --top-clear. */

.sheet {
  position: fixed;
  z-index: 3;
  top: var(--top-clear, calc(max(var(--gap), env(safe-area-inset-top)) + 52px));
  bottom: max(var(--gap), env(safe-area-inset-bottom));
  left: max(var(--gap), env(safe-area-inset-left));
  width: 380px;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(14, 22, 36, 0.9);
}

.sheet-grip {
  display: none;
}

/* 44 px to hit, the disc drawn smaller inside it. */
.sheet-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: 0;
  background: radial-gradient(
    circle,
    var(--fill-strong) 0 16px,
    transparent 16.5px
  );
  cursor: pointer;
  z-index: 1;
  display: grid;
  place-items: center;
}

.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 24px;
  flex: 1;
}

.page-loading {
  margin: 24px 0;
  color: var(--ink-dim);
  text-align: center;
}

.page-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-right: 36px;
}

.page-swatch {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.page-title {
  min-width: 0;
}

.page-swatch.is-line {
  display: grid;
  place-items: center;
  background: var(--fill-strong);
  box-shadow: none;
}

.page-swatch.is-small {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.page-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.page-section .page-title-row h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  color: #fff;
}

.page-glyph {
  flex: none;
}

.page-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  color: #fff;
}

.page-parts {
  margin: 3px 0 0;
  font-size: 14px;
  color: var(--ink-dim);
}

.page-parts span + span::before {
  content: "\00a0\00b7\00a0";
}

/* The links under the title, a row that scrolls where it overflows. */
.page-links {
  display: flex;
  gap: 8px;
  margin: 14px -20px 4px;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.page-link-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 17px;
  background: rgba(120, 120, 128, 0.36);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.page-links {
  align-items: center;
}

.page-link-pill.is-share {
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 22px;
}

.page-link-pill.is-share svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-link-pill:focus-visible,
.page-card:focus-visible,
.page-nav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Where it formed's and the Glacial history's cards. */
.page-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(120, 120, 128, 0.36);
  color: inherit;
  text-decoration: none;
}

.page-card-thumb {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
}

.page-card-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  color: var(--ink-dim);
}

.page-card-text strong {
  font-size: 15px;
  color: #fff;
}

.page-section > .page-card:first-child {
  margin-top: 0;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-size: 15px;
  text-decoration: none;
}

.page-chevron {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: rgba(235, 235, 245, 0.3);
  stroke-width: 2;
  stroke-linecap: round;
}

.page-section {
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-section h3,
.page-sources h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #fff;
}

.page-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.page-chips li {
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--fill-strong);
  font-size: 13px;
}

.page-lith {
  margin: 0 0 10px;
  font-weight: 600;
}

.page-body,
.page-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-line;
}

.page-body.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--lines, 5);
  line-clamp: var(--lines, 5);
  overflow: hidden;
}

.page-text + .page-text,
.page-text.is-after {
  margin-top: 8px;
}

.page-meta.is-tight {
  margin-top: 2px;
}

.page-meta.is-under {
  margin: -4px 0 8px;
}

.page-section h4,
.page-article h4 {
  margin: 10px 0 6px;
  font-size: 15px;
  color: #fff;
}

.page-lead {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  color: #fff;
}

.page-strip {
  width: 100%;
  margin-bottom: 10px;
}

.page-strip svg,
.story-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.page-stacked {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.45;
}

.page-stacked span:first-child {
  color: var(--ink-dim);
  font-size: 13px;
}

.page-photo {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(120, 120, 128, 0.36);
}

.page-photo.is-wide {
  aspect-ratio: 16 / 9;
}

.page-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-place {
  margin: 0 0 2px;
  font-weight: 650;
  color: #fff;
}

.page-article + .page-article {
  margin-top: 18px;
}

.page-link {
  margin: 10px 0 0;
  font-size: 14px;
}

.page-link a,
.page-genera a {
  color: var(--accent);
}

.page-fold {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 8px;
}

.page-fold-head {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border: 0;
  background: none;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
}

.page-fold-head[aria-expanded]::after {
  content: "+";
  color: var(--ink-dim);
}

.page-fold-head[aria-expanded="true"]::after {
  content: "−";
}

.page-fold-head:disabled {
  cursor: default;
}

.page-fold-head small {
  margin-left: auto;
  color: var(--ink-dim);
  font-size: 13px;
}

.page-fold-body {
  padding-bottom: 8px;
}

.page-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-rows button,
.page-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: none;
  text-align: left;
}

.page-rows li:first-child button,
.page-rows li:first-child .page-row {
  border-top: 0;
}

.page-rows button {
  cursor: pointer;
}

.page-row-swatch {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.page-row-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-row-text strong,
.column-units strong {
  font-weight: 600;
  font-size: 15px;
}

.page-row-text small,
.column-units small,
.page-genera small {
  color: var(--ink-dim);
  font-size: 13px;
}

.page-row-check {
  color: var(--accent);
  font-weight: 700;
}

.page-linked {
  margin: 6px 0;
}

.story {
  margin-top: 14px;
}

.story h4 {
  margin-top: 0;
}

.story-chart {
  margin-top: 4px;
}

.story-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-dim);
}

.story-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.story-swatch {
  width: 12px;
  height: 10px;
  border-radius: 2px;
}

.story-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.column-units {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
}

.column-units li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0 6px 6px;
  border-left: 3px solid transparent;
}

.column-units li.is-here {
  border-left-color: #c2185b;
  background: rgba(194, 24, 91, 0.12);
}

.column-units li > span:last-child {
  display: flex;
  flex-direction: column;
}

.page-part {
  margin-top: 18px;
}

.page-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 15px;
}

.page-groups li,
.page-genera li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-genera {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
}

.page-genera li {
  gap: 10px;
}

.page-genera li > span:last-child small {
  margin-left: 8px;
}

.silhouette {
  flex: none;
  display: inline-block;
  background-color: rgba(235, 235, 245, 0.6);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.page-more.is-link {
  display: block;
  margin-top: 10px;
}

.page-more {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
}

.page-note {
  margin: 0;
  color: var(--ink-dim);
  font-size: 14px;
}

.page-meta {
  margin: 8px 0 0;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.45;
}

.page-meta.is-faint {
  color: var(--ink-faint);
}

.page-fact {
  display: flex;
  gap: 14px;
  font-size: 15px;
}

.page-fact span:first-child {
  width: 3.5em;
  flex: none;
  color: var(--ink-dim);
}

.page-sources {
  padding-top: 16px;
}

.page-source {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 8px;
}

.page-source a,
.page-source strong {
  color: var(--ink);
  font-weight: 600;
}

.sheet-close svg {
  width: 14px;
  height: 14px;
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
}

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

@media (max-width: 899px) {
  .sheet {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 55%;
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transition:
      height 260ms cubic-bezier(0.22, 0.75, 0.2, 1),
      transform 220ms ease-out;
  }

  .sheet.is-full {
    height: calc(100% - max(var(--gap), env(safe-area-inset-top)) - 8px);
  }

  /* The grip runs the sheet's width: a tap opens it full, a swipe down
     lets it down and then closes it. */
  .sheet-grip {
    display: block;
    flex: none;
    width: 100%;
    height: 28px;
    border: 0;
    background: none;
    cursor: grab;
    position: relative;
    touch-action: none;
  }

  .sheet.is-dragged {
    transition: none;
  }

  .sheet-grip::before {
    content: "";
    position: absolute;
    left: calc(50% - 18px);
    right: calc(50% - 18px);
    top: 10px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.35);
  }

  .sheet-body {
    padding-top: 4px;
  }
}
