/* Android 9 Kiosk Display Optimization */
/* Optimized for portrait-oriented Android kiosk displays */

/* ============================================
   ANDROID WEBVIEW FIXES
   ============================================ */
html {
  /* Fix for Android WebView rendering */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  /* Prevent overscroll bounce on Android */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   PORTRAIT ORIENTATION OPTIMIZATION
   ============================================ */
@media (orientation: portrait) {
  /* Full viewport height for portrait displays */
  .site-main {
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
  }
  
  /* Stack content vertically for portrait */
  .hero {
    padding: clamp(2rem, 8vh, 6rem) 0;
  }
  
  .hero h1 {
    font-size: clamp(2rem, 6vw, 4rem);
    line-height: 1.2;
  }
  
  .hero p {
    font-size: clamp(1rem, 3vw, 1.5rem);
  }
  
  /* Grid adjustments for portrait */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  /* Cards in portrait mode */
  .card,
  .feature-card,
  .project-card {
    max-width: 100%;
    margin-bottom: 1.5rem;
  }
}

/* ============================================
   LARGE PORTRAIT KIOSK (>= 800px width)
   ============================================ */
@media (orientation: portrait) and (min-width: 800px) {
  body {
    font-size: clamp(1.125rem, 1.5vw, 1.5rem);
  }
  
  .container {
    max-width: 90%;
    padding-left: 2rem;
    padding-right: 2rem;
  }
  
  .site-header {
    min-height: 100px;
    padding: 1rem 0;
  }
  
  .branding-logo {
    max-height: clamp(60px, 8vw, 100px);
  }
  
  .nav-link {
    font-size: clamp(1.125rem, 2vw, 1.5rem);
    padding: 0.75rem 1rem;
  }
  
  .nav-cta {
    font-size: clamp(1rem, 2vw, 1.25rem);
    padding: 1rem 1.5rem;
  }
  
  /* Larger touch targets for kiosk */
  button,
  a.btn,
  input[type="submit"] {
    min-height: 64px;
    font-size: clamp(1.125rem, 2vw, 1.5rem);
    padding: 1rem 2rem;
    border-radius: 0.75rem;
  }
  
  input,
  textarea,
  select {
    min-height: 64px;
    font-size: clamp(1.125rem, 2vw, 1.5rem);
    padding: 1rem 1.25rem;
  }
  
  /* Section spacing for portrait */
  section {
    padding-top: clamp(3rem, 8vh, 6rem);
    padding-bottom: clamp(3rem, 8vh, 6rem);
  }
  
  /* Two columns for larger portrait displays */
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
  
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
}

/* ============================================
   EXTRA LARGE PORTRAIT KIOSK (>= 1080px width)
   ============================================ */
@media (orientation: portrait) and (min-width: 1080px) {
  body {
    font-size: clamp(1.25rem, 1.5vw, 1.75rem);
  }
  
  .container {
    max-width: 85%;
    padding-left: 3rem;
    padding-right: 3rem;
  }
  
  .site-header {
    min-height: 120px;
    padding: 1.5rem 0;
  }
  
  .branding-logo {
    max-height: clamp(80px, 10vw, 140px);
  }
  
  h1 {
    font-size: clamp(3rem, 8vw, 5rem);
    margin-bottom: 2rem;
  }
  
  h2 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin-bottom: 1.5rem;
  }
  
  h3 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 1.5rem;
  }
  
  p,
  li {
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    line-height: 1.7;
  }
  
  /* Touch targets */
  button,
  a.btn,
  input[type="submit"] {
    min-height: 80px;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    padding: 1.25rem 2.5rem;
    border-radius: 1rem;
  }
  
  input,
  textarea,
  select {
    min-height: 80px;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    padding: 1.25rem 1.5rem;
  }
  
  /* Three columns for extra large portrait */
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
  }
  
  .card,
  .feature-card,
  .project-card {
    padding: 2.5rem;
    border-radius: 1.5rem;
  }
}

/* ============================================
   ANDROID-SPECIFIC TOUCH OPTIMIZATIONS
   ============================================ */
