/* Salina Magazine - Modern Secure Viewer Stylesheet */

:root {
  --bg-color: #0d0f12;
  --bg-gradient: radial-gradient(circle at center, #1b2028 0%, #0a0c0e 100%);
  --panel-bg: rgba(22, 26, 33, 0.85);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --danger: #ef4444;
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-book: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-main);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* ==========================================================================
   PASSWORD MODAL (GLASSMORPHISM)
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 9, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.35s ease, visibility 0.35s;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.password-card {
  width: 90%;
  max-width: 440px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: modalEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from {
    transform: scale(0.92) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.lock-icon-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.lock-icon-badge svg {
  width: 30px;
  height: 30px;
}

.password-card h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.password-card p.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 26px;
}

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-group input {
  width: 100%;
  padding: 14px 48px 14px 16px;
  background: rgba(10, 12, 16, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: #ffffff;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-password-btn:hover {
  color: var(--text-primary);
}

.toggle-password-btn svg {
  width: 20px;
  height: 20px;
}

.remember-group {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 22px;
  cursor: pointer;
}

.remember-group input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.btn-unlock {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: background 0.2s, transform 0.1s;
}

.btn-unlock:hover {
  background: var(--accent-hover);
}

.btn-unlock:active {
  transform: scale(0.98);
}

.btn-unlock:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-message {
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(3px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
  40%, 60% { transform: translate3d(5px, 0, 0); }
}

/* ==========================================================================
   APP HEADER & CONTROLS
   ========================================================================== */

header.magazine-header {
  height: 56px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  flex-shrink: 0;
}

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

.header-brand .title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-brand .badge {
  font-size: 11px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ==========================================================================
   VIEWPORT & FLIPBOOK STAGE
   ========================================================================== */

main.viewer-container {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#flipbook-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 1350px;
  max-height: calc(100vh - 136px);
  transform-origin: center center;
  transition: transform 0.25s ease-out;
}

#flipbook-element {
  margin: auto;
  box-shadow: var(--shadow-book);
  border-radius: 4px;
}

/* Book pages inside StPageFlip */
.magazine-page {
  background-color: #ffffff;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.08);
}

.magazine-page img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* Page loading placeholder */
.page-loading-skeleton {
  position: absolute;
  inset: 0;
  background: #1e232d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.skeleton-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Page Spine Gradient for realistic book fold */
.magazine-page.--left::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 35px;
  height: 100%;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.05) 50%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}

.magazine-page.--right::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 35px;
  height: 100%;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.05) 50%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
}

/* Side navigation arrow overlays */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 18, 24, 0.7);
  border: 1px solid var(--panel-border);
  color: #ffffff;
  width: 50px;
  height: 70px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s;
  opacity: 0.7;
}

.nav-arrow:hover {
  background: rgba(59, 130, 246, 0.85);
  border-color: var(--accent);
  opacity: 1;
  transform: translateY(-50%) scale(1.05);
}

.nav-arrow.prev {
  left: 20px;
}

.nav-arrow.next {
  right: 20px;
}

.nav-arrow svg {
  width: 28px;
  height: 28px;
}

/* ==========================================================================
   BOTTOM TOOLBAR
   ========================================================================== */

footer.magazine-toolbar {
  height: 60px;
  min-height: 60px;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  gap: 16px;
  z-index: 100;
  flex-shrink: 0;
  position: relative;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-indicator-badge {
  font-size: 14px;
  font-weight: 600;
  min-width: 140px;
  text-align: center;
  letter-spacing: 0.3px;
  color: var(--text-primary);
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 260px;
}

.page-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  cursor: pointer;
  transition: transform 0.1s;
}

.page-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================================================== */

@media (max-width: 768px) {
  /* Floating left/right arrows kept visible and nicely sized for thumbs */
  .nav-arrow {
    display: flex;
    width: 38px;
    height: 54px;
    border-radius: 8px;
    background: rgba(15, 18, 24, 0.85);
    opacity: 0.85;
    z-index: 60;
  }

  .nav-arrow.prev {
    left: 6px;
  }

  .nav-arrow.next {
    right: 6px;
  }

  .nav-arrow svg {
    width: 20px;
    height: 20px;
  }

  /* Bottom toolbar guaranteed visible on mobile screens */
  footer.magazine-toolbar {
    height: auto;
    min-height: 52px;
    padding: 6px 12px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .page-controls {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }

  /* Hide extra outer jump buttons on mobile to avoid overcrowding */
  #first-btn,
  #last-btn {
    display: none;
  }

  .slider-container {
    display: none;
  }

  .page-indicator-badge {
    min-width: 90px;
    font-size: 13px;
  }
}
