/* ==========================================================================
   responsive.css
   Mobile and tablet refinements.

   IMPORTANT: every rule in this file lives inside a `max-width` media query.
   Nothing here can affect the desktop layout -- above 1024px this stylesheet
   contributes no rules at all. Load it LAST.
   ========================================================================== */

/* --------------------------------------------------------------------------
   TABLET  (<= 1024px)
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {

  /* The news rows hold a fixed-width arrow that overflows once the
     available width drops below the desktop container. */
  .news-content,
  .news-item {
    min-width: 0;
    max-width: 100%;
  }
  .news-title {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Multi-column grids reflow instead of squeezing. */
  .services-grid,
  .concept-cards,
  .facility-grid,
  .choose-grid,
  .effects-list,
  .flow-list,
  .clinic-checklist,
  .acu-checklist,
  .footer-main-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
  }

  /* Side-by-side text/image blocks get a little breathing room. */
  .about-container,
  .concept-container,
  .price-container,
  .staff-container,
  .facility-container,
  .faq-container,
  .news-container {
    gap: 32px;
  }
}

/* --------------------------------------------------------------------------
   SMALL TABLET / LARGE PHONE  (<= 900px)
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {

  /* Consistent page gutter everywhere.
     The footer sets its own padding, so exclude it -- otherwise the gutter
     is applied twice and the content box ends up wider than the screen. */
  section,
  [class$="-section"],
  [class*="-container"]:not(.footer-container) {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Grid and flex children default to min-width:auto, which lets a wide
     descendant (the 9-column hours table, a map iframe) push the whole
     column past the viewport. This is the fix for that. */
  .footer-main-grid > *,
  .footer-nav > *,
  .services-grid > *,
  .concept-cards > *,
  .facility-grid > *,
  .choose-grid > *,
  .hours-card,
  .map-box,
  main > section > * {
    min-width: 0;
  }

  /* Vertical rhythm: the desktop spacing is far too tall on a phone. */
  section,
  [class$="-section"] {
    padding-top: 56px;
    padding-bottom: 56px;
  }

  /* Any remaining two-column flex layout stacks. */
  .about-container,
  .concept-container,
  .price-container,
  .staff-container,
  .facility-container,
  .news-container,
  .accident-container,
  .beauty-container,
  .athlete-container,
  .choose-container,
  .consult-container,
  .counseling-container,
  .clinic-container,
  .acu-container,
  .flow-container,
  .effects-container {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Images and media never exceed the column. */
  .about-tsurumaru-image,
  .concept-image-wrapper,
  .director-image-wrapper,
  .facility-image-wrapper,
  .accident-image-box,
  .beauty-image-box,
  .athlete-image-box,
  .choose-image-box,
  .consult-image-box,
  .doctor-photo-box,
  .counseling-image-wrapper,
  .after-accident-image-wrapper,
  .card-img-box {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    float: none !important;
  }

  /* The philosophy circle composition is an absolutely-positioned collage
     sized in fixed pixels. It must NOT be swept up in the blanket
     `width: 100%` rule above -- that forced every circle to the column width
     and made them overlap and crop hard. Lay them out as a simple grid
     instead, which scales cleanly and cannot collide. */
  .philosophy-graphics {
    position: static !important;
    height: auto !important;
    max-width: 460px !important;
    margin: 0 auto !important;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    place-items: center;
  }
  .philosophy-graphics .circle-img-box {
    position: static !important;
    width: 100% !important;
    max-width: 200px !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
  }

  /* Absolutely-positioned decorations are a desktop luxury: they overlap
     badly once the layout stacks, so return them to normal flow. */
  .decoration,
  .deco,
  .floating-shape,
  .bg-shape {
    position: static !important;
    display: none;
  }
}

/* --------------------------------------------------------------------------
   PHONE  (<= 768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {

  /* ---- Typography: fluid, never smaller than legible ---- */

  h1, .banner-title-en, .hero-title {
    font-size: clamp(26px, 7.5vw, 40px) !important;
    line-height: 1.3 !important;
  }
  h2, .title-en, .concept-title-en, .news-title-en, .facility-title {
    font-size: clamp(22px, 6.4vw, 32px) !important;
    line-height: 1.35 !important;
  }
  h3, .card-title, .flow-card-title, .facility-item-title {
    font-size: clamp(16px, 4.6vw, 20px) !important;
    line-height: 1.45 !important;
  }
  .title-jp, .banner-title-jp {
    font-size: clamp(13px, 3.8vw, 16px) !important;
  }

  /* Body copy: 15px minimum so it is comfortable to read on a phone. */
  p, li, td, .card-desc, .reserve-desc, .card-text,
  .flow-card-desc, .facility-item-text {
    font-size: 15px !important;
    line-height: 1.85 !important;
  }

  /* Japanese text wraps mid-word by default, which reads badly.
     Break on natural boundaries instead. */
  p, li, h1, h2, h3, .card-title, .card-desc {
    word-break: normal;
    overflow-wrap: anywhere;
    line-break: strict;
  }

  /* ---- Layout ---- */

  .services-grid,
  .concept-cards,
  .facility-grid,
  .choose-grid,
  .effects-list,
  .flow-list,
  .clinic-checklist,
  .acu-checklist,
  .footer-main-grid,
  .footer-nav {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  section,
  [class$="-section"] {
    padding-top: 48px;
    padding-bottom: 48px;
  }

  /* ---- Hero ---- */

  .hero {
    height: auto !important;
    min-height: 78vh !important;
  }
  .hero-banner {
    min-height: 220px !important;
    padding-top: 24px !important;
    padding-bottom: 40px !important;
  }
  .hero-content {
    padding: 0 20px !important;
  }

  /* The homepage catchphrase is set vertically. Vertical Japanese text does
     not fit a phone screen -- switch it back to horizontal. */
  .catchphrase {
    writing-mode: horizontal-tb !important;
    -webkit-writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    position: static !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 0 12px !important;
    padding: 0 20px !important;
    font-size: clamp(18px, 5.4vw, 26px) !important;
    line-height: 1.7 !important;
    letter-spacing: 0.02em !important;
  }

  /* Hero contents sit as a bottom-aligned stack rather than floating
     over the middle of the photograph. */
  .hero {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-end !important;
    align-items: stretch !important;
    padding-bottom: 34px !important;
  }
  .hero > .catchphrase { order: 1; }
  .hero > .location-badge { order: 2; }

  .location-badge {
    position: static !important;
    display: block;
    margin: 0 !important;
    padding: 0 20px;
    font-size: 11px !important;
    line-height: 1.6 !important;
    text-align: left;
    white-space: normal !important;
  }

  /* ---- Tables ---- */

  /* Wide tables scroll rather than crushing their columns.
     main.js wraps every table in .table-scroll. */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-inline: -20px;
    padding-inline: 20px;
  }
  .table-scroll > table {
    min-width: 520px;
  }
  /* ---- Restack data tables as cards ----
     A 3-column price table forced into 520px means either a sideways scroll
     or columns so narrow that every heading wraps mid-word. Neither is
     acceptable on a phone, so each row becomes its own card and each value
     is labelled with its column heading (added by main.js). */
  .price-table,
  .menu-table,
  .treatment-table,
  .traffic-table,
  .related-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
  }

  .price-table thead,
  .menu-table thead,
  .treatment-table thead,
  .traffic-table thead,
  .related-table thead {
    /* Headings now live on each cell, so hide the header row -- but keep it
       reachable for screen readers rather than display:none. */
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .price-table tbody,
  .menu-table tbody,
  .treatment-table tbody,
  .traffic-table tbody,
  .related-table tbody { display: block !important; width: 100%; }

  .price-table tr,
  .menu-table tr,
  .treatment-table tr,
  .traffic-table tr,
  .related-table tr {
    display: block !important;
    width: 100%;
    margin-bottom: 14px;
    padding: 6px 0;
    background: #fff;
    border: 1px solid #eee7d9;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  }

  .price-table td,
  .menu-table td,
  .treatment-table td,
  .traffic-table td,
  .related-table td {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100% !important;
    padding: 11px 16px !important;
    border: 0 !important;
    border-bottom: 1px solid #f4f0e6 !important;
    text-align: right !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
  }
  .price-table tr td:last-child,
  .menu-table tr td:last-child,
  .treatment-table tr td:last-child,
  .traffic-table tr td:last-child,
  .related-table tr td:last-child { border-bottom: 0 !important; }

  /* The column heading, printed in front of its value. */
  .has-labels td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 40%;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: #8a8271;
    letter-spacing: 0.02em;
  }

  /* The first cell is the row's subject -- give it more presence. */
  .price-table td:first-child,
  .menu-table td:first-child,
  .treatment-table td:first-child,
  .traffic-table td:first-child,
  .related-table td:first-child {
    justify-content: flex-start;
    text-align: left !important;
    font-weight: 700;
    font-size: 14.5px !important;
    background: #fcfaf5;
  }
  .price-table td:first-child::before,
  .menu-table td:first-child::before,
  .treatment-table td:first-child::before,
  .traffic-table td:first-child::before,
  .related-table td:first-child::before { display: none; }

  /* Icons sat in their own narrow column; inline them with the label. */
  .price-table td .menu-icon-circle,
  .menu-table td .menu-icon-circle,
  .treatment-table td .icon-wrapper,
  .related-table td .icon-wrapper {
    margin: 0 10px 0 0 !important;
  }

  /* These are now cards, not a wide table -- nothing left to scroll. */
  .table-scroll:has(.price-table),
  .table-scroll:has(.menu-table),
  .table-scroll:has(.treatment-table),
  .table-scroll:has(.traffic-table),
  .table-scroll:has(.related-table) {
    overflow-x: visible;
    margin-inline: 0;
    padding-inline: 0;
  }
  .price-table th, .price-table td,
  .menu-table th, .menu-table td,
  .menu-cell, .desc-cell {
    padding: 12px 10px !important;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
  }
  .menu-icon-circle,
  .icon-wrapper {
    width: 34px !important;
    height: 34px !important;
  }

  /* The opening-hours grid is genuinely 9 columns -- keep it scrollable. */
  .hours-scroll {
    margin-inline: 0;
    padding-inline: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .hours-table {
    min-width: 300px;
    font-size: 11px;
  }
  .hours-table th,
  .hours-table td { padding: 7px 2px !important; }

  /* ---- Cards ---- */

  .service-card,
  .concept-card,
  .facility-card,
  .clinic-card,
  .acu-card,
  .flow-card,
  .director-card {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Hover lift is meaningless on touch and can leave cards stuck raised. */
  .service-card:hover,
  .concept-card:hover,
  .facility-card:hover,
  .clinic-card:hover,
  .acu-card:hover,
  .flow-card:hover,
  .director-card:hover {
    transform: none;
    box-shadow: none;
  }

  /* ---- Buttons and touch targets ---- */

  /* 44px is the minimum comfortable tap target. */
  .btn-pill,
  .btn-pill1,
  .btn-blue-reserve,
  .category-btn,
  .faq-question-btn,
  .mobile-nav__link,
  .mobile-nav__cta {
    min-height: 48px;
  }
  .btn-pill,
  .btn-pill1 {
    width: 100% !important;
    max-width: 100% !important;
  }
  .btn-label { font-size: 14px !important; }

  /* Category filters wrap instead of overflowing. */
  .category-list {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .category-btn {
    padding: 10px 16px !important;
    font-size: 13px !important;
  }

  /* ---- FAQ ---- */

  .faq-question-btn {
    padding: 16px 14px !important;
    gap: 12px !important;
  }
  .faq-question-text {
    font-size: 14.5px !important;
    line-height: 1.6 !important;
    text-align: left !important;
  }
  .faq-answer-wrapper,
  .faq-answer-panel {
    font-size: 14px !important;
    line-height: 1.8 !important;
  }

  /* ---- News ---- */

  .news-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    padding: 16px 0 !important;
  }
  .news-title { font-size: 14.5px !important; line-height: 1.6 !important; }
  .news-date  { font-size: 12px !important; }
  .news-arrow { display: none; }

  /* ---- Draggable carousels ---- */

  /* Turn the JS drag slider into a native touch-scroller on phones: far
     smoother, and it cannot get stuck mid-drag. This targets ONLY the
     orthopedic-page marquee (.slider-card cards inside .slider-section).

     It must NOT touch #sliderViewport / #sliderTrack -- that id pair is
     the facility-section image carousel on the homepage, which is driven
     entirely by buildCarousel() in main.js (drag + arrow buttons + dots,
     all working off track.style.transform). Forcing overflow-x:auto and
     transform:none here used to leak onto that carousel too and silently
     kill it dead on phones: the arrows/dots would render (they're built
     by JS) but tapping them did nothing, because the !important transform
     override left the track pinned in place, and the forced overflow
     also exposed a native scrollbar the desktop version never shows. */
  .slider-card {
    scroll-snap-align: start;
    flex: 0 0 78%;
  }

  /* ---- Footer ---- */

  .site-footer { padding: 44px 20px 28px !important; }
  .reserve-buttons { width: 100% !important; }
  .map-box { height: 240px !important; }
  .footer-bottom {
    flex-direction: column-reverse !important;
    align-items: flex-start !important;
    gap: 12px !important;
    font-size: 11px !important;
  }

  /* ---- Misc ---- */

  /* Decorative SVG curves get shallow so they do not eat screen height. */
  .hero-bottom-curve { height: 40px !important; }
  .hero-bottom-curve svg { height: 100% !important; }

  /* Big round decorative numbers shrink. */
  .step-number,
  .card-number {
    font-size: 20px !important;
    width: 40px !important;
    height: 40px !important;
  }
}

/* --------------------------------------------------------------------------
   SMALL PHONE  (<= 480px)
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {

  section,
  [class$="-section"],
  [class*="-container"]:not(.footer-container) {
    padding-left: 16px;
    padding-right: 16px;
  }
  section,
  [class$="-section"] {
    padding-top: 40px;
    padding-bottom: 40px;
  }

  .hero-content,
  .catchphrase,
  .location-badge { padding-inline: 16px !important; }

  .table-scroll { margin-inline: -16px; padding-inline: 16px; }

  .site-footer { padding: 36px 16px 24px !important; }
  .hours-card  { padding: 14px !important; }

  .brand-logo__img { height: 34px !important; }

  .btn-label  { font-size: 13.5px !important; }
  .btn-icon-circle { width: 38px !important; height: 38px !important; }

  .slider-card { flex: 0 0 86%; }

  /* Stop long unbroken strings (URLs, phone numbers) forcing a scrollbar. */
  a, p, td, li { overflow-wrap: break-word; }
}

/* --------------------------------------------------------------------------
   LANDSCAPE PHONE
   A short viewport should not be stuck behind a full-height hero.
   -------------------------------------------------------------------------- */

@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .hero { min-height: 100vh !important; }
  .mobile-nav { padding-top: 72px; }
  section,
  [class$="-section"] { padding-top: 36px; padding-bottom: 36px; }
}


