/* Epika Ad Zones v0.1.2
   Provider-neutral sponsored-content layout for Epika Mail.
   Desktop: right rail. Mobile: inline cards in the message list. */

:root {
    /*
     * EPIKMAIL_PHASE_93A_RESPONSIVE_COLUMNS
     *
     * Sponsor rail gives priority to the reading pane:
     *   1368px -> ~200px
     *   1920px -> ~260px
     */
    --epika-ad-rail-width: clamp(200px, 13.55vw, 260px);
    --epika-ad-border: #e1e6ed;
    --epika-ad-text: #20242a;
    --epika-ad-muted: #687386;
    --epika-ad-blue: #0b63df;
    --epika-ad-shadow: 0 7px 24px rgba(31, 35, 40, .07);
}

#epika-ad-rail {
    box-sizing: border-box;
    display: none;
    /* Keep the sponsor rail as the last flex item in #rl-right.
       SnappyMail/Epika views can receive their own flex order during rendering;
       an explicit high order prevents the rail from landing between the folder
       panel and the message list. */
    order: 9999 !important;
    flex: 0 0 var(--epika-ad-rail-width);
    width: var(--epika-ad-rail-width);
    min-width: var(--epika-ad-rail-width);
    max-width: var(--epika-ad-rail-width);
    height: 100%;
    min-height: 0;
    overflow: hidden;
    color: var(--epika-ad-text);
}

#epika-ad-rail.epika-ad-rail-visible {
    display: flex;
    flex-direction: column;
}

.epika-ad-rail-head {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 50px;
    min-height: 50px;
    padding: 4px 4px 8px 8px;
    color: #5f6368;
    font-size: 13px;
    font-weight: 700;
}

.epika-ad-rail-head small {
    color: #9098a5;
    font-size: 11px;
    font-weight: 500;
}

.epika-ad-rail-scroll {
    min-height: 0;
    overflow: auto;
    padding: 0 1px 12px;
    scrollbar-width: thin;
}

.epika-ad-card {
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    margin: 0 0 12px;
    color: var(--epika-ad-text);
    background: #fff;
    border: 1px solid var(--epika-ad-border);
    border-radius: 18px;
    box-shadow: var(--epika-ad-shadow);
}

.epika-ad-card-link {
    display: block;
    color: inherit !important;
    text-decoration: none !important;
}

.epika-ad-visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 10;
    min-height: 150px;
    overflow: hidden;
    background:
        radial-gradient(circle at 75% 20%, rgba(255,255,255,.85), rgba(255,255,255,0) 32%),
        linear-gradient(135deg, #eef4ff 0%, #dce9ff 50%, #f6f8fb 100%);
}

