@import url('../components/reward-float.css');
/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-lite-suffix {
    display: inline;
  }
  #feed-header .feed-header-label,
  #feed-header:not(.feed-header--filters) {
    display: none;
  }
  /* Hide desktop-only panels and toggles */
  #covers-toggle,
  #right-toggle,
  #feed-toggle {
    display: none !important;
  }
  /* Place detail dialogs above full-screen mobile panels.
     Avoid !important so the forum's inline z-index bump can still win. */
  .pub-overlay {
    z-index: 600;
  }
  /* Keep the public catalog available as the full-screen Add Book panel. */
  #covers-panel {
    display: none !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 500;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)) !important;
    padding-top: calc(1rem + env(safe-area-inset-top)) !important;
    box-sizing: border-box;
    border: none !important;
    /* Use an opaque background for the full-screen mobile panel. */
    background: #111827 !important;
    /* Cancel persisted desktop slide transforms before mobile panel toggling. */
    transform: none !important;
  }
  body.mobile-addbook-open #covers-panel {
    display: flex !important;
    flex-direction: column;
  }
  body.mobile-addbook-open #feed-panel {
    display: none !important;
  }
  #mobile-addbook-close-btn {
    display: none;
    /* Keep the close button above the sticky catalog header while scrolling. */
    position: sticky;
    top: 0;
    z-index: 60;
    align-self: flex-start;
    width: 100%;
    /* Center the return glyph and label together. */
    align-items: center;
    gap: 0.3rem;
    text-align: left;
    background: #111827;
    border: none;
    color: #9ca3af;
    font-size: 0.95rem;
    padding: 0.25rem 0 1rem;
    cursor: pointer;
  }
  body.mobile-addbook-open #mobile-addbook-close-btn {
    display: flex;
  }
  /* Forced on unconditionally in covers.js's _visibleCoverItems() on mobile -
     showing the chip would imply it can be toggled off, which it can't. */
  #covers-filter-livereading {
    display: none !important;
  }
  /* Hide desktop-only shortcuts and settings controls on mobile. */
  #app-banner-f1-btn {
    display: none !important;
  }
  #main-screen {
    display: none !important;
  }

  /* Single-column layout */
  #landing-wrapper {
    padding: 0 !important;
    display: block !important;
  }
  #feed-panel {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0.75rem !important;
    padding-top: calc(0.75rem + env(safe-area-inset-top)) !important;
    box-sizing: border-box;
  }
  body.feed-collapsed #feed-panel {
    min-height: 100%;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0.75rem !important;
    padding-top: calc(0.75rem + env(safe-area-inset-top)) !important;
    padding-bottom: 0.75rem !important;
  }

  /* Right panel: hidden after login, full-screen on mobile auth OR when the
     feed's "My Books" button opens it (mobile-books-open). */
  #landing-right {
    display: none !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 500;
    padding: 2rem 1.5rem !important;
    padding-top: calc(2rem + env(safe-area-inset-top)) !important;
    box-sizing: border-box;
    overflow-y: auto;
    border: none !important;
    /* Full-screen panels must be opaque so the feed cannot show through. */
    background: #111827 !important;
    /* Cancel persisted desktop slide transforms before mobile panel toggling. */
    transform: none !important;
  }
  body.mobile-auth #landing-right,
  body.mobile-books-open #landing-right {
    display: flex !important;
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
  }
  body.mobile-auth #feed-panel {
    display: none !important;
  }

  /* Retain flex-based label centering from shared button styles. */
  #mobile-books-btn,
  #mobile-addbook-btn {
    display: inline-flex !important;
  }
  /* Guests can browse the public catalog, but My Books requires an account. */
  body.guest-browsing #mobile-books-btn {
    display: none !important;
  }
  #mobile-login-btn {
    display: none !important;
  }
  body.guest-browsing #mobile-login-btn {
    display: inline-flex !important;
  }
  /* Mobile entry buttons use the shared four-second pulse.
     They intentionally remain animated under reduce-motion as primary navigation. */
  #mobile-books-btn {
    border-color: #2563eb !important;
    color: #93c5fd !important;
    animation: mobile-books-pulse 4s ease-in-out infinite;
  }
  #mobile-books-btn:hover {
    border-color: #3b82f6 !important;
    color: #bfdbfe !important;
  }
  #mobile-addbook-btn {
    border-color: #d97706 !important;
    color: #fcd34d !important;
    animation: mobile-addbook-pulse 4s ease-in-out infinite;
  }
  #mobile-addbook-btn:hover {
    border-color: #f59e0b !important;
    color: #fde68a !important;
  }
  @keyframes mobile-books-pulse {
    0%,
    100% {
      box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
      box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.35);
    }
  }
  @keyframes mobile-addbook-pulse {
    0%,
    100% {
      box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
    50% {
      box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.35);
    }
  }

  #login-screen {
    width: min(100%, 44rem);
    margin: 0 auto;
  }

  #mobile-guest-btn {
    display: block;
    width: 280px;
    max-width: 100%;
    margin-top: 1rem;
    padding: 0.55rem 1rem;
    background: rgba(245, 166, 35, 0.08);
    border: 1.5px solid #d97706;
    border-radius: 0.5rem;
    color: #fcd34d;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    animation: mobile-guest-pulse 4s ease-in-out infinite;
  }
  #mobile-guest-btn:hover {
    border-color: #f59e0b;
    color: #fde68a;
  }

  /* Scroll-to-top buttons: only center one visible, always centered */
  #covers-scroll-top,
  #right-scroll-top {
    display: none !important;
  }
  #center-scroll-top {
    left: 50% !important;
    transform: translateX(-50%) !important;
  }

  /* App banner */
  #app-banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
  }
  #app-banner-title {
    font-size: clamp(0.7rem, 3.2vw, 1rem);
  }
  #app-version {
    font-size: 0.7rem;
    margin-left: 0.15rem;
  }
  #app-banner-sub {
    display: none !important;
  }
  #app-banner-right {
    display: contents;
  }
  #app-banner-brand {
    font-size: clamp(0.55rem, 2.3vw, 0.75rem);
    white-space: nowrap;
  }
  #app-banner-btns {
    grid-column: 1 / -1;
    flex-wrap: nowrap;
    gap: 0.2rem;
    justify-content: flex-start;
  }
  #app-banner-tools {
    display: contents;
  }
  #app-banner-community {
    position: fixed;
    z-index: 20;
    right: calc(10px + env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    display: flex;
    width: max-content;
    max-width: calc(100vw - 76px - env(safe-area-inset-left) - env(safe-area-inset-right));
    gap: 3px;
    padding: 3px;
    border: 1px solid #374151;
    border-radius: 7px;
    background: #111827f2;
    box-shadow: 0 6px 20px #0008;
    backdrop-filter: blur(7px);
  }
  #app-banner-tools :is(button, a) {
    position: relative;
    flex: 0 1 36px;
    min-width: 30px;
    height: 36px;
    padding: 0;
    font-size: 0;
    border-radius: 6px;
  }
  #app-banner-tools > button {
    flex-basis: 30px;
    height: 30px;
  }
  #app-banner-btns
    :is(#bonus-gc-btn, #notif-btn, #display-settings-btn, #collectibles-btn, #profile-btn) {
    flex: 0 0 30px;
    width: 30px;
    min-width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
  }
  #app-banner-btns #profile-btn {
    background: #111827;
    border: 1px solid #374151;
  }
  #app-banner-btns #bonus-gc-btn {
    margin-left: auto;
  }
  #app-banner-btns #bonus-gc-btn svg {
    width: 18px;
    height: 18px;
  }
  #app-banner-btns #profile-avatar {
    width: 22px;
    height: 22px;
    border-width: 1px;
  }
  body.mobile-auth #app-banner-btns #profile-btn,
  body.guest-browsing #app-banner-btns #profile-btn {
    display: none;
  }
  #app-banner-btns :is(#mobile-addbook-btn, #mobile-books-btn) {
    padding-inline: 0.2rem;
  }
  #app-banner-community > :is(button, a) {
    width: 36px;
    flex-shrink: 0;
  }
  #app-banner-tools :is(button, a):focus-visible {
    outline: 2px solid #c8894a;
    outline-offset: 2px;
  }
  #app-banner-tools .bell-icon,
  #app-banner-tools .cog-icon {
    width: 18px;
    height: 18px;
  }
  #app-banner-tools
    :is(
      #app-banner-guide-btn,
      #app-banner-catalogue-btn,
      #stats-btn,
      #forum-btn,
      #feedback-btn,
      #inbox-btn
    )::before {
    content: '';
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: var(--banner-icon) center / contain no-repeat;
    mask: var(--banner-icon) center / contain no-repeat;
  }
  #app-banner-guide-btn {
    --banner-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5c-3-2-7-2-9-1v15c2-1 6-1 9 1 3-2 7-2 9-1V4c-2-1-6-1-9 1Zm0 0v15'/%3E%3C/svg%3E");
  }
  #stats-btn {
    --banner-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20V10h4v10m2 0V4h4v16m2 0v-7h4v7M3 20h18'/%3E%3C/svg%3E");
  }
  #app-banner-catalogue-btn {
    --banner-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4h5v16H3zM10 4h5v16h-5zM17 5l4-1 2 15-4 1zM3 8h5m2 0h5'/%3E%3C/svg%3E");
  }
  #forum-btn {
    --banner-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16v11H10l-5 4v-4H4V5Zm4 5h8m-8 3h5'/%3E%3C/svg%3E");
  }
  #feedback-btn {
    --banner-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 11 15-6v14L4 13v-2Zm4 4 1 6h4l-2-5M4 11H2v2h2'/%3E%3C/svg%3E");
  }
  #inbox-btn {
    --banner-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m3 6 9 7 9-7'/%3E%3C/svg%3E");
  }
  #inbox-btn[data-unread]:not([data-unread=''])::after {
    content: attr(data-unread);
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 14px;
    padding: 1px 3px;
    border-radius: 6px;
    background: #166534;
    color: #dcfce7;
    font-size: 0.6rem;
    line-height: 1.2;
  }
  #books-tip-bar {
    padding: 0.45rem 0.75rem;
  }
  #feed-panel,
  body.feed-collapsed #feed-panel {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)) !important;
  }
  body:not(.mobile-books-open):not(.mobile-addbook-open):not(.mobile-auth) #center-scroll-top {
    left: calc(12px + env(safe-area-inset-left)) !important;
    right: auto;
    transform: none !important;
  }

  /* Feed cards full width */
  .feed-card {
    border-radius: 6px;
  }

  /* Public modal full screen - fixed inset so header always stays at top */
  .pub-overlay {
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }
  .pub-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    height: 100vh !important;
    /* Use dvh to keep the dialog's header reachable when browser chrome changes. */
    max-height: 100dvh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
  }
  .pub-modal.pub-modal--run {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
  }

  /* Disable hover image preview on mobile */
  #feed-img-preview {
    display: none !important;
  }

  /* Inline modals full screen */
  .modal-inner {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    overflow-y: auto;
  }

  /* Center settings on mobile instead of using the desktop side-panel offset. */
  #cover-tooltip-settings {
    left: 50% !important;
    transform: translateX(-50%);
    width: min(94vw, 300px) !important;
  }

  /* Stats modal */
  #stats-modal-overlay {
    padding: 0 !important;
    align-items: stretch !important;
  }
  #stats-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }
}

