/* ==========================================================================
   1. TOKENS, CONFIGURATIONS & FONTS
   ========================================================================== */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: rgba(255, 255, 255, 0.02);
  --bg-overlay: rgba(0, 0, 0, 0.8);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.8);
  --accent-color: #006651;
  --error-color: #dc3545;
  --border-radius: 12px;
  --border-radius-large: 24px;
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-error: 0 8px 32px rgba(220, 53, 69, 0.3);
  --backdrop-blur: blur(20px);
}

@font-face {
  font-family: 'Outfit';
  src: url('/fonts/Outfit/Outfit-VariableFont_wght.woff2') format('woff2-variations'),
       url('/fonts/Outfit/Outfit-VariableFont_wght.woff') format('woff-variations'),
       url('/fonts/Outfit/Outfit-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900; 
  font-display: swap;
  font-style: normal;
}

@supports (height: 100dvh) {
  :root {
    --drop-zone-vh: 100dvh;
  }
}

* {
  box-sizing: border-box;
}

/* ==========================================================================
   2. APPMOBILE DOCUMENT BASE & CORE ROOT LAYOUT
   ========================================================================== */
body {
  position: relative;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100vw;
  padding: 2rem;
  box-sizing: border-box;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2.5rem 0.5rem 2.5rem;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  z-index: 10;
}

header[hidden] {
  display: none !important;
}

/* ==========================================================================
   3. SYSTEM PARALLAX INFRASTRUCTURE (ANIMATED BACKGROUND)
   ========================================================================== */

/* Only inject, process, and animate the background asset on desktops/large tablets */
/* @media (min-width: 800px) {
  body::before {
    content: "";
    position: fixed;
    left: 50%;
    top: 0;
    width: 100vw;
    height: 30000px; 
    transform: translateX(-50%) translateY(0) translateZ(0);
    will-change: transform; 
    z-index: -1;
    background-image: url('../assets/grid-long.jpg');
    background-repeat: repeat;
    background-position: center top;
    background-size: auto contain; 
    animation: scrollBackground 120s linear infinite;
    opacity: 0.05; 
    pointer-events: none; 
  }
}

@keyframes scrollBackground {
  from {
    transform: translateX(-50%) translateY(0) translateZ(0);
  }
  to {
    transform: translateX(-50%) translateY(-28244px) translateZ(0); 
  }
} */

/* ==========================================================================
   4. DASHBOARD TEXT STYLING BLOCK
   ========================================================================== */
.top-heading {
  text-align: center;
  max-width: 95vw;
  margin-bottom: 3rem;
  z-index: 101; 
  overflow-wrap: break-word;
  word-wrap: break-word;
}

h1 {
  font-family: 'Outfit', sans-serif;
  margin: 0;
  font-size: clamp(1.8rem, 15vw, 4rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

p {
  font-family: 'Outfit', sans-serif;
  max-width: 500px;
  font-size: 1rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   5. INTERACTIVE DROP TARGET ARCHIVE MANAGEMENT
   ========================================================================== */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 75vw;
  border: 2.5px dashed var(--accent-color);
  background: rgba(30, 32, 36, 0.85);
  border-radius: 28px;
  padding: 3rem 3rem;
  font-size: 1.1rem;
  text-align: center;
  transition: box-shadow 0.2s, border-color 0.2s;
  box-sizing: border-box;
}

.drop-zone.dragover {
  border-color: var(--accent-hover);
  background: rgba(0, 184, 148, 0.08);
  box-shadow: 0 0px 40px rgba(0,184,148,0.18), 0 2px 12px rgba(0,184,148,0.12);
}

.drop-zone .drop-icon {
  font-size: 3.2rem;
  color: var(--accent-color);
  margin-bottom: 1.1rem;
  display: block;
  opacity: 0.92;
}

.drop-zone p {
  color: var(--text-secondary);
  font-size: 1.15rem;
  font-weight: 200;
  letter-spacing: 0.01em;
}

.separator {
  font-family: 'Outfit', sans-serif;
  max-width: 500px;
  padding: 1rem 0 2rem 0;
  font-size: 1.25rem;
  color: var(--text-secondary);
}


.file-label {
  display: inline-block;
  background: var(--accent-color);
  color: #fff;
  font-weight: 600;
  font-size: 1.08rem;
  padding: 0.7em 1.6em;
  border-radius: 18px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,184,148,0.08);
  border: none;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s;
}

.file-label:hover, .file-label:focus {
  background: var(--text-secondary);
  color: var(--bg-primary);
  box-shadow: 0 0px 16px rgb(0, 0, 0);
  transform: scale(1.045);
}

/* ==========================================================================
   6. FILE PARSING PROGRESS DISPLAYS
   ========================================================================== */
.progress-container {
  width: 100%;
  max-width: 480px;
  margin: 1.5rem auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-radius: 16px;
  backdrop-filter: var(--backdrop-blur);
}

.progress-bar {
  height: 6px;
  background: linear-gradient(90deg, var(--accent-color) 0%, var(--accent-hover) 100%);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease-in-out;
  flex: 1;
  box-shadow: 0 0 8px rgba(0, 184, 148, 0.3);
}

.nav-controls button svg {
  display: block;
  width: 14px;  
  height: 14px;
  margin: auto;
  fill: rgba(255, 255, 255, 0.85); 
  transition: fill 0.2s, transform 0.2s;
}

.nav-controls button:hover:not(:disabled) svg {
  fill: var(--accent-color) !important;
}

.nav-controls button:disabled svg {
  fill: rgba(255, 255, 255, 0.25) !important;
}

/* ==========================================================================
   7. CORE WORKING CANVAS WORKSPACE (READER LAYER)
   ========================================================================== */
.reader-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  flex: 1 1 0;
  min-height: 0;
  background: var(--bg-primary) !important; 
  z-index: 2;                               
  position: relative;
}

.reader-container, .comic-page {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.comic-page {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.comic-page img {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain; 
  display: block;
  margin: auto !important; 
  cursor: grab;
  user-select: none;
  transform-origin: center center;
  will-change: transform;
}

.comic-page img:active {
  cursor: grabbing;
}

/* ==========================================================================
   8. PERMANENT SYSTEM VIEW RENDERING BUFFERS
   ========================================================================== */
.canvas-layer {
  position: absolute;
  inset: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: auto;
  display: block;
  will-change: opacity;
  transition: opacity 0.1s ease-in-out; 
}

.canvas-layer.active {
  opacity: 1;
  z-index: 4;
  pointer-events: auto;
}

.canvas-layer.hidden {
  opacity: 0;
  z-index: 3;
  pointer-events: none;
}

/* ==========================================================================
   9. LEGACY CODE COMPONENT WRAPPERS (SPREAD & STAGE MODE SCRAPS)
   ========================================================================== */
.page-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.page-stage img {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.page-stage[style*="display: flex"] img {
  max-width: calc(50vw - 4px) !important;
  max-height: 100vh !important;
}

/* ==========================================================================
   10. INTERFACE LAYER OVERLAY MANAGEMENT
   ========================================================================== */
/* --- Top Center Environment Management --- */
.top-control-capsule {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: inline-flex;
  align-items: center;
  
  width: max-content !important;
  max-width: 95vw !important;
  white-space: nowrap !important;
  
  background: rgba(20, 20, 20, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--border-radius-large);
  padding: 0.4rem 0.8rem;
  z-index: 1003;
  backdrop-filter: blur(5px);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease-in-out, opacity 0.2s ease-in-out;
}
.top-control-capsule button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--border-radius);
  transition: background 0.2s, color 0.2s;
}

.top-control-capsule button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-color);
}

