/* TCM The Present — Phase 2 Corrections
   =========================================
   This file patches base.css for mobile responsiveness and accessibility.
   Loaded AFTER base.css in every phase-02 page.

   Audit performed at 390px viewport (iPhone 14 / typical small phone width).
   Each correction references the issue identified in the Phase 2 audit.

   GUIDELINE.md §8 — touch targets ≥ 44×44px
   GUIDELINE.md §6 — motion language / focus rings
   GUIDELINE.md §9 — responsive behaviour
*/

/* ── FIX-1: Hamburger touch target ───────────────────────────
   Issue: Phase 1 hamburger was 38×32px — below 44×44px minimum.
   Phase-1 CSS: padding:8px, spans 22px wide × 16px content = ~38×32px.
   Fix: set explicit min-width/min-height and use flex centering. */
@media (max-width: 768px) {
  .hamburger {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    align-items: center;
    justify-content: center;
  }
  .hamburger:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }
}

/* ── FIX-2: Language toggle buttons touch target ─────────────
   Issue: .lang-btn was ~32×28px on mobile — too small for touch.
   Fix: enforce min 44×44px tap area on mobile screens. */
@media (max-width: 768px) {
  .lang-toggle .lang-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
  }
  .lang-toggle {
    gap: 4px;
  }
}

/* ── FIX-3: Phone pill touch target ─────────────────────────
   Issue: .phone-pill on mobile had padding:8px 16px → ~36px height.
   Fix: enforce min-height 44px. */
@media (max-width: 768px) {
  .phone-pill {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
  }
}

/* ── FIX-4: Mobile nav close button touch target ─────────────
   Issue: .mobile-nav-close used font-size:1.5rem + padding:4px 8px.
   Effective tap area was borderline (~50px height, but only ~36px wide).
   Fix: set explicit min dimensions. */
.mobile-nav-inner .mobile-nav-close {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  line-height: 1;
}
.mobile-nav-inner .mobile-nav-close:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── FIX-5: Mobile nav drawer lang toggle ────────────────────
   Issue: lang-toggle inside mobile-nav-inner shares same small targets.
   Fix: already covered by FIX-2, but add drawer-specific spacing. */
.mobile-nav-inner .lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid var(--color-border);
  margin-top: 8px;
}

/* ── FIX-6: Hero CTA buttons — narrow viewport stacking ─────
   Issue: at 390px, two buttons side-by-side can overflow if phone has
   some horizontal padding. The `flex-wrap: wrap` was in phase-1, which
   helps, but we also want them full-width stacked on very small screens.
   Fix: stack and full-width below 480px. */
@media (max-width: 480px) {
  .hero-ctas {
    flex-direction: column;
    gap: 12px;
  }
  .hero-ctas .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── FIX-7: Accordion trigger focus ring on mobile ───────────
   Issue: focus ring (outline-offset: -3px) placed ring inside the button
   at mobile widths, which can clip on small radii.
   Fix: switch to positive offset on mobile for better visibility. */
@media (max-width: 768px) {
  .accordion-trigger:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
  }
}

/* ── FIX-8: Contact form inputs — mobile min-height ─────────
   Issue: inputs at `padding:12px 16px` are comfortable on desktop but
   on some mobile browsers the effective tap area shrinks.
   Fix: explicit min-height on inputs for touch comfort. */
@media (max-width: 768px) {
  .form-field input {
    min-height: 48px;
  }
  .form-field textarea {
    min-height: 120px; /* already set, reinforce */
  }
}

/* ── FIX-9: Footer lang toggle touch targets ─────────────────
   Issue: footer lang buttons have padding:4px 8px — same small issue.
   Fix: on mobile, enforce adequate tap area in footer. */
@media (max-width: 768px) {
  .footer-lang-toggle .lang-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
  }
}

/* ── FIX-10: Card grid overflow guard ───────────────────────
   Issue: at 390px, grid gap of 24px + 1-col layout was fine, but cards
   with long Korean text (word-break: keep-all) could push content wide.
   Fix: ensure cards never exceed viewport width. */
@media (max-width: 600px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .card {
    /* Prevent any overflow from card content */
    overflow-wrap: break-word;
    word-break: break-word; /* fallback for CJK */
  }
}