body {
  --personal-reward-default-left: calc(75vw + var(--sidebar-w) / 4);
}
body.sidebar-collapsed {
  --personal-reward-default-left: 75vw;
}
#reward-float-layer {
  position: fixed;
  left: var(--personal-reward-left, var(--personal-reward-default-left, 50%));
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
  z-index: 3200;
}

.reward-float--xp {
  border-color: rgba(103, 232, 249, 0.55);
  background: rgba(8, 47, 73, 0.94);
  color: #67e8f9;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.38),
    0 0 18px rgba(34, 211, 238, 0.18);
}

.reward-float--coins {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(69, 38, 3, 0.94);
  color: #fde68a;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.38),
    0 0 18px rgba(245, 158, 11, 0.22);
}

.reward-float--level {
  gap: 0.55rem;
  padding-inline: 0.9rem;
  border-color: rgba(245, 158, 11, 0.62);
  background: rgba(69, 26, 3, 0.94);
  color: #fde68a;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.42),
    0 0 22px rgba(245, 158, 11, 0.24);
}

.reward-float-kicker {
  color: #fbbf24;
  letter-spacing: 0.08em;
}

.reward-float-title {
  color: #fff7cc;
}

.reward-float .coin-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
}

.reward-float--coins .coin-icon {
  width: 0.95rem;
  height: 0.95rem;
}

/* Admin app-reward floaters use distinct colors from personal rewards. */
#app-reward-float-layer {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
  z-index: 3200;
}

.app-reward-float {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  max-width: min(320px, 78vw);
  padding: 0.45rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(167, 139, 250, 0.55);
  background: rgba(46, 16, 74, 0.94);
  color: #d8b4fe;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.38),
    0 0 18px rgba(167, 139, 250, 0.2);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transform: translateY(0);
  opacity: 0;
  animation: reward-float-rise 4.6s ease-out forwards;
}

.app-reward-float--coins {
  border-color: rgba(244, 114, 182, 0.55);
  background: rgba(74, 15, 45, 0.94);
  color: #fbcfe8;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.38),
    0 0 18px rgba(244, 114, 182, 0.22);
}

.app-reward-float-user {
  color: #f0abfc;
  font-weight: 800;
}

.app-reward-float .coin-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
}

/* Legacy diamond wallet is displayed as rubies after the currency rebrand. */
.reward-float--diamonds,
.app-reward-float.app-reward-float--diamonds {
  color: #fda4af;
  border-color: #be123c;
  background: #351922;
}
