/*
  Design tokens. The colours are the anatomy kit's, as on the model pages of the landmarks repo.
  The rest comes from the CSS of scrit.to (body type, figure shadow, dividers, entrance) and
  craft.gustavofior.com (column, type scale, cards, radii, easing).
*/
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(inter-latin-wght-normal.woff2) format("woff2-variations");
}

:root {
  color-scheme: light;
  --font-sans: "Inter Variable", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --text-xs: 12px;
  --text-card: 13px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --leading-tight: 1.2;
  --leading-body: 1.4;
  --leading-prose: 1.8;
  --tracking: -0.25px;

  --bg: #f2f2ef;
  --surface: #fbfbfa;
  --heading: #18181a;
  --text: #57575a;
  --text-faint: #8c8c90;
  --hairline: #e2e2df;
  --divider-from: #18181a14;
  --divider-to: #18181a00;
  --selection: #c0c0c049;
  --shadow-card: 0 0 0 1px #0000000f, 0 1px 2px -1px #0000000f, 0 2px 4px 0 #0000000a;
  --shadow-figure: 0 0 0 1px #77777714, 0 2px 2px -0.5px #77777714;

  --radius-card: 18px;
  --radius-chip: 8px;
  --radius-link: 4px;
  --radius-key: 3px;

  --ease-snappy: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-reveal: cubic-bezier(0.22, 1, 0.36, 1);

  --column: 640px;
  --gutter: 28px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0b0b;
    --surface: #131313;
    --heading: #e6e6e6;
    --text: #a3a3a3;
    --text-faint: #6e6e6e;
    --hairline: #222;
    --divider-from: #ffffff14;
    --divider-to: #fff0;
    --selection: #ffffff24;
    --shadow-card: 0 0 0 1px #ffffff1a;
    --shadow-figure: 0 0 0 1px #ffffff1a;
  }
}

@media (min-width: 640px) {
  :root {
    --gutter: 32px;
  }
}

/* Base */

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking);
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "cv05" 1;
}

::selection {
  background: var(--selection);
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd,
figure {
  margin: 0;
  padding: 0;
}

h1,
h2,
h3 {
  color: var(--heading);
  font-weight: 550;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

ol,
ul {
  list-style: none;
}

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

:focus-visible {
  outline: 1.5px solid color-mix(in srgb, var(--text) 50%, transparent);
  outline-offset: 2px;
}

.column {
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 72px var(--gutter) 64px;
}

@media (min-width: 560px) {
  .column {
    padding: 112px var(--gutter) 96px;
  }
}

.divider {
  height: 1.25px;
  background: linear-gradient(to right, var(--divider-from), var(--divider-to));
}

.prose {
  color: var(--text);
  line-height: var(--leading-prose);
}

.link {
  color: var(--heading);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--text) 30%, transparent);
  text-underline-offset: 4px;
  transition: text-decoration-color 0.3s ease-out;
}

.link:hover {
  text-decoration-color: currentColor;
}

/* Home */

.intro {
  display: grid;
  gap: 12px;
}

.intro h1 {
  margin-bottom: 8px;
  font-size: var(--text-base);
  line-height: 1;
}

.intro p {
  line-height: var(--leading-body);
}

.intro .note {
  color: var(--text-faint);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 48px;
}

@media (min-width: 480px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.card-art {
  aspect-ratio: 1;
  padding: 12px 12px 0;
}

.card-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: scale 0.5s var(--ease-snappy);
}

.card-text {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 4px 12px;
  padding: 16px;
}

.card h2 {
  font-size: var(--text-card);
  font-weight: 500;
  line-height: var(--leading-tight);
}

.card .rank {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.card .place {
  grid-column: 1 / -1;
  color: var(--text);
  font-size: var(--text-xs);
  line-height: calc(16 / 12);
}

@media (hover: hover) {
  .card:hover .card-art img {
    scale: 1.03;
  }
}

.site-footer {
  display: grid;
  gap: 20px;
  margin-top: 48px;
  color: var(--text);
  line-height: var(--leading-body);
}

/* Landmark page */

.wordmark {
  position: absolute;
  top: 26px;
  left: var(--gutter);
  color: var(--heading);
  font-size: var(--text-base);
  font-weight: 550;
  line-height: 1;
}

.back {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--text);
  font-size: var(--text-xs);
  transition: color 0.2s;
}

