/* mobile.css — Responsive design centered around build capability */

/* ── Mobile build CTA (hidden on desktop) ─────────── */

#mobile-build-cta {
  display: none;
}

/* ── Tablet: ≤1024px ──────────────────────────────── */

@media (max-width: 1024px) {
  .page {
    width: 100%;
    max-width: 794px;
    padding: 72px 64px;
  }

  #ruler {
    display: none;
  }

  #canvas {
    height: calc(100vh - 44px - 32px);
    padding: 24px 8px;
  }
}

/* ── Mobile: ≤768px ───────────────────────────────── */

@media (max-width: 768px) {

  /* ── Toolbar: scrollable, compact ───────────────── */

  #toolbar {
    height: 40px;
    padding: 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #toolbar::-webkit-scrollbar {
    display: none;
  }

  .tb-group {
    gap: 1px;
    flex-shrink: 0;
  }

  .tb-btn {
    height: 28px;
    min-width: 28px;
    padding: 0 4px;
    font-size: 12px;
  }

  .tb-select {
    height: 24px;
    font-size: 11px;
    padding: 0 4px;
    max-width: 90px;
  }

  .tb-sep {
    margin: 0 3px;
    height: 16px;
  }

  .tb-color-wrap {
    width: 28px;
    height: 28px;
  }

  /* ── Ruler: hidden ─────────────────────────────── */

  #ruler {
    display: none;
  }

  /* ── Canvas ────────────────────────────────────── */

  #canvas {
    height: calc(100vh - 40px - 28px - 48px);
    padding: 16px 4px;
  }

  /* ── Pages: full-width, less padding ───────────── */

  .page {
    width: calc(100vw - 8px);
    max-width: 100%;
    min-height: auto;
    padding: 32px 24px;
    margin: 0 auto 16px;
    border-radius: 4px;
    font-size: 10pt;
    line-height: 1.3;
  }

  /* ── X link + Build button ─────────────────────── */

  #btn-x {
    top: 6px;
    right: 82px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }

  #btn-x svg {
    width: 12px;
    height: 12px;
  }

  #btn-build {
    top: 6px;
    right: 8px;
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
  }

  /* ── Status bar ────────────────────────────────── */

  #statusbar {
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
    gap: 6px;
  }

  /* ── Chatbox ───────────────────────────────────── */

  #chatbox {
    width: calc(100vw - 16px);
    bottom: 36px;
    padding: 0 10px;
    border-radius: 8px;
  }

  #chat-input {
    height: 36px;
    font-size: 13px;
  }

  /* ── AI flash message ──────────────────────────── */

  .ai-flash {
    bottom: 80px;
    font-size: 11px;
    max-width: calc(100vw - 32px);
    white-space: normal;
    text-align: center;
  }

  /* ── Selection widget ──────────────────────────── */

  #sel-widget {
    max-width: calc(100vw - 16px);
    border-radius: 6px;
    padding: 3px 4px;
  }

  #sel-widget button {
    height: 26px;
    min-width: 26px;
    font-size: 11px;
  }

  /* ── Build modal: full-screen on mobile ────────── */

  #build-modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
    padding: 16px;
    display: flex;
    flex-direction: column;
  }

  #build-overlay {
    align-items: stretch;
    justify-content: stretch;
  }

  .build-header {
    margin-bottom: 12px;
    flex-shrink: 0;
  }

  .build-hint {
    font-size: 12px;
    margin-bottom: 12px;
    flex-shrink: 0;
  }

  .build-dropzone {
    padding: 20px 16px;
    margin-bottom: 12px;
    flex-shrink: 0;
  }

  .build-dropzone-icon {
    font-size: 24px;
  }

  .build-dropzone-label {
    font-size: 12px;
  }

  .build-prompt {
    min-height: 60px;
    font-size: 13px;
    margin-bottom: 12px;
    flex-shrink: 0;
  }

  .build-submit {
    height: 44px;
    font-size: 14px;
    border-radius: 10px;
    flex-shrink: 0;
  }

  .build-progress {
    flex: 1;
    overflow-y: auto;
    margin-top: 12px;
  }

  .build-steps {
    max-height: none;
  }

  .build-section-card {
    padding: 8px 10px;
  }

  .build-section-card-title {
    font-size: 11px;
  }

  .build-overall-progress {
    margin-top: 12px;
  }

  /* ── Mobile build CTA ──────────────────────────── */

  #mobile-build-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
  }

  /* Show CTA only when canvas is empty */
  #canvas:empty ~ #mobile-build-cta,
  #mobile-build-cta.visible {
    opacity: 1;
    pointer-events: auto;
  }

  #mobile-build-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 24px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #c8961e 0%, #e6b422 50%, #c8961e 100%);
    color: #1a1a1a;
    font-family: Inter, sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(200, 150, 30, 0.4);
    transition: box-shadow 0.2s, transform 0.1s;
  }

  #mobile-build-btn:active {
    transform: scale(0.97);
  }

  #mobile-build-cta p {
    font-size: 12px;
    color: #666;
    text-align: center;
  }
}

/* ── Small phones: ≤480px ─────────────────────────── */

@media (max-width: 480px) {

  /* Hide less-used toolbar groups */
  #toolbar .tb-group:nth-child(n+9) {
    display: none;
  }

  .page {
    padding: 24px 16px;
    font-size: 10pt;
  }

  #btn-build {
    padding: 0 8px;
    font-size: 10px;
  }

  #btn-build svg {
    display: none;
  }

  #btn-x {
    right: 68px;
    width: 24px;
    height: 24px;
  }

  #build-modal {
    padding: 12px;
  }

  .build-header h2 {
    font-size: 14px;
  }

  .build-dropzone {
    padding: 16px 12px;
  }

  #chatbox {
    bottom: 32px;
  }

  #statusbar {
    height: 24px;
    font-size: 10px;
    padding: 0 6px;
  }

  /* Hide char count on very small screens */
  #char-count,
  #char-count + .sb-sep {
    display: none;
  }

  #mobile-build-btn {
    height: 44px;
    padding: 0 20px;
    font-size: 14px;
  }
}

/* ── Touch improvements ───────────────────────────── */

@media (hover: none) and (pointer: coarse) {
  .tb-btn {
    min-width: 36px;
    min-height: 36px;
  }

  .tb-btn:active {
    background: #333;
  }

  .build-submit:active {
    opacity: 0.8;
  }

  /* Larger touch targets for build section cards */
  .build-section-card {
    padding: 12px;
  }

  /* Slightly bigger file remove buttons */
  .build-file-remove {
    padding: 4px 8px;
    font-size: 16px;
  }
}
