/* Responsive Design System - Mobile First Approach */

/* Base Mobile Styles (320px and up) */
@media screen and (min-width: 320px) {
  body {
    font-size: 14px;
    overflow-x: hidden;
  }
  
  #container {
    width: 100%;
    padding: 0;
  }
  
  #main {
    width: 95% !important;
    margin: 1rem auto !important;
    padding: 1rem !important;
    float: none !important;
  }
  
  /* Mobile Navigation */
  header nav {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    height: 100vh;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    transition: left 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
  }
  
  header nav.shownav {
    left: 0;
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
  }
  
  header nav ul {
    flex-direction: column;
    padding: 2rem 1rem;
  }
  
  header nav ul li {
    width: 100%;
    margin: 0.5rem 0;
    text-align: left;
  }
  
  header nav ul li a {
    display: block;
    padding: 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
  }
  
  header nav ul li a:hover {
    background: rgba(0, 172, 193, 0.2);
    transform: translateX(10px);
  }
  
  /* Mobile menu button */
  .navbar {
    display: block !important;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1002;
    background: rgba(0, 172, 193, 0.9);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .navbar:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(0, 172, 193, 0.4);
  }
  
  .navbutton::before {
    content: "☰";
    font-size: 24px;
    color: white;
  }
  
  /* Mobile Typography */
  h1 {
    font-size: 1.75rem !important;
  }
  
  h2 {
    font-size: 1.5rem !important;
  }
  
  h3 {
    font-size: 1.25rem !important;
  }
  
  .site-name {
    font-size: 1.5rem !important;
  }
  
  .blog-motto {
    font-size: 0.875rem !important;
    display: none;
  }
  
  /* Mobile Cards */
  .post, article.post {
    padding: 1rem !important;
    margin: 1rem 0 !important;
    border-radius: 12px !important;
  }
  
  /* Mobile Sidebar */
  #asidepart {
    display: none !important;
  }
  
  .openaside {
    display: none !important;
  }
  
  /* Mobile Search */
  input[type="search"] {
    width: 150px !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
  }
  
  input[type="search"]:focus {
    width: 180px !important;
  }
  
  /* Mobile Footer */
  footer {
    padding: 2rem 1rem !important;
  }
  
  .social-font {
    width: 100% !important;
    text-align: center !important;
    padding: 0 !important;
  }
  
  .social-font a {
    width: 2.5rem !important;
    height: 2.5rem !important;
    font-size: 1.25rem !important;
    margin: 0.25rem !important;
    display: inline-flex !important;
    float: none !important;
  }
  
  /* Mobile Tables */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Mobile Images */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Mobile Code Blocks */
  pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.875rem;
  }
  
  /* Mobile Pagination */
  #page-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  
  #page-nav a,
  #page-nav span {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
  }
}

/* Phablet Styles (480px and up) */
@media screen and (min-width: 480px) {
  body {
    font-size: 15px;
  }
  
  #main {
    padding: 1.5rem !important;
  }
  
  .blog-motto {
    display: block;
  }
  
  input[type="search"] {
    width: 180px !important;
  }
  
  input[type="search"]:focus {
    width: 220px !important;
  }
}

/* Tablet Styles (768px and up) */
@media screen and (min-width: 768px) {
  body {
    font-size: 16px;
  }
  
  #main {
    width: 90% !important;
    padding: 2rem !important;
  }
  
  /* Tablet Navigation */
  .navbar {
    display: none !important;
  }
  
  header nav {
    position: relative;
    left: 0;
    width: auto;
    height: auto;
    background: transparent;
    overflow: visible;
  }
  
  header nav ul {
    flex-direction: row;
    padding: 0;
    justify-content: flex-end;
    align-items: center;
  }
  
  header nav ul li {
    width: auto;
    margin: 0 0.5rem;
  }
  
  header nav ul li a {
    padding: 0.5rem 1rem;
  }
  
  header nav ul li a:hover {
    transform: translateY(-2px);
  }
  
  /* Tablet Typography */
  h1 {
    font-size: 2.25rem !important;
  }
  
  h2 {
    font-size: 1.875rem !important;
  }
  
  h3 {
    font-size: 1.5rem !important;
  }
  
  .site-name {
    font-size: 2rem !important;
  }
  
  /* Tablet Sidebar */
  #asidepart {
    display: block !important;
    position: fixed;
    right: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px);
    transition: right 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    padding: 2rem 1rem;
  }
  
  #asidepart.fadeIn {
    right: 0;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
  }
  
  .openaside {
    display: block !important;
    position: fixed;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 172, 193, 0.9);
    border-radius: 50% 0 0 50%;
    width: 40px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 998;
  }
  
  .openaside:hover {
    width: 50px;
    background: rgba(0, 172, 193, 1);
  }
  
  .closeaside {
    position: absolute;
    right: 1rem;
    top: 1rem;
    width: 30px;
    height: 30px;
    cursor: pointer;
  }
  
  /* Tablet Footer */
  footer {
    padding: 3rem 2rem !important;
  }
  
  .social-font a {
    width: 3rem !important;
    height: 3rem !important;
    font-size: 1.5rem !important;
  }
}

