/* The horizon that levels itself: warm paper, a level crop with a tilted photo behind it, a dial of degrees under
   it. Archivo (width 62 to 125, weight 100 to 900) for the words and the degrees; one red for the level. */
:root {
  --paper: #f3f0e8;    /* the page */
  --ink: #141414;      /* the words, the crop corners, the dial */
  --muted: #8d887e;    /* the small words and the short ticks */
  --accent: #e2432a;   /* the hairline on the horizon and the needle of the dial */
  --grid: rgba(255, 255, 255, 0.7); /* the thirds over the photo while it turns */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Archivo Variable', 'Archivo', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.top {
  position: absolute;
  top: 26px;
  left: 32px;
  right: 32px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.top p {
  margin: 0;
}

.mark {
  font-size: 15px;
  font-weight: 640;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.005em;
}

.tool {
  font-size: 13px;
  color: var(--muted);
  font-variation-settings: 'wdth' 100;
}

/* the script writes the frame's left, top, width and height */
.desk {
  position: absolute;
  inset: 0;
  visibility: hidden;
}

.desk.is-ready {
  visibility: visible;
}

.name {
  position: absolute;
  margin: 0;
  font-size: 14px;
  font-weight: 520;
  font-variation-settings: 'wdth' 96;
  color: var(--ink);
  white-space: nowrap;
}

.crop {
  position: absolute;
  margin: 0;
  overflow: hidden;
  cursor: ew-resize;
  touch-action: pan-y;
}

/* the photo behind the crop: an element turned by the script, its child for the picture */
.photo {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.photo__img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

/* the hairline the tool lays on the horizon: it turns with the photo */
.photo__level {
  position: absolute;
  left: -10%;
  width: 120%;
  height: 1px;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.thirds {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.thirds__v,
.thirds__h {
  position: absolute;
  background: var(--grid);
}

.thirds__v {
  top: 0;
  bottom: 0;
  width: 1px;
}

.thirds__h {
  left: 0;
  right: 0;
  height: 1px;
}

/* the crop corners: two short strokes each, just outside the frame */
.corner {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.corner--tl { border-top: 2px solid var(--ink); border-left: 2px solid var(--ink); }
.corner--tr { border-top: 2px solid var(--ink); border-right: 2px solid var(--ink); }
.corner--bl { border-bottom: 2px solid var(--ink); border-left: 2px solid var(--ink); }
.corner--br { border-bottom: 2px solid var(--ink); border-right: 2px solid var(--ink); }

/* the dial: a ruler of degrees that slides under a fixed needle */
.dial {
  position: absolute;
  height: 34px;
  overflow: hidden;
  cursor: ew-resize;
  touch-action: pan-y;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
}

.dial__ruler {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  will-change: transform;
}

.tick {
  position: absolute;
  top: 8px;
  width: 1px;
  height: 7px;
  background: var(--muted);
}

.tick--five {
  top: 4px;
  height: 11px;
  background: var(--ink);
}

.tick__n {
  position: absolute;
  top: 19px;
  left: 0;
  transform: translateX(-50%);
  font-size: 10px;
  font-style: normal;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' 90;
  white-space: nowrap;
}

.dial__needle {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 17px;
  margin-left: -0.5px;
  background: var(--accent);
}

.angle {
  position: absolute;
  margin: 0;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

/* the degrees: the script moves their weight and width as the photo levels */
.angle span:first-child {
  --g: 300;
  --w: 110;
  display: inline-block;
  font-variation-settings: 'wght' var(--g), 'wdth' var(--w);
}

.angle__deg {
  font-weight: 300;
  color: var(--muted);
}

@media (max-width: 640px) {
  .top {
    top: 20px;
    left: 20px;
    right: 20px;
  }

  .mark {
    font-size: 14px;
  }

  .tool {
    font-size: 12px;
  }

  .name {
    font-size: 13px;
  }

  .angle {
    font-size: 26px;
  }
}