/* ==========================================================================\n   MOBILE POLISH — news + drawer\n   ========================================================================== */
@media (max-width: 992px) {
  .mobile-nav {
    width: min(92vw, 420px) !important;
    max-width: 420px !important;
    padding: 0 18px 24px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }
  .mobile-nav__top {
    position: sticky !important;
    top: 0 !important;
    z-index: 3 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-height: 72px !important;
    padding: 10px 0 !important;
    background: inherit !important;
    border-bottom: 1px solid rgba(62,102,59,.14) !important;
  }
  .mobile-nav__brand img {
    display: block !important;
    width: auto !important;
    height: 38px !important;
    max-width: 210px !important;
    object-fit: contain !important;
  }
  .mobile-nav__close {
    display: flex !important;
    position: relative !important;
    width: 44px !important;
    height: 44px !important;
    flex: 0 0 44px !important;
    align-items: center !important;
    justify-content: center !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: #3e663b !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav__close span {
    position: absolute !important;
    width: 19px !important;
    height: 2px !important;
    background: #fff !important;
    border-radius: 2px !important;
  }
  .mobile-nav__close span:first-child { transform: rotate(45deg) !important; }
  .mobile-nav__close span:last-child { transform: rotate(-45deg) !important; }
  .mobile-nav__list { padding-top: 12px !important; }
  .mobile-nav__link { padding: 14px 4px !important; }
  .mobile-nav__cta { margin-top: 16px !important; }
  .mobile-nav__address { padding-bottom: 8px !important; }
}