.capsule-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 0.4rem;
}

.top-control-capsule.nav-hidden {
  transform: translateX(-50%) translateY(-100px);
  opacity: 0;
  pointer-events: none;
}

.top-hide-ui-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-color);
}

.top-hide-ui-btn.nav-hidden {
  transform: translateX(-50%) translateY(-100px);
  opacity: 0;
  pointer-events: none;
}

.nav-controls {
  position: absolute;
  left: 50%;
  bottom: calc(5vh + env(safe-area-inset-bottom)) !important;
  
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: rgba(20, 20, 20, 0.45);
  border-radius: var(--border-radius-large);
  padding: 0.6rem 1rem;
  box-shadow: var(--shadow);
  z-index: 20;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.13);
  transition: transform 0.25s ease-in-out, opacity 0.2s ease-in-out;
}

.nav-controls.nav-hidden {
  transform: translateX(-50%) translateY(25vh) !important;
  opacity: 0;
  pointer-events: none;
}

.nav-controls button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 300;
  position: relative;
}

.nav-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: scale(0.95);
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
}

.nav-controls button:disabled:hover {
  opacity: 0.6;
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.08);
}

.nav-controls button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-color);
  transform: scale(1.1);
}

/* --- Live Input Tracking Fields --- */
#pageCounter {
  font-size: 0.9rem;
  min-width: 70px;
  white-space: nowrap;
  text-align: center;
  font-weight: 400;
  background: none;
  color: var(--text-secondary);
  border: none;
  margin: 0 0.5rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
  user-select: none;
}

