/* The toast from a line: a Save draft button drawn with one hairline on a black page and, under it, the
   notifications, each a dark face between two hairlines, with the time left drawn in orange along its bottom edge. */
:root {
  --page: #000000;          /* the page */
  --face: #0c0c0c;          /* a notification */
  --face-hover: #121212;    /* a notification under the pointer */
  --edge: #2e2e2e;          /* the hairlines round it */
  --accent: #ff5b37;        /* the line it is born from: the time left */
  --ink: #f3f1ec;           /* the words */
  --muted: #8d8a83;         /* the quieter words */
  --rim: rgba(255, 255, 255, 0.24);   /* the button's hairline */
}

/* the width added to the words under the pointer, eased with a spring */
@property --hov {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap, no zoom */
html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Archivo Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

/* the button and, under it, the room for the notifications (script.js sets --slots from MAX) */
.desk {
  position: relative;
  width: min(380px, 100%);
  height: calc(80px + var(--slots, 3) * 70px + (var(--slots, 3) - 1) * 10px);
}

.desk__head {
  display: flex;
  justify-content: center;
  height: 52px;
}

/* ---------------------------------------------------------------- the button */
.save {
  --hov: 0;
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  height: 52px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: --hov 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* the hairline round the button: it swells a little with a spring under the pointer */
.save__rim {
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid var(--rim);
  border-radius: inherit;
  background: rgba(255, 255, 255, 0);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease, border-color 0.25s ease;
}

.save__label {
  font-variation-settings: 'wdth' calc(100 + var(--hov)), 'wght' 540;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .save:hover {
    --hov: 16;
  }

  .save:hover .save__rim {
    transform: scale(1.035, 1.06);
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.42);
  }
}

.save:active .save__rim {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.08);
  transition-duration: 0.12s;
}

.save:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

/* ---------------------------------------------------------------- the notifications */
.stack {
  position: absolute;
  top: 80px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* the slot: the pile makes room with FLIP, by moving the slots */
.toast {
  position: relative;
  flex: none;
  height: 70px;
}

/* the notification itself: it follows a finger sideways */
.toast__card {
  position: absolute;
  inset: 0;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* the dark face between the two hairlines: script.js opens it from the middle with a clip */
.toast__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 18px;
  background: var(--face);
  clip-path: inset(50% 0 50% 0);
  visibility: hidden;
  transition: background-color 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
  .toast__card:hover .toast__face {
    background: var(--face-hover);
  }
}

.toast__text {
  flex: 1;
  min-width: 0;
}

/* each line of words rises out of its own window */
.row {
  display: block;
  overflow: hidden;
}

.row.is-set {
  overflow: visible;
}

.row__in {
  display: block;
  font-variation-settings: 'wdth' var(--wd, 100), 'wght' var(--wg, 500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast__title {
  font-size: 15px;
  line-height: 20px;
  letter-spacing: -0.005em;
}

.toast__meta {
  margin-top: 1px;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row--side {
  flex: none;
  padding: 2px 0;
}

.row--side .row__in {
  overflow: visible;
}

.toast__undo {
  --hov: 0;
  display: block;
  height: 30px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-variation-settings: 'wdth' calc(var(--wd, 100) + var(--hov)), 'wght' var(--wg, 560);
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: --hov 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, border-color 0.2s ease, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

@media (hover: hover) and (pointer: fine) {
  .toast__undo:hover {
    --hov: 14;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.4);
  }
}

.toast__undo:active,
.toast__undo.is-pressed {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.1);
}

.toast__undo:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.toast__close {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* a finger gets a bigger target than the drawn cross */
.toast__close::before {
  content: '';
  position: absolute;
  inset: -8px -4px;
}

@media (hover: hover) and (pointer: fine) {
  .toast__close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
  }
}

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

.toast__close svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* the hairlines: the top edge, the bottom edge and, over it, the time left; script.js moves and stretches them */
.toast__line,
.toast__tick {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.toast__line {
  width: 100%;
  height: 1px;
  background: var(--edge);
  transform: scaleX(0);
  transform-origin: 50% 50%;
}

.toast__line--time {
  background: var(--accent);
}

/* the two small marks at the ends of the time left, like the ends of a dimension line */
.toast__tick {
  width: 1px;
  height: 7px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: 50% 50%;
}
