/*
 * lens.css - the LENS screen: where the tree of app/screens/lens/lens-panels.js
 * and the ring of lens-ring.js stand.
 *
 * RULE (as in app.css): no colour and no font family here, only the custom
 * properties generated from app/design/tokens.js.
 *
 *   .lens
 *     .lens-body                 scrolls when a small screen cannot hold it
 *       .lens-left               head, title, ring (these three placed absolutely in the block's
 *                                top), then EXACT P and the lineage strip
 *       .lens-right              the data rows, the media
 *     .limb-straight             the scale of all 63 rungs, fixed at the bottom
 *
 * Two arrangements, set by lens.js on .lens:
 *   [data-arrangement='column']  phones and narrow windows: the two blocks one under the other,
 *                                at the positions of DESIGN.md section 7 (ring centre 268 / 188,
 *                                lineage y 356, rows from y 414 at pitch 25, media from y 573 at
 *                                pitch 21.5, limb y 742); hold them with tools/measure.mjs
 *   [data-arrangement='side']    wide windows (the screen 1180 px or more): the blocks side by side, the ring 1.3 x
 */

.lens {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.lens-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.lens .limb-straight {
  flex: 0 0 auto;
}

.lens-left {
  position: relative;
}

/* ------------------------------------------------------------ head, title */

.lens-head {
  position: absolute;
  left: 0;
  pointer-events: none;
}

.lens-head .title {
  font-size: 8.5px;
  line-height: 10px;
  color: var(--c-ash);
}

.lens-head .sub {
  margin-top: 5px;
  font-size: 6.5px;
  line-height: 8px;
  color: var(--c-etch3);
}

.lens-title {
  position: absolute;
  left: 0;
}

.lens-letter {
  margin-left: -3px;
  font-size: 78px;
  line-height: 78px;
  font-weight: var(--w-title);
}

.lens-word {
  margin: 9.4px 0 0;
  font-size: 15px;
  line-height: 15px;
  letter-spacing: 0.34em;
  color: var(--c-bone);
}

.lens-kind,
.lens-note {
  font-size: 6.6px;
  line-height: 6.6px;
  letter-spacing: 0.2em;
}

.lens-kind {
  margin-top: 11.6px;
  color: var(--c-ash);
}

.lens-note {
  margin-top: 5.4px;
  color: var(--c-sol-label);
}

.lens-cycle {
  margin-top: 9px;
  font-size: 12.5px;
  line-height: 14px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the ring */

.lens-ring {
  position: absolute;
  right: 0;
}

.lens-ring-canvas {
  position: absolute;
  left: 0;
  top: 0;
}

.th {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  white-space: nowrap;
}

.th-under {
  align-items: center;
  transform: translateX(-50%);
}

/* the peak stands near the screen's edge: a long Earth date grows inward from there */
.th-peak .th-earth {
  right: -6px;
}

/* beside a glyph (end, node): the word, then the span with its Earth time on the same line */
.th-beside {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  align-items: baseline;
  column-gap: 7px;
}

.th-beside .th-word {
  grid-column: 1 / 3;
}

.th-beside .th-earth {
  margin: 0;
}

.th-word {
  font-size: 6.8px;
  color: var(--c-ash);
}

/* centre the ink of a tracked word under its glyph, not its advance */
.th-under .th-word {
  margin-right: calc(var(--track-caps) * -1);
}

.th-span {
  margin-top: 3.2px;
  font-size: 9.5px;
  font-weight: var(--w-earth);
  color: var(--c-ash);
}

.th-span .u {
  color: inherit;
}

.th-earth {
  margin-top: 2.6px;
  font-size: 9px;
}

/* under a glyph there is room for two lines only: the Earth time of peak and valley stands above the glyph */
.th-under .th-earth {
  position: absolute;
  bottom: calc(100% + 26px * var(--ring-scale, 1));
  margin: 0;
}

.th.next .th-word {
  color: var(--c-now);
}

.th.next .th-span {
  color: var(--c-bone);
}

/* --------------------------------------------------------------- data rows */

.lens-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 25px;
  padding: 3px 0 5px;
  border-bottom: 1px solid var(--c-etch1);
  font-size: 12.5px;
  line-height: 16px;
}

.lens-row .label {
  margin-right: auto;
  font-size: 7px;
  /* shorter than the value's line, so that aligning the baselines does not make the row taller */
  line-height: 8px;
  color: var(--c-ash);
}

.lens-row .values {
  max-width: 78%;
  text-align: right;
}

.lens-row .value {
  font-weight: var(--w-value);
}

.lens-row .extra {
  display: block;
  font-size: 9.5px;
  line-height: 12px;
  font-weight: var(--w-earth);
  color: var(--c-ash);
  overflow-wrap: anywhere;
}

.lens-row .extra:empty {
  display: none;
}

.lens-row .row-earth {
  font-size: 11.5px;
  line-height: 12px;
}

.lens-prefix {
  border-bottom: 0;
}

/* a row that has no pure value (a device of SPEC 16.4, the period of a rung below the Blink) */
.lens-row.earth-only .values {
  display: none;
}

.lens-siblings .values {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* the one red of the app, here as the band of the rung that is visible light */
.lens-band.visible-light .value {
  color: var(--c-h-alpha);
}

.lens-device .label {
  display: flex;
  gap: 0.9em;
}

.lens-device .device-rate {
  font-family: var(--font-reading);
  font-size: 9.5px;
  letter-spacing: 0;
  font-style: normal;
}

.lens-lineage {
  margin-top: 2px;
  height: 62px;
  cursor: pointer;
}

.lens-rows {
  margin-top: 2.5px;
}

/* ------------------------------------------------------------------- media */

.lens-media {
  margin-top: 20.5px;
}

.m-heads {
  display: flex;
  align-items: baseline;
  gap: 14px;
  height: 14px;
  font-size: 7px;
  line-height: 10px;
}

.m-heads .caps {
  font-size: 7px;
  line-height: 8px;
}

.m-title {
  margin-right: auto;
  color: var(--c-ash);
}

.m-head-light,
.m-heads .m-head-metres {
  color: var(--c-etch3);
  font-style: normal;
}

.m-row {
  display: grid;
  grid-template-columns: 156px 108px minmax(0, 1fr);
  align-items: baseline;
  height: 21.5px;
  font-size: 12px;
  line-height: 21.5px;
  white-space: nowrap;
}

.m-name {
  font-size: 11.5px;
  font-weight: var(--w-value);
  color: var(--c-major-name);
}

.m-row.first .m-name {
  color: var(--c-bone);
}

.m-bar {
  position: relative;
  align-self: center;
  height: 1px;
  background: var(--c-etch1);
  transform: translateY(1.5px);
}

.m-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 1px;
  background: var(--c-lumen-mid);
}

.m-fill::after {
  content: '';
  position: absolute;
  right: -1.6px;
  top: -1.1px;
  width: 3.2px;
  height: 3.2px;
  border-radius: 50%;
  background: inherit;
}

.m-row.first .m-fill {
  top: -0.15px;
  height: 1.3px;
  background: var(--c-lumen);
}

.m-light,
.m-metres {
  justify-self: end;
  font-weight: var(--w-value);
}

.m-metres {
  font-size: 11.5px;
}

/* ------------------------------------------------------------------- phone */

/*
 * The limb's letters stand at y 742 and its index a little lower, in the air above the sigils
 * (which app.css draws from y 772): the screen reaches down to there, past its own box.
 */
#app[data-layout='phone'][data-screen='lens'] #screen {
  overflow: visible;
}