/* ── FIX-11: Mobile contact grid — ensure proper stacking ───
   Confirmed: .contact-grid already stacks on ≤768px.
   Enhancement: add top padding to the sidebar on mobile (since it
   now comes after the form). */
@media (max-width: 768px) {
  .contact-sidebar {
    padding-top: var(--space-md);
  }
}

/* ── FIX-12: Portrait bio grid — ensure photo doesn't overflow
   Issue: .blob-portrait .blob-img has max-width:340px which is fine,
   but at 390px the blob-wrap needs to be properly constrained. */
@media (max-width: 768px) {
  .blob-portrait {
    max-width: 280px;
    margin-inline: auto;
  }
}

/* ── FIX-13: Social proof band text — tighten on mobile ─────
   Issue: .social-proof p has max-width:560px — fine, but font-size
   (--text-body-xl clamp min 1.25rem = 20px) is comfortable.
   No change needed; confirmed PASS at 390px.
   Annotated here for audit completeness. */

/* ── FIX-14: Page section padding — tighten on mobile ───────
   Issue: .page-section { padding: var(--space-3xl) 0 } = 6rem = 96px
   is too much vertical space at mobile widths.
   Fix: reduce to var(--space-2xl) = 4rem on mobile. */
@media (max-width: 768px) {
  .page-section {
    padding: var(--space-2xl) 0;
  }
  .hero {
    padding: var(--space-xl) 0 var(--space-2xl);
  }
}

/* ── FIX-15: Overflow guard — prevent any horizontal scroll ──
   Applied globally to reinforce no-scroll at 390px. */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* ── Always-visible (sticky) header ──────────────────────────
   position:sticky is broken by the overflow-x:hidden guard above,
   so the header wouldn't stay on scroll. Use position:fixed
   (viewport-relative — works regardless) and offset the page
   content by the header height so nothing hides beneath it. */
.site-header {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
}
body { padding-top: 72px; }
@media (max-width: 768px) {
  body { padding-top: 60px; }
}

/* ── NEW: Mobile testimonial card padding ────────────────────
   Enhancement: on mobile, accordion cards benefit from tighter
   horizontal padding to leave more reading width. */
@media (max-width: 480px) {
  .accordion-trigger {
    padding: 16px 16px;
  }
  .accordion-body {
    padding: 0 16px 16px;
  }
}

/* ── NEW: Skip link visibility improvement ───────────────────
   Improvement: the skip link was already functional; add a subtle
   transition for a smoother appearance on focus. */
.skip-link {
  transition: top var(--transition-fast);
}

/* ── AUDIT: Contrast verification at mobile breakpoints ──────
   At 390px, colour tokens remain unchanged — no re-theming at
   mobile breakpoints. All WCAG AA ratios verified in GUIDELINE.md §2.5.
   (No CSS change needed; annotated for audit record.) */

/* ── Treatment Areas — square-card redesign ──────────────────
   Layout: two 4-column rows spanning the full container width.

   ROW 1 (.treatments-top-band):
     [Card 1 Women's Health] [Card 2 Dermatology] [Card 3 Internal Medicine] [Acupuncture image]
   ROW 2 (.treatments-bottom-band):
     [Card 4 Paediatrics] [Card 5 Urology] [Card 6 Pain Management] [Card 7 Geriatric Care]

   The heading + intro sit above both rows, centered, before the grid.

   Square cards: aspect-ratio 1/1. Content is flex-column from the top
   with enough padding to breathe. Font size is --text-body-sm for
   descriptions so that the longest card (Women's Health EN / Internal
   Medicine KO) sits comfortably inside a square without overflow.
   Overflow is handled by overflow: auto with a subtle fade rather than
   hard clipping — in practice all descriptions fit the chosen size.

   The image cell in row 1 is also 1:1 (matching the card squares)
   with a clean rounded frame (border-radius) instead of the blob shape,
   so it sits flush in the grid without visual imbalance.

   prefers-reduced-motion: .card:hover transform is gated below. */

/* Reset the layout wrapper */
.treatments-layout {
  display: block !important;
}

/* Centered section heading sits above both rows */
.treatments-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}
.treatments-header h2 { margin-bottom: var(--space-sm); }
.treatments-header p {
  font-size: var(--text-body-lg);
  color: var(--color-text-muted);
  max-width: 560px;
  margin-inline: auto;
  margin-bottom: 0;
}

