/**
 * ToolGrid Tablet Responsiveness Fixes
 * Targeted CSS for tablet breakpoints (768px to 1024px)
 * Fixes root layout issues without affecting mobile or desktop
 */

/* iPad Air / iPad Pro 11" (820px) */
@media (min-width: 768px) and (max-width: 850px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
    max-width: 100%;
  }

  .tg-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .tg-card {
    padding: 14px;
  }

  .tg-card h3 {
    font-size: 15px;
  }

  .tg-card p {
    font-size: 13px;
  }

  .tg-tool-form-row {
    grid-template-columns: 1fr;
  }

  .tg-mode-toggle {
    flex-direction: row;
  }

  .tg-mode-toggle button {
    flex: 1;
    width: auto;
  }

  .tg-hero {
    padding: 40px 16px;
  }

  .tg-hero h1 {
    font-size: 28px;
  }

  .tg-hero p {
    font-size: 15px;
  }

  .tg-search {
    font-size: 16px;
    padding: 12px 14px;
  }

  .tg-cat-btn {
    padding: 10px 14px;
    font-size: 13px;
  }

  .tg-tool-wrap {
    padding: 20px 16px;
  }

  .tg-tool-header h1 {
    font-size: 24px;
  }

  .tg-tool-header p {
    font-size: 14px;
  }

  .tg-howto,
  .tg-related {
    padding: 20px 0;
  }

  .tg-related-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* iPad Standard / iPad Air 2 (834px) */
@media (min-width: 851px) and (max-width: 900px) {
  .container {
    padding-left: 18px;
    padding-right: 18px;
    max-width: 100%;
  }

  .tg-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }

  .tg-card {
    padding: 15px;
  }

  .tg-card h3 {
    font-size: 16px;
  }

  .tg-card p {
    font-size: 14px;
  }

  .tg-tool-form-row {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .tg-mode-toggle {
    flex-direction: row;
  }

  .tg-mode-toggle button {
    flex: 1;
    width: auto;
  }

  .tg-hero {
    padding: 45px 18px;
  }

  .tg-hero h1 {
    font-size: 30px;
  }

  .tg-hero p {
    font-size: 16px;
  }

  .tg-search {
    font-size: 16px;
    padding: 12px 14px;
  }

  .tg-cat-btn {
    padding: 11px 15px;
    font-size: 14px;
  }

  .tg-tool-wrap {
    padding: 24px 18px;
  }

  .tg-tool-header h1 {
    font-size: 26px;
  }

  .tg-tool-header p {
    font-size: 15px;
  }

  .tg-howto,
  .tg-related {
    padding: 24px 0;
  }

  .tg-related-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Surface Pro 7 / iPad Pro 10.5" (912px) */
@media (min-width: 901px) and (max-width: 950px) {
  .container {
    padding-left: 20px;
    padding-right: 20px;
    max-width: 100%;
  }

  .tg-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }

  .tg-card {
    padding: 16px;
  }

  .tg-card h3 {
    font-size: 16px;
  }

  .tg-card p {
    font-size: 14px;
  }

  .tg-tool-form-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .tg-mode-toggle {
    flex-direction: row;
  }

  .tg-mode-toggle button {
    flex: 1;
    width: auto;
  }

  .tg-hero {
    padding: 50px 20px;
  }

  .tg-hero h1 {
    font-size: 32px;
  }

  .tg-hero p {
    font-size: 17px;
  }

  .tg-search {
    font-size: 16px;
    padding: 12px 14px;
    max-width: 600px;
  }

  .tg-cat-btn {
    padding: 12px 16px;
    font-size: 14px;
  }

  .tg-tool-wrap {
    padding: 28px 20px;
  }

  .tg-tool-header h1 {
    font-size: 28px;
  }

  .tg-tool-header p {
    font-size: 15px;
  }

  .tg-howto,
  .tg-related {
    padding: 28px 0;
  }

  .tg-related-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

/* iPad Pro 12.9" (1024px) */
@media (min-width: 951px) and (max-width: 1024px) {
  .container {
    padding-left: 24px;
    padding-right: 24px;
    max-width: 100%;
  }

  .tg-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }

  .tg-card {
    padding: 18px;
  }

  .tg-card h3 {
    font-size: 17px;
  }

  .tg-card p {
    font-size: 14px;
  }

  .tg-tool-form-row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .tg-mode-toggle {
    flex-direction: row;
  }

  .tg-mode-toggle button {
    flex: 1;
    width: auto;
  }

  .tg-hero {
    padding: 60px 24px;
  }

  .tg-hero h1 {
    font-size: 36px;
  }

  .tg-hero p {
    font-size: 18px;
  }

  .tg-search {
    font-size: 16px;
    padding: 13px 15px;
    max-width: 700px;
  }

  .tg-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 32px;
  }

  .tg-cat-btn {
    padding: 12px 18px;
    font-size: 14px;
  }

  .tg-tool-wrap {
    padding: 32px 24px;
  }

  .tg-tool-header h1 {
    font-size: 32px;
  }

  .tg-tool-header p {
    font-size: 16px;
  }

  .tg-howto,
  .tg-related {
    padding: 32px 0;
  }

  .tg-related-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }
}

/* Landscape Orientation Adjustments */
@media (orientation: landscape) and (max-height: 600px) {
  .tg-hero {
    padding: 20px 16px;
  }

  .tg-hero h1 {
    font-size: 22px;
    margin-bottom: 8px;
  }

  .tg-hero p {
    font-size: 13px;
    margin-bottom: 12px;
  }

  .search-container {
    margin-top: 12px;
  }

  .tg-cats {
    margin-bottom: 16px;
  }

  .tg-grid {
    gap: 12px;
  }
}

/* Portrait Orientation Adjustments */
@media (orientation: portrait) and (min-width: 768px) and (max-width: 1024px) {
  body {
    font-size: 14px;
  }

  .tg-grid {
    grid-auto-rows: minmax(200px, auto);
  }

  .tg-tool-form-row {
    grid-template-columns: 1fr;
  }

  .tg-mode-toggle {
    flex-direction: column;
  }

  .tg-mode-toggle button {
    width: 100%;
  }
}

/* Foldable Device Support (e.g., Samsung Galaxy Z Fold) */
@media (screen-spanning: single-fold-vertical) {
  .container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }

  .tg-grid {
    grid-column: 1 / -1;
  }
}

@media (screen-spanning: single-fold-horizontal) {
  .container {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 0;
  }

  .tg-grid {
    grid-row: 1 / -1;
  }
}

/* Touch-friendly adjustments for tablet */
@media (hover: none) and (pointer: coarse) and (min-width: 768px) and (max-width: 1024px) {
  .tg-btn,
  .tg-input,
  .tg-textarea,
  .tg-select {
    min-height: 44px;
  }

  .tg-card {
    padding: 16px;
  }

  .tg-cat-btn {
    min-height: 44px;
    padding: 12px 16px;
  }

  /* Increase touch target sizes */
  button,
  a,
  input[type="checkbox"],
  input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Add more spacing for touch */
  .tg-mode-toggle button {
    padding: 14px 16px;
  }
}

/* Ensure no layout shifts on tablet */
@media (min-width: 768px) and (max-width: 1024px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }

  body {
    -webkit-user-select: none;
    user-select: none;
  }

  input,
  textarea,
  select,
  button,
  a {
    -webkit-user-select: text;
    user-select: text;
  }

  /* Prevent unwanted scrollbars */
  html {
    overflow-y: scroll;
  }

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