/* ==========================================================================
   Responsive Styles — Tailored for Mobile Phones & Tablets
   ========================================================================== */

@media (max-width: 860px) {

  /* ── App Viewport on Mobile ── */
  .app-container {
    padding: 18px 16px 16px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* ── Header Centered ── */
  .site-header {
    width: 100%;
    align-items: center;
    text-align: center;
    gap: var(--space-3);
  }

  .brand-symbol {
    width: 78px;
    height: 78px;
  }

  .brand-title {
    display: none;
  }

  .brand-title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .brand-tagline-mobile {
    display: block;
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-weight: var(--fw-medium);
    letter-spacing: -0.01em;
  }

  /* Hide desktop controls */
  .nav-controls-desktop {
    display: none;
  }

  /* ── Mobile Action Row ── */
  .mobile-header-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 4px;
  }

  /* ── Mobile Social Links (Transparent bg, larger icons) ── */
  .social-icons-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
  }

  .mobile-icon-btn {
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0;
    transition: transform 0.15s ease;
  }

  .mobile-icon-btn:active {
    transform: scale(0.9);
    background: transparent !important;
  }

  .mobile-icon-btn img {
    width: 32px;
    height: 32px;
    object-fit: contain;
  }

  /* ── Mobile Tab Bar (Taller container, background-based active state without border) ── */
  .mobile-tab-bar {
    display: flex;
    align-items: center;
    background: var(--bg-subtle);
    border: none !important;
    box-shadow: none !important;
    border-radius: var(--radius-pill);
    padding: 5px;
    width: 100%;
    max-width: 340px;
    min-height: 54px;
    height: 54px;
  }

  .mobile-tab-btn {
    flex: 1;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    font-size: 0.95rem;
    font-weight: var(--fw-semibold);
    border: none !important;
    outline: none !important;
    background: transparent;
    color: var(--text-primary);
    border-radius: 22px;
    transition: all var(--dur-normal) var(--smooth);
    text-align: center;
    cursor: pointer;
    box-shadow: none !important;
  }

  .mobile-tab-btn:active {
    transform: scale(0.96);
  }

  .mobile-tab-btn.active {
    background: var(--text-primary) !important;
    color: var(--text-inverse) !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
  }

  /* ── Mobile Contact Form Card (Content-hug: no huge bottom white space) ── */
  .contact-card-wrapper {
    position: absolute;
    top: 195px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 360px;
    height: auto !important;
    min-height: auto !important;
    max-height: calc(100dvh - 215px);
    display: none;
    z-index: var(--z-mobile-contact);
    background: #FFFFFF;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 4px 4px 0px var(--border-color);
    padding: 18px 18px 16px 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .contact-card-wrapper.mobile-contact-visible {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: auto !important;
    min-height: auto !important;
  }

  .contact-card-wrapper .contact-form {
    width: 100%;
    max-width: 100%;
    gap: 16px;
    margin-bottom: 0;
  }

  .contact-card-wrapper .line-input,
  .contact-card-wrapper .custom-select-trigger {
    font-size: 16px !important; /* Prevents auto-zoom in iOS Safari */
    padding: 10px 8px;
  }

  .contact-card-wrapper .submit-btn {
    padding: 13px 20px;
    font-size: 1rem;
    margin-top: 4px;
    margin-bottom: 0;
    border-radius: 12px;
  }

  body.mobile-contact-active .cards-playground {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.25s ease;
  }

  /* ── Mobile Neo-Brutalist Cards (Square-ish, 3-line clamp, physical press) ── */
  .neo-card {
    width: min(calc(100vw - 110px), 242px);
    max-width: 242px;
    border-radius: 12px;
    border-top: 1.5px solid var(--border-color);
    border-left: 1.5px solid var(--border-color);
    border-right: 5px solid var(--border-color);
    border-bottom: 5px solid var(--border-color);
    background-color: #FFFFFF;
    opacity: 1 !important;
  }

  .neo-card:active,
  .neo-card.is-dragging {
    border-top-width: 1.5px !important;
    border-left-width: 1.5px !important;
    border-right-width: 1.5px !important;
    border-bottom-width: 1.5px !important;
    transform: translate(3.5px, 3.5px) rotate(var(--curr-rot, 0deg)) !important;
  }

  .card-inner {
    padding: 16px 14px;
    min-height: 245px;
    gap: 14px;
  }

  /* Exactly 3 lines max for bold description on mobile (never 2, never 4) */
  .card-title-link {
    font-size: 1.05rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: calc(1.05rem * 1.25 * 3);
  }

  /* ── Mobile Project Detail Modal ── */
  .modal-card {
    width: calc(100% - 32px);
    max-width: 400px;
    max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 18px 20px 18px;
    border-radius: 16px;
    box-shadow: 5px 5px 0px var(--border-color);
    gap: 14px;
  }

  .modal-title {
    font-size: 1.35rem;
    padding-right: 32px;
  }

  .modal-desc {
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .modal-actions {
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 6px;
  }

  .modal-action-btn {
    width: 100%;
    padding: 13px 16px;
    font-size: 0.95rem;
    justify-content: center;
  }

  .modal-close-btn {
    top: 16px;
    right: 16px;
    width: 34px;
    height: 34px;
  }
}

/* ── Ultra-compact phones (<= 380px) ── */
@media (max-width: 380px) {
  .app-container {
    padding: 14px 12px 12px 12px;
  }

  .mobile-tab-btn {
    font-size: 0.8rem;
    padding: 7px 6px;
  }

  .contact-card-wrapper {
    top: 195px;
    padding: 16px 14px;
    width: calc(100% - 24px);
  }

  .card-inner {
    padding: 14px 12px;
    min-height: 190px;
  }
}

/* ── Landscape Mobile Handheld ── */
@media (max-height: 520px) and (orientation: landscape) {
  .app-container {
    padding: 10px 16px;
    overflow-y: auto;
  }

  .contact-card-wrapper {
    top: 100px;
    bottom: 10px;
  }

  .modal-card {
    max-height: 94dvh;
    padding: 16px;
  }
}