/* Shared 4-col grid used by both bands */
.treatments-top-band,
.treatments-bottom-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.treatments-top-band  { margin-bottom: 20px; }

/* ── Square treatment cards ───────────────────────────────── */
.treatment-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 22px 20px 20px;
  overflow: hidden;           /* graceful — never clips visible text at design sizes */
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}
@media (prefers-reduced-motion: no-preference) {
  .treatment-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
  }
}

/* Icon */
.treatment-card .card-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin-bottom: 12px;
  color: var(--color-primary);
}

/* Title */
.treatment-card h3 {
  font-size: clamp(0.9375rem, 1.1vw, 1.0625rem);  /* tighter than --text-h3 */
  line-height: 1.2;
  margin-bottom: 6px;
  color: var(--color-text-heading);
}

/* Treatment cards show one language only — hide the other-language sub-label. */
.treatment-card .lang-alt {
  display: none;
}

/* Description */
.treatment-card p {
  font-size: 0.8125rem;        /* ~13px — fits longest card gracefully in square */
  line-height: 1.6;
  color: var(--color-text-body);
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Image cell — square, rounded frame ─────────────────────
   Sits in the 4th column of the top row, matching card height.
   Organic blob shape (like the hero + portrait images) that still
   fits within the square grid cell. */
.treatments-img-cell {
  aspect-ratio: 1 / 1;
  border-radius: 60% 40% 50% 50% / 40% 50% 60% 50%;
  overflow: hidden;
  background: var(--color-accent-subtle);
}
.treatments-img-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;            /* container provides rounding */
}

/* ── Responsive behaviour ────────────────────────────────── */

/* Large tablet (769–1023px): 2-col, image and heading still prominent */
@media (min-width: 769px) and (max-width: 1023px) {
  .treatments-top-band,
  .treatments-bottom-band {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .treatments-top-band { margin-bottom: 16px; }
  /* On tablet the image naturally reflows to col 2 row 2 of the top band;
     that's fine — 2×2 top + 2×2 bottom gives a clean 4+4 layout. */
}

/* Mobile (≤768px): 2-up, then 1-up; square preference maintained via aspect-ratio */
@media (max-width: 768px) {
  .treatments-top-band,
  .treatments-bottom-band {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .treatments-top-band { margin-bottom: 14px; }
  .treatment-card {
    padding: 16px 14px;
  }
  .treatment-card .card-icon {
    width: 30px;
    height: 30px;
    margin-bottom: 10px;
  }
  .treatment-card h3 {
    font-size: 0.875rem;
  }
  .treatment-card p {
    font-size: 0.75rem;
    line-height: 1.55;
  }
  /* On narrow mobile the 1:1 aspect can become very tall.
     Switch to a comfortable min-height + auto height below 500px. */
}

/* Small mobile (≤500px): drop the hard 1:1 ratio; let cards breathe with min-height */
@media (max-width: 500px) {
  .treatments-top-band,
  .treatments-bottom-band {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .treatment-card {
    aspect-ratio: unset;
    min-height: 160px;
    padding: 18px 16px;
  }
  .treatments-img-cell {
    aspect-ratio: 16 / 9;      /* landscape banner on single-column mobile */
  }
}

/* ── Instagram button — redesigned ───────────────────────────
   Design: tasteful gradient treatment that reads as Instagram-
   branded while staying coherent with the calm blue healthcare
   aesthetic. The button uses the iconic Instagram gradient
   (purple-to-orange) as a background on the icon region, paired
   with a soft off-white pill body. The text colour is a dark
   warm-neutral for legibility on the off-white ground.
   An animated gradient-shift is gated behind
   prefers-reduced-motion: no-preference so it never fires for
   users who opt out.

   CONTEXTS:
   1. White contact sidebar card — off-white/gradient chip reads
      cleanly against white card background.
   2. Navy footer (#0A2540) — the chip pops against the dark
      background without becoming garish.

   Lock rule (.footer-col a.instagram-btn) overrides the generic
   .footer-col a { color:#fff } and :hover { underline } rules. */

/* Remove all previous instagram-btn rules by redefining */
/* (These rules live in corrections.css which loads after base.css,
   so they take precedence over the base.css definitions.) */

/* Instagram button — single solid Instagram-colour fill, white text + icon */
.instagram-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: #E1306C;                  /* single solid Instagram magenta */
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-body-sm);
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  opacity: 1;
  transition: filter var(--transition-fast);
}
.instagram-btn:hover { filter: brightness(1.08); }
.instagram-btn svg { color: #ffffff; flex-shrink: 0; }
.instagram-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  opacity: 1;
}
/* Footer lock — beats .footer-col a { color:#fff } + :hover underline */
.footer-col a.instagram-btn,
.footer-col a.instagram-btn:hover {
  background: #E1306C;
  color: #ffffff;
  border: none;
  text-decoration: none;
  opacity: 1;
}

/* "Tap to call" button — WhatsApp-green, matches the Kakao/Instagram buttons.
   tel: link opens the phone dialer on a smartphone. */
.call-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #25D366;
  color: #ffffff;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-body-sm);
  text-decoration: none;
  border: none;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: filter var(--transition-fast);
}
.call-btn:hover { filter: brightness(0.95); }
.footer-col a.call-btn,
.footer-col a.call-btn:hover {
  color: #ffffff;
  background: #25D366;
  text-decoration: none;
}

