/* The faceted tabs: a jeweller's guide to the shapes of a diamond on a black page. Four tabs in a dark tray, the
   chosen one in a sliver of smoky crystal, the stone under them and its words below. The crystal and the stone are
   drawn by the script, which reads its colours here. */
:root {
  --page: #000000;          /* the page */
  --tray: #121316;          /* the tray of the tabs */
  --ink: #f5f3ef;           /* the chosen tab, the titles and the figures */
  --muted: #8c8983;         /* the other tabs, the names of the figures */
  --text: #aaa69f;          /* the text */
  --crystal: #2a2d33;       /* the crystal of the chosen tab */
  --crystal-light: #eef2f8; /* its facets where they catch the light */
  --stone-dark: #05070a;    /* the darkest facets of the stone */
  --stone-light: #ffffff;   /* the brightest */
  --stone-tint: #b9cdf2;    /* the cool cast of the studio in the stone */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Urbanist Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  padding: clamp(40px, 16vh, 150px) 16px 48px;   /* held from the top: when the text changes height, only its bottom moves */
}

.guide {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
}

/* ---------------------------------------------------------------- the tabs and the crystal */
.seg {
  position: relative;
  width: 100%;
  height: 52px;
  border-radius: 18px;
  background: var(--tray);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 10px 30px -12px rgba(0, 0, 0, 0.9);
}

/* the crystal is drawn over the whole tray, under the names; clicks go through it to the tabs */
.seg__crystal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.seg__tabs {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);   /* as many equal columns as there are tabs */
  height: 100%;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* a name is as bright and as heavy as the crystal under it is near (--lit, written by the script as the crystal
   slides), and a little brighter under the mouse (--hov) */
@property --hov {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}

.seg__tab {
  --lit: 0;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: color-mix(in srgb, var(--ink) calc(min(1, var(--lit) + var(--hov) * 0.45) * 100%), var(--muted));
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: pan-y;
  transition: --hov 0.25s ease;
}

.seg__tab[aria-selected='true'] {
  --lit: 1;
  cursor: grab;
}

.seg__name {
  display: block;
  font-size: 15px;
  line-height: 20px;
  font-weight: calc(560 + 120 * var(--lit));
  letter-spacing: 0.005em;
  white-space: nowrap;
  transition: transform 0.16s ease-out;
}

.seg.is-dragging,
.seg.is-dragging .seg__tab {
  cursor: grabbing;
}

@media (hover: hover) and (pointer: fine) {
  .seg__tab:hover {
    --hov: 1;
  }
}

/* pressed, the name gives a little under the finger */
@media (prefers-reduced-motion: no-preference) {
  .seg__tab:active .seg__name {
    transform: scale(0.95);
    transition-duration: 0.08s;
  }
}

.seg__tab:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -3px;
  border-radius: 15px;
}

html[data-using='pointer'] .seg__tab:focus-visible {
  outline: none;
}

/* with the motion reduced the crystal and the stone are not dragged or turned by hand */
@media (prefers-reduced-motion: reduce) {
  .seg__tab[aria-selected='true'],
  .stone {
    cursor: default;
  }
}

/* ---------------------------------------------------------------- the stone */
.stone {
  position: relative;
  width: 100%;
  height: 228px;
  margin-top: 6px;
  touch-action: pan-y;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.stone.is-turning {
  cursor: grabbing;
}

.stone__view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------------- the words */
.pages {
  position: relative;
  width: 100%;
  margin-top: 4px;
}

.page {
  outline: none;
  text-align: center;
}

.page:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 8px;
  border-radius: 8px;
}

.page__title {
  margin: 0 0 10px;
  font-family: 'Noto Serif Display Variable', Georgia, serif;
  font-size: clamp(27px, 7vw, 32px);
  font-weight: 380;
  font-stretch: 86%;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.page__text {
  margin: 0 auto;
  max-width: 36ch;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  text-wrap: pretty;
}

.page__facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 22px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 16px;
}

.page__facts > div + div {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.page__facts dt {
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

.page__facts dd {
  margin: 3px 0 0;
  font-size: 16px;
  line-height: 22px;
  font-weight: 620;
  color: var(--ink);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .stone {
    height: 208px;
  }

  .seg__name {
    font-size: 14.5px;
  }

  .page__text {
    font-size: 15.5px;
  }

  .page__facts dt {
    font-size: 12.5px;
  }

  .page__facts dd {
    font-size: 15px;
  }
}
