/* The weather behind the glass: an oak window on a black page. The frame is honey oak with its grain, the day and the
   temperatures are burnt into the wood, the plate under the day chosen is brushed brass; everything behind the glass
   (the town, the sky, the rain) is drawn by the script and takes its colours from the weather. */
:root {
  --page: #000000;            /* the page */
  --oak: #c48d55;             /* the oak of the frame, in the light */
  --oak-deep: #9a6634;        /* and in its shadow, at the edges */
  --grain: #5a3416;           /* the darker lines of the grain */
  --burn: #3b200c;            /* the writing burnt into the wood */
  --brass: #d8b462;           /* the brass plate */
  --brass-light: #f6e3a6;     /* the light on the brass */
  --brass-deep: #8a6420;      /* the brass in its shadow */
  --mist: #d9e2ea;            /* the mist on the inside of the glass */
  --frost: #f2f7ff;           /* the frost on the edges, on a snowy day */
  --flash: #dfe7ff;           /* the light of the lightning */
  --rain-sky: #3b495a;        /* the sky behind the glass on a day of rain: at the top, at the horizon, and the land */
  --rain-horizon: #8796a5;
  --rain-land: #3a4752;
  --wind-sky: #45668a;        /* on a day of gales */
  --wind-horizon: #c4cfd8;
  --wind-land: #42586a;
  --snow-sky: #8a9aae;        /* on a day of snow */
  --snow-horizon: #dde5ec;
  --snow-land: #e2e9f0;
  --sun-sky: #2b7bcf;         /* on a sunny day */
  --sun-horizon: #f3dcae;
  --sun-land: #76874e;
  --storm-sky: #1b1d2a;       /* on a day of thunder */
  --storm-horizon: #5c5a6f;
  --storm-land: #21242d;
  --lamp: #ffc46a;            /* the lit windows and the street lamps */
  --stone: #6f6d69;           /* the stone of the houses */
  --slate: #2a3139;           /* the slate of the roofs */
  --leaf: #1f2b29;            /* the trees */
  --sun: #fff1c9;             /* the sun and its light */
  --radius: 22px;             /* the corners of the frame */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--burn);
  font-family: 'Fraunces Variable', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 28px 16px;
}

/* ---------------------------------------------------------------- the frame */
.window {
  --rail-top: 72px;
  --rail-bottom: 92px;
  --stile: 14px;
  position: relative;
  isolation: isolate;
  width: min(380px, 100%);
  height: 424px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--oak);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* the four pieces of oak: the rails with their grain across, the stiles with their grain up and down; the stiles run
   the whole height and the rails meet them at a thin joint */
.window__wood {
  position: absolute;
  z-index: 0;
  background-color: var(--oak);
  pointer-events: none;
}

.window__wood--top,
.window__wood--bottom {
  left: 0;
  right: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='380' height='96'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' stitchTiles='stitch' baseFrequency='0.0035 0.19' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.2 0 0 0 0 0.08 2.6 0 0 0 -1.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='380' height='96'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' stitchTiles='stitch' baseFrequency='0.012 0.9' numOctaves='2' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.16 0 0 0 0 0.05 1.6 0 0 0 -0.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(255, 226, 180, 0.22), rgba(255, 226, 180, 0) 40%, rgba(70, 36, 10, 0.16));
  background-size: 380px 96px, 380px 96px, 100% 100%;
}

.window__wood--top {
  top: 0;
  height: var(--rail-top);
  background-position: 0 0, 0 0, 0 0;
}

.window__wood--bottom {
  bottom: 0;
  height: var(--rail-bottom);
  background-position: -120px -4px, -60px 0, 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 230, 186, 0.42);
}

.window__wood--left,
.window__wood--right {
  top: 0;
  bottom: 0;
  z-index: 1;
  width: var(--stile);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='430'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' stitchTiles='stitch' baseFrequency='0.19 0.0035' numOctaves='3' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.2 0 0 0 0 0.08 2.6 0 0 0 -1.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    linear-gradient(90deg, rgba(70, 36, 10, 0.12), rgba(255, 226, 180, 0.16) 45%, rgba(70, 36, 10, 0.18));
  background-size: 28px 430px, 100% 100%;
}

.window__wood--left {
  left: 0;
  box-shadow: inset -1px 0 0 rgba(70, 36, 12, 0.5);
}

.window__wood--right {
  right: 0;
  background-position: -14px 0, 0 0;
  box-shadow: inset 1px 0 0 rgba(70, 36, 12, 0.5);
}

/* the round edge of the frame: light on the top, dark below */
.window::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow:
    inset 0 1.5px 0 rgba(255, 236, 200, 0.55),
    inset 0 -2px 0 rgba(60, 28, 6, 0.55),
    inset 0 0 0 1px rgba(80, 44, 16, 0.55),
    inset 0 0 18px rgba(60, 28, 6, 0.32);
  pointer-events: none;
}

/* the lightning lights up the wood, strongest round the glass */
.window__flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  background: radial-gradient(70% 60% at 50% 48%, var(--flash), transparent 75%);
  mix-blend-mode: soft-light;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- burnt into the wood */
.head,
.days {
  font-variation-settings: 'SOFT' 60, 'WONK' 0;
}