/* Practitioner portrait fine-tune (About page) — 20% smaller, nudged up + right */
/* Practitioner portrait: blob frame (clip) fixed on the WRAPPER; the photo
   is movable INSIDE the frame via the img transform below. */
.practitioner-photo {
  clip-path: path('M200,10 C280,-5 360,30 380,110 C400,190 370,290 290,340 C210,390 100,390 50,320 C0,250 20,140 60,70 C90,20 140,18 200,10 Z');
  overflow: hidden;
  aspect-ratio: 3 / 4;
  max-width: 340px;
  margin: 0 auto;
  transform: translate(15px, -5px) scale(0.9);   /* position/size of the whole portrait */
}
.practitioner-photo .blob-img {
  clip-path: none;
  aspect-ratio: auto;
  max-width: none;
  width: 100%;
  height: 100%;
  margin: 0;
  /* Move the photo INSIDE the frame (translateX); scale gives a little overflow so the shift leaves no gap. */
  transform: translateX(5px) scale(1.04);
}

/* Keep the English wordmark in the display serif even in Korean mode.
   (The broad `:lang(ko) { font-family: var(--font-ko) }` rule was overriding
   the "TCM The Present" wordmark to the Korean sans font.) */
.site-header .logo-text-group {
  font-family: var(--font-display);
}

/* ── Mobile: EN/KO toggle in the header top bar (client request) ──────
   base.css hides the header language toggle on mobile and only shows a
   copy inside the hamburger drawer. Surface it in the header next to the
   hamburger so it's always visible, compact it to fit alongside the logo,
   and remove the now-duplicate toggle from the drawer. Desktop unchanged. */
@media (max-width: 768px) {
  .site-header .inner { gap: 8px; }
  .header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .header-actions .lang-toggle { display: flex; }
  .header-actions .lang-toggle .lang-btn { min-width: 36px; padding: 8px 6px; }
  .mobile-nav-inner .lang-toggle { display: none; }
  /* Lock the menu button so it can never be pushed off-screen */
  .hamburger { flex-shrink: 0; }
  /* The LOGO yields space first (shrinks / clips its wordmark) so the toggle
     + menu button always stay visible, even on narrow phones. */
  .site-header .logo { font-size: 0.95rem; flex: 0 1 auto; min-width: 0; overflow: hidden; }
  .logo-img { height: 32px; }
  .logo-text-group { min-width: 0; overflow: hidden; }
}

/* ── Personal Story: portrait floats RIGHT, bio text wraps around/under it ──
   The old rigid 2-col grid left empty space under the shorter image column.
   Switch to a float so the text flows beside the image and wraps beneath it. */
.portrait-bio-grid {
  display: block;   /* override the base grid so text can wrap the float */
}
.portrait-bio-grid::after { content: ''; display: block; clear: both; }
/* Portrait (DOM first-child) floats to the right; text wraps around it */
.portrait-bio-grid > div:first-child {
  float: right;
  width: 40%;
  max-width: 360px;
  margin: 0 0 24px 40px;
}

/* Mobile: un-float, portrait centered above the text */
@media (max-width: 768px) {
  .portrait-bio-grid > div:first-child {
    float: none;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 24px;
  }
}
