/* The Evening Star: the daily sky of Constellations on the game page.
   Every class starts with "es-", so nothing here touches the rest of the site.
   The colours come from the Classic theme of the app (src/sky_palette.gd). */

@font-face {
  font-family: "ES Digits";
  src: url("/fonts/open-sans-digits.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0030-0039;
}

/* ---------- The hero around the game ---------- */

/* On a phone: the title, the game, then the text and the badges. */
.game-hero.es-hero {
  padding-block: 1rem 2.5rem;
  /* The glow of a star can reach past the panel. It must never make the page
     scroll sideways. */
  overflow-x: hidden;
  overflow-x: clip;
}

.es-hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "title" "game" "more";
  gap: 1rem;
  align-items: start;
}

.es-hero-title {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.es-hero .es {
  grid-area: game;
}

.es-hero-more {
  grid-area: more;
}

.es-hero .game-icon {
  width: 56px;
  height: auto;
  border-radius: 22%;
}

.es-hero h1 {
  margin: 0;
  font-size: clamp(1.7rem, 1.2rem + 2.4vw, 3rem);
  line-height: 1.1;
}

.es-hero .subtitle {
  margin: 0;
  font-size: 1.05rem;
}

.es-hero-more .store-row {
  margin-top: 0.5rem;
}

/* On a wide screen: the title and the badges in one row, and the game under
   them, as wide as the page. */
@media (min-width: 60rem) {
  .game-hero.es-hero {
    padding-block: 2.5rem 4rem;
  }

  .es-hero .wrap {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title more" "game game";
    column-gap: 2rem;
    row-gap: 1.75rem;
    align-items: center;
  }

  .es-hero-title {
    gap: 1.25rem;
  }

  .es-hero .game-icon {
    width: 88px;
  }

  .es-hero .subtitle {
    font-size: 1.3rem;
  }

  /* The panel spans the full width of the page, from the logo to the last
     link of the menu, and the board stands in its middle. */
  .es-hero .es {
    max-width: none;
  }

  /* The buttons and the end card keep the width of a phone, under the board. */
  .es-hero .es-controls,
  .es-hero .es-card {
    width: 100%;
    max-width: 30rem;
    margin-inline: auto;
  }

  .es-hero-more .store-row {
    margin-top: 0;
  }

  .es-hero-more .store-row:has(li[data-store]) {
    margin: -0.75rem;
  }
}

/* ---------- The panel ---------- */

.es {
  --es-text: #eef0ff;
  --es-dim: #9aa3cf;
  --es-panel: #0d1230;
  --es-edge: #3a4680;
  --es-quiet: #1a2150;
  --es-gold: #f5c75a;
  --es-line: #a9d6ff;
  --es-accent: #7ce8c9;
  --es-hint: #c9a6ff;
  --es-ink: #141a3f;
  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
  color: var(--es-text);
  /* As in the app: Open Sans draws every digit, and Outfit every letter. */
  font-family: "ES Digits", "Outfit", system-ui, sans-serif;
  line-height: 1.4;
}

@media (prefers-contrast: more) {
  .es {
    --es-text: #ffffff;
    --es-dim: #d0d6f2;
    --es-panel: #000000;
    --es-edge: #8a96e0;
    --es-quiet: #141a40;
    --es-gold: #ffd400;
    --es-line: #8fd3ff;
    --es-accent: #33ffc4;
    --es-hint: #d9b8ff;
    --es-ink: #000000;
  }
}

/* Before the script runs: a quiet panel of the right size, so the page does
   not jump. */
.es:not(.es-ready) {
  min-height: 15rem;
  border: 1px solid var(--es-edge);
  border-radius: 1.25rem;
  background: linear-gradient(#141a3f, #05060f);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  color: var(--es-dim);
}

/* The game and How to Play share one cell of the grid, so the panel keeps
   the same size when one replaces the other. */
.es-panel {
  position: relative;
  display: grid;
  padding: 1rem 1rem 1.1rem;
  border: 1px solid var(--es-edge);
  border-radius: 1.25rem;
  background: #05060f;
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.45);
  isolation: isolate;
}

.es-game,
.es-intro,
.es-cover {
  grid-area: 1 / 1;
  min-width: 0;
}

.es-panel.es-reading .es-game {
  visibility: hidden;
}

/* The cover: until Play, the panel holds only the name of the sky, its date
   and difficulty, and the Play button. */
.es-panel.es-covered .es-game,
.es-panel.es-covered .es-intro,
.es-panel:not(.es-covered) .es-cover {
  display: none;
}

.es-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 13rem;
  padding: 1rem 0.5rem;
  text-align: center;
}

.es-cover-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.2;
}

.es-cover .es-cover-date {
  justify-content: center;
  margin: 0;
}

.es-cover .es-btn.es-play {
  width: 100%;
  max-width: 16rem;
  margin-top: 0.9rem;
}

