/* ============ BASE LAYOUT ============ */

/* Common box model and body settings */
:root {  
  --elm-height: clamp(30px, 2.5rem, 40px);
  --elm-height-small: clamp(23px, 2.5rem, 30px);
  --spacer: 0.3125rem; /* ~5px in rem */
  --double-spacer: 0.6250rem; /* ~10px in rem */
  --block-width: calc(25% - 3/4 * var(--spacer)); /* may later be used as a max-width */
  --font-size: 0.75rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}


html, body {
	height: 100%; 
	overflow: hidden
}  

body {
  margin: 0;
  font-family: sans-serif;
}

/* Container for the viewer */
#pdf-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#canvas-container {
  display: flex;
  justify-content: center; /* initial: center when PDF is small */
  align-items: center; /* flex-start; */
  background: #444;
  /*padding: 0.5rem;*/
  flex: 1;
  overflow: auto;
}

#canvas-container.multi-page {  
  align-items: flex-start;
}

/* When the PDF overflows horizontally, switch to left alignment */
#canvas-container.x-overflown {  
  justify-content: flex-start;
}

/* When the PDF overflows vertically, switch to top alignment */
#canvas-container.y-overflown {
  align-items: flex-start;
}

/* The PDF canvas */
#pdf-canvas {
  /* Remove any max-width constraints if you want the intrinsic size to show */
  /* max-width: 100%; */ 
  overflow: hidden;
  flex-shrink: 0; /* Prevent the canvas from shrinking inside its flex container */
  background: transparent; /* or background: #444; */
  opacity: 0;
  transition: opacity 0.5s ease;
}

.pdf-pages {
	padding: var(--double-spacer);
}

/* For multi-page canvases */
#canvas-container.multi-page .pdf-page-canvas {
  display: block;
  width: auto;
 scroll-margin-top: var( --double-spacer);
  height: 1 / 1.414; /*Ratio of an A4*/
  opacity: 1 !important; /* It has to be visible */
}

/* top-bar container (layout part) */
.top-bar {
  display: none; /* Initially hidden, will be said to flex during initialization */
  align-items: flex-start;
 justify-content: center;  
  gap: var(--spacer);
  overflow: hidden;           /* ensures that content is clipped when height is reduced */
  transition: height 0.3s ease;  /* optional, for a smooth animation */
}

.top-bar > * {
  padding: 3px 0;  
}

.full-controls {
	display: flex;
    justify-content: center;
    align-items: center;
}

#hor-bar {
  display: flex;
  align-items: center;  
  justify-content: center; 
}

#hor-bar .buttons {
  display: flex;
  align-items: flex-start;   
  flex: 1;  
  /*display: none;*/ /* hide programatically */
}

#pdf-select {
	width: 20rem;
}

.icon {
  width: 2.5em;
  height: 100%;
}

.sep {
    background: transparent;
    width: var(--double-spacer);
    height: 100%;
}

.bottom-bar {
	display: none;
}

/*------------- mobile layout ----------- */

/* Mobile styles (viewport width <= 970px) */
@media (max-width: 970px) {
  /* In topbar: hide full controls, show only the pdf-select */
  .top-bar .full-controls {
    display: none;
  }
  .pdf-select-container {
    width: 100%;
    display: flex;
    justify-content: center;
  }
  #pdf-select {
    width: 100%;
    box-sizing: border-box;
  }

  /* Style the bottom floating bar */
  .bottom-bar {
    display: flex;
    justify-content: center;
    position: absolute;
    bottom: 0;
    width: 100%;
    background: var(--primary-bg);
    padding: var(--spacer);
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.3);
    z-index: 5;
  }
  
  /* Ensure the bottom bar only takes up as much space as its content */
  .bottom-bar > * {
    margin: 0 0.25rem;
  }
  
  /* Inherit button styling from topbar buttons */
  .bottom-bar button {
    height: var(--elm-height-small);
    aspect-ratio: 1 / 1;
    background: var(--accent);
    color: var(--light-txt);
    border: 1px solid var(--light-gray2);
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
  }
  
  .bottom-bar .icon {
    width: 1.5em;
    height: 1.5em;
  }


  
  /* Style the page-info element (if you need to match button height) */
  .bottom-bar #page-info-mobile {
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
   
  }
}

