/* The inbox that opens like a slit: the inbox of a made-up mail app (Quillby) on a warm white page. The rows fold
   away above and below the chosen one and the message opens in the gap. */
:root {
  --page: #f1eee7;          /* the page */
  --page-light: #faf8f3;    /* the soft light on the page */
  --app: #f8f6f1;           /* the body of the window */
  --row: #fffefb;           /* a row of the list */
  --row-hover: #ffffff;     /* a row under the pointer */
  --sheet: #ffffff;         /* the open message */
  --ink: #17171a;           /* the words */
  --soft: #4a4a50;          /* the body of the message */
  --muted: #8a8880;         /* the small words */
  --line: rgba(23, 23, 26, 0.08); /* the hairlines */
  --accent: #2f4cff;        /* cobalt: the New pills, Reply, the count */
  --accent-soft: rgba(47, 76, 255, 0.1); /* the tint of the New pill */
  --ink-toast: #17171a;     /* the archived toast */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background:
    radial-gradient(70% 60% at 50% 12%, var(--page-light), transparent 72%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* the window */
.app {
  --rowh: clamp(48px, 11vh, 66px);
  position: relative;
  width: min(460px, 94vw);
  height: min(560px, 92vh);
  display: flex;
  flex-direction: column;
  background: var(--app);
  border-radius: clamp(16px, 3.4vmin, 22px);
  box-shadow:
    0 0 0 1px rgba(23, 23, 26, 0.06),
    0 1px 1px rgba(23, 23, 26, 0.04),
    0 8px 18px -8px rgba(40, 32, 20, 0.12),
    0 34px 60px -28px rgba(40, 32, 20, 0.22);
  overflow: hidden;
}

.app__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  z-index: 5;
}

.bar {
  flex: none;
  height: clamp(44px, 9vh, 58px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 clamp(12px, 3vmin, 18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand__mark {
  width: 20px;
  height: 20px;
  fill: var(--ink);
  stroke: none;
}

.brand__mark path {
  fill: none;
  stroke: var(--app);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand__name {
  font-size: 14px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.bar__title {
  font-size: 13px;
  color: var(--muted);
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.bar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}

.count__win {
  display: inline-block;
  height: 14px;
  overflow: hidden;
  line-height: 14px;
}

.count__n {
  display: block;
  font-variant-numeric: tabular-nums;
}

.tray {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--soft);
}

.tray svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tray__n {
  position: absolute;
  top: 1px;
  right: -3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
  font-size: 9.5px;
  font-weight: 650;
  line-height: 15px;
  text-align: center;
  opacity: 0;
  transform: scale(0.6);
}

/* the list and its rows: every row is positioned by GSAP (y), the button inside takes the CSS states */
.list {
  position: relative;
  flex: 1;
  margin: 0 clamp(6px, 1.6vmin, 9px) clamp(6px, 1.6vmin, 9px);
  border-radius: clamp(12px, 2.6vmin, 16px);
  overflow: hidden;
  background: rgba(23, 23, 26, 0.025);
  box-shadow: inset 0 0 0 1px var(--line);
}

.row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--rowh);
  will-change: transform;
}

.row__btn {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: clamp(9px, 2.2vmin, 12px);
  padding: 0 clamp(11px, 2.8vmin, 16px);
  text-align: left;
  background: var(--row);
  box-shadow: inset 0 -1px 0 var(--line), 0 1px 0 rgba(23, 23, 26, 0.03);
  transition: background-color 0.25s ease, transform 0.18s cubic-bezier(.3, 1.4, .5, 1);
}

.row__btn:active {
  transform: scale(0.985);
}

.avatar {
  flex: none;
  width: clamp(28px, 6vmin, 36px);
  height: clamp(28px, 6vmin, 36px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--tint, #ebe6dc);
  color: rgba(23, 23, 26, 0.72);
  font-size: clamp(10px, 2.1vmin, 12px);
  font-weight: 620;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(23, 23, 26, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.avatar > span {
  display: block;
  transition: transform 0.35s cubic-bezier(.3, 1.5, .5, 1);
}

.row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.row__top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sender {
  display: block;
  width: max-content;
  max-width: 100%;
  white-space: nowrap;
  font-size: clamp(12px, 2.6vmin, 14px);
  line-height: 1.2;
  font-weight: 520;
  transform-origin: 0 0;
}

.row.is-unread .sender {
  font-weight: 680;
}

.new {
  flex: none;
  height: 16px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 16px;
  display: none;
}

.row.is-unread .new {
  display: block;
}

.time {
  margin-left: auto;
  flex: none;
  font-size: clamp(10.5px, 2.2vmin, 11.5px);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: transform 0.35s cubic-bezier(.3, 1.4, .5, 1);
}

.subject {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(11.5px, 2.5vmin, 13.5px);
  line-height: 1.25;
  font-weight: 560;
  letter-spacing: -0.005em;
  transform-origin: 0 0;
}

.row:not(.is-unread) .subject {
  font-weight: 460;
  color: var(--soft);
}

.preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(11px, 2.3vmin, 12.5px);
  line-height: 1.25;
  color: var(--muted);
}

.row__go {
  flex: none;
  width: 14px;
  height: 14px;
  margin-left: -6px;
  margin-right: -4px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(.3, 1.4, .5, 1);
}

.row.is-hover .row__btn {
  background: var(--row-hover);
}

.row.is-hover .time {
  transform: translateX(-6px);
}

.row.is-hover .row__go {
  opacity: 1;
  transform: none;
}

.row.is-hover .avatar > span {
  transform: translateY(-1px);
}

@media (hover: hover) {
  .row:hover .row__btn {
    background: var(--row-hover);
  }

  .row:hover .time {
    transform: translateX(-6px);
  }

  .row:hover .row__go {
    opacity: 1;
    transform: none;
  }

  .row:hover .avatar > span {
    transform: translateY(-1px);
  }
}

/* a folded row keeps only its paper edge: the words fade while it folds */
.row__btn > .avatar,
.row__btn > .row__main {
  transition: opacity 0.3s ease;
}

.row.is-folded .row__btn > * {
  opacity: 0;
}

/* the open message: placed at its final size, uncovered by its clip from the rectangle of the row */
.sheet-shadow {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  z-index: 40;
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(23, 23, 26, 0.05),
    0 6px 14px -6px rgba(40, 32, 20, 0.16),
    0 18px 36px -18px rgba(40, 32, 20, 0.22);
  visibility: hidden;
  pointer-events: none;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 2.4vmin, 16px) clamp(12px, 3vmin, 18px) clamp(10px, 2.4vmin, 16px);
  background: var(--sheet);
  visibility: hidden;
}

.sheet__top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: clamp(24px, 5vmin, 30px);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 100%;
  padding: 0 9px 0 5px;
  margin-left: -6px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--soft);
  transition: background-color 0.25s ease, transform 0.18s cubic-bezier(.3, 1.4, .5, 1);
}

.back svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.35s cubic-bezier(.3, 1.5, .5, 1);
}

.back:active {
  transform: scale(0.95);
}

.back.is-hover {
  background: rgba(23, 23, 26, 0.05);
}

.back.is-hover svg {
  transform: translateX(-2px);
}

.sheet__when {
  font-size: 11.5px;
  color: var(--muted);
}

.sheet__from {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(8px, 2.2vmin, 16px);
}

.avatar--big {
  width: clamp(34px, 7.6vmin, 44px);
  height: clamp(34px, 7.6vmin, 44px);
  font-size: clamp(12px, 2.6vmin, 14.5px);
  transform-origin: 0 0;
}

.from {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sender--big {
  font-size: clamp(13.5px, 2.9vmin, 15.5px);
  font-weight: 660;
}

.addr {
  font-size: clamp(11px, 2.3vmin, 12px);
  color: var(--muted);
}

.subject--big {
  flex: none;
  margin: clamp(8px, 2.2vmin, 16px) 0 0;
  font-size: clamp(17px, 4.2vmin, 25px);
  line-height: 1.15;
  font-weight: 640;
  letter-spacing: -0.02em;
  font-variation-settings: 'wdth' 104;
  color: var(--ink);
}

.sheet__body {
  flex: 1;
  min-height: 0;
  margin-top: clamp(6px, 1.8vmin, 14px);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 78%, transparent);
  mask-image: linear-gradient(#000 78%, transparent);
}

.sheet__body p {
  margin: 0 0 clamp(4px, 1.2vmin, 9px);
  font-size: clamp(12px, 2.6vmin, 14px);
  line-height: 1.5;
  color: var(--soft);
}

.actions {
  flex: none;
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: clamp(30px, 6.6vmin, 36px);
  padding: 0 clamp(10px, 2.6vmin, 14px);
  border-radius: 99px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(23, 23, 26, 0.1), 0 1px 2px rgba(23, 23, 26, 0.05);
  font-size: clamp(11.5px, 2.5vmin, 13px);
  font-weight: 580;
  transition: transform 0.2s cubic-bezier(.3, 1.4, .5, 1), box-shadow 0.25s ease;
}

.act svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(.3, 1.6, .5, 1);
}

.act__t {
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.45s cubic-bezier(.3, 1.4, .5, 1);
}

.act--main {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 1px 2px rgba(20, 30, 120, 0.25), 0 6px 14px -6px rgba(47, 76, 255, 0.55);
}

.act:active {
  transform: scale(0.95);
}

.act.is-hover .act__t {
  font-variation-settings: 'wdth' 116;
}

.act.is-hover svg {
  transform: translateY(-1px) rotate(-6deg);
}

.act[data-archive].is-hover svg {
  transform: translateY(1px);
}

@media (hover: hover) {
  .back:hover {
    background: rgba(23, 23, 26, 0.05);
  }

  .back:hover svg {
    transform: translateX(-2px);
  }

  .act:hover .act__t {
    font-variation-settings: 'wdth' 116;
  }

  .act:hover svg {
    transform: translateY(-1px) rotate(-6deg);
  }

  .act[data-archive]:hover svg {
    transform: translateY(1px);
  }

  .toast__undo:hover {
    background: rgba(255, 255, 255, 0.16);
  }
}

/* the archived toast */
.toast {
  position: absolute;
  left: 0;
  right: 0;
  width: max-content;
  margin: 0 auto;
  bottom: clamp(14px, 3.4vmin, 22px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 0 6px 0 14px;
  border-radius: 99px;
  background: var(--ink-toast);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.45);
  visibility: hidden;
}

.toast__undo {
  height: 26px;
  padding: 0 11px;
  border-radius: 99px;
  font-weight: 620;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  transition: background-color 0.25s ease, transform 0.18s ease;
}

.toast__undo.is-hover {
  background: rgba(255, 255, 255, 0.16);
}

.toast__undo:active {
  transform: scale(0.95);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 80;
  width: 22px;
  height: 22px;
  fill: #17171a;
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
  opacity: 0;
  pointer-events: none;
  transform-origin: 5px 3px;
}
