/*
The daily puzzle page (templates/daily.html, scripts/daily.js). It borrows the
app's mono theme in light mode: a white board with black cages, a grey keypad
tray, and off-white keys and tiles. Sizes are in px because the site's body
text is larger than a game's controls want.
*/
body.daily-page {
  --daily-tile: #FAFBFB;
  --daily-key: #F4F5F5;
  --daily-tray: #CFD2D1;
  --daily-gold: #9E7C1F;
  font-size: 16px;
  line-height: 1.35;
  color: var(--primary-color);
}
.daily-page [hidden] {
  display: none !important;
}
/* The keypad tray sticks to the bottom of the window, which needs the page
itself to be what scrolls. `clip` keeps the solved board's glow from adding a
sideways scroll without making the wrapper a scroll container. */
.daily-page .wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: visible;
  overflow-x: clip;
}
.daily-column {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  box-sizing: border-box;
}
/*
Masthead
*/
.daily-masthead {
  background: var(--background-inverted);
  color: var(--primary-inverted);
  padding-top: env(safe-area-inset-top);
}
.daily-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  padding-bottom: 12px;
}
.daily-wordmark {
  font-family: var(--font-family-bold);
  font-size: 22px;
  line-height: 1.2;
  color: var(--primary-inverted);
  border-bottom: none;
}
.daily-logo {
  display: block;
  line-height: 0;
  border-bottom: none;
}
.daily-logo svg {
  width: 26px;
  fill: var(--primary-inverted);
}
/*
Heading: the title with the puzzle's number beside it, and a line under them,
on the left; the clock while playing, on the right.
*/
.daily-main {
  flex: 1;
  padding-bottom: 32px;
}
/* main.css makes every section at least half a screen tall for the home page.
   Here a section is only as tall as what is in it. */
.daily-page section {
  min-height: 0;
}
.daily-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  align-content: center;
  column-gap: 12px;
  padding-top: 18px;
  min-height: 56px;
}
.daily-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.daily-heading h1 {
  font-size: clamp(22px, 6.6vw, 28px);
  line-height: 1.15;
  white-space: nowrap;
}
/* The line under the title, on a row of its own so the title and the clock
   stay level with each other whether or not it is showing. */
.daily-countdown {
  grid-column: 1 / -1;
  margin-top: 2px;
  min-height: 20px;
  font-size: 14px;
  line-height: 20px;
  color: rgba(34, 34, 34, 0.65);
}
/* The line and the clock fade in and out and keep their place while they are
   off, so the title stays put from one phase to the next. */
