/* ==========================================================================
   TD-BUILD.COM - Premium Mobile Responsive & Fluid Typography System
   Design Principles:
   - 100% full text visibility across ALL screen sizes (No truncation / No word cutoffs)
   - Graceful phrase-level Thai line wrapping
   - Fluid typography with CSS clamp()
   - Multi-tier breakpoints: 1200px, 1024px, 768px, 480px, 400px, 360px, 320px
   ========================================================================== */

/* Global layout safeguards */
html, body {
  overflow-x: clip;
  max-width: 100vw;
}

/* Phrase line break control - keeps Thai phrases together naturally */
.title-phrase {
  display: inline-block;
  white-space: nowrap;
}

.title-highlight {
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ==========================================
   1. LARGE DESKTOPS & LAPTOPS (Max 1200px)
   ========================================== */
@media (max-width: 1200px) {
  .hero-title {
    font-size: 2.5rem;
  }
  
  .footer-grid {
    grid-template-columns: 1.2fr 1fr 1fr 1.2fr;
    gap: 28px;
  }
}

/* ==========================================
   2. TABLET LANDSCAPE (Max 1024px)
   ========================================== */
@media (max-width: 1024px) {
  .nav-menu, 
  .header-phone {
    display: none !important;
  }
  
  .menu-toggle {
    display: flex !important;
  }
  
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 35px;
  }
  
  .hero {
    padding: 45px 0 65px;
  }
  
  .hero-card-box,
  .fast-contact-box {
    max-width: 580px;
    margin: 0 auto;
    width: 100%;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  
  .stat-item:nth-child(2)::after {
    display: none;
  }
  
  .services-grid,
  .portfolio-grid,
  .reviews-grid,
  .guarantee-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
  
  .process-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px 20px;
  }
  
  .why-grid {
    grid-template-columns: 1fr;
    gap: 35px;
  }
  
  .why-image-badge {
    position: static;
    margin-top: -20px;
    margin-left: 20px;
  }
  
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 35px;
  }
  
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 30px;
  }
}

/* ==========================================
   3. TABLET PORTRAIT & MOBILE (Max 768px)
   ========================================== */