.es-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
}

.es-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  column-gap: 0.75rem;
}

.es-sound {
  grid-row: 1 / span 2;
  grid-column: 3;
  align-self: center;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.4rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--es-dim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.es-sound:hover {
  color: var(--es-text);
}

.es-sound:focus-visible {
  outline: 3px solid var(--es-accent);
  outline-offset: 0;
}

.es-sound svg {
  width: 1.4rem;
  height: 1.4rem;
}

.es-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--es-text);
}

.es-date {
  grid-row: 2;
  margin: 0.1rem 0 0;
  color: var(--es-dim);
  font-size: 0.95rem;
}

/* The difficulty of a sky: gold stars for its level, and outlines for the
   rest of the three. Smaller and quieter than the stars of a solved sky. */
/* The date and the rating share a line while they fit. Otherwise the rating
   moves under the date, with no indent. */
.es-date,
.es-card-next {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.75em;
}

.es-card-next {
  justify-content: center;
}

.es-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  white-space: nowrap;
}

.es-stars {
  display: inline-flex;
  gap: 0.1em;
}

.es-stars svg {
  width: 0.95em;
  height: 0.95em;
}

.es-star-on {
  fill: var(--es-gold);
}

.es-star-off {
  fill: none;
  stroke: var(--es-dim);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

/* On a phone, the clock and the sound stand beside the title only, so the
   date and the difficulty get the full width of the panel under them. */
@media (max-width: 30rem) {
  .es-head {
    align-items: center;
  }

  .es-head .es-clock,
  .es-head .es-sound {
    grid-row: 1;
  }

  .es-head .es-date {
    grid-column: 1 / -1;
  }
}

.es-clock {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  color: var(--es-text);
}

.es-clock svg,
.es-card-stats svg {
  width: 1.05em;
  height: 1.05em;
}

.es-progress {
  margin-top: 0.6rem;
}

.es-count {
  display: block;
  text-align: right;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.es-bar {
  height: 5px;
  margin-top: 0.25rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.1);
  overflow: hidden;
}

.es-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--es-line);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.15s ease-out;
}

.es-progress.es-gold .es-count {
  color: var(--es-gold);
}

.es-progress.es-gold .es-bar i {
  background: var(--es-gold);
}

/* ---------- The sky ---------- */

.es-stage {
  position: relative;
  margin: 0.2rem 0 0;
  /* A drag on the sky draws the line, so the browser must not scroll. The
     margins of the panel still scroll the page. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.es-stage.es-still {
  touch-action: auto;
}

/* The canvas reaches far past the board on every side, so a glow draws over
   the header, the buttons, and the edge of the panel, and is never cut off.
   The stage under it takes the touches. */
.es-board {
  position: absolute;
  display: block;
  pointer-events: none;
}

.es-cheer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  font-weight: 600;
  color: var(--es-gold);
  text-shadow: 0 0 2px #2b1f05, 0 2px 0 #2b1f05, 0 0 18px rgb(0 0 0 / 0.6);
  opacity: 0;
}

.es-cheer.es-pop {
  animation: es-pop 1.8s ease-out forwards;
}

@keyframes es-pop {
  0% { opacity: 0; transform: scale(0.6); }
  15% { opacity: 1; transform: scale(1.08); }
  25% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.02); }
}

.es-reason {
  min-height: 1.4em;
  margin: 0.25rem 0 0.6rem;
  text-align: center;
  font-size: 0.98rem;
}

/* On a narrow phone, a refusal can take two lines: keep room for both, so the
   buttons never jump. */
@media (max-width: 26rem) {
  .es-reason {
    min-height: 2.8em;
    font-size: 0.92rem;
  }
}

/* ---------- Buttons ---------- */

.es-controls {
  display: flex;
  gap: 0.6rem;
}

.es-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3.1rem;
  padding: 0.55rem 1.1rem;
  border: 2px solid var(--es-edge);
  border-radius: 0.9rem;
  background: var(--es-quiet);
  color: var(--es-text);
  font: 600 1.15rem/1.1 "ES Digits", "Outfit", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.es-controls .es-btn {
  flex: 1;
}

.es-btn:hover:not(:disabled) {
  filter: brightness(1.15);
}

.es-btn:focus-visible {
  outline: 3px solid var(--es-accent);
  outline-offset: 2px;
}

.es-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.es-hint {
  border-color: var(--es-hint);
}

.es-hint-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding-inline: 0.3rem;
  border-radius: 999px;
  background: var(--es-hint);
  color: var(--es-ink);
  font-size: 0.95rem;
}

.es-hint-count[hidden] {
  display: none;
}

.es-controls .es-rules {
  flex: 0 0 3.1rem;
  padding: 0;
  border-radius: 999px;
}

/* Undo glows while the line has no legal step. */
.es-undo.es-stuck {
  animation: es-stuck 1.4s ease-in-out infinite;
}