/* ============ BASE STYLING ============ */

/* Default color and background values (can be overridden in variants) */
:root {
  --primary-bg: #333;         /* top-bar background */
  --secondary-bg: #00000018;   /* Block background */
  --accent: #eb784d;          /* Buttons, etc. */
  --light-gray1: #888;         /* For select backgrounds */
  --light-gray2: #aaa;         /* For button borders */
  --dark-txt: #000;           
  --light-txt: #fff;
  --medium-gray: #444;         /* Body background */
}

/* Body colors */
body {
  background: var(--medium-gray);
  font-size: var(--font-size);
  color: var(--light-txt);
}

/* top-bar styling */
.top-bar {
  background: var(--primary-bg);  
  padding: var(--spacer);
}

.top-bar .container {  
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-bar .txt, .bottom-bar .txt {
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-bar .txt { 
  min-width: 4.5em;  
  height: var(--elm-height);
}

.bottom-bar .txt {
  min-width: 3.2em;	
  height: var(--elm-height-small);
}

/* Button styling */
.top-bar button, .info-popup button {
  height: var(--elm-height);
  aspect-ratio: 1 / 1;
  background: var(--accent);
  color: var(--light-txt);
  border: 1px solid var(--light-gray2);
  border-radius: 3px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  appearance: none;
}

.top-bar button, 
.top-bar button:active, 
.top-bar button:focus,
.bottom-bar button, 
.bottom-bar button:active, 
.bottom-bar button:focus,
 .info-popup button,
.info-popup button:active, 
.info-popup button:focus {
  background-color: var(--accent);
}

.top-bar button:hover, 
.bottom-bar button:hover,
.info-popup button:hover {  
  background-color: #d66e3b;
  transform: scale(1.05);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.top-bar .icon {
    width: 2em;
    height: 100%;
}

/* Select styling */
.top-bar select {
  width: 100%;	
  height: var(--elm-height);
  background: var(--light-gray1);
  color: var(--dark-txt);
  border-radius: 3px;
}

.top-bar button:disabled, .bottom-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.top-bar button, .bottom-bar button {
  transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.bottom-bar button.alt {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 1.3rem;
  width: 1.3rem;
  background: transparent;
  border: none;
}

/* Position info-mobile flush to the right with some spacing */
#info-mobile {
  right: var(--spacer);
}

/* Position download-mobile to the left of info-mobile */
#download-mobile {
  right: calc(var(--spacer) + 1.3rem + var(--spacer));
}


.pdf-pages {
  display: flex;
  flex-direction: column;
  gap: var(--spacer); /* space between pages */
  padding: var(--spacer);
  overflow-y: auto;
  /*width: 100%;*/
  flex: 1;
  align-items: center;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Semi-transparent dark background */
  backdrop-filter: blur(5px);      /* Apply a blur effect */
  z-index: 10;                     /* Ensure it sits above your page content */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Info popup styles */
.info-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #eee;
  color: black;
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 20;
  min-width: 300px;
  max-width: calc(100vw - 2rem); /* Keeps a margin of 1rem on each side */
  width: auto; /* Adjusts width based on content, up to the max-width */
}

.info-popup .info-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.info-popup .separator {
  margin: 1.5em 0;
  width: 100%;
  height: 1px;
  background: #00000050;
}

#pdf-properties {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5em;
}

#property-names p {
  font-weight: bold;
}

#property-values {
  max-width: 400px;
}

#property-values p {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 100%;
  display: block;
}

.info-popup button {
  margin-top: 10px;
  aspect-ratio: initial;
  padding: 0.5em 1em;
}