/**
 * Responsive Styles - Premium Design
 * Media queries and responsive design for QVG Capital theme
 */

/* ============================================
   Desktop (Default - 1200px+)
   ============================================ */

/* Button text switching - default state */
.btn-text-short {
  display: none;
}

/* Styles above are for desktop */

/* ============================================
   Large Tablets & Small Desktops (1024px - 1199px)
   ============================================ */

@media (max-width: 1199px) {
  .container {
    max-width: 1024px;
  }

  .hero-title {
    font-size: var(--font-size-4xl);
  }

  .grid-cols-4 {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Header adjustments */
  .header-actions .btn {
    padding: 0.5rem 1rem;
  }
}

/* ============================================
   Tablets (768px - 1023px)
   ============================================ */

@media (max-width: 1023px) {
  /* Prevent horizontal scrolling on mobile/tablet */
  html,
  body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Ensure all elements respect viewport width */
  *,
  *::before,
  *::after {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Exclude elements that need to overflow for specific functionality */
  .table-responsive,
  .table-responsive *,
  pre,
  code {
    max-width: none;
  }

  :root {
    --container-padding: 1.25rem;
    --spacing-xl: 4rem;
    --spacing-2xl: 6rem;
    --header-height: 70px;
  }

  .container {
    max-width: 768px;
  }

  /* Header CTA adjustments for tablet */
  .header-cta {
    gap: 0.5rem;
  }

  .btn-header-outline,
  .btn-header-primary {
    padding: 0.75rem 1.25rem;
    font-size: 0.65rem;
  }

  /* Grid adjustments */
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Two column layout becomes single column */
  .two-column-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  /* Dropdown menu on mobile */
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    border: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0;
    margin: 0;
    padding: 0;
    display: none;
  }

  .nav-item.is-active .dropdown-menu {
    display: block;
  }

  .dropdown-menu a {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-base);
  }

  /* Hero adjustments */
  .hero {
    min-height: 100vh;
    padding-top: 20vh;
  }

  .hero-title {
    font-size: var(--font-size-3xl);
  }

  .hero-tagline {
    font-size: var(--font-size-lg);
  }

  .hero-buttons {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-sm);
  }

  /* Footer adjustments */
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Section spacing */
  .section {
    padding: var(--spacing-lg) 0;
  }

  .section-lg {
    padding: var(--spacing-xl) 0;
  }

  /* Page navigation adjustments */
  .page-navigation {
    position: relative;
    top: 0;
  }

  .page-nav-list {
    flex-wrap: wrap;
    justify-content: center;
  }

  .page-nav-link {
    padding: 0.75rem 1rem;
    font-size: var(--font-size-xs);
  }

  /* Fund ticker - expand to show all content on tablet */
  .fund-ticker {
    position: relative;
    height: auto;
    min-height: auto;
    overflow: visible;
    padding: 0.75rem 0;
    margin: 0;
    border-bottom: none;
  }

  .fund-ticker .container {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 0.75rem;
  }

  .fund-ticker .ticker-fund {
    font-size: 0.75rem;
  }

  /* Header follows ticker naturally on tablet - no gaps */
  .site-header {
    position: relative;
    top: 0;
    margin-top: 0;
    margin-bottom: 0;
  }

  /* Remove margin from content after header */
  .site-header + *,
  .fullscreen-menu + *,
  main,
  .site-content,
  .insights-page-wrapper,
  .page-content {
    margin-top: 0 !important;
  }

  /* Ensure page hero sections connect to header */
  .insights-page-hero,
  .page-hero,
  .hero {
    margin-top: 0 !important;
  }

  /* Remove body padding since header is no longer fixed */
  body:not(.admin-bar) {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  /* Admin bar adjustments - ticker and header are relative, not fixed */
  .admin-bar .fund-ticker {
    top: auto;
    position: relative;
  }

  .admin-bar .site-header {
    top: auto;
    position: relative;
  }
}

/* ============================================
   Mobile Landscape (576px - 767px)
   ============================================ */