@keyframes es-stuck {
  0%, 100% { box-shadow: 0 0 0 0 rgb(124 232 201 / 0); border-color: var(--es-edge); }
  50% { box-shadow: 0 0 16px 2px rgb(124 232 201 / 0.45); border-color: var(--es-accent); }
}

.es-btn.es-gold {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: var(--es-gold);
  color: var(--es-ink);
  font-size: 1.25rem;
  min-height: 3.4rem;
}

.es-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--es-gold);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- The end card ---------- */

.es-card[hidden],
.es-intro[hidden],
.es-controls[hidden],
.es-reason[hidden] {
  display: none;
}

.es-card {
  margin-top: 0.5rem;
  text-align: center;
}

.es-card-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--es-gold);
}

.es-card-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

/* The calendar of the last 7 days, under the result. */
.es-week {
  margin: 0.75rem 0 1rem;
}

.es-week-title {
  margin: 0 0 0.45rem;
  color: var(--es-dim);
  font-size: 0.95rem;
}

.es-week-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.es-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 0;
  padding: 0.4rem 0.1rem 0.45rem;
  border: 1px solid var(--es-edge);
  border-radius: 0.7rem;
  background: rgb(13 18 48 / 0.85);
  color: var(--es-text);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.es-day:hover:not(:disabled) {
  border-color: var(--es-dim);
}

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

.es-day:disabled {
  opacity: 0.35;
  cursor: default;
}

.es-day-name {
  color: var(--es-dim);
  font-size: 0.72rem;
  line-height: 1.2;
}

.es-day-num {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.2;
}

.es-day-mark svg {
  display: block;
  width: 1rem;
  height: 1rem;
}

/* A faint dot for a sky not played, an outline for a sky begun, and a gold
   star for a solve, which glows when it took no hints. */
.es-day-new .es-day-mark svg path {
  fill: var(--es-edge);
  transform: scale(0.45);
  transform-origin: 12px 13px;
}

.es-day-begun .es-day-mark svg path {
  fill: none;
  stroke: var(--es-gold);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.es-day-done .es-day-mark svg path {
  fill: var(--es-gold);
}

.es-day-clean .es-day-mark svg {
  filter: drop-shadow(0 0 3px rgb(245 199 90 / 0.8));
}

/* The day on the screen. */
.es-day-now {
  border: 2px solid var(--es-gold);
  background: rgb(245 199 90 / 0.12);
}

/* The calendar pops up with the card: each day in turn. */
.es-week-pop .es-day {
  animation: es-day-pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes es-day-pop {
  from { opacity: 0; transform: scale(0.6); }
  to { transform: none; }
}

.es-card-next {
  margin: 0.75rem 0 0;
  color: var(--es-dim);
  font-size: 0.98rem;
}

.es-card-app {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--es-edge);
  border-radius: 1rem;
  background: rgb(13 18 48 / 0.85);
}

.es-card-app-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.es-card-app-text {
  margin: 0.35rem 0 0;
  color: var(--es-dim);
}

.es-card-app .store-row,
.es-card-app .es-stores {
  justify-content: center;
  margin-top: 0.5rem;
}

.es-card-app .store-row:has(li[data-store]) {
  margin: 0.25rem 0 -0.5rem;
}

.es-card-app .store-soon {
  color: var(--es-text);
}

/* ---------- How to play ---------- */

/* As the rules screen of the app: the example on the night sky of the
   panel, then one card for each rule, its name in gold. */
.es-intro {
  align-self: center;
  justify-self: center;
  width: 100%;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
}

.es-intro-title {
  margin: 0.25rem 0 0;
  font-size: 1.45rem;
  font-weight: 600;
  text-align: center;
}

/* Every ripple of the example stays whole: the canvas reaches past its
   place, over the title and the first card. */
.es-demo {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 20rem;
  margin: -2.75rem 0 -2.5rem;
  pointer-events: none;
}

.es-intro-rules {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.es-intro-rules li {
  padding: 0.75rem 1rem;
  border: 1px solid var(--es-edge);
  border-radius: 1rem;
  background: rgb(13 18 48 / 0.8);
}

.es-intro-rules h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--es-gold);
}

.es-intro-rules p {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
}

/* ---------- A sky that did not load ---------- */

.es-rest {
  margin: 3rem 0 1rem;
  text-align: center;
  font-size: 1.15rem;
}

.es-offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
}

@media (prefers-reduced-motion: reduce) {
  .es-cheer.es-pop {
    animation-duration: 2.4s;
    animation-name: es-fade;
  }

  .es-undo.es-stuck {
    animation: none;
  }

  .es-undo.es-stuck {
    border-color: var(--es-accent);
  }

  @keyframes es-fade {
    0%, 100% { opacity: 0; }
    15%, 75% { opacity: 1; }
  }
}
