/* The sundial that tells the time: a sundial on warm paper, seen from above. Hairline ticks, a gnomon, a shadow
   with a soft tip and one vermilion sun. The time in words is set in Fraunces (a variable serif, weight 100 to 900),
   the digits in Instrument Sans (width 75 to 100). */
:root {
  --paper: #f3f0e8;              /* the page */
  --ink: #141414;                /* the gnomon, the shadow, the words */
  --grey: #8d887e;               /* the small texts and the hour numbers */
  --tick: rgba(20, 20, 20, 0.28); /* the five-minute ticks */
  --rule: rgba(20, 20, 20, 0.14); /* the rim and the sun's path */
  --accent: #ff4a1c;             /* the sun */
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  --pad: clamp(16px, 5vw, 72px);
  --dial: min(calc(100vw - 2 * var(--pad)), 92svh, 700px);
  display: grid;
  grid-template-rows: 1fr auto auto 0.8fr auto;
  justify-items: center;
  align-items: center;
  min-height: 100svh;
  padding: clamp(18px, 3.4vw, 40px) var(--pad) clamp(16px, 2.6vw, 30px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ---------------------------------------------------------------- the top line */
.top {
  align-self: start;
  justify-self: stretch;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 14px;
  letter-spacing: -0.005em;
}

.top__name {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 16px;
  font-weight: 560;
  font-variation-settings: 'SOFT' 50, 'WONK' 0;
}

.top__name,
.top__note {
  display: inline-block;
}

.top__note {
  color: var(--grey);
  text-align: right;
}

/* ---------------------------------------------------------------- the dial */
.dial {
  position: relative;
  width: min(var(--dial), calc((100svh - 330px) * 1.39));
  min-width: min(300px, 100%);
  aspect-ratio: 1000 / 720;
  margin: 14px 0 6px;
  outline: none;
}

.dial__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.rim,
.path {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.path {
  stroke-dasharray: 2 5;
}

.ticks {
  fill: none;
  stroke: var(--tick);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.ticks--hours {
  stroke: rgba(20, 20, 20, 0.55);
}

.ticks--now {
  stroke: var(--ink);
  stroke-width: 2;
}

.gnomon {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: square;
  vector-effect: non-scaling-stroke;
}

.sun {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: butt;
  vector-effect: non-scaling-stroke;
}

.dial:focus-visible .rim {
  stroke: var(--ink);
}

/* the hour numbers round the ticks */
.labels {
  position: absolute;
  inset: 0;
}

.label {
  position: absolute;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--grey);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  transition: color 0.35s ease;
}

.label__in {
  display: block;
}

.label.is-now {
  color: var(--ink);
}

/* ---------------------------------------------------------------- the reading */
.read {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 0;
}

.read__row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 17px;
}

.digits {
  --st: 1;
  display: inline-flex;
  align-items: baseline;
  font-weight: 520;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.slot {
  position: relative;
  display: inline-block;
  width: calc(0.6em * var(--st));
  height: 1.15em;
  overflow: hidden;
  vertical-align: bottom;
}

.slot__d {
  position: absolute;
  inset: 0;
  line-height: 1.15;
  text-align: center;
}

.digits__colon {
  display: inline-block;
  height: 1.15em;
  padding: 0 0.06em;
  line-height: 1.15;
  vertical-align: bottom;
  transform: translateY(-0.09em);
}

.read__date {
  color: var(--grey);
  font-size: 13px;
  min-width: 6.4em;
}

.words {
  --wt: 540;
  display: grid;
  justify-items: center;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(26px, calc((100vw - 2 * var(--pad)) / 12.5), 66px);
  font-variation-settings: 'SOFT' 50, 'WONK' 0;
  line-height: 1.12;
  letter-spacing: -0.02em;
  min-height: 1.3em;
  white-space: nowrap;
}

.words__line {
  grid-area: 1 / 1;
  white-space: pre;
}

.ch {
  --lw: 0;
  display: inline-block;
  font-weight: calc(var(--wt) + var(--lw));
  will-change: transform;
}

.hint {
  grid-row: 5;
  align-self: end;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--grey);
}

@media (max-width: 640px) {
  .top {
    font-size: 13px;
  }

  .label {
    font-size: 9px;
  }

  .read__row {
    font-size: 15px;
  }
}

.dial__svg stop {
  stop-color: var(--ink);
}