@media (max-width: 600px) {
  .mobile-nav {
    width: 100vw !important;
    max-width: none !important;
    padding: 0 16px 20px !important;
  }
  .mobile-nav__top { min-height: 66px !important; }
  .mobile-nav__brand img { height: 34px !important; max-width: 190px !important; }
  .mobile-nav__close { width: 42px !important; height: 42px !important; flex-basis: 42px !important; }
}

@media (max-width: 900px) {
  /* News page: keep each item compact and readable instead of stacking every
     field into a tall column. Desktop rules are untouched. */
  .news-section { overflow: hidden !important; }
  .news-container {
    width: 100% !important;
    max-width: 100% !important;
    gap: 28px !important;
  }
  .news-sidebar {
    width: 100% !important;
    max-width: 100% !important;
  }
  .category-list {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    gap: 8px !important;
  }
  .category-list li { min-width: 0 !important; }
  .category-btn {
    width: 100% !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    padding: 11px 8px !important;
  }
  .news-content { width: 100% !important; min-width: 0 !important; }
  #news-list { width: 100% !important; }
  .news-item {
    display: grid !important;
    grid-template-columns: 64px minmax(0, 1fr) 24px !important;
    grid-template-areas: "date body arrow" !important;
    align-items: center !important;
    column-gap: 12px !important;
    row-gap: 5px !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 15px 0 !important;
    border-bottom: 1px solid rgba(62,102,59,.18) !important;
    text-decoration: none !important;
  }
  .news-date {
    grid-area: date !important;
    width: 64px !important;
    min-width: 64px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    line-height: 1.15 !important;
  }
  .news-date .year { font-size: 11px !important; }
  .news-date .day { font-size: 16px !important; font-weight: 700 !important; }
  .news-badge {
    grid-area: body !important;
    justify-self: start !important;
    margin: 0 0 3px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    padding: 3px 8px !important;
    border-radius: 999px !important;
  }
  .news-title {
    grid-area: body !important;
    align-self: end !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    overflow: hidden !important;
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 13.5px !important;
    line-height: 1.55 !important;
    overflow-wrap: anywhere !important;
  }
  .news-arrow {
    grid-area: arrow !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 24px !important;
    height: 24px !important;
  }
  .news-arrow svg { width: 15px !important; height: auto !important; }
}

@media (max-width: 480px) {
  .category-list { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .category-btn { font-size: 12px !important; padding: 10px 5px !important; }
  .news-item {
    grid-template-columns: 58px minmax(0, 1fr) 20px !important;
    column-gap: 10px !important;
    padding: 13px 0 !important;
  }
  .news-date { width: 58px !important; min-width: 58px !important; }
  .news-date .day { font-size: 15px !important; }
  .news-title { font-size: 13px !important; }
}
