/* =====================================================
   Menu Guide Korea - Quality Enhancement Layer v1
   Phase 2: Micro-interactions, A11y, Responsive fixes
   Loaded after: style-improved.css, style-hero.css
   ===================================================== */

/* ============================================================
   0. SKIP NAVIGATION — keyboard accessibility
   Visually hidden until focused; moves keyboard users past header
   ============================================================ */
.skip-nav {
    position: absolute;
    top: -100%;
    left: var(--space-4, 1rem);
    z-index: 9999;
    padding: var(--space-3, 0.75rem) var(--space-6, 1.5rem);
    background: var(--color-primary, #C0392B);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
    text-decoration: none;
    transition: top 0.15s ease;
}

.skip-nav:focus {
    top: 0;
    outline: 3px solid var(--color-accent, #D4A017);
    outline-offset: 2px;
}

/* ============================================================
   1. SCROLL-DRIVEN SECTION ANIMATIONS
   Replaces eager load-time delays on below-fold sections.
   Chrome 115+, Firefox 110+, Safari 17.2+ (2026 safe)
   ============================================================ */
@supports (animation-timeline: view()) {
  .popular-dishes,
  .how-it-works,
  .features,
  .demo-section,
  .faq-section,
  .about-section,
  .app-disclaimer {
    animation: sq-reveal linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 22%;
  }

  /* Individual cards get their own view-driven entry */
  .step-card,
  .feature-card {
    animation: sq-reveal linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 30%;
  }

  @keyframes sq-reveal {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* ============================================================
   2. FAQ ACCORDION — SMOOTH OPEN ANIMATION
   @starting-style: Chrome 117+, Firefox 129+, Safari 17.5+
   Animates opacity+translate when [open] is added.
   ============================================================ */
@starting-style {
  details.faq-item[open] > .faq-answer {
    opacity: 0;
    transform: translateY(-6px);
  }
}

details.faq-item[open] > .faq-answer {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Smooth hover lift for FAQ items */
.faq-item {
  transition: box-shadow 0.2s ease, border-color 0.2s ease,
              transform 0.2s ease !important;
}

.faq-item:hover {
  transform: translateY(-1px) !important;
}

/* ============================================================
   3. SEARCH BUTTON — SPRINGY HOVER/ACTIVE
   ============================================================ */
.search-btn {
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.18s ease,
    background 0.18s ease !important;
}

.search-btn:hover {
  transform: translateY(-50%) scale(1.1) !important;
  background: linear-gradient(
    135deg,
    var(--color-primary-light) 0%,
    var(--color-primary) 100%
  ) !important;
}

.search-btn:active {
  transform: translateY(-50%) scale(0.93) !important;
  transition-duration: 0.07s !important;
}

/* ============================================================
   4. FEATURE CARD ICON — COLOR TRANSITION ON HOVER
   Extends the partial hover in style-hero.css
   ============================================================ */
.feature-icon-wrap {
  transition: background 0.22s ease !important;
}

.feature-icon-wrap .material-symbols-outlined {
  transition: color 0.22s ease;
}

.feature-card:hover .feature-icon-wrap {
  background: var(--color-primary) !important;
}

.feature-card:hover .feature-icon-wrap .material-symbols-outlined {
  color: white !important;
}

/* ============================================================
   5. FOCUS-VISIBLE — ACCESSIBLE KEYBOARD NAVIGATION
   Replaces default browser focus rings project-wide
   ============================================================ */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Remove focus ring on mouse/touch clicks */
:focus:not(:focus-visible) {
  outline: none;
}

/* Pill-shaped elements: tighter offset + full radius */
.lang-btn:focus-visible,
.dish-tag:focus-visible,
.hero-lang-item:focus-visible {
  outline-offset: 2px;
  border-radius: var(--radius-full);
}

.search-btn:focus-visible {
  border-radius: var(--radius-lg);
  outline-offset: 2px;
}

.faq-item > summary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

/* ============================================================
   6. PHOTO BUTTON — SPRINGY PRESS EFFECT
   ============================================================ */
.photo-btn {
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.photo-btn:active {
  transform: scale(0.96) !important;
  transition-duration: 0.07s !important;
}

/* ============================================================
   7. DISH TAGS — KEYBOARD FOCUS = HOVER STATE
   ============================================================ */
.dish-tag:focus-visible {
  background: var(--color-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
}

/* ============================================================
   8. BACK BUTTON — DIRECTION-AWARE HOVER
   ============================================================ */
.back-btn {
  transition: all 0.2s ease !important;
}

.back-btn:hover {
  transform: translateX(-3px) !important;
}

/* ============================================================
   9. STEP CARD — SPRINGY LIFT ON HOVER
   ============================================================ */
.step-card {
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease !important;
}

/* ============================================================
   10. DEMO CTA — SUBTLE PULSE ON TOUCH ICON
   ============================================================ */
.demo-cta .material-symbols-outlined {
  animation: cta-nudge 2.2s ease-in-out infinite;
  display: inline-block;
}

@keyframes cta-nudge {
  0%, 100% { transform: translateX(0); }
  40%       { transform: translateX(3px); }
  60%       { transform: translateX(-1px); }
}

/* ============================================================
   11. ABOUT STAT BOX — NUMBER SCALE ON HOVER
   ============================================================ */
.stat-box .stat-value {
  display: inline-block;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-box:hover .stat-value {
  transform: scale(1.1);
}

/* ============================================================
   12. 320px SMALL MOBILE — HERO MICRO-ADJUSTMENTS
   ============================================================ */
@media (max-width: 360px) {
  .hero-content {
    padding: 28px 16px 34px;
  }

  .hero-title {
    font-size: 1.72rem !important;
    letter-spacing: -0.02em;
  }

  .hero-subtitle {
    font-size: 0.875rem;
    margin-bottom: 20px;
    max-width: none;
  }

  .hero-eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    padding: 3px 11px;
  }

  .hero-lang-strip {
    gap: 5px;
  }

  .hero-lang-item {
    font-size: 0.68rem;
    padding: 3px 8px;
  }

  /* Compact search box on tiny screens */
  .menu-input {
    padding-left: var(--space-4);
    font-size: var(--text-base);
  }

  .language-selector {
    gap: var(--space-2);
  }

  .lang-btn {
    padding: var(--space-2) var(--space-3);
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .hero-wrapper {
    min-height: 320px;
  }

  .search-box {
    margin-top: var(--space-6) !important;
  }

  /* Compact section titles on small mobile */
  .section-title {
    font-size: var(--text-2xl) !important;
  }
}

/* ============================================================
   13. TABLET 768px — FEATURE GRID CONFIRMATION
   (style-improved.css already sets 2-col at 640px,
    but explicitly ensure 2-col layout between 640-1023px)
   ============================================================ */
@media (min-width: 640px) and (max-width: 1023px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
  }
}

/* ============================================================
   14. INLINE STYLE EXTRACTIONS — replaces scattered style=""
   ============================================================ */
.hint-icon {
    font-size: 15px;
    vertical-align: middle;
    margin-right: 3px;
    color: var(--color-accent);
}

.cta-icon {
    font-size: 16px;
    vertical-align: middle;
    margin-right: 4px;
}

.disclaimer-icon {
    font-size: 15px;
    vertical-align: middle;
    margin-right: 4px;
    color: var(--color-warning);
}

.attribution-icon {
    font-size: 14px;
    vertical-align: middle;
    margin-right: 3px;
}

/* Empty results state */
.empty-results {
    text-align: center;
    padding: var(--space-12, 3rem) var(--space-6, 1.5rem);
    grid-column: 1 / -1; /* span full grid width */
}

/* ============================================================
   16. REDUCED MOTION — OVERRIDE ALL ANIMATIONS
   Inherits from style-improved.css but adds sq-reveal + cta
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .demo-cta .material-symbols-outlined {
    animation: none;
  }

  .sq-reveal,
  details.faq-item[open] > .faq-answer {
    transition: none !important;
  }

  @supports (animation-timeline: view()) {
    .popular-dishes,
    .how-it-works,
    .features,
    .demo-section,
    .faq-section,
    .about-section,
    .app-disclaimer,
    .step-card,
    .feature-card {
      animation: none !important;
      opacity: 1 !important;
      transform: none !important;
    }
  }
}

/* ============================================================
   17. HOW IT WORKS — 수직 타임라인 (AI 3카드 패턴 해체)
   ============================================================ */
.section-title--left {
  justify-content: flex-start !important;
  text-align: left !important;
  padding-left: var(--space-6) !important;
}

.how-it-works .steps-container {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  max-width: 600px !important;
  margin: 0 0 0 var(--space-6) !important;
  position: relative;
}

/* 수직 연결선 */
.how-it-works .steps-container::before {
  content: '';
  position: absolute;
  left: 27px;
  top: 56px;
  bottom: 56px;
  width: 2px;
  background: linear-gradient(to bottom, var(--color-accent), rgba(212, 160, 23, 0.2));
  pointer-events: none;
}

/* CSS Grid: 숫자 왼쪽, 제목+설명 오른쪽 */
.how-it-works .step-card {
  display: grid !important;
  grid-template-columns: 56px 1fr !important;
  grid-template-rows: auto auto !important;
  gap: 0 var(--space-5) !important;
  text-align: left !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: var(--space-2) 0 var(--space-8) 0 !important;
}

.how-it-works .step-number {
  grid-column: 1;
  grid-row: 1 / 3;
  margin: 0 !important;
  background: white !important;
  border: 3px solid var(--color-accent) !important;
  color: var(--color-accent) !important;
  align-self: start;
}

.how-it-works .step-title {
  grid-column: 2;
  grid-row: 1;
  font-size: var(--text-xl) !important;
}

.how-it-works .step-description {
  grid-column: 2;
  grid-row: 2;
}

.step-arrow {
  display: none !important;
}

.how-it-works {
  background: transparent !important;
}

/* ============================================================
   18. FEATURES — Bento 비대칭 그리드 (4균등 그리드 해체)
   ============================================================ */
@media (min-width: 1024px) {
  .feature-grid {
    grid-template-columns: 1.4fr 1fr !important;
    grid-template-rows: auto auto !important;
  }

  [data-bento="hero"] {
    grid-row: 1 / 3;
    text-align: left;
    min-height: 280px;
    padding: var(--space-10) var(--space-8) !important;
  }

  [data-bento="hero"] .feature-icon-wrap,
  [data-bento="hero"] .feature-title,
  [data-bento="hero"] .feature-description {
    margin: 0;
    text-align: left;
  }

  [data-bento="sm"] {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-6) !important;
  }

  [data-bento="sm"] .feature-icon-wrap {
    margin: 0 !important;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
  }

  [data-bento="wide"] {
    grid-column: 1 / 3;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-6) var(--space-8) !important;
  }

  [data-bento="wide"] .feature-icon-wrap {
    margin: 0 !important;
    flex-shrink: 0;
  }
}

/* ============================================================
   19. ABOUT — 2컬럼 스플릿 레이아웃 + 2×2 stat 그리드
   ============================================================ */
.about-section {
  text-align: left !important;
}

.about-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

@media (min-width: 768px) {
  .about-body {
    flex-direction: row;
    align-items: center;
    gap: var(--space-12);
  }

  .about-text-col {
    flex: 1;
  }

  .about-stats {
    flex: 0 0 auto;
    width: 280px !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-3) !important;
  }
}

.about-stats {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: var(--space-3) !important;
}

.about-stats .stat-box {
  padding: var(--space-5) !important;
}

.about-stats .stat-value {
  font-size: var(--text-2xl) !important;
}

.about-description {
  margin: 0 !important;
  text-align: left;
}

/* ============================================================
   20. HOW IT WORKS — 계단식 버그 완전 수정
   ============================================================ */
.how-it-works .steps-container {
  align-items: stretch !important;
}

.how-it-works .step-card {
  width: 100% !important;
  box-sizing: border-box !important;
  align-items: start !important;
  margin: 0 !important;
}

@media (max-width: 767px) {
  .how-it-works .steps-container {
    margin-left: 0 !important;
    max-width: 100% !important;
    padding: 0 var(--space-4);
  }

  .how-it-works .steps-container::before {
    left: 19px;
  }
}

/* ============================================================
   21. ABOUT — DARK SECTION
   배경: #1A1A1A / 타이틀+본문: white / stat 숫자: Golden Amber
   ============================================================ */
.about-section {
  background: #1A1A1A !important;
  border-radius: var(--radius-2xl) !important;
  padding: var(--space-12) var(--space-8) !important;
}

.about-section .section-title,
.about-section .section-title--left {
  color: white !important;
  padding-left: 0 !important;
}

.about-section .about-description {
  color: rgba(255, 255, 255, 0.75) !important;
}

.about-section .stat-box {
  background: rgba(255, 255, 255, 0.07) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: none !important;
}

.about-section .stat-box:hover {
  background: rgba(255, 255, 255, 0.11) !important;
  box-shadow: 0 6px 24px rgba(212, 160, 23, 0.12) !important;
}

.about-section .stat-value {
  color: var(--color-accent) !important;
}

.about-section .stat-label {
  color: rgba(255, 255, 255, 0.6) !important;
}

@media (max-width: 480px) {
  .about-section {
    padding: var(--space-8) var(--space-5) !important;
    border-radius: var(--radius-xl) !important;
  }
}

/* ============================================================
   22. POPULAR DISHES — 좌측 정렬 (AI 피라미드 해체)
   ============================================================ */
.popular-dishes .dish-tags {
  justify-content: flex-start !important;
  margin: 0 !important;
  max-width: none !important;
}
