/* A year of daylight: an almanac on warm paper. A ring of 365 hairlines, one a day, each as long as that day's hours
   of light; a vermilion hand, a big number in Archivo (a variable typeface, width 62 to 125, weight 100 to 900) and
   four cities to choose from. */
:root {
  --paper: #f3f0e8;              /* the page */
  --ink: #141414;                /* the days already gone, the number, the chosen city */
  --grey: #8d887e;               /* the small texts and the months */
  --future: rgba(20, 20, 20, 0.17); /* the days still to come */
  --rule: rgba(20, 20, 20, 0.16); /* the guide circles */
  --accent: #ff4a1c;             /* the hand and the mark over the chosen city */
}

* {
  box-sizing: border-box;
}

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

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

.stage {
  --pad: clamp(16px, 5vw, 72px);
  --dial: min(64svh, calc(100vw - 2 * var(--pad) - 56px), 620px);
  display: grid;
  grid-template-rows: auto 1fr auto 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;
}

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

.top__name {
  font-weight: 640;
  font-variation-settings: 'wdth' 112;
}

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

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

/* ---------------------------------------------------------------- the dial */
.dial {
  position: relative;
  width: var(--dial);
  aspect-ratio: 1;
  margin: 18px 0;
  outline: none;
  touch-action: none;
}

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

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

.guide--half {
  stroke-dasharray: 2 4;
}

.guide--months {
  stroke: var(--grey);
  opacity: 0.6;
}

.days {
  fill: none;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.days--future {
  stroke: var(--future);
}

.days--past {
  stroke: var(--ink);
}

.hand {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: square;
  vector-effect: non-scaling-stroke;
}

.dial:focus-visible .guide--base {
  stroke: var(--ink);
  stroke-width: 2;
}

/* the scale, in the seam between the last day of the year and the first */
.scale {
  position: absolute;
  left: 50%;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--grey);
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.scale--half {
  top: calc(50% - 32.6%);
}

.scale--full {
  top: calc(50% - 45.2%);
}

.months {
  position: absolute;
  inset: 0;
}

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

.month__in {
  display: block;
}

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

/* the reading in the middle of the ring */
.read {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: calc(var(--dial) * 0.012);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.read__date {
  font-size: max(11px, calc(var(--dial) * 0.024));
  letter-spacing: 0.01em;
  color: var(--grey);
  font-variant-numeric: tabular-nums;
}

.read__value {
  display: flex;
  align-items: baseline;
  font-size: calc(var(--dial) * 0.092);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' 100, 'wght' 560;
  white-space: nowrap;
}

.read__num {
  display: inline-block;
  letter-spacing: -0.02em;
}

.read__unit {
  display: inline-block;
  margin: 0 0.22em 0 0.06em;
  font-size: 0.36em;
  font-variation-settings: 'wdth' 100, 'wght' 420;
  color: var(--grey);
}

.read__unit:last-child {
  margin-right: 0;
}

/* ---------------------------------------------------------------- the cities */
.cities {
  position: relative;
  display: flex;
  gap: clamp(14px, 3vw, 34px);
  padding-top: 14px;
}

.cities__mark {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 10px;
  margin-left: -1px;
  background: var(--accent);
  transform-origin: 50% 0;
}

.city {
  appearance: none;
  margin: 0;
  padding: 6px 2px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--grey);
  font-variation-settings: 'wdth' 92, 'wght' 400;
  cursor: pointer;
  transition: color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.city.is-on {
  color: var(--ink);
}

.city:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

@media (hover: hover) {
  .city:not(.is-on):hover {
    color: var(--ink);
  }
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--grey);
}

@media (max-width: 640px) {
  .stage {
    --dial: min(calc(100vw - 2 * var(--pad) - 40px), 58svh);
  }

  .top {
    font-size: 13px;
  }

  .month {
    font-size: 10px;
  }

  .scale {
    font-size: 9px;
  }

  .city {
    font-size: 14px;
  }
}