.head {
  position: absolute;
  z-index: 2;
  top: 0;
  left: var(--stile);
  right: var(--stile);
  height: var(--rail-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 12px 0 10px;
  pointer-events: none;
}

.head > *,
.head p,
.head h2 {
  margin: 0;
}

.burnt,
.head__place,
.head__note,
.head__temp,
.day {
  color: var(--burn);
  text-shadow: 0 1px 0 rgba(255, 228, 184, 0.38), 0 0 1.2px rgba(70, 30, 6, 0.55);
}

.head__where {
  min-width: 0;
}

.head__place {
  font-size: 20px;
  font-weight: 650;
  font-variation-settings: 'opsz' 28, 'SOFT' 60, 'WONK' 0;
  line-height: 24px;
  letter-spacing: -0.005em;
}

.head__note {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 480;
  font-variation-settings: 'opsz' 12, 'SOFT' 80, 'WONK' 0;
  line-height: 18px;
  white-space: nowrap;
  opacity: 0.86;
}

.head__temp {
  position: relative;
  display: flex;
  align-items: flex-start;
  flex: none;
  padding-right: 52px;
  line-height: 1;
  white-space: nowrap;
}

.head__num {
  font-size: 48px;
  font-weight: 420;
  font-variation-settings: 'opsz' 96, 'SOFT' 100, 'WONK' 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.head__deg {
  margin-left: 1px;
  font-size: 30px;
  font-weight: 420;
  font-variation-settings: 'opsz' 72, 'SOFT' 100, 'WONK' 0;
}

.head__low {
  position: absolute;
  right: 0;
  bottom: 6px;
  width: 48px;
  font-size: 12.5px;
  font-weight: 560;
  font-variation-settings: 'opsz' 12, 'SOFT' 80, 'WONK' 0;
  line-height: 15px;
  text-align: right;
  opacity: 0.8;
}

.swap {
  display: inline-block;
}

/* ---------------------------------------------------------------- the pane */
.pane {
  position: absolute;
  z-index: 2;
  top: var(--rail-top);
  left: var(--stile);
  right: var(--stile);
  bottom: var(--rail-bottom);
  overflow: hidden;
  border-radius: 5px;
  background: #3a4552;
  touch-action: none;
  cursor: grab;
  box-shadow:
    0 0 0 1px rgba(46, 22, 6, 0.75),
    0 0 0 3.5px rgba(176, 120, 66, 0.9),
    0 1.5px 0 3.5px rgba(255, 226, 182, 0.42),
    0 -1px 0 3.5px rgba(74, 38, 12, 0.5);
}

.pane.is-wiping {
  cursor: grabbing;
}

.pane__glass {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* the putty and the shade of the frame on the glass, deeper under the top rail */
.pane__bead {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 2px 0 rgba(28, 12, 2, 0.42),
    inset 0 10px 16px -8px rgba(10, 4, 0, 0.55),
    inset 0 -6px 12px -8px rgba(10, 4, 0, 0.35),
    inset 6px 0 10px -8px rgba(10, 4, 0, 0.4),
    inset -6px 0 10px -8px rgba(10, 4, 0, 0.4);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the days */
.days {
  position: absolute;
  z-index: 2;
  left: var(--stile);
  right: var(--stile);
  bottom: 0;
  height: var(--rail-bottom);
  display: grid;
  grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr));
  padding: 10px 4px 12px;
}

/* the brass plate under the day chosen, with its brushed lines and the light running across it */
.days__plate {
  position: absolute;
  top: 10px;
  bottom: 12px;
  left: 0;
  border-radius: 9px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, rgba(0, 0, 0, 0.045) 1px 2px),
    linear-gradient(100deg, transparent calc(var(--sheen, 30%) - 18%), rgba(255, 250, 225, 0.55) var(--sheen, 30%), transparent calc(var(--sheen, 30%) + 18%)),
    linear-gradient(172deg, var(--brass-light) 0%, var(--brass) 34%, var(--brass-deep) 70%, var(--brass) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 220, 0.8),
    inset 0 -1px 0 rgba(70, 44, 6, 0.6),
    inset 0 0 0 1px rgba(110, 76, 18, 0.55),
    0 2px 2px rgba(50, 24, 4, 0.45),
    0 5px 10px -3px rgba(50, 24, 4, 0.5);
  pointer-events: none;
}

.day {
  position: relative;
  display: grid;
  grid-template-rows: 16px 26px 18px;
  justify-items: center;
  align-content: center;
  row-gap: 3px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.day__name {
  font-size: 13px;
  font-weight: 600;
  font-variation-settings: 'opsz' 12, 'SOFT' 80, 'WONK' 0;
  line-height: 16px;
  letter-spacing: 0.01em;
}

.day__ico {
  display: block;
  width: 26px;
  height: 26px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 0 rgba(255, 228, 184, 0.38));
  transition: transform 0.35s cubic-bezier(0.34, 1.7, 0.5, 1);
}

.day__temp {
  font-size: 15px;
  font-weight: 560;
  font-variation-settings: 'opsz' 14, 'SOFT' 80, 'WONK' 0;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

.day > span {
  opacity: 0.8;
  transition: opacity 0.3s;
}

/* on the brass the letters are engraved: a little darker, with the light caught below them */
.day[aria-checked='true'] {
  color: #2c1a04;
  text-shadow: 0 1px 0 rgba(255, 246, 214, 0.65);
}

.day[aria-checked='true'] > span,
.day[aria-checked='true'] > svg {
  opacity: 1;
}

.day[aria-checked='true'] .day__ico {
  filter: drop-shadow(0 1px 0 rgba(255, 246, 214, 0.65));
}

@media (hover: hover) and (pointer: fine) {
  .day[aria-checked='false']:hover > span {
    opacity: 1;
  }

  .day[aria-checked='false']:hover .day__ico {
    transform: translateY(-2px) scale(1.06);
  }
}

.day:focus-visible {
  outline: 2px solid var(--burn);
  outline-offset: -3px;
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* a narrow screen: the big figure a little smaller */
@media (max-width: 400px) {
  .head__num {
    font-size: 44px;
  }

  .head__place {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .day__ico,
  .day > span {
    transition: none;
  }
}
