/* ============================================
   Mobile Overrides (loaded at max-width: 768px)
   ============================================ */

/* ---- Touch Targets (44px minimum) ---- */

.btn {
  min-height: 44px;
  padding: 10px 16px;
}

.btn-sm {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.input-field,
.query-input,
select.input-field {
  min-height: 44px;
  /* 16px prevents iOS Safari zoom-on-focus */
  font-size: 16px;
}

textarea.input-field,
textarea.query-input {
  min-height: 80px;
  font-size: 16px;
}

.tab-btn {
  min-height: 44px;
  padding: 10px 16px;
}

.nav-item {
  min-height: 44px;
  padding: 10px 12px;
}

/* ---- Active States (touch feedback) ---- */

.btn:active {
  transform: scale(0.97);
  opacity: 0.85;
  transition: none;
}

.nav-item:active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.tab-btn:active {
  color: var(--text-primary);
}

/* Disable hover effects that cause sticky states on touch */
@media (hover: none) {
  .btn-primary:hover {
    background: var(--accent-green-dim);
    color: var(--text-primary);
  }
  .btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-default);
  }
  .nav-item:hover {
    background: none;
    color: var(--text-secondary);
  }
}

/* ---- Tables: Fit to Screen (NO horizontal scroll) ---- */

.table-wrapper {
  overflow-x: visible;
  -webkit-overflow-scrolling: touch;
}

/* Remove the scroll fade hint — tables should fit now */
.table-wrapper::after {
  display: none;
}

table {
  width: 100%;
  table-layout: auto;
  font-size: 0.78rem;
}

table th,
table td {
  /* Allow text to wrap — prevents horizontal overflow */
  white-space: normal;
  word-break: break-word;
  padding: 6px 8px;
  font-size: 0.75rem;
  line-height: 1.4;
}

table th {
  font-size: 0.65rem;
  letter-spacing: 0.02em;
}

/* Make monospace table cells slightly smaller */
td code {
  font-size: 0.72rem;
  word-break: break-all;
}

/* ---- Code Blocks: Fit to Screen ---- */

pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 0.75rem;
  padding: 12px;
  line-height: 1.5;
  max-width: 100%;
}

pre code {
  font-size: 0.75rem;
}

code {
  font-size: 0.78em;
  word-break: break-word;
}

/* ---- Responsive Layouts ---- */

/* SOP comparison: stack to single column */
.sop-comparison {
  grid-template-columns: 1fr !important;
  gap: 8px;
}

/* SVGs with inline max-width: scale to container */
.network-diagram svg {
  max-width: 100% !important;
  height: auto;
}

/* Terminal/JSON output: readable font size */
.terminal-output,
.json-response {
  font-size: 0.8rem;
  line-height: 1.5;
  max-height: 220px;
  word-break: break-word;
}

/* HTTP request display: allow wrapping */
.http-request-display {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.75rem;
}

/* ---- Flex rows with API path labels: allow wrapping ---- */

.flex.gap-sm {
  flex-wrap: wrap;
}

/* API path labels: allow shrinking */
.flex.gap-sm > span[style*="white-space:nowrap"] {
  white-space: normal !important;
  font-size: 0.78rem !important;
}

/* ---- Network / Handshake Diagram ---- */

.network-diagram {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

.handshake-container {
  min-width: 400px;
}

.handshake-endpoint {
  min-width: 60px !important;
  width: 60px !important;
  font-size: 0.7rem;
  padding: 6px;
}

.handshake-msg-label {
  font-size: 0.6rem;
}

/* ---- IDOR Inputs (override inline max-width) ---- */

.lab-container .flex .input-field[style*="max-width"] {
  max-width: none !important;
  flex: 1;
  min-width: 60px;
}

/* ---- Callouts ---- */

.callout {
  padding: 12px;
  font-size: 0.85rem;
}

/* ---- Lab containers ---- */

.lab-objective {
  font-size: 0.82rem;
  padding: 10px 12px;
}

/* ---- Encoder toggle buttons: wrap properly ---- */

.encoder-toggle {
  flex-wrap: wrap;
}

.encoder-toggle .btn {
  min-height: 36px;
  font-size: 0.78rem;
}

/* ---- Cookie table: smaller ---- */

.cookie-table th {
  font-size: 0.6rem;
}

/* ---- Quiz options: allow wrapping ---- */

.quiz-options {
  flex-wrap: wrap;
}

/* ---- Smaller Phones (480px) ---- */

@media (max-width: 480px) {
  .lab-container {
    padding: 14px;
  }

  .lab-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .encoder-grid {
    gap: 10px;
  }

  .panel {
    padding: 12px;
  }

  pre {
    padding: 10px;
    font-size: 0.7rem;
  }

  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.1rem; }
  h3 { font-size: 1rem; }

  table th, table td {
    padding: 5px 6px;
    font-size: 0.7rem;
  }

  table th {
    font-size: 0.6rem;
  }

  .main-content {
    padding: 12px 10px;
  }
}

/* ---- Header controls on mobile ---- */
.header-controls {
  position: static;
  transform: none;
  margin-left: auto;
  flex-shrink: 0;
}

.header-btn {
  padding: 3px 7px;
  font-size: 0.7rem;
}

#theme-toggle {
  font-size: 0.9rem;
  padding: 2px 6px;
}

.app-title {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}

.main-content {
  overflow-x: hidden;
  max-width: 100vw;
}

.handshake-container {
  min-width: 0 !important;
}
