/*
  BusyCal Bookings: What's New, the current release's highlights in a dialog over the
  dashboard (host/whats_new_dialog.html), on a screen of their own (host/whats_new.html), and
  the website's version under the Settings cards.

  Loaded after dashboard.css and built on the public tokens, so the dialog has the
  dashboard's type, colors, radii, shadows and motion in both appearances. The layout follows
  WhatsNewKit's dialog on the Mac: a large centered title, a column of rows with an
  illustration beside a bold title and a sentence, and one Continue button under the list,
  outside the part that scrolls.

  The dialog sits in the host footer, whose smaller grey type it would otherwise inherit, so it
  sets its own. The Content Security Policy blocks style attributes, so the illustrations'
  colors live here as classes (host/whats_new_icons.html).

  Sections:
    1. Illustration colors
    2. Heading and rows, shared by the dialog and the screen
    3. The dialog
    4. The screen without script
    5. Settings: the version line
    6. Motion
    7. Phones
    8. Dark appearance, forced colors and print
*/

/* ---------- 1. Illustration colors ---------- */

/*
  Each gradient runs from a lighter top to the base color, as WhatsNewKit's shapes take a
  soft highlight toward the top. The hues are close to the Mac's system colors; blue is
  BusyCal's own. The drawings are decorative, so their colors carry no meaning and need no
  contrast ratio.
*/
.wn-blue-0 { stop-color: #6ea4f3; }
.wn-blue-1 { stop-color: #3b78dd; }
.wn-indigo-0 { stop-color: #8784f6; }
.wn-indigo-1 { stop-color: #5550d8; }
.wn-teal-0 { stop-color: #4fd5dc; }
.wn-teal-1 { stop-color: #17a5b6; }
.wn-violet-0 { stop-color: #bb8ef8; }
.wn-violet-1 { stop-color: #8a50e7; }
.wn-pink-0 { stop-color: #ff8aa9; }
.wn-pink-1 { stop-color: #ec4a7c; }
.wn-green-0 { stop-color: #5edb88; }
.wn-green-1 { stop-color: #22ad57; }
.wn-yellow-0 { stop-color: #ffdb5e; }
.wn-yellow-1 { stop-color: #f7b21c; }
.wn-metal-0 { stop-color: #d3d7de; }
.wn-metal-1 { stop-color: #8e95a0; }

/* The gradients' own box takes no room. */
.whats-new-palette {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.whats-new-art {
  width: 44px;
  height: 44px;
  flex: none;
  overflow: visible;
}

/* The calendar's header: a deeper blue rather than black over the page, so the band keeps its
   color instead of turning grey. */
.wn-band { fill: rgb(20 58 150 / 0.3); }

/* White details at three strengths: the chosen day and the fan's pin, the other days, and the
   clock's lit span. */
.wn-white { fill: #ffffff; }
.wn-soft { fill: rgb(255 255 255 / 0.5); }
.wn-faint { fill: rgb(255 255 255 / 0.2); }

/* Lines drawn on a shape: clock hands, ticks and the check mark. Each sets its width. */
.wn-line {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wn-line--soft { stroke: rgb(255 255 255 / 0.55); }
.wn-line--orange { stroke: #ff9f0a; }

.wn-pin {
  fill: #ff9f0a;
  stroke: #ffffff;
  stroke-width: 1.6px;
}

/*
  The gap around a shape in front: a stroke in the surface's color, painted before the fill,
  so only its outer half shows. It reads as a cut through the shape behind, in either
  appearance, without an outline.
*/
.wn-cut {
  stroke: var(--whats-new-gap, var(--surface));
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* ---------- 2. Heading and rows ---------- */

/* The title and version, centered over the rows, as on the Mac. */
.whats-new-head {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  max-width: 440px;
  margin: 0 auto var(--space-8);
  text-align: center;
}

.whats-new-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.whats-new-version {
  color: var(--text-3);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* Rows keep a reading width and their own left edge inside the centered column. */
.whats-new-list {
  display: grid;
  gap: var(--space-6);
  max-width: 420px;
  margin: 0 auto;
}

/*
  The illustration is centered against the words, which keep the second column even when a
  row has no illustration, so a long title or sentence wraps under itself.
*/
.whats-new-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-4);
}

.whats-new-words {
  display: grid;
  grid-column: 2;
  gap: 2px;
  min-width: 0;
}

.whats-new-item-title {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  overflow-wrap: anywhere;
}

.whats-new-item-detail {
  color: var(--text-2);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

/* Continue: the public primary button, wide enough to read as the one way on. */
.whats-new-foot {
  display: flex;
  justify-content: center;
}

.whats-new-continue {
  min-width: 200px;
}

/* ---------- 3. The dialog ---------- */

/*
  The dashboard's modal card, as for adding a reply address: the raised surface, the largest
  radius and the floating shadow. The dialog itself doesn't scroll. Its heading and rows
  scroll in their own part, and Continue keeps its place under them. It is never wider than
  the window less the page gutters, nor taller than the window less a margin.
*/
.whats-new {
  --whats-new-gap: var(--surface-raised);
  --whats-new-pad: var(--space-10);
  width: min(540px, calc(100vw - 2 * var(--gutter)));
  max-width: none;
  max-height: min(720px, calc(100dvh - 2 * var(--space-6)));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  color: var(--text);
  font-size: var(--text-base);
  line-height: var(--leading);
  text-align: start;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

/* Only an open dialog takes the column layout; a closed one keeps the browser's display: none. */
.whats-new[open] {
  display: flex;
  flex-direction: column;
}

.whats-new::backdrop {
  background: rgb(10 14 22 / 0.42);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/*
  The part that scrolls. Its background has the accent glow the dashboard opens with, which
  scrolls away with the title. A hairline marks the bottom edge only while rows continue below
  it: the line is fixed to the visible edge, and a strip of the surface at the end of the
  content covers it once the list is scrolled to the end, or when everything fits. The
  bottom padding keeps the last row clear of that edge.
*/
.whats-new-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-10) var(--whats-new-pad) var(--space-6);
  border-radius: calc(var(--radius-xl) - 1px) calc(var(--radius-xl) - 1px) 0 0;
  background:
    linear-gradient(var(--surface-raised), var(--surface-raised)) bottom / 100% 2px no-repeat local,
    linear-gradient(var(--line), var(--line)) bottom / 100% 1px no-repeat scroll,
    radial-gradient(120% 240px at 50% -110px, var(--accent-wash), transparent 74%) top / 100% 240px no-repeat local,
    var(--surface-raised);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

/* The keyboard can focus the scrolling part to scroll it; its ring sits just inside the card. */
.whats-new-scroll:focus-visible {
  outline-offset: -4px;
  border-radius: calc(var(--radius-xl) - 1px) calc(var(--radius-xl) - 1px) var(--radius-md) var(--radius-md);
}

.whats-new .whats-new-foot {
  flex: none;
  padding: var(--space-4) var(--whats-new-pad) var(--space-6);
}

/* ---------- 4. The screen without script ---------- */

/* The dialog's card on the page, with the same heading, rows and Continue. */
.whats-new-card {
  --whats-new-gap: var(--surface);
  max-width: 540px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-10) var(--space-8);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 240px at 50% -110px, var(--accent-wash), transparent 74%) top / 100% 240px no-repeat,
    var(--surface);
  box-shadow: var(--shadow-card);
}

.whats-new-card .whats-new-foot {
  margin-top: var(--space-8);
}

/* ---------- 5. Settings: the version line ---------- */

/*
  The website's version under the cards, quiet as a footnote, then What's New while the
  release has highlights. The link keeps the public link's look and target.
*/
.settings-version {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-2);
  color: var(--text-3);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* ---------- 6. Motion ---------- */

/*
  The dialog fades and lifts in like the reply-address dialog, then its rows follow one after
  another, a little apart, so the eye reads down the list. With reduced motion it appears and
  leaves at once: the public stylesheet turns every transition and animation off, and these
  only apply when no reduction is asked for.
*/
@media (prefers-reduced-motion: no-preference) {
  .whats-new[open] {
    transition:
      opacity var(--motion) var(--ease-out),
      transform var(--motion) var(--ease-out);
  }

  .whats-new[open]::backdrop {
    transition: opacity var(--motion) linear;
  }

  @starting-style {
    .whats-new[open] {
      opacity: 0;
      transform: translateY(8px) scale(0.98);
    }

    .whats-new[open]::backdrop {
      opacity: 0;
    }
  }

  /*
    It leaves a little faster, but only where the browser can keep a closing dialog in the top
    layer while it fades (the overlay property). Elsewhere a fading dialog would show for a
    moment in its place in the footer, so it closes at once.
  */
  @supports (overlay: auto) {
    .whats-new:not([open]) {
      opacity: 0;
      transform: translateY(8px) scale(0.98);
      transition:
        opacity var(--motion-quick) var(--ease-in),
        transform var(--motion-quick) var(--ease-in),
        overlay var(--motion-quick) allow-discrete,
        display var(--motion-quick) allow-discrete;
    }

    .whats-new:not([open])::backdrop {
      opacity: 0;
      transition:
        opacity var(--motion-quick) linear,
        overlay var(--motion-quick) allow-discrete,
        display var(--motion-quick) allow-discrete;
    }
  }

  .whats-new[open] .whats-new-item {
    animation: whats-new-row 360ms var(--ease-out) 90ms backwards;
  }

  .whats-new[open] .whats-new-item:nth-child(2) { animation-delay: 140ms; }
  .whats-new[open] .whats-new-item:nth-child(3) { animation-delay: 190ms; }
  .whats-new[open] .whats-new-item:nth-child(4) { animation-delay: 240ms; }
  .whats-new[open] .whats-new-item:nth-child(5) { animation-delay: 290ms; }
  .whats-new[open] .whats-new-item:nth-child(n + 6) { animation-delay: 340ms; }
}

@keyframes whats-new-row {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- 7. Phones ---------- */

/*
  Below 480 px the dialog nearly fills the window, with narrower margins, a smaller title
  and illustrations, and Continue across the full width, as a sheet does on iPhone. The
  screen's card does the same inside the page gutters.
*/
@media (max-width: 479px) {
  .whats-new {
    --whats-new-pad: var(--space-5);
    width: calc(100vw - 2 * var(--space-3));
    max-height: calc(100dvh - 2 * var(--space-3));
  }

  .whats-new-scroll {
    padding-top: var(--space-8);
    padding-bottom: var(--space-5);
  }

  .whats-new .whats-new-foot {
    padding-top: var(--space-3);
    padding-bottom: var(--space-5);
  }

  .whats-new-card {
    padding: var(--space-8) var(--space-5) var(--space-6);
  }

  .whats-new-card .whats-new-foot {
    margin-top: var(--space-6);
  }

  .whats-new-head {
    margin-bottom: var(--space-6);
  }

  .whats-new-title {
    font-size: var(--text-lg);
  }

  .whats-new-list {
    gap: var(--space-5);
  }

  .whats-new-item {
    grid-template-columns: 40px minmax(0, 1fr);
    column-gap: 14px;
  }

  .whats-new-art {
    width: 40px;
    height: 40px;
  }

  .whats-new-continue {
    flex: 1 1 auto;
    min-width: 0;
  }
}

/* ---------- 8. Dark appearance, forced colors and print ---------- */

/*
  On the dark surface the same hues sit a step lighter, as the Mac's system colors do in dark
  appearance, and the gap takes the dark surface through --whats-new-gap.
*/
@media (prefers-color-scheme: dark) {
  .wn-blue-0 { stop-color: #7cb0ff; }
  .wn-blue-1 { stop-color: #4485ec; }
  .wn-indigo-0 { stop-color: #9593ff; }
  .wn-indigo-1 { stop-color: #605ce8; }
  .wn-teal-0 { stop-color: #62e0e6; }
  .wn-teal-1 { stop-color: #1fb3c4; }
  .wn-violet-0 { stop-color: #c79dff; }
  .wn-violet-1 { stop-color: #965cf2; }
  .wn-pink-0 { stop-color: #ff97b4; }
  .wn-pink-1 { stop-color: #f2568a; }
  .wn-green-0 { stop-color: #6be495; }
  .wn-green-1 { stop-color: #29b862; }
  .wn-metal-0 { stop-color: #c7ccd4; }
  .wn-metal-1 { stop-color: #858c97; }

  .wn-band { fill: rgb(16 46 128 / 0.34); }
}

/*
  Forced colors draw the cards and the edge above Continue in the system's colors, without the
  glow and the hairline's covering strip. The illustrations keep their colors, as images do,
  with their gaps in the system's background.
*/
@media (forced-colors: active) {
  .whats-new,
  .whats-new-card {
    --whats-new-gap: Canvas;
    border: 1px solid CanvasText;
  }

  .whats-new-scroll,
  .whats-new-card {
    background: Canvas;
  }

  .whats-new .whats-new-foot {
    border-top: 1px solid CanvasText;
  }

  .whats-new-art {
    forced-color-adjust: none;
  }
}

@media print {
  .whats-new-card {
    border: 0;
    box-shadow: none;
  }

  .whats-new-card .whats-new-foot {
    display: none;
  }
}