.daily-countdown,
.daily-clock {
  transition: opacity 0.25s ease;
}
.daily-countdown.is-off,
.daily-clock.is-off {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s 0.25s;
}
.daily-number {
  padding: 2px 6px;
  border-radius: 5px;
  background: #000;
  color: var(--background);
  font-family: var(--font-family-bold);
  font-size: 14px;
}
.daily-clock {
  padding: 4px 10px;
  border: 1px solid #000;
  border-radius: 999px;
  background: var(--background);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/*
Cards, tiles, and buttons
*/
.daily-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding-top: 28px;
  text-align: center;
}
.daily-preview {
  display: block;
  width: 132px;
  height: 132px;
}
.daily-message {
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  font-size: 15px;
  color: rgba(34, 34, 34, 0.65);
  text-align: center;
}
noscript .daily-message {
  padding-top: 28px;
}
.daily-tiles {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 12px;
  width: 100%;
}
.daily-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 6px;
  border-radius: 7px;
  background: var(--daily-tile);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
  text-align: center;
}
.daily-tile strong {
  font-family: var(--font-family-bold);
  font-size: 20px;
  line-height: 1.15;
}
.daily-tile span {
  font-family: var(--font-family-bold);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(34, 34, 34, 0.6);
}
.daily-tile--gold strong {
  color: var(--daily-gold);
}
.daily-button {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.125);
  color: #000;
  font-family: var(--font-family-bold);
  font-size: 17px;
  line-height: 1.2;
  cursor: pointer;
}
.daily-button--primary {
  background: #000;
  color: #fff;
}
.daily-button:active {
  opacity: 0.7;
}
.daily-page button:focus-visible,
.daily-page a:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}
/*
Board. The canvas draws it; the grid of buttons over it takes taps and the
keyboard, and gives a screen reader something to read. The room above is for
the tab that says notes are on, which hangs off the top edge.
*/
.daily-board {
  position: relative;
  isolation: isolate;
  width: min(100%, max(240px, calc(100vh - 330px)));
  width: min(100%, max(240px, calc(100dvh - 330px)));
  aspect-ratio: 1 / 1;
  margin: 28px auto 0;
}
.daily-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #fff;
}
.daily-cells {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-rows: repeat(var(--daily-size), minmax(0, 1fr));
}
/* A drag across the board selects cells, so while a game is on a touch there
doesn't scroll the page. */
.daily-page.is-playing .daily-cells {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.daily-cells > div {
  display: grid;
  grid-template-columns: repeat(var(--daily-size), minmax(0, 1fr));
}
.daily-cells button {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.daily-cells button:disabled {
  cursor: default;
}
/* No focus ring on the board: the keyboard's cell is the selected one, and
   the yellow highlight already marks it. */
.daily-page .daily-cells button:focus-visible {
  outline: none;
}
.daily-tab {
  position: absolute;
  left: 16px;
  bottom: 100%;
  padding: 5px 10px;
  background: #000;
  color: var(--daily-key);
  font-family: var(--font-family-bold);
  font-size: 15px;
  line-height: 1.2;
  white-space: pre;
  clip-path: inset(100% 0 0 0);
  transition: clip-path 0.25s ease;
}
.daily-tab.is-visible {
  clip-path: inset(0);
}
/* The try tab hangs off the board's other corner while a try is on. It only
   names the mode: the keys that end a try are on the keypad. */
.daily-tab--try {
  left: auto;
  right: 16px;
}
/* The glow that turns around a solved board, as in the app. */
@property --daily-glow-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
.daily-glow {
  position: absolute;
  inset: -3px;
  z-index: -1;
  opacity: 0;
  filter: blur(10px);
  background: conic-gradient(from var(--daily-glow-angle), #ff3b30, #ff9500, #ffcc00, #34c759, #007aff, #af52de, #ff2d55, #ff3b30);
  transition: opacity 0.15s linear;
}
.daily-board.is-solved .daily-glow {
  opacity: 1;
  transition: opacity 0.25s linear 0.2s;
  animation: daily-glow-turn 6s linear infinite;
}
@keyframes daily-glow-turn {
  to {
    --daily-glow-angle: 360deg;
  }
}
/*
Result
*/
.daily-result {
  padding-top: 24px;
  text-align: center;
}
.daily-party {
  font-size: 24px;
  line-height: 1.2;
}
.daily-party.is-perfect {
  font-size: 36px;
}
.daily-result h2 {
  margin-top: 12px;
  font-size: 20px;
  line-height: 1.2;
}
.daily-result .daily-message {
  margin-top: 6px;
}
.daily-result .daily-tiles {
  grid-auto-flow: row;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 20px;
}
.daily-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}
.daily-app {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 2px solid rgba(0, 0, 0, 0.1);
}
.daily-app p {
  max-width: 400px;
  margin: 0 auto;
  font-size: 15px;
  color: rgba(34, 34, 34, 0.75);
}
.daily-app-link {
  display: inline-block;
  margin-top: 16px;
  border-bottom: none;
  line-height: 0;
}
.daily-app-link img {
  width: 144px;
}
/* The result's pieces arrive one after another once the puzzle is solved. */
.daily-result.is-arriving > * {
  animation: daily-arrive 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
/* The first piece waits for the keypad to slide away (TRAY_EXIT_MS in
   daily.js), then the rest follow as the page eases down to them. */
.daily-result.is-arriving > :nth-child(1) { animation-delay: 0.4s; }
.daily-result.is-arriving > :nth-child(2) { animation-delay: 0.55s; }
.daily-result.is-arriving > :nth-child(3) { animation-delay: 0.55s; }
.daily-result.is-arriving > :nth-child(4) { animation-delay: 0.75s; }
.daily-result.is-arriving > :nth-child(5) { animation-delay: 0.95s; }
.daily-result.is-arriving > :nth-child(6) { animation-delay: 1.15s; }
@keyframes daily-arrive {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}
.daily-confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
}
/*
How to play
*/
.daily-rules {
  margin-top: 28px;
  padding-top: 24px;
  padding-bottom: 8px;
  border-top: 2px solid rgba(0, 0, 0, 0.1);
  font-size: 15px;
  line-height: 1.45;
}
.daily-rules h2 {
  font-size: 16px;
  line-height: 1.3;
}
/* The site's yellow underline is faint on this light background. */
.daily-rules a {
  border-bottom-color: #000;
}
.daily-rules p {
  margin-top: 12px;
  color: rgba(34, 34, 34, 0.85);
}
/* Keyboard controls, under the instructions with a heading like theirs. Each
   control is its keys, drawn as keycaps, with what they do right beside
   them. The controls run on like words in a line and wrap where they need
   to. */
.daily-keyboard {
  margin-top: 36px;
}
.daily-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.2;
}
.daily-shortcuts > div {
  display: flex;
  align-items: center;
  gap: 7px;
}
.daily-shortcuts dt {
  display: flex;
  align-items: center;
  gap: 3px;
}
.daily-shortcuts dd {
  color: rgba(34, 34, 34, 0.75);
  white-space: nowrap;
}
.daily-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--daily-tile);
  color: rgba(34, 34, 34, 0.85);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
}
.daily-key--wide {
  padding: 0 7px;
}
.daily-key svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}
.daily-key--left svg {
  transform: rotate(-90deg);
}
.daily-key--right svg {
  transform: rotate(90deg);
}
.daily-key--down svg {
  transform: rotate(180deg);
}
.daily-key-join {
  margin: 0 2px;
  font-size: 12px;
  color: rgba(34, 34, 34, 0.6);
}
/* The keyboard controls are for a device that has one, so a phone or a
   tablet does not show them. */
