/* Global Responsive CSS for All Pages */

/* Use modern viewport units */
html {
  scroll-behavior: smooth;
}

/* Ensure proper rendering on all devices */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Touch-friendly button sizes for mobile */
@media (max-width: 768px) {
  button,
  a.button,
  input[type="button"],
  input[type="submit"] {
    min-height: 44px; /* iOS recommended touch target */
    min-width: 44px;
  }
}

/* Improve text readability */
body {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* Flexible images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Shared site header */
.site-header {
  width: min(1280px, 100%);
  min-height: 64px;
  margin: 0 auto;
  padding: 0 4px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border, var(--line, rgba(255, 255, 255, 0.12)));
}

.site-logo {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text, #f8fafc);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.site-logo img {
  width: 44px;
  height: 40px;
  flex: none;
  object-fit: contain;
}

.site-logo-text {
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.site-logo-text span {
  color: var(--accent, #38bdf8);
}

.site-logo:hover {
  opacity: 0.78;
}

.site-logo:focus-visible,
.site-theme-toggle:focus-visible {
  outline: 3px solid var(--accent, #38bdf8);
  outline-offset: 3px;
}

.site-theme-toggle {
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  background: var(--control-bg, rgba(255, 255, 255, 0.04));
  color: var(--text, #f8fafc);
  font-size: 20px;
  cursor: pointer;
}

.site-theme-toggle:hover {
  background: var(--control-hover, rgba(255, 255, 255, 0.08));
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive containers */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (max-width: 1024px) {
  .container {
    padding: 0 12px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 8px;
  }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  body {
    padding: 8px;
  }
  
  header {
    gap: 6px !important;
  }
  
  main {
    gap: 8px !important;
  }
}

/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
  body {
    font-size: 15px;
  }
  
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.4rem;
  }
}

/* Ensure readable fonts on high DPI displays */
@media (min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  body {
    -webkit-text-size-adjust: none;
    -ms-text-size-adjust: none;
  }
}

/* Hide horizontal scrollbar on small devices */
@media (max-width: 480px) {
  body {
    overflow-x: hidden;
  }

  .site-header {
    min-height: 56px;
    padding: 0 2px 10px;
  }

  .site-logo img {
    width: 38px;
    height: 35px;
  }

  .site-logo-text {
    font-size: 0.98rem;
  }
}

/* Improve spacing for small devices */
@media (max-width: 480px) {
  h1, h2, h3, h4, h5, h6 {
    margin-top: 12px;
    margin-bottom: 10px;
  }
  
  p {
    margin-bottom: 12px;
  }
}
