/* ==========================================================================
   Vanish — styles.css
   Polished inbox + opened-email interface
   ========================================================================== */

html {
  scroll-behavior: smooth;
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ==========================================================================
   SCROLLBARS
   ========================================================================== */

* {
  scrollbar-width: thin;
  scrollbar-color: #2A3341 transparent;
}

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: #2A3341;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #3E4B5C;
}

/* ==========================================================================
   INBOX LIST
   ========================================================================== */

#inbox-list {
  position: relative;
}

/* Individual email item */

.msg-item {
  width: 100%;
  text-align: left;
  padding: 15px 16px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.msg-item:hover {
  background: rgba(255, 255, 255, 0.035);
}

.msg-item:active {
  transform: scale(0.995);
}

.msg-item.active {
  background:
    linear-gradient(
      90deg,
      rgba(55, 226, 154, 0.075),
      rgba(55, 226, 154, 0.025)
    );
  border-left-color: #37E29A;
}

.msg-item.active:hover {
  background:
    linear-gradient(
      90deg,
      rgba(55, 226, 154, 0.095),
      rgba(55, 226, 154, 0.035)
    );
}

/* Sender */

.msg-item .text-sm.font-medium {
  letter-spacing: -0.01em;
}

/* Subject */

.msg-item p {
  max-width: 100%;
}

/* Preview/snippet */

.msg-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.45;
}

/* ==========================================================================
   INBOX HEADER
   ========================================================================== */

#inbox-count {
  min-width: 24px;
  text-align: center;
}

/* ==========================================================================
   EMPTY INBOX
   ========================================================================== */

#inbox-empty {
  min-height: 330px;
}

/* ==========================================================================
   MESSAGE VIEWER
   ========================================================================== */

#viewer-content {
  position: relative;
  min-width: 0;
}

/*
 * The opened-message header is deliberately separated
 * from the actual email content.
 */

#viewer-content > div:first-child {
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.018),
      rgba(255, 255, 255, 0)
    );
}

/* Subject */

#viewer-subject {
  max-width: calc(100% - 20px);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

/* Sender/date metadata */

#viewer-from,
#viewer-date {
  overflow-wrap: anywhere;
}

/* ==========================================================================
   EMAIL CONTENT AREA
   ========================================================================== */

#viewer-content .overflow-y-auto {
  background:
    radial-gradient(
      circle at top,
      rgba(55, 226, 154, 0.025),
      transparent 45%
    );
}

/*
 * The iframe is intentionally given a clean email-reading
 * surface. The actual email HTML remains isolated inside
 * the sandbox.
 */

#viewer-frame {
  display: block;
  width: 100%;
  min-height: 430px;
  border: 1px solid #2A3341;
  border-radius: 14px;
  background: #ffffff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 10px 30px rgba(0, 0, 0, 0.18);
}

/* ==========================================================================
   ATTACHMENTS
   ========================================================================== */

#viewer-attachments {
  max-width: 100%;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;

  max-width: 100%;

  padding: 7px 10px;

  border: 1px solid #2A3341;
  border-radius: 9px;

  background: rgba(21, 27, 37, 0.8);

  color: #C2CCD8;

  font-size: 11px;
  line-height: 1.2;

  transition:
    background 150ms ease,
    border-color 150ms ease;
}

.attachment-chip:hover {
  background: #1D2430;
  border-color: #3E4B5C;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip span:nth-of-type(1) {
  max-width: 190px;
}

/* ==========================================================================
   OPENED MESSAGE EMPTY STATE
   ========================================================================== */

#viewer-empty {
  min-height: 500px;
}

/* ==========================================================================
   MOBILE MESSAGE VIEWER
   ========================================================================== */

@media (max-width: 767px) {

  /*
   * On mobile, opening an email turns the viewer
   * into a full-screen reading panel.
   */

  #viewer-content.mobile-open {
    position: fixed;
    inset: 0;
    z-index: 40;

    width: 100vw;
    height: 100dvh;

    border-radius: 0;
    border: 0;

    background: #080B10;
  }

  #viewer-content.mobile-open > div:first-child {
    flex-shrink: 0;
    padding-top: calc(
      16px + env(safe-area-inset-top)
    );
  }

  #viewer-content.mobile-open
    .overflow-y-auto {
    padding-bottom: calc(
      24px + env(safe-area-inset-bottom)
    );
  }

  #viewer-content.mobile-open
    #viewer-frame {
    min-height: calc(100dvh - 150px);
    border-radius: 12px;
  }

  #viewer-content.mobile-open
    #btn-close-viewer {
    display: flex;
  }

  body:has(#viewer-content.mobile-open) {
    overflow: hidden;
  }
}

/* ==========================================================================
   DESKTOP EMAIL VIEWER
   ========================================================================== */

@media (min-width: 768px) {

  #viewer-content {
    min-height: 520px;
  }

  #viewer-content .overflow-y-auto {
    min-height: 0;
  }

  #viewer-frame {
    min-height: 430px;
  }
}

/* ==========================================================================
   ADDRESS PANEL
   ========================================================================== */

#address-box {
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

#address-box:hover {
  border-color: #3E4B5C;
}

#address-box.flash-copied {
  border-color: rgba(55, 226, 154, 0.65);
  box-shadow:
    0 0 0 3px rgba(55, 226, 154, 0.08);
}

/* ==========================================================================
   COPY TOOLTIP
   ========================================================================== */

#copy-tooltip.show {
  opacity: 1;
  transform:
    translateX(-50%)
    scale(1);
}

/* ==========================================================================
   POLLING BAR
   ========================================================================== */

#poll-bar {
  transition: width 100ms linear;
}

/* ==========================================================================
   BUTTON MICRO-INTERACTIONS
   ========================================================================== */

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(55, 226, 154, 0.65);
  outline-offset: 2px;
}

/* ==========================================================================
   TOAST
   ========================================================================== */

#toast {
  max-width: min(
    calc(100vw - 32px),
    420px
  );

  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  animation:
    toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform:
      translate(-50%, 8px)
      scale(0.97);
  }

  to {
    opacity: 1;
    transform:
      translate(-50%, 0)
      scale(1);
  }
}

/* ==========================================================================
   CARDS
   ========================================================================== */

.shadow-card {
  box-shadow:
    0 1px 0 0 rgba(255, 255, 255, 0.04) inset,
    0 12px 30px -18px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   AD SLOTS
   ========================================================================== */

.border-dashed {
  transition:
    border-color 150ms ease,
    background 150ms ease;
}

.border-dashed:hover {
  border-color: #3E4B5C;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

footer a {
  transition:
    color 150ms ease,
    opacity 150ms ease;
}

footer a:hover {
  color: #C2CCD8;
}

/* ==========================================================================
   SMALL SCREENS
   ========================================================================== */

@media (max-width: 640px) {

  #viewer-frame {
    min-height: 380px;
  }

  .msg-item {
    padding: 14px 13px;
  }

  #viewer-content .overflow-y-auto {
    padding: 14px;
  }

  .attachment-chip span:nth-of-type(1) {
    max-width: 140px;
  }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
