/* Mobile gallery UI: original info button, stable locale metadata and a
   gesture-driven drawer. Gesture tracking writes transform directly in script.js. */
:root {
  --gallery-ease-out: cubic-bezier(.23, 1, .32, 1);
  --gallery-ease-drawer: cubic-bezier(.32, .72, 0, 1);
}

@media (max-width: 1024px) {
  /* Restore the original standalone information button. */
  .info-button-mobile {
    color: var(--text-primary);
    background: var(--bg-glass);
    border: 1px solid var(--border-default);
    box-shadow: none;
    touch-action: manipulation;
  }
  .info-button-mobile:hover {
    border-color: var(--border-default);
    background: var(--control-bg-hover);
    box-shadow: none;
  }
  @media (hover: none) and (pointer: coarse) {
    .info-button-mobile:hover { transform: none; }
  }
  .info-button-mobile:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    box-shadow: none;
  }

  .bottom-sheet-header {
    align-items: center;
    justify-content: flex-start;
    gap: 0;
  }
  .bottom-sheet-heading { min-width: 0; }
  .bottom-sheet-header h2 {
    padding-left: 0;
    font-size: clamp(19px, 5.2vw, 24px);
    line-height: 1.25;
  }

  /* Mobile locale stays right of the heading, not in the scrolling body.
     A stable header height prevents the switch from jumping as the title wraps. */
  .description-bottom-sheet .bottom-sheet-header {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 8px;
    min-height: 84px;
    padding: 16px 18px;
  }
  .description-bottom-sheet .bottom-sheet-heading {
    display: flex;
    align-items: center;
    width: auto;
    min-width: 0;
    gap: 8px;
  }
  .description-bottom-sheet .bottom-sheet-heading .description-title__content {
    min-width: 0;
  }
  .description-bottom-sheet .bottom-sheet-heading .description-title__ornament {
    flex: 0 0 22px;
    width: 22px;
    height: 34px;
  }
  .description-bottom-sheet .bottom-sheet-header h2 {
    min-width: 0;
    margin: 0;
    padding: 0;
    font-size: clamp(17px, 4.6vw, 21px);
    line-height: 1.25;
    overflow-wrap: anywhere;
  }
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet {
    display: inline-flex;
    position: static;
    align-items: center;
    justify-self: end;
    flex: 0 0 auto;
    width: max-content;
    gap: 4px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    white-space: nowrap;
  }
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet::before,
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet::after,
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet .lang-switcher__btn::before,
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet .lang-switcher__btn::after {
    display: none;
    content: none;
  }
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet .lang-switcher__btn {
    display: inline-flex;
    position: static;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 4px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--text-muted);
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    line-height: 1;
    font-weight: 600;
    letter-spacing: .1em;
    text-decoration: none;
    cursor: pointer;
    transition: color 150ms ease, border-color 150ms ease;
  }
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet .lang-switcher__btn.is-active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    font-weight: 600;
  }
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet .lang-switcher__btn:hover {
    background: transparent;
    color: var(--text-primary);
  }
  .description-bottom-sheet .bottom-sheet-header > .lang-switcher--sheet .lang-switcher__btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
  }

  /* Full-width Vaul-like drawer. The 500ms easing is fast at the start.
     Pointer tracking and release spring are managed in script.js. */
  .description-bottom-sheet {
    transition: opacity 220ms var(--gallery-ease-out), visibility 220ms;
  }
  .description-bottom-sheet .bottom-sheet-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: opacity 220ms var(--gallery-ease-out);
    opacity: 1;
  }
  .description-bottom-sheet .bottom-sheet-content {
    transform: translate3d(0, 100%, 0);
    transform-origin: bottom center;
    transition: transform 500ms var(--gallery-ease-drawer);
    will-change: transform;
  }
  .description-bottom-sheet.active .bottom-sheet-content {
    transform: translate3d(0, 0, 0);
  }
  .description-bottom-sheet.is-dragging .bottom-sheet-content {
    transition: none;
  }
  .bottom-sheet-header,
  .bottom-sheet-handle {
    touch-action: none;
  }
  .description-bottom-sheet.active .bottom-sheet-header,
  .description-bottom-sheet.active .bottom-sheet-body,
  .description-bottom-sheet.active .bottom-sheet-button {
    animation: none;
  }
  .bottom-sheet-button { border-color: transparent; box-shadow: none; }
  .bottom-sheet-button:hover { box-shadow: none; }
  .description-bottom-sheet:focus { outline: none; }

  /* Keep the previous fast mobile image viewer and its clean X control. */
  .image-modal--mobile .image-modal-close {
    display: flex;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, -8px, 0) scale(.96);
    border: 0;
    outline: none;
    box-shadow: none;
    color: var(--text-primary);
    transition:
      transform 180ms var(--gallery-ease-out),
      opacity 140ms var(--gallery-ease-out),
      background 120ms ease;
  }
  .image-modal--mobile.is-viewer-ready .image-modal-close {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0) scale(1);
  }
  .image-modal--mobile .image-modal-close:hover {
    border: 0;
    box-shadow: none;
    background: rgba(41, 48, 57, .95);
  }
  .image-modal--mobile .image-modal-close:active {
    transform: scale(.96);
    background: rgba(41, 48, 57, .95);
  }
  .image-modal--mobile .image-modal-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .info-button-mobile,
  .description-bottom-sheet .bottom-sheet-content,
  .description-bottom-sheet .bottom-sheet-backdrop,
  .image-modal--mobile .image-modal-close {
    transition-duration: 1ms !important;
  }
}