@media (hover: none), (pointer: coarse) {
  .daily-keyboard {
    display: none;
  }
}
/*
Keypad, in a tray that stays at the bottom of the window. The frame's black
shows through the gaps between keys as their dividing lines.
*/
.daily-tray {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 14px max(12px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: var(--daily-tray);
}
/* On a solve the keypad slides out under the window before it goes. */
.daily-tray.is-leaving {
  pointer-events: none;
  animation: daily-tray-leave 0.32s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes daily-tray-leave {
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}
.daily-keypad {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 504px;
  margin: 0 auto;
  border: 3px solid #000;
  border-radius: 11px;
  overflow: hidden;
  background: #000;
}
.daily-keys {
  display: flex;
  gap: 1px;
}
.daily-keys button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--daily-key);
  color: #000;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.daily-keys--actions button {
  height: 44px;
}
.daily-keys--actions svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.daily-keys--actions button.is-on {
  background: #000;
  color: var(--daily-key);
}
.daily-keys--numbers button {
  height: 60px;
  font-family: var(--font-mono);
  font-size: 28px;
  line-height: 1;
}
.daily-keys button:active:not(:disabled) {
  background: #E2E4E4;
}
.daily-keys--actions button.is-on:active {
  background: #333;
}
.daily-keys--numbers button:disabled {
  color: rgba(0, 0, 0, 0.35);
  cursor: default;
}
.daily-keys button[hidden] {
  display: none;
}
/* The more key turns the action keys over to undo and redo, the way a
   keyboard's 123 key swaps its letters. It is one of four equal keys on the
   main page and keeps that width on the other, so it never moves. */
.daily-keys--actions .daily-key-more {
  flex: 0 0 calc((100% - 3px) / 4);
}
/* Undo and redo keep their place and fade while there is nothing for them. */
.daily-keys--actions button:disabled {
  color: rgba(0, 0, 0, 0.3);
  cursor: default;
}
.daily-page .daily-keys button:focus-visible {
  outline-offset: -4px;
}
/* The footer comes back once the game is over. */
.daily-page.is-playing .site-footer,
.daily-page.is-finishing .site-footer {
  display: none;
}
.daily-page.is-playing .daily-main {
  padding-bottom: 20px;
}
@media only screen and (max-width: 350px) {
  #dailyMoves {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .daily-tab,
  .daily-glow,
  .daily-countdown,
  .daily-clock,
  .daily-countdown.is-off,
  .daily-clock.is-off {
    transition: none;
  }
  .daily-board.is-solved .daily-glow,
  .daily-result.is-arriving > *,
  .daily-tray.is-leaving {
    animation: none;
  }
}
