/* ============================================================
   TRELLIS PLAYGROUND — MOBILE RESPONSIVE OVERHAUL
   Scoped to the v2 TRELLIS playground and layered after style.css.
   ============================================================ */

/* Mobile-only status pulse */
@keyframes trellis-tpg-status-pulse {
  0% { width: 18%; }
  50% { width: 58%; }
  100% { width: 30%; }
}

@media (max-width: 768px) {
  /* Restore the standard mobile page gutter — the global mobile rule at
     style.css:6981 tightens `.playground-inner` to `var(--space-2)` for
     the BioEmu card layout, but the v2 TRELLIS card needs the full
     `--page-gutter` (20px) breathing room to match every other section. */
  .trellis-pg-v2.playground-section .playground-inner,
  .trellis-pg-v2 .playground-inner {
    padding-inline: var(--page-gutter);
  }

  /* Layout + stacked column cleanup */
  .trellis-pg-v2 .tpg-col {
    padding: 16px;
    gap: 10px;
  }

  .trellis-pg-v2 .tpg-block {
    gap: 6px;
  }

  .trellis-pg-v2 .tpg-col--input + .tpg-col--result {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 16px;
  }

  .trellis-pg-v2 .tpg-col--result > .tpg-col-title {
    display: none;
  }

  /* Upload zone */
  .trellis-pg-v2 .upload-zone {
    min-height: 110px;
    height: 110px;
    gap: 6px;
    padding: 12px;
    border-radius: 12px;
    border-color: rgba(114,116,255,0.20);
    background: rgba(79,66,253,0.03);
  }

  .trellis-pg-v2 .upload-zone-empty {
    gap: 4px;
  }

  .trellis-pg-v2 .upload-zone-empty::after {
    content: 'PNG · JPG · WEBP';
    font-size: 10px;
    color: rgba(255,255,255,0.55);
  }

  .trellis-pg-v2 .upload-zone-icon {
    width: 28px;
    height: 28px;
  }

  .trellis-pg-v2 .upload-zone-icon svg {
    width: 28px;
    height: 28px;
    stroke: rgba(114,116,255,0.50);
  }

  .trellis-pg-v2 .upload-zone-empty p {
    margin: 0;
    font-size: 12px;
    color: rgba(255,255,255,0.60);
  }

  .trellis-pg-v2 .upload-zone.is-loaded {
    /* Column layout on mobile: image preview on top + filename/actions
       row below. Override the empty-state fixed 110px height and let
       the zone grow to fit the preview comfortably. */
    height: auto;
    min-height: 110px;
    padding: 10px;
    gap: 8px;
  }

  .trellis-pg-v2 .upload-zone-preview {
    max-height: 160px;
  }

  .trellis-pg-v2 .upload-zone-meta {
    gap: 8px;
  }

  .trellis-pg-v2 .upload-zone-filename {
    font-size: 12px;
  }

  .trellis-pg-v2 .upload-zone-action {
    width: 30px;
    height: 30px;
  }

  .trellis-pg-v2 .upload-zone-action svg {
    width: 14px;
    height: 14px;
  }

  /* Mode toggle */
  .trellis-pg-v2 .pg-mode-toggle {
    width: 100%;
    align-self: stretch;
  }

  .trellis-pg-v2 .pg-mode-btn {
    flex: 1 1 0;
    min-height: 38px;
    justify-content: center;
    font-size: 12px;
  }

  .trellis-pg-v2 .pg-mode-btn svg {
    width: 13px;
    height: 13px;
  }

  .trellis-pg-v2 .pg-mode-btn.is-active {
    background: rgba(114,116,255,0.15);
    border: 1px solid rgba(114,116,255,0.30);
    box-shadow: none;
    color: var(--text-2);
  }

  /* Text prompt */
  .trellis-pg-v2 .sequence-textarea {
    min-height: 100px;
    height: 100px;
    padding: 10px;
    font-size: var(--text-sm);
    line-height: 1.55;
  }

  .trellis-pg-v2 .tpg-char-counter {
    margin-top: -4px;
    font-size: 10px;
    color: rgba(255,255,255,0.55);
    text-align: right;
  }

  /* Parameters accordion */
  .trellis-pg-v2 .pg-params-toggle {
    min-height: 40px;
    padding: 0 12px;
    gap: 6px;
    font-size: 12px;
  }

  .trellis-pg-v2 .pg-params-body {
    padding: 14px 12px 12px;
    gap: 16px;
  }

  .trellis-pg-v2 .pg-param-name {
    font-size: 11px;
  }

  .trellis-pg-v2 .pg-param-info {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(255,255,255,0.30);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
  }

  .trellis-pg-v2 .pg-param-valuebox {
    min-width: 36px;
    padding: 3px 8px;
    font-size: 11px;
    background: rgba(255,255,255,0.07);
    font-variant-numeric: tabular-nums;
  }

  .trellis-pg-v2 .pg-green-slider::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
  }

  .trellis-pg-v2 .pg-green-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
  }

  .trellis-pg-v2 .pg-slider-ticks {
    margin-top: 4px;
  }

  .trellis-pg-v2 .pg-param-block:has(.pg-seed-input) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .trellis-pg-v2 .pg-param-block:has(.pg-seed-input) .pg-param-header {
    min-width: 0;
    justify-content: flex-start;
  }

  .trellis-pg-v2 .pg-param-block:has(.pg-seed-input) .pg-param-name {
    min-width: 0;
  }

  .trellis-pg-v2 .pg-seed-input {
    width: 80px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
  }

  /* Action buttons */
  .trellis-pg-v2 .tpg-actions--input {
    padding-top: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .trellis-pg-v2 .tpg-actions--input .pg-btn-primary {
    width: 100%;
    min-height: 46px;
    flex: none;
    border-radius: 12px;
    font-size: var(--text-sm);
    letter-spacing: 0.08em;
  }

  .trellis-pg-v2 .tpg-actions--input .pg-btn-primary .btn-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: rgba(255,255,255,0.18);
  }

  .trellis-pg-v2 .tpg-actions--input .pg-btn-ghost {
    min-height: 30px;
    padding: 0;
    margin: 0 auto;
    background: transparent;
    border: none;
    box-shadow: none;
    font-size: 11px;
    color: rgba(255,255,255,0.55);
  }

  .trellis-pg-v2 .tpg-actions--result {
    flex-wrap: wrap;
    gap: 8px;
  }

  .trellis-pg-v2 .tpg-actions--result .pg-btn-danger,
  .trellis-pg-v2 .tpg-actions--result .pg-btn-ghost {
    min-height: 40px;
    flex: 1 1 calc(50% - 4px);
    font-size: 12px;
  }

  .trellis-pg-v2 .tpg-actions--result .pg-btn-export {
    min-height: 40px;
    flex: 1 1 100%;
    width: 100%;
    font-size: 12px;
  }

  /* Viewport states */
  .trellis-pg-v2 .result-viewport {
    min-height: 120px;
    max-height: 120px;
    height: 120px;
    margin-bottom: 0;
    aspect-ratio: auto;
    flex: none;
    gap: 6px;
    border-radius: 14px;
  }

  .trellis-pg-v2 .result-viewport-placeholder {
    gap: 6px;
    padding: 12px;
  }

  .trellis-pg-v2 .result-viewport-placeholder svg {
    width: 32px;
    height: 32px;
    stroke: rgba(79,66,253,0.40);
  }

  .trellis-pg-v2 .result-viewport-label {
    font-size: 12px;
  }

  .trellis-pg-v2 .result-viewport-sub {
    font-size: 10px;
    max-width: 240px;
  }

  .trellis-pg-v2 .tpg-col--result:has(.tpg-status--loading) .result-viewport,
  .trellis-pg-v2 .tpg-col--result:has(.result-viewport-placeholder[hidden]) .result-viewport {
    min-height: 0;
    max-height: none;
    height: auto;
    aspect-ratio: 1 / 1;
    border-color: rgba(114,116,255,0.25);
  }

  /* Shrink orientation gizmo on mobile so it doesn't crowd the viewport */
  .trellis-pg-v2 .tpg-gizmo {
    width: 44px;
    height: 44px;
    left: 8px;
    bottom: 8px;
    padding: 3px;
  }

  /* Tech strip */
  .trellis-pg-v2 .tpg-techstrip {
    padding: 14px 16px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .trellis-pg-v2 .tech-stack-title {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
  }

  .trellis-pg-v2 .tech-stack-tags {
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent 100%);
    mask-image: linear-gradient(to right, #000 85%, transparent 100%);
  }

  .trellis-pg-v2 .tech-stack-tags::-webkit-scrollbar {
    display: none;
  }

  .trellis-pg-v2 .tech-tag {
    height: 22px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    font-size: 9px;
    font-weight: 500;
    white-space: nowrap;
    color: rgba(255,255,255,0.55);
  }

  /* Status banners */
  .trellis-pg-v2 .tpg-status {
    position: relative;
    padding: 10px 12px 19px;
    border-radius: 10px;
    font-size: 12px;
    overflow: hidden;
  }

  .trellis-pg-v2 .tpg-status::before,
  .trellis-pg-v2 .tpg-status::after {
    content: '';
    position: absolute;
    left: 12px;
    bottom: 10px;
    height: 3px;
    border-radius: 999px;
  }

  .trellis-pg-v2 .tpg-status::before {
    right: 12px;
    background: rgba(255,255,255,0.08);
  }

  .trellis-pg-v2 .tpg-status::after {
    width: 34%;
    background: currentColor;
    opacity: 0.75;
  }

  .trellis-pg-v2 .tpg-status--loading {
    background: rgba(114,116,255,0.06);
    border-color: rgba(114,116,255,0.15);
  }

  .trellis-pg-v2 .tpg-status--loading::after {
    animation: trellis-tpg-status-pulse 1.25s ease-in-out infinite;
  }

  .trellis-pg-v2 .tpg-status--info {
    background: rgba(0,187,195,0.06);
    border-color: rgba(0,187,195,0.15);
  }

  .trellis-pg-v2 .tpg-status--info::after {
    width: calc(100% - 24px);
    animation: none;
  }

  /* Mobile helper hooks */
  .trellis-pg-v2 .tpg-mobile-helper {
    font-size: 10px;
    color: rgba(255,255,255,0.55);
    text-align: center;
  }
}

@media (max-width: 480px) {
  /* Tightest spacing */
  .trellis-pg-v2 .tpg-col {
    padding: 14px;
  }

  .trellis-pg-v2 .tpg-col--input + .tpg-col--result {
    padding-top: 14px;
  }

  .trellis-pg-v2 .tpg-techstrip {
    padding: 14px;
  }

  /* Compact mode toggle and upload state */
  .trellis-pg-v2 .pg-mode-btn {
    gap: 5px;
  }

  /* Slider tick dots instead of labels */
  .trellis-pg-v2 .pg-slider-ticks {
    padding: 0 2px;
    font-size: 0;
    line-height: 0;
  }

  .trellis-pg-v2 .pg-slider-ticks span {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: transparent;
  }
}