.epika-ad-card[data-theme="epika"] .epika-ad-visual {
    color: #111827;
    background:
        linear-gradient(145deg, rgba(255,255,255,.94), rgba(255,255,255,.74)),
        linear-gradient(135deg, #0b63df, #ef4444);
}

.epika-ad-card[data-theme="neutral"] .epika-ad-visual {
    color: #364152;
    background:
        radial-gradient(circle at 25% 25%, rgba(11,99,223,.14), transparent 34%),
        radial-gradient(circle at 80% 75%, rgba(239,68,68,.11), transparent 36%),
        #f5f7fb;
}

.epika-ad-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.epika-ad-visual-text {
    padding: 18px;
    font-size: clamp(22px, 2vw, 34px);
    font-weight: 800;
    letter-spacing: .08em;
    text-align: center;
}

.epika-ad-badge {
    position: absolute;
    z-index: 2;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 7px;
    color: #3d4653;
    background: rgba(255, 255, 255, .88);
    border: 1px solid rgba(31,35,40,.08);
    border-radius: 999px;
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.epika-ad-menu-button {
    position: absolute;
    z-index: 4;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    padding: 0;
    color: #3d4653;
    background: rgba(255,255,255,.9);
    border: 1px solid rgba(31,35,40,.08);
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 26px;
    text-align: center;
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.epika-ad-menu-button:hover { background: #fff; }

.epika-ad-menu {
    position: absolute;
    z-index: 8;
    top: 43px;
    right: 8px;
    display: none;
    width: 180px;
    padding: 6px;
    background: #fff;
    border: 1px solid #dde3eb;
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(31,35,40,.16);
}

.epika-ad-card.epika-ad-menu-open .epika-ad-menu { display: block; }

.epika-ad-menu button {
    display: block;
    width: 100%;
    padding: 9px 10px;
    color: #343b46;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
}

.epika-ad-menu button:hover { background: #f3f5f8; }

.epika-ad-body {
    padding: 13px 14px 15px;
}

.epika-ad-title {
    display: -webkit-box;
    overflow: hidden;
    color: #1f2329;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.28;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.epika-ad-description {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 6px;
    color: var(--epika-ad-muted);
    font-size: 12px;
    line-height: 1.42;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.epika-ad-domain {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    margin-top: 11px;
    color: #4a5463;
    font-size: 11px;
    font-weight: 600;
}

.epika-ad-domain::before {
    content: "";
    flex: 0 0 9px;
    width: 9px;
    height: 9px;
    background: var(--epika-ad-blue);
    border-radius: 50%;
}

.epika-ad-domain span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.epika-ad-rail-foot {
    padding: 2px 8px 9px;
    color: #969eaa;
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
}

.epika-ad-mobile-slot {
    box-sizing: border-box;
    display: none;
    padding: 8px 10px 10px;
}

.epika-ad-mobile-slot .epika-ad-card {
    margin: 0;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(31,35,40,.06);
}

.epika-ad-mobile-slot .epika-ad-card-link {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
}

.epika-ad-mobile-slot .epika-ad-visual {
    min-height: 104px;
    aspect-ratio: auto;
    border-radius: 13px 0 0 13px;
}

.epika-ad-mobile-slot .epika-ad-visual-text {
    padding: 10px;
    font-size: 14px;
    letter-spacing: .05em;
}

.epika-ad-mobile-slot .epika-ad-body {
    min-width: 0;
    padding: 13px 36px 11px 12px;
}

.epika-ad-mobile-slot .epika-ad-title {
    font-size: 14px;
    -webkit-line-clamp: 2;
}

.epika-ad-mobile-slot .epika-ad-description {
    margin-top: 4px;
    font-size: 11px;
    -webkit-line-clamp: 2;
}

.epika-ad-mobile-slot .epika-ad-domain { margin-top: 7px; }
.epika-ad-mobile-slot .epika-ad-badge { top: 7px; left: 7px; min-height: 18px; font-size: 8px; }
.epika-ad-mobile-slot .epika-ad-menu-button { top: 7px; right: 7px; width: 27px; height: 27px; font-size: 18px; line-height: 23px; }
.epika-ad-mobile-slot .epika-ad-menu { top: 38px; right: 7px; }

.epika-ad-toast {
    position: fixed;
    z-index: 10050;
    right: 18px;
    bottom: 18px;
    max-width: min(360px, calc(100vw - 36px));
    padding: 11px 14px;
    color: #fff;
    background: rgba(31,35,40,.94);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,.2);
    font-size: 12px;
    line-height: 1.4;
}

@media screen and (min-width: 1280px) {
    body:not(.rl-mobile) #epika-ad-rail.epika-ad-rail-visible { display: flex; }
}

/* Side-by-side message view becomes too narrow on smaller desktop widths. */
/*
 * EPIKMAIL_PHASE_93A_RESPONSIVE_COLUMNS
 *
 * Keep the compact sponsor rail available in desktop side-view
 * down to 1280px. The existing <=1279px rule below remains the
 * hard cutoff.
 */
@media screen and (max-width: 1549px) and (min-width: 1280px) {
    body.sm-msgView-side #epika-ad-rail.epika-ad-rail-visible {
        display: flex !important;
    }
}

@media screen and (max-width: 1279px) {
    #epika-ad-rail { display: none !important; }
}

@media screen and (max-width: 799px) {
    .epika-ad-mobile-slot { display: block; }
    #epika-ad-rail { display: none !important; }
}


/* v0.1.2: desktop rail must stay physically on the far right. */
@media screen and (min-width: 1280px) {
    body:not(.rl-mobile) #rl-right > #V-MailMessageList,
    body:not(.rl-mobile) #rl-right > #V-MailMessageView {
        min-width: 0 !important;
    }

    body:not(.rl-mobile) #rl-right > #epika-ad-rail {
        order: 9999 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}


/* epikmail + Yandex Advertising Network desktop right rail */
.epikmail-yandex-scroll {
    padding-left: 4px;
    padding-right: 4px;
}

.epikmail-yandex-holder {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 250px;
    max-height: 600px;
    overflow: hidden;
    border-radius: 16px;
}

.epikmail-yandex-slot {
    box-sizing: border-box;
    width: 100%;
    min-width: 280px;
    max-width: 320px;
    min-height: 250px;
    max-height: 600px;
    margin: 0 auto;
    overflow: hidden;
}

.epikmail-yandex-loading {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    place-items: center;
    min-height: 250px;
    color: #98a1af;
    background: #f7f9fc;
    border: 1px solid #e5e9ef;
    border-radius: 16px;
    font-size: 12px;
}

.epikmail-yandex-slot:not(:empty) + .epikmail-yandex-loading { display: none; }

/* =========================================================
   EPIKMAIL PHASE 88D - BOTTOM READING PANE
   ========================================================= */

/*
 * SnappyMail changes #rl-right to flex-direction: column
 * when sm-msgView-bottom is active.
 *
 * epika's vertical sponsor rail is also a direct flex item.
 * Its horizontal flex-basis would therefore consume vertical
 * space in bottom mode and collapse the message reader.
 *
 * Bottom reading mode uses the full width for list + reader,
 * so the vertical sponsor rail is intentionally hidden here.
 */
@media screen and (min-width: 800px) {

  html.sm-msgView-bottom #epika-ad-rail {
    display: none !important;
  }

  /*
   * Mail list keeps its native SnappyMail 35vh / resize
   * behaviour. Reader receives every remaining pixel.
   */
  html.sm-msgView-bottom #rl-right {
    min-height: 0 !important;
  }

  html.sm-msgView-bottom
    #rl-right > #V-MailMessageList {
    flex: 0 0 auto !important;

    width: 100% !important;
    min-width: 0 !important;

    /*
     * epika-theme normally forces this view to height:100%.
     * That is correct for no-split / side layouts, but in
     * bottom mode it consumes the entire column and leaves
     * the reader with 0px.
     *
     * Let the container shrink-wrap its toolbar + message list.
     */
    height: auto !important;
    min-height: 0 !important;
  }

  html.sm-msgView-bottom
    #rl-right > #V-MailMessageView {
    flex: 1 1 0 !important;

    width: 100% !important;

    min-width: 0 !important;
    min-height: 0 !important;

    overflow: auto !important;
  }

  /*
   * The native message card uses:
   *
   *   height: calc(100% - 50px)
   *
   * Once its parent has a real height again this lets it fill
   * the space below its toolbar normally.
   */
  html.sm-msgView-bottom
    #V-MailMessageView > .messageView {
    min-height: 0 !important;
  }
}