/* Remove default Android highlighting */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Larger touch targets for Android */
a,
button,
input,
select,
textarea,
label {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection in specific areas */
p,
span,
h1,
h2,
h3,
h4,
h5,
h6 {
  -webkit-user-select: text;
  user-select: text;
}

/* Improve scrolling on Android */
.site-main,
.modal,
.dropdown-panel {
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   ANDROID WEBVIEW FONT RENDERING
   ============================================ */
body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1;
}

/* ============================================
   SAFE AREAS FOR ANDROID NOTCH/CUTOUTS
   ============================================ */
.site-header {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-top: max(1rem, env(safe-area-inset-top));
}

.site-footer {
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.container {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* ============================================
   ANDROID NAVIGATION BAR SPACING
   ============================================ */
@media (orientation: portrait) {
  .site-main {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}

/* ============================================
   ANDROID MODAL/POPUP OPTIMIZATION
   ============================================ */
.modal,
.popup,
.dialog {
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (orientation: portrait) and (min-width: 800px) {
  .modal,
  .popup,
  .dialog {
    max-width: 80%;
    padding: 2.5rem;
    border-radius: 1.5rem;
  }
}

/* ============================================
   ANDROID DROPDOWN OPTIMIZATION
   ============================================ */
@media (orientation: portrait) {
  .dropdown-panel,
  .dropdown-menu {
    min-width: 240px;
    padding: 1rem;
  }
  
  .dropdown-item {
    font-size: clamp(1rem, 2vw, 1.25rem);
    padding: 1rem 1.25rem;
    min-height: 56px;
  }
}

@media (orientation: portrait) and (min-width: 800px) {
  .dropdown-panel,
  .dropdown-menu {
    min-width: 300px;
    padding: 1.25rem;
  }
  
  .dropdown-item {
    font-size: clamp(1.125rem, 2vw, 1.5rem);
    padding: 1.25rem 1.5rem;
    min-height: 64px;
  }
}

/* ============================================
   ANDROID FORM OPTIMIZATION
   ============================================ */
/* Prevent zoom on input focus */
input,
select,
textarea {
  font-size: 16px !important; /* Minimum to prevent zoom on Android */
}

@media (orientation: portrait) and (min-width: 800px) {
  input,
  select,
  textarea {
    font-size: clamp(1.125rem, 2vw, 1.5rem) !important;
  }
}

/* Better checkbox and radio button sizing */
input[type="checkbox"],
input[type="radio"] {
  min-width: 32px;
  min-height: 32px;
  margin-right: 1rem;
}

@media (orientation: portrait) and (min-width: 800px) {
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 40px;
    min-height: 40px;
    margin-right: 1.25rem;
  }
}

/* ============================================
   RECAPTCHA OPTIMIZATION FOR PORTRAIT
   ============================================ */
.g-recaptcha {
  transform: scale(1);
  transform-origin: center center;
}

@media (orientation: portrait) and (max-width: 360px) {
  .g-recaptcha {
    transform: scale(0.9);
  }
}

@media (orientation: portrait) and (min-width: 800px) {
  .g-recaptcha {
    transform: scale(1.2);
  }
}

@media (orientation: portrait) and (min-width: 1080px) {
  .g-recaptcha {
    transform: scale(1.5);
  }
}

/* ============================================
   FLOATING ELEMENTS FOR PORTRAIT
   ============================================ */
.floating-jobs-badge {
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  right: max(20px, env(safe-area-inset-right, 20px));
}

@media (orientation: portrait) and (min-width: 800px) {
  .floating-jobs-badge {
    padding: 1.25rem 1.75rem;
    bottom: max(32px, env(safe-area-inset-bottom, 32px));
  }
  
  .badge-icon {
    width: 2rem;
    height: 2rem;
  }
  
  .badge-label {
    font-size: 0.875rem;
  }
  
  .badge-count {
    font-size: 1rem;
  }
}

@media (orientation: portrait) and (min-width: 1080px) {
  .floating-jobs-badge {
    padding: 1.5rem 2rem;
  }
  
  .badge-icon {
    width: 2.5rem;
    height: 2.5rem;
  }
  
  .badge-label {
    font-size: 1rem;
  }
  
  .badge-count {
    font-size: 1.25rem;
  }
}

/* ============================================
   NAVIGATION FOR PORTRAIT KIOSK
   ============================================ */
@media (orientation: portrait) {
  /* Always show hamburger menu on portrait */
  .nav-links {
    display: none !important;
  }
  
  .nav-toggle {
    display: inline-flex !important;
    min-width: 56px;
    min-height: 56px;
  }
  
  /* Mobile panel full width in portrait */
  .mobile-panel {
    inset: 0;
  }
  
  .mobile-sheet {
    width: 100%;
    max-width: 100%;
  }
  
  .mobile-nav-item {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    padding: 1rem 1.25rem;
    min-height: 64px;
  }
  
  .nav-section-title {
    font-size: clamp(0.875rem, 2vw, 1.25rem);
    padding: 0.75rem 1.25rem;
  }
}

@media (orientation: portrait) and (min-width: 800px) {
  .nav-toggle {
    min-width: 72px;
    min-height: 72px;
  }
  
  .nav-toggle .bars {
    width: 32px;
    height: 24px;
  }
  
  .nav-toggle .bars span {
    height: 3px;
  }
  
  .mobile-nav-item {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    padding: 1.25rem 1.5rem;
    min-height: 80px;
  }
  
  .nav-icon {
    width: 32px;
    height: 32px;
  }
}

/* ============================================
   CONTENT WIDTH LIMITS FOR PORTRAIT
   ============================================ */
@media (orientation: portrait) {
  /* Prevent content from being too wide */
  .hero-inner {
    max-width: 90%;
  }
  
  p {
    max-width: 100%;
  }
  
  /* Center images and media */
  img,
  video {
    margin-left: auto;
    margin-right: auto;
  }
}

/* ============================================
   TABLE OPTIMIZATION FOR PORTRAIT
   ============================================ */
@media (orientation: portrait) {
  /* Make tables scrollable horizontally if needed */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 100%;
    font-size: clamp(0.875rem, 2vw, 1.125rem);
  }
  
  th,
  td {
    padding: clamp(0.75rem, 2vw, 1.25rem);
    white-space: nowrap;
  }
}

@media (orientation: portrait) and (min-width: 800px) {
  table {
    font-size: clamp(1rem, 2vw, 1.5rem);
  }
  
  th,
  td {
    padding: clamp(1rem, 2vw, 1.5rem);
  }
}

/* ============================================
   LOADING STATES FOR ANDROID
   ============================================ */
.loading {
  pointer-events: none;
  opacity: 0.6;
}

/* ============================================
   ANDROID HARDWARE ACCELERATION
   ============================================ */
.card,
.feature-card,
.project-card,
.modal,
button,
.nav-toggle {
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* ============================================
   PREVENT TEXT INFLATION ON ANDROID
   ============================================ */
body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ============================================
   BETTER FOCUS STATES FOR KIOSK
   ============================================ */
*:focus {
  outline: 3px solid #0341c9;
  outline-offset: 2px;
}

@media (orientation: portrait) and (min-width: 800px) {
  *:focus {
    outline-width: 4px;
    outline-offset: 4px;
  }
}

/* ============================================
   SMOOTH SCROLLING FOR ANDROID
   ============================================ */
html {
  scroll-behavior: smooth;
}

/* Disable smooth scroll for reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   IMAGE OPTIMIZATION FOR ANDROID
   ============================================ */
img {
  max-width: 100%;
  height: auto;
  display: block;
  image-rendering: -webkit-optimize-contrast;
}

/* ============================================
   FOOTER SPACING FOR PORTRAIT
   ============================================ */
@media (orientation: portrait) {
  .site-footer {
    padding: clamp(2rem, 5vh, 4rem) 0 clamp(2rem, 5vh, 4rem);
    font-size: clamp(0.875rem, 2vw, 1.25rem);
  }
}