#pageCounter:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-color);
  transform: scale(1.05);
}

.page-edit-input {
  width: 40px !important;
  height: 20px !important;
  border: none !important;
  background: rgba(255, 255, 255, 0.15) !important;
  color: var(--text-primary) !important;
  text-align: center !important;
  border-radius: 6px !important;
  font-size: 0.9rem !important;
  font-family: inherit !important;
  outline: none !important;
  margin: 0 2px !important;
  padding: 0 4px !important;
  transition: var(--transition) !important;
}

.page-edit-input:focus {
  background: rgba(0, 184, 148, 0.2) !important;
  color: var(--accent-color) !important;
  box-shadow: 0 0 0 1px rgba(0, 184, 148, 0.3) !important;
}

.page-edit-input::-webkit-inner-spin-button,
.page-edit-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-edit-input[type=number] {
  -moz-appearance: textfield;
}

/* --- Secondary Notifications Metrics --- */
.zoom-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg-overlay);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 30;
  pointer-events: none;
}

.zoom-indicator.show {
  opacity: 1;
}

.error-container {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--error-color);
  color: var(--text-primary);
  padding: 0.8rem 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-error);
  z-index: 1000;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  opacity: 0.98;
  backdrop-filter: var(--backdrop-blur);
}

/* ==========================================================================
   11. CONDITION RUNTIME HOOKS (ACTIVE OVERRIDES)
   ========================================================================== */
body.comic-active::before {
  background-image: none !important;
  animation: none !important;
  display: none;
}

body.comic-active .top-heading {
  display: none !important;
}

body.comic-active main {
  min-height: 100vh;
  height: 100vh;
  padding: 0;
}

body.comic-active #dropZone {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.comic-active .page-stage img {
  max-width: 100vw;
  max-height: 100vh;
}

/* ==========================================================================
   12. PLATFORM TARGET BREAKPOINTS (RESPONSIVE VIEWPORTS)
   ========================================================================== */
@media (max-width: 700px) {
  .reader-container {
    max-width: 100vw;
    padding: 0;
    height: 100vh;
  }
  
  .comic-page {
    max-width: 100vw;
    max-height: 100vh;
  }
  
  .nav-controls {
    bottom: 2vh;
    padding: 0.5rem 0.8rem;
    gap: 0.6rem;
  }
  
  .nav-controls button {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }
  
  #pageCounter {
    font-size: 0.9rem;
    min-width: 70px;
    white-space: nowrap;
  }
  
  .page-edit-input {
    width: 35px !important;
    font-size: 0.8rem !important;
  }
}

/* ==========================================================================
   13. SUBSYSTEM HARDWARE STANDARDS (MEDIA PRINT PLUGINS)
   ========================================================================== */
@media print {
  .nav-controls,
  .drop-zone,
  .progress-container,
  .error-container {
    display: none !important;
  }
  
  .comic-page img {
    max-width: none;
    max-height: none;
    width: 100%;
    height: auto;
  }
}