html {
  font-size: 16px; /* Base font-size prevents iOS zoom triggers */
}

input,
select,
textarea {
  font-size: 16px !important; /* Force 16px on iOS to disable auto-zoom */
  -webkit-text-size-adjust: 100%; /* iOS-specific: disable font scaling */
}
body {
  font-family: sans-serif;
  background-color: #f9fafb;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}
.container {
  width: 100vw;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  box-sizing: border-box;
}
.view {
  width: 100%;
  max-width: 1920px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-grow: 1;
  margin-bottom: 0;
}
.header-bar {
  top: 0;
  width: 100%;
  max-width: 1440px;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  margin: 0 auto;
  z-index: 1000;
}
.title-bar {
  display: flex;
  align-items: flex-start;
  width: 100%;
  margin-top: 1em;
}
.title-bar h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.5;
  vertical-align: middle;
}
.right-buttons {
  display: flex;
  justify-content: flex-end;
}
.header-bar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  width: 165px;
  text-decoration: none;
  color: var(--pico-contrast-inverse, #ffffff);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}
.header-bar a.id-cards-link {
  background: #4b5563;
  border-color: #374151;
}
.header-bar a.id-cards-link:hover {
  background: #374151;
  transform: translateY(-1px);
}
.header-bar button i, .header-bar a.id-cards-link i {
  font-size: 1.2rem;
}
.left-buttons button:nth-child(1) {
  background: var(--pico-primary, #3b82f6);
  border-color: var(--pico-primary-border, #2563eb);
}
.left-buttons button:nth-child(1):hover {
  background: var(--pico-primary-hover, #2563eb);
  transform: translateY(-1px);
}
.left-buttons button:nth-child(2) {
  background: #28a745;
  border-color: #1f8a38;
}
.left-buttons button:nth-child(2):hover {
  background: #1f8a38;
  transform: translateY(-1px);
}
.left-buttons button:nth-child(3) {
  background: #dc2626;
  border-color: #b91c1c;
}
.left-buttons button:nth-child(3):hover {
  background: #b91c1c;
  transform: translateY(-1px);
}
.left-buttons a.id-cards-link {
  background: #4b5563;
  border-color: #374151;
}
.left-buttons a.id-cards-link:hover {
  background: #374151;
  transform: translateY(-1px);
}
.back-button {
  font-size: 1rem;
  border-radius: 6px;
  margin-right: 7.5rem;
}
.button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: auto;
}
.left-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}
.left-buttons button span, .left-buttons a.id-cards-link span {
  margin-left: 5px;
}
details.dropdown {
  width: 222.8px;
}
.dropdown summary i,
.dropdown ul li a i {
  margin-right: 7px;
}
.content-container {
  display: flex;
  width: 100%;
  gap: 3rem;
  height: 625px;
}
.left-panel {
  width: 25%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}
.right-panel {
  width: 75%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.webcam-container {
  width: 100%;
  height: 264.8px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
  transform: rotate(-180deg);
}
.webcam-container.webcam-container-low-opacity {
  background: white;
  box-shadow: none;
}
#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.id-card-avatar:not([src*="lh3.googleusercontent.com"]) {
  width: 30vmin;
  height: 30vmin;
  object-fit: cover;
  transform-origin: center;
}
#webcam.webcam-low-opacity {
  opacity: 0.4;
  filter: grayscale(100%) blur(4px);
}
#webcam.webcam-disabled::before,
#webcam.webcam-disabled::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: #ffffff;
  transform: rotate(45deg);
  transform-origin: center;
}
#webcam.webcam-disabled::after {
  transform: rotate(-45deg);
}
.button-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.button-disabled span {
  text-decoration: line-through;
}
.input-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}
.input-container label {
  font-size: 1rem;
  color: #1f2937;
}
.required {
  color: red;
  font-size: 1rem;
}
input {
  --pico-border-color: #d1d5db;
  font-size: 1rem;
  border-radius: 6px;
  background-color: #ffffff !important;
}
.id-card {
  width: 100%;
  height: 625px;
  aspect-ratio: 16 / 10;
  border: none;
  border-radius: 12px;
  padding: 2rem;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
  position: relative;
}
.id-card-header {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 1rem;
  gap: 1.5rem;
}
.id-card-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-16deg);
  color: red;
  opacity: 0.1;
  font-weight: bold;
  font-size: 6.5em;
  width: 100%;
  text-align: center;
}
.id-card-logo {
  width: 5vmin;
  height: auto;
  object-fit: contain;
}
.id-card-avatar {
  width: 34vmin;
  height: 34vmin;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}