@media (max-width: 768px) {
  /* Container padding */
  .container {
    padding: 0 14px;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Top Announcement Bar */
  .top-bar {
    padding: 5px 0;
  }

  .top-bar-left {
    display: none !important;
  }
  
  .top-bar .container {
    padding: 0 10px;
    justify-content: center;
  }

  .top-bar-right {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 14px;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
  }

  .top-bar-item {
    font-size: 0.74rem;
    gap: 5px;
  }

  /* Header Navigation */
  .header {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    left: 0;
    width: 100%;
    z-index: 1000 !important;
  }

  .header .container {
    height: 60px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 1;
    min-width: 0;
  }

  .logo-icon-circle {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 2px;
    flex-shrink: 0;
  }

  .logo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
  }

  .logo-brand-en {
    font-size: clamp(0.68rem, 2.8vw, 0.80rem);
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -0.15px;
    color: #FFFFFF;
  }

  .logo-brand-th {
    font-size: clamp(0.55rem, 2.2vw, 0.65rem);
    font-weight: 400;
    white-space: nowrap;
    color: #CBD5E1;
    margin-top: 1px;
  }

  .logo-brand {
    font-size: 0.78rem;
  }

  .logo-tagline {
    display: none;
  }

  .header-action {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: auto;
  }

  .header-action .btn,
  .btn-header-cta {
    padding: 5px 8px;
    font-size: clamp(0.66rem, 2.4vw, 0.74rem);
    font-weight: 600;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    gap: 4px;
    flex-shrink: 0;
  }

  .header-action .btn i,
  .btn-header-cta i {
    font-size: 0.84rem;
  }

  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
    color: var(--text-white);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
  }

  /* Section Spacing & Typography */
  .section {
    padding: 48px 0;
  }

  .section-sm {
    padding: 30px 0;
  }
  
  .section-title {
    font-size: clamp(1.40rem, 5vw, 1.65rem);
    line-height: 1.35;
    margin-bottom: 10px;
  }

  .section-desc {
    font-size: clamp(0.86rem, 3vw, 0.92rem);
    line-height: 1.6;
  }

  .section-badge {
    font-size: 0.75rem;
    padding: 4px 12px;
    margin-bottom: 8px;
  }

  /* Hero Section */
  .hero {
    padding: 38px 0 48px;
    min-height: auto;
  }

  .hero-badge {
    font-size: clamp(0.70rem, 2.6vw, 0.78rem);
    padding: 4px 10px;
    margin-bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
    max-width: 100%;
    text-align: center;
  }
  
  .hero-title {
    font-size: clamp(1.40rem, 5.2vw, 1.75rem);
    line-height: 1.35;
    margin-bottom: 12px;
  }
  
  .hero-desc {
    font-size: clamp(0.86rem, 3vw, 0.92rem);
    line-height: 1.65;
    margin-bottom: 20px;
  }
  
  .hero-buttons {
    flex-direction: column;
    width: 100%;
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .hero-buttons .btn {
    width: 100%;
    padding: 11px 16px;
    font-size: 0.90rem;
  }

  .hero-features {
    gap: 10px;
    padding-top: 14px;
  }

  .hero-feature-item {
    font-size: clamp(0.80rem, 2.8vw, 0.85rem);
    line-height: 1.45;
  }

  /* Page Hero Banner for Inner Pages */
  .page-hero-title,
  section.section-dark.section-sm h1 {
    font-size: clamp(1.40rem, 5.2vw, 1.75rem) !important;
    line-height: 1.3;
    margin-bottom: 8px !important;
  }

  .page-hero-desc,
  section.section-dark.section-sm p {
    font-size: clamp(0.86rem, 3vw, 0.92rem) !important;
    line-height: 1.6;
    margin-bottom: 12px !important;
  }

  /* Fast Contact Card / Hero Box */
  .hero-card-box,
  .fast-contact-box,
  .fast-contact-box-light,
  .contact-card-box {
    padding: 20px 16px !important;
    border-radius: var(--radius-lg);
  }

  .fast-contact-title,
  .fast-contact-title-light,
  .hero-card-box h3,
  .contact-card-box h3 {
    font-size: clamp(1.15rem, 4.5vw, 1.30rem) !important;
    margin-bottom: 6px;
    line-height: 1.3;
  }

  .fast-contact-desc,
  .fast-contact-desc-light,
  .hero-card-box p,
  .contact-card-box p {
    font-size: 0.84rem !important;
    line-height: 1.5;
    margin-bottom: 14px;
  }

  .btn-direct-line,
  .btn-direct-call,
  .btn-direct-fb,
  .btn-direct-tiktok {
    padding: 10px 12px !important;
    font-size: 0.86rem !important;
    gap: 7px !important;
    width: 100% !important;
  }

  /* Grids */
  .services-grid,
  .portfolio-grid,
  .reviews-grid,
  .guarantee-grid,
  .process-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .service-card,
  .portfolio-card,
  .guarantee-card {
    padding: 18px 16px;
  }

  .service-card-title,
  .portfolio-title {
    font-size: 1.12rem;
    line-height: 1.35;
  }

  .service-card-desc,
  .portfolio-desc {
    font-size: 0.86rem;
    line-height: 1.6;
  }

  /* Form Elements */
  .form-group label {
    font-size: 0.86rem;
  }

  .form-control {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .footer-col-title {
    font-size: 1.05rem;
    margin-bottom: 12px;
  }

  .footer-links a,
  .footer-contact-item {
    font-size: 0.86rem;
  }
}

/* ==========================================
   4. ULTRA COMPACT PHONES (Max 360px & 320px)
   ========================================== */
@media (max-width: 360px) {
  .container {
    padding: 0 10px;
  }

  .header .container {
    height: 56px;
    padding: 0 8px;
    gap: 4px;
  }

  .logo-icon-circle {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }

  .logo-brand-en {
    font-size: 0.68rem;
    letter-spacing: -0.2px;
  }

  .logo-brand-th {
    font-size: 0.56rem;
  }

  .header-action .btn,
  .btn-header-cta {
    padding: 4px 6px;
    font-size: 0.65rem;
    gap: 2px;
  }

  .menu-toggle {
    width: 28px;
    height: 28px;
    font-size: 1.15rem;
  }

  .top-bar-right {
    font-size: 0.70rem;
    gap: 2px 8px;
  }
}