/* Desktop Styles (1024px and up) */
@media screen and (min-width: 1024px) {
  #container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
  }
  
  #main {
    width: 70% !important;
    margin-right: 2rem !important;
  }
  
  /* Desktop Sidebar */
  #asidepart {
    position: relative !important;
    right: 0 !important;
    width: 25% !important;
    height: auto !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
    margin-top: 2rem;
  }
  
  #asidepart aside {
    position: sticky;
    top: 100px;
    background: rgba(26, 26, 26, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .openaside,
  .closeaside {
    display: none !important;
  }
  
  /* Desktop Typography */
  h1 {
    font-size: 2.5rem !important;
  }
  
  h2 {
    font-size: 2rem !important;
  }
  
  h3 {
    font-size: 1.625rem !important;
  }
  
  .site-name {
    font-size: 2.5rem !important;
  }
  
  /* Desktop Search */
  input[type="search"] {
    width: 200px !important;
  }
  
  input[type="search"]:focus {
    width: 250px !important;
  }
}

/* Large Desktop Styles (1440px and up) */
@media screen and (min-width: 1440px) {
  body {
    font-size: 17px;
  }
  
  #container {
    max-width: 1600px;
  }
  
  #main {
    width: 75% !important;
  }
  
  #asidepart {
    width: 20% !important;
  }
  
  h1 {
    font-size: 3rem !important;
  }
  
  h2 {
    font-size: 2.25rem !important;
  }
  
  h3 {
    font-size: 1.875rem !important;
  }
}

/* Ultra Wide Desktop Styles (1920px and up) */
@media screen and (min-width: 1920px) {
  body {
    font-size: 18px;
  }
  
  #container {
    max-width: 1800px;
  }
  
  #main {
    max-width: 1200px !important;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  a, button, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Disable hover effects on touch devices */
  a:hover,
  button:hover,
  .post:hover,
  .social-font a:hover {
    transform: none !important;
    box-shadow: none !important;
  }
  
  /* Better spacing for touch */
  .article-tag-link,
  .article-category-link {
    padding: 0.5rem 1rem !important;
    margin: 0.5rem 0.25rem !important;
  }
}

/* Landscape Mobile Optimization */
@media screen and (max-width: 768px) and (orientation: landscape) {
  body {
    font-size: 14px;
  }
  
  header {
    padding: 0.5rem 0 !important;
  }
  
  .site-name {
    font-size: 1.25rem !important;
  }
  
  .blog-motto {
    display: none;
  }
  
  #main {
    margin-top: 0.5rem !important;
  }
}

/* Print Styles */
@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  header,
  footer,
  .navbar,
  .openaside,
  #asidepart,
  .social-font,
  #google_translate_element {
    display: none !important;
  }
  
  #main {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
  
  pre, blockquote {
    page-break-inside: avoid;
  }
  
  h2, h3 {
    page-break-after: avoid;
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  body {
    background: #000000 !important;
    color: #ffffff !important;
  }
  
  a {
    color: #00ffff !important;
    text-decoration: underline !important;
  }
  
  .post,
  #main,
  #asidepart aside {
    border: 2px solid #ffffff !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  /* Already dark by default, but ensure consistency */
  body {
    background: #0a0a0a;
  }
}

/* Fixes for specific elements */
.article-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
}

.article-content iframe {
  max-width: 100%;
  margin: 1rem auto;
  display: block;
}

/* Responsive tables */
.article-content table {
  width: 100%;
  margin: 1rem 0;
}

@media screen and (max-width: 768px) {
  .article-content table {
    font-size: 0.875rem;
  }
  
  .article-content td,
  .article-content th {
    padding: 0.5rem;
  }
}

/* Ensure Google Translate widget is responsive */
#google_translate_element {
  position: fixed !important;
  top: 10px !important;
  right: 10px !important;
  z-index: 9999 !important;
  max-width: 200px;
}

@media screen and (max-width: 768px) {
  #google_translate_element {
    top: auto !important;
    bottom: 10px !important;
    right: 10px !important;
  }
}

/* Smooth scrolling for all devices */
html {
  scroll-behavior: smooth;
}

/* Better focus indicators for accessibility */
*:focus {
  outline: 2px solid #00acc1;
  outline-offset: 2px;
}

/* Skip to content link for accessibility */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: #00acc1;
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 100;
}

.skip-to-content:focus {
  top: 0;
}