#app[data-layout='phone'] .lens {
  bottom: calc(var(--v) * -47);
  --top: var(--inset-top);
}

/* in EARTH mode app.css draws the sigils' box 19.1 v higher (its marks stay where they are) */
#app[data-layout='phone'][data-mode='earth'] .lens {
  bottom: calc(var(--v) * -27.9);
}

/* ---------------------------------------------- one column (set by lens.js) */

/*
 * [data-arrangement='column']: phones, and windows too narrow for two blocks side by side.
 * --top is where the content begins: the phone keeps the corner marks above it.
 */
.lens {
  --top: 60px;
}

.lens[data-arrangement='column'] .lens-body {
  /* the design's column is 353 px wide; a wider window centres it */
  padding: 0 max(20px, calc(50% - 190px));
}

.lens[data-arrangement='column'] .lens-left {
  /* room for the head, the title and the ring: EXACT P stands at y 322 */
  padding-top: calc(var(--top) + 216px);
}

.lens[data-arrangement='column'] .lens-head {
  top: calc(var(--top) - 14px);
}

.lens[data-arrangement='column'] .lens-title {
  top: calc(var(--top) + 22px);
}

.lens[data-arrangement='column'] .lens-ring {
  /* the ring's centre at (width - 125, 188): the box is 250 px */
  top: calc(var(--top) - 28px);
  right: -20px;
}

/* EARTH in one column: the metres take the rule's place beside the spans of light */
#app[data-mode='earth'] .lens[data-arrangement='column'] .m-row {
  grid-template-columns: 150px minmax(0, 1fr) 104px;
}

#app[data-mode='earth'] .lens[data-arrangement='column'] .m-bar {
  display: none;
}

#app[data-mode='earth'] .lens[data-arrangement='column'] .m-head-metres {
  width: 90px;
  text-align: right;
}

/* -------------------------------------------- side by side (set by lens.js) */

.lens[data-arrangement='side'] .lens-body {
  display: grid;
  grid-template-columns: minmax(420px, 500px) minmax(340px, 500px);
  column-gap: clamp(40px, 7vw, 104px);
  justify-content: center;
  /* a tall window: the two blocks stand in the middle of the air, not under its top edge; `safe` keeps their
     top reachable when they are taller than the window (a browser without it keeps `start`) */
  align-content: start;
  align-content: safe center;
  padding: clamp(36px, 8dvh, 72px) 40px 0;
}

.lens[data-arrangement='side'] .lens-left {
  padding-top: 348px;
}

.lens[data-arrangement='side'] .lens-head {
  top: 0;
}

.lens[data-arrangement='side'] .lens-title {
  top: 36px;
}

.lens[data-arrangement='side'] .lens-ring {
  top: 4px;
  right: -14px;
}

.lens[data-arrangement='side'] .lens-right {
  padding-top: 30px;
}

.lens[data-arrangement='side'] .lens-media {
  margin-top: 34px;
}

.lens[data-arrangement='side'] .m-row {
  grid-template-columns: 170px minmax(60px, 1fr) 118px;
  column-gap: 14px;
}

#app[data-mode='earth'] .lens[data-arrangement='side'] .m-row {
  grid-template-columns: 170px minmax(60px, 1fr) 118px 118px;
}

.lens[data-arrangement='side'] .m-head-light,
.lens[data-arrangement='side'] .m-head-metres {
  width: 118px;
  text-align: right;
}

#app[data-layout='desktop'] .lens .limb-straight {
  max-width: 760px;
  align-self: center;
  margin-bottom: 14px;
}