.back:hover {
  color: var(--heading);
}

.title h1 {
  font-size: var(--text-lg);
  font-weight: 500;
  line-height: calc(28 / 18);
}

.title p {
  margin-top: 4px;
  color: var(--text);
}

.model {
  position: relative;
  margin: 32px 0 16px;
  padding: 44px 16px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-figure);
}

/* Keep the whole model in view: the stage is 640 units wide and --h units tall. */
.model .lm-stage {
  width: min(100%, calc((100svh - 220px) * 640 / var(--h)));
  margin: 0 auto;
}

/* Hide the model until its script has turned it to its opening turn. */
[data-theme] .model .lm-stage {
  transition: opacity 0.3s var(--ease-reveal);
}

[data-theme] .model .lm-stage:not([data-ready]) {
  opacity: 0;
}

.model .lm-stage:focus-visible {
  box-shadow: none;
  border-radius: var(--radius-chip);
  outline-offset: 6px;
}

.corner {
  position: absolute;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.3;
  letter-spacing: 0;
}

/* The readout names the lit tier, which can be long: it wraps, and the ruler sits at the top. */
.corner[data-readout] {
  right: 20px;
  bottom: 16px;
  max-width: calc(100% - 40px);
  color: var(--text);
  text-align: right;
}

.corner.ruler {
  top: 16px;
  left: 20px;
  white-space: nowrap;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  color: var(--text);
  font-size: var(--text-xs);
  line-height: calc(16 / 12);
}

.controls li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 2px 4px;
  border-radius: var(--radius-key);
  background: color-mix(in srgb, var(--heading) 7%, transparent);
  box-shadow: var(--shadow-card);
  color: var(--heading);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  text-align: center;
}

.section {
  margin-top: 40px;
}

.section h2 {
  margin-bottom: 16px;
  font-size: var(--text-base);
  font-weight: 500;
}

.tiers {
  display: grid;
  margin: 0 -8px;
}

.tiers .iso-key {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-chip);
  color: var(--text);
  line-height: var(--leading-body);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.tiers .iso-key[data-on] {
  background: color-mix(in srgb, var(--heading) 6%, transparent);
  color: var(--heading);
}

.tiers .num,
.tiers .span {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: calc(var(--text-sm) * 1.4);
}

.facts {
  display: grid;
  grid-template-columns: minmax(88px, auto) 1fr;
  margin-top: 16px;
  line-height: var(--leading-body);
}

.facts dt,
.facts dd {
  padding: 10px 0;
  border-top: 1px solid var(--hairline);
}

.facts dt {
  padding-right: 16px;
  color: var(--text-faint);
}

.facts dd {
  color: var(--text);
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
  line-height: var(--leading-body);
}

.pager a:last-child {
  text-align: right;
}

.pager small {
  display: block;
  color: var(--text-faint);
  font-size: var(--text-xs);
}

.pager a span {
  color: var(--heading);
}

.index-nav {
  display: none;
}

@media (min-width: 1100px) {
  .index-nav {
    display: block;
    position: fixed;
    top: 50%;
    left: 0;
    width: 224px;
    padding-left: 32px;
    translate: 0 -50%;
    font-size: var(--text-xs);
  }

  .index-nav ul {
    display: grid;
    gap: 4px;
  }

  .index-nav a {
    display: inline-block;
    margin: 0 -6px;
    padding: 4px 6px;
    border-radius: var(--radius-link);
    color: var(--text-faint);
    transition: color 0.2s;
  }

  .index-nav a:hover,
  .index-nav a[aria-current] {
    color: var(--heading);
  }
}

/* Motion */

@view-transition {
  navigation: auto;
}

@keyframes reveal {
  from {
    opacity: 0;
    filter: blur(4px);
  }
}

.reveal {
  animation: reveal 0.45s var(--ease-reveal) both;
  animation-delay: calc(min(var(--i, 0), 18) * 12ms + 60ms);
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  .reveal {
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }

  .card:hover .card-art img {
    scale: none;
  }
}