@media (max-width: 767px) {
  :root {
    --container-padding: 1rem;
    --spacing-lg: 3rem;
    --spacing-xl: 4rem;
    --header-height: 60px;
    --ticker-height: 36px;
  }

  .container {
    max-width: 100%;
  }

  /* Grid adjustments */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  /* Typography adjustments */
  h1 {
    font-size: var(--font-size-3xl);
  }

  h2 {
    font-size: var(--font-size-2xl);
  }

  h3 {
    font-size: var(--font-size-xl);
  }

  h4 {
    font-size: var(--font-size-lg);
  }

  .hero-title {
    font-size: var(--font-size-2xl);
  }

  .hero-tagline {
    font-size: var(--font-size-base);
  }

  /* Button adjustments */
  .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .btn-group {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  /* Table responsive */
  .table-responsive {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .table {
    min-width: 600px;
  }

  /* Fund ticker - expand to show all content on narrow viewports */
  .fund-ticker {
    position: relative;
    padding: 0.75rem 0;
    height: auto;
    min-height: auto;
    overflow: visible;
    margin: 0;
    border-bottom: none;
  }

  .fund-ticker .container {
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 var(--spacing-sm);
    gap: 0.25rem 0.5rem;
  }

  .fund-ticker .ticker-date {
    flex-basis: 100%;
    text-align: center;
    margin-bottom: 0.125rem;
    display: block;
    width: 100%;
  }

  .fund-ticker .ticker-divider {
    display: none;
  }

  .fund-ticker .ticker-fund {
    font-size: 0.7rem;
    text-align: center;
  }

  /* Header follows ticker naturally on narrow viewports - no gaps */
  .site-header {
    position: relative;
    top: 0;
    margin-top: 0;
    margin-bottom: 0;
  }

  /* Remove margin from content after header */
  .site-header + *,
  .fullscreen-menu + *,
  main,
  .site-content,
  .insights-page-wrapper,
  .page-content {
    margin-top: 0 !important;
  }

  /* Ensure page hero sections connect to header */
  .insights-page-hero,
  .page-hero,
  .hero {
    margin-top: 0 !important;
  }

  /* Admin bar adjustments - ticker and header are relative, not fixed */
  .admin-bar .fund-ticker {
    top: auto;
    position: relative;
  }

  .admin-bar .site-header {
    top: auto;
    position: relative;
  }

  .hero-fullscreen .hero-content {
    padding-top: var(--spacing-xl);
  }

  /* Footer adjustments */
  .footer-content {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  /* Card padding adjustments */
  .card,
  .feature-card {
    padding: var(--spacing-md);
  }

  /* Section spacing */
  .section {
    padding: var(--spacing-md) 0;
  }

  .section-sm {
    padding: var(--spacing-sm) 0;
  }

  .section-lg {
    padding: var(--spacing-lg) 0;
  }

  /* Hero adjustments */
  .hero {
    min-height: 100vh;
    padding-top: 18vh;
  }

  .hero-content {
    padding: var(--spacing-md);
  }

  /* Logo size */
  .site-logo img,
  .site-logo-img {
    max-height: 50px;
  }

  /* Page Navigation Mobile */
  .page-navigation {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .page-nav-list {
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding: 0 var(--spacing-sm);
    min-width: max-content;
  }

  .page-nav-link {
    padding: 0.625rem 0.75rem;
    font-size: 0.65rem;
    white-space: nowrap;
  }

  /* Header adjustments */
  .header-inner {
    padding: 0 var(--spacing-sm);
  }

  /* Keep header CTA buttons visible and properly sized */
  .header-cta {
    gap: 0.375rem;
  }

  .btn-header-outline,
  .btn-header-primary {
    width: auto;
    padding: 0.625rem 1rem;
    font-size: 0.6rem;
  }
}

/* ============================================
   Mobile Portrait (320px - 575px)
   ============================================ */

@media (max-width: 575px) {
  :root {
    --font-size-4xl: 2rem;
    --font-size-3xl: 1.75rem;
    --font-size-2xl: 1.5rem;
    --font-size-xl: 1.25rem;
    --header-height: 56px;
    --ticker-height: 32px;
  }

  /* Typography adjustments */
  h1 {
    font-size: var(--font-size-2xl);
  }

  h2 {
    font-size: var(--font-size-xl);
  }

  h3 {
    font-size: var(--font-size-lg);
  }

  .hero-title {
    font-size: var(--font-size-xl);
    line-height: var(--line-height-snug);
  }

  .hero-tagline {
    font-size: var(--font-size-sm);
    letter-spacing: 0.02em;
  }

  /* Button adjustments */
  .btn {
    padding: 0.875rem 1.5rem;
    font-size: var(--font-size-xs);
  }

  .btn-lg {
    padding: 1rem 2rem;
    font-size: var(--font-size-sm);
  }

  .btn-sm {
    padding: 0.5rem 1rem;
  }

  /* Form adjustments */
  .form-control {
    font-size: var(--font-size-sm);
    padding: 0.875rem 1rem;
  }

  /* Card adjustments */
  .card,
  .feature-card,
  .team-card-body {
    padding: var(--spacing-sm);
  }

  /* Header adjustments */
  .header-inner {
    padding: 0 var(--spacing-xs);
  }

  .site-logo img,
  .site-logo-img {
    max-height: 40px;
  }

  /* Hero adjustments */
  .hero {
    min-height: 100vh;
    padding-top: 16vh;
  }

  /* Fund ticker font size and layout for very small screens */
  .fund-ticker {
    font-size: 0.65rem;
  }

  .fund-ticker .ticker-fund {
    font-size: 0.6rem;
  }

  /* Footer social icons */
  .social-icon {
    width: 40px;
    height: 40px;
  }

  .social-icon svg {
    width: 18px;
    height: 18px;
  }

  /* Section spacing */
  .section {
    padding: var(--spacing-sm) 0;
  }

  .section-lg {
    padding: var(--spacing-md) 0;
  }

  /* Page navigation very small screens */
  .page-nav-link {
    padding: 0.5rem 0.625rem;
    font-size: 0.6rem;
  }

  /* Team cards */
  .team-card-body {
    padding: var(--spacing-sm);
  }

  .team-card-name {
    font-size: var(--font-size-base);
  }

  .team-card-role {
    font-size: var(--font-size-xs);
  }

  /* Feature cards */
  .feature-card-icon {
    width: 60px;
    height: 60px;
  }

  .feature-card-icon svg {
    width: 24px;
    height: 24px;
  }

  .feature-card-title {
    font-size: var(--font-size-lg);
  }

  /* Keep header CTA buttons visible at smallest screens */
  .header-cta {
    gap: 0.25rem;
  }

  .btn-header-outline,
  .btn-header-primary {
    width: auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.55rem;
    letter-spacing: 0.02em;
  }

  /* Button text switching for small mobile screens */
  .btn-text-full {
    display: none;
  }
  .btn-text-short {
    display: inline;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  /* Hide non-essential elements */
  .site-header,
  .site-footer,
  .mobile-menu-toggle,
  .fund-ticker,
  .btn,
  .social-icon,
  .page-navigation,
  .scroll-to-top {
    display: none !important;
  }

  /* Reset colors for print */
  body {
    color: #000;
    background: #fff;
    font-size: 12pt;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  /* Show URLs after links */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }

  /* Page breaks */
  h1, h2, h3 {
    page-break-after: avoid;
    color: #000;
  }

  img {
    page-break-inside: avoid;
    max-width: 100%;
  }

  /* Optimize tables for print */
  table {
    border-collapse: collapse;
  }

  th, td {
    border: 1px solid #000;
    padding: 0.5rem;
  }

  /* Cards as simple boxes */
  .card {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }
}

/* ============================================
   Landscape Orientation
   ============================================ */

@media (orientation: landscape) and (max-height: 600px) {
  .hero {
    min-height: 100vh;
    padding: var(--spacing-md) 0;
  }

  .hero-title {
    font-size: var(--font-size-2xl);
  }

  .hero-tagline {
    font-size: var(--font-size-base);
  }

  /* Reduce header/ticker impact */
  :root {
    --header-height: 50px;
    --ticker-height: 28px;
  }
}

/* ============================================
   High Resolution Displays
   ============================================ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Optimize images and graphics for retina displays */
  .site-logo img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* ============================================
   Touch Device Optimization
   ============================================ */

@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  .btn,
  .form-control,
  .nav-item a {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 40px;
  }

  /* Remove hover effects that don't work on touch */
  .card:hover,
  .feature-card:hover,
  .team-card:hover {
    transform: none;
  }

  /* Keep shadow effects on active state instead */
  .card:active,
  .feature-card:active,
  .team-card:active {
    transform: scale(0.98);
  }

  /* Larger touch area for page navigation */
  .page-nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Make dropdowns tap-to-open instead of hover */
  .dropdown-menu {
    display: none;
  }

  .nav-item.is-active .dropdown-menu {
    display: block;
  }

  /* Social icons larger on touch */
  .social-icon {
    width: 48px;
    height: 48px;
  }
}

/* ============================================
   Dark Mode Support (Optional - Commented)
   ============================================ */

/*
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg-white: #1a1a1a;
    --color-bg-light: #2a2a2a;
    --color-text: #e5e5e5;
    --color-text-dark: #ffffff;
    --color-text-muted: #a0a0a0;
    --color-border: #404040;
    --color-cream: #2d2a24;
    --color-cream-light: #3d3a34;
  }
}
*/

/* ============================================
   Container Queries (Modern browsers)
   ============================================ */

@supports (container-type: inline-size) {
  .card-container {
    container-type: inline-size;
  }

  @container (max-width: 400px) {
    .card {
      padding: var(--spacing-sm);
    }

    .card-title {
      font-size: var(--font-size-lg);
    }
  }
}

/* ============================================
   Accessibility - Focus Visible
   ============================================ */

@media (prefers-reduced-motion: no-preference) {
  /* Only animate for users who haven't requested reduced motion */
  :focus-visible {
    outline: 2px solid var(--color-teal);
    outline-offset: 2px;
    transition: outline-offset 0.2s ease;
  }
}

/* ============================================
   High Contrast Mode
   ============================================ */

@media (prefers-contrast: high) {
  :root {
    --color-border: #000;
    --color-text-muted: #333;
  }

  .btn {
    border-width: 3px;
  }

  .card {
    border-width: 2px;
  }
}
