/* Mobile: Responsiveness, viewport lock, and small screen refinements */

/* 1. KUNCI GESER SAMPING (SEMUA UKURAN) */
body {
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

/* Browser modern: "clip" memotong luapan tanpa merusak scroll & sticky */
@supports (overflow-x: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

/* Media & elemen tidak boleh lebih lebar dari layar */
img, video, canvas, svg, iframe {
  max-width: 100%;
}

/* Teks panjang tanpa spasi (misal nama/URL) tetap patah ke baris baru */
h1, h2, h3, h4, p, blockquote, span, a, label {
  overflow-wrap: break-word;
}

.note-message,
.note-sender-name,
.thought-card-title,
.thought-detail-title,
.thought-detail-text {
  overflow-wrap: anywhere;
}

/* Cegah "grid blowout": isi grid tidak boleh mendorong lebar kolom */
.thoughts-grid > *,
.notes-grid > *,
.photobooth-container > *,
.frame-cards-grid > *,
.thoughts-controls > *,
.note-form-row > * {
  min-width: 0;
}

/* Menu HP yang tersembunyi di kanan layar tidak boleh menambah lebar halaman */
.mobile-menu {
  overflow: hidden;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility 0s linear 0.3s;
}

.mobile-menu.open {
  visibility: visible;
  transition: opacity var(--transition-base), visibility 0s;
}

.mobile-menu-content {
  width: min(280px, 82vw);
}

/* 2. TABLET & HP (≤ 768px) */
@media (max-width: 768px) {
  :root {
    --nav-height: 56px;
  }

  .container {
    padding-left: 18px;
    padding-right: 18px;
  }

  /* Navbar */
  .nav-container {
    padding: 0 18px;
  }

  .mobile-menu-content {
    padding: 72px 26px 32px;
  }

  .mobile-nav-link {
    font-size: 1rem;
    padding: 11px 0;
  }

  /* ── Pemikiran: grid 2 kolom ringkas seperti desktop ── */
  .thoughts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  /* Filter tema dibungkus rapi ke bawah, tidak digeser samping */
  .filter-pills {
    flex-wrap: wrap;
    overflow-x: visible;
    justify-content: center;
    padding-bottom: 0;
  }

  .search-box {
    min-width: 0;
    width: 100%;
  }

  .add-thought-row {
    justify-content: center;
    margin-bottom: 24px;
  }

  /* Pagination ringkas */
  .thoughts-pagination {
    margin-top: 28px;
    gap: 12px;
  }

  .pagination-controls {
    gap: 6px;
  }

  .pagination-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 12px;
    font-size: 0.78rem;
  }

  .pagination-slide-badge {
    font-size: 0.72rem;
    padding: 4px 12px;
  }

  .pagination-info {
    font-size: 0.74rem;
    text-align: center;
  }

  /* ── Catatan Pengunjung: dibagi menjadi 2 kolom di HP ── */
  .notes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .notes-info {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    margin-bottom: 16px;
  }

  .notes-max {
    font-size: 0.72rem;
  }

  .note-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.74rem;
  }

  .note-card-header {
    gap: 8px;
  }

  .note-pinned-badge {
    font-size: 0.6rem;
    padding: 2px 8px;
    gap: 4px;
  }

  .btn-send-note {
    width: 100%;
    justify-content: center;
    align-self: stretch;
  }

  /* Cegah iPhone zoom otomatis saat mengetik (font input wajib ≥ 16px) */
  input,
  select,
  textarea,
  .search-input,
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px !important;
  }

  /* ── Photobooth ── */
  .photobooth-container {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .camera-controls .btn-camera {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Petunjuk "template di samping" tidak relevan di HP (template ada di bawah) */
  .frame-selector-hint {
    display: none;
  }

  .frame-selector-header {
    margin-bottom: 10px;
  }

  .frame-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .frame-card-info {
    min-width: 0;
  }

  .frame-card-name,
  .frame-card-desc {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── Modal Baca Lengkap ── */
  .modal-overlay {
    padding: 14px;
    align-items: center;
  }

  .modal-content {
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .thought-detail-text {
    font-size: 0.95rem;
    line-height: 1.75;
    margin-bottom: 22px;
  }

  .thought-detail-number {
    margin-bottom: 14px;
  }

  .thought-detail-title {
    margin-bottom: 18px;
  }

  .thought-detail-meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  .thought-detail-actions {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
  }

  .btn-modal-action {
    padding: 7px 14px;
    font-size: 0.78rem;
  }

  /* Efek hover tidak perlu di layar sentuh (mencegah kartu "melompat") */
  .thought-card:hover,
  .note-card:hover,
  .frame-card:hover,
  .featured-thought:hover {
    transform: none;
  }
}

/* 3. HP STANDAR (≤ 480px) */
@media (max-width: 480px) {
  .container {
    padding-left: 14px;
    padding-right: 14px;
  }

  .nav-container {
    padding: 0 14px;
  }

  /* Hero */
  .hero {
    padding: 78px 14px 32px;
  }

  .hero-headline {
    font-size: 1.5rem;
  }

  .hero-subheadline {
    font-size: 0.85rem;
  }

  /* Section */
  .section {
    padding: 40px 0;
  }

  .section-header {
    margin-bottom: 22px;
  }

  .section-title {
    font-size: 1.32rem;
  }

  .section-subtitle {
    font-size: 0.8rem;
  }

  /* Kutipan Pilihan */
  .featured-thought {
    padding: 22px 16px;
    margin: 0 0 24px;
    border-radius: var(--radius-md);
  }

  .featured-label {
    font-size: 0.62rem;
    margin-bottom: 12px;
  }

  .featured-quote {
    font-size: 0.98rem;
    margin-bottom: 12px;
  }

  /* ── Kartu pemikiran tetap 2 kolom, dibuat mungil & rapi ── */
  .thoughts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .thought-card {
    padding: 14px 12px;
    gap: 6px;
    border-radius: var(--radius-sm);
  }

  .thought-card-top {
    gap: 4px;
  }

  .thought-card-tags {
    gap: 4px;
  }

  .thought-card-category {
    font-size: 0.58rem;
    letter-spacing: 0.04em;
  }

  .kholif-fav-badge {
    font-size: 0.54rem;
    padding: 1px 5px;
    gap: 2px;
  }

  .kholif-fav-badge svg {
    width: 8px;
    height: 8px;
  }

  .thought-card-number {
    font-size: 0.62rem;
  }

  .thought-card-title {
    font-size: 0.88rem;
    line-height: 1.32;
  }

  .thought-card-preview {
    font-size: 0.74rem;
    line-height: 1.45;
    -webkit-line-clamp: 3;
  }

  .thought-card-footer {
    padding-top: 8px;
    gap: 8px;
  }

  .thought-card-meta-row {
    gap: 4px;
  }

  .thought-card-date {
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .thought-card-read-hint {
    font-size: 0.66rem;
  }

  .thought-card-arrow {
    width: 11px;
    height: 11px;
  }

  .card-favorite-btn svg {
    width: 13px;
    height: 13px;
  }

  /* Pills filter */
  .pill {
    padding: 5px 11px;
    font-size: 0.72rem;
  }

  /* Catatan pengunjung: tetap 2 kolom berdampingan di layar HP */
  .notes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .note-form-container {
    padding: 18px 14px;
  }

  .note-card {
    padding: 12px 10px;
    gap: 7px;
  }

  .note-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.68rem;
  }

  .note-sender-name {
    font-size: 0.78rem;
    gap: 4px;
  }

  .note-owner-badge {
    font-size: 0.58rem;
    padding: 1px 6px;
  }

  .note-pinned-badge {
    font-size: 0.56rem;
    padding: 2px 7px;
    gap: 3px;
  }

  .note-time {
    font-size: 0.62rem;
  }

  .note-message {
    font-size: 0.76rem;
    line-height: 1.45;
    max-height: 120px;
  }

  .note-reactions {
    gap: 4px;
    padding-top: 6px;
  }

  .note-reaction-btn {
    padding: 2px 6px;
    font-size: 0.65rem;
    gap: 3px;
  }

  .reaction-emoji {
    font-size: 0.74rem;
  }

  .reaction-count {
    font-size: 0.64rem;
  }

  /* Photobooth */
  .camera-card,
  .frame-selector-box,
  .live-strip-card {
    padding: 14px 12px;
  }

  .btn-camera {
    padding: 9px 14px;
    font-size: 0.78rem;
  }

  /* Modal */
  .thought-detail-modal {
    padding: 44px 16px 20px;
  }

  .modal-nav {
    margin-bottom: 14px;
  }

  /* About */
  .about-title {
    font-size: 1.08rem;
  }

  .about-bio {
    font-size: 0.82rem;
  }

  /* Footer */
  .footer {
    padding: 36px 14px 24px;
  }
}

/* 4. HP SANGAT KECIL (≤ 350px) */
@media (max-width: 350px) {
  .thoughts-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .frame-card-desc {
    display: none;
  }

  .hero-headline {
    font-size: 1.35rem;
  }
}