.id-card-name {
  font-size: 3rem;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
}
.id-card-job-title, .id-card-student-title, .id-card-campus, .id-card-skanska-contractor {
  font-size: 1.5rem;
  font-weight: 400;
  color: #6b7280;
  margin: 0.25rem 0;
  text-align: center;
}
.id-card-return-text, .id-card-skanska-return-text {
  font-size: 1.8rem;
  font-weight: 400;
  color: red;
  margin: 2.25rem 0;
  text-align: center;
}
.id-card-motto {
  font-size: 1.3rem;
  color: #4b5563;
  text-align: center;
  line-height: 1.4;
  margin-top: 1.1rem;
}
[role=button]:focus,
button:focus,
.header-bar a.id-cards-link:focus {
  --pico-box-shadow: none !important;
  box-shadow: none !important;
}
.modal article {
  max-width: 600px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.modal header, .modal footer {
  padding: 1rem;
}
.modal h3 {
  margin: 0;
  color: #1f2937;
  text-align: center;
}
.modal p {
  margin: 1rem;
  color: #4b5563;
  text-align: center;
}
#validation-modal p {
  text-align: left;
}
.modal .close {
  font-size: 1rem;
  border-radius: 6px;
}
.modal footer button {
  font-size: 1rem;
  border-radius: 6px;
}
.modal.success h3 {
  color: #28a745;
}
.modal.success .fa-circle-check {
  color: #28a745;
  font-size: 2em;
  margin-right: 0.5rem;
}
.modal.success .fa-xmark {
  color: #333;
  font-size: 1.5em;
}
.modal.success .fa-xmark:hover {
  color: #000;
}
.loader {
  width: 50px;
  aspect-ratio: 1;
  display: grid;
  border-radius: 50%;
  background:
    linear-gradient(0deg, rgb(0 0 0/50%) 30%, #0000 0 70%, rgb(0 0 0/100%) 0) 50%/8% 100%,
    linear-gradient(90deg, rgb(0 0 0/25%) 30%, #0000 0 70%, rgb(0 0 0/75%) 0) 50%/100% 8%;
  background-repeat: no-repeat;
  animation: l23 1s infinite steps(12);
  margin: 1rem auto;
}
.loader::before,
.loader::after {
  content: "";
  grid-area: 1/1;
  border-radius: 50%;
  background: inherit;
  opacity: 0.915;
  transform: rotate(30deg);
}
.loader::after {
  opacity: 0.83;
  transform: rotate(60deg);
}
@keyframes l23 {
  100% {transform: rotate(1turn)}
}
/* Portrait warning positioning */
.portrait-warning {
  display: none; /* Hidden by default */
  position: fixed;
  top: 15%; /* 40% from top (~60% from bottom) */
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Align content towards top */
  align-items: center; /* Center horizontally */
  padding-bottom: 2rem;
  background: #f9fafb;
  z-index: 10000;
  box-sizing: border-box;
  color: #1f2937;
  touch-action: manipulation; /* Prevent pinch-zoom gestures */
  -webkit-text-size-adjust: 100%; /* Prevent iOS text scaling */
  zoom: 1; /* Force zoom level */
}

/* Upside-down warning positioning */
.upside-down-warning {
  display: none; /* Hidden by default */
  position: fixed;
  top: 15%; /* 40% from top (~60% from bottom) */
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Align content towards top */
  align-items: center; /* Center horizontally */
  padding-bottom: 2rem;
  background: #f9fafb;
  z-index: 10000;
  box-sizing: border-box;
  color: #1f2937;
  touch-action: manipulation; /* Prevent pinch-zoom gestures */
  -webkit-text-size-adjust: 100%; /* Prevent iOS text scaling */
  zoom: 1; /* Force zoom level */
}

/* Warning logo styling */
.warning-logo {
  width: 400px; /* Fixed width for consistency */
  height: auto; /* Maintain aspect ratio */
  margin-bottom: 1rem; /* Space between logo and h2 */
}

.portrait-warning h2,
.upside-down-warning h2,
.portrait-warning p,
.upside-down-warning p {
  margin: 0.5rem 0;
  text-align: center;
  max-width: 80%;
  font-size: 1.2rem;
}
/* Modal positioning */
dialog#validation-modal,
dialog#progress-modal,
dialog#success-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none; /* Hidden by default, shown by showModal() */
  justify-content: center; /* Center horizontally */
  align-items: center; /* Center vertically for container */
  background: transparent; /* Transparent to rely on article background */
  z-index: 10001; /* Above warnings */
  box-sizing: border-box;
}

dialog#validation-modal[open],
dialog#progress-modal[open],
dialog#success-modal[open] {
  display: flex; /* Show when open */
}

dialog#validation-modal article,
dialog#progress-modal article,
dialog#success-modal article {
  position: absolute;
  top: 40%; /* Start at 40% from top (~65% from bottom) */
  transform: translateY(-50%); /* Adjust to center the modal vertically */
  width: 90%;
  max-width: 500px;
  padding: 1rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
}

/* Success modal: align tick and text vertically */
#success-message {
  display: flex;
  align-items: center; /* Vertically center icon and text */
  justify-content: center;
  gap: 0.5rem; /* Space between icon and text */
  font-size: 1.2rem;
}

#success-message i.fa-circle-check {
  font-size: 1.5rem; /* Slightly larger icon */
  color: #28a745; /* Green color for tick */
}
@media screen and (max-width: 1194px) {
  .container {
    padding: 0.5rem 1rem;
    max-width: 1100px;
  }
  .header-bar {
    padding: 0;
  }
  .input-container {
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-left: -0.5rem;
  }
  .right-buttons {
    margin-right: -0.5rem;
  }
  .content-container {
    max-width: 1100px;
    height: 550px;
    gap: 1rem;
  }
  #webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: none;
  }
  .id-card {
    max-width: 800px;
    height: 550px;
    padding: 3.5rem 3rem;
  }
  .id-card-header {
    margin-bottom: 2rem;
  }
  .id-card-logo {
    width: 50vmin;
  }
  .id-card-avatar {
    width: 30vmin;
    height: 30vmin;
  }
  .id-card-name {
    font-size: 2.5rem;
  }
  .id-card-motto {
    font-size: 1.1rem;
    margin-top: 0.8rem;
  }
  .id-card-watermark {
    font-size: 5em;
  }
  .id-card-return-text, .id-card-skanska-return-text {
    font-size: 1.5rem;
  }
}
@media screen and (pointer: coarse) {
  .id-card-avatar:not([src*="lh3.googleusercontent.com"]) {
    transform: rotate(-180deg);
  }
}
