/**
 * Shared mobile fixes for Lokaly demo sites.
 * Load after styles.css, theme files, and admin.css.
 */

/* ── Base overflow / width ── */
html {
  overflow-x: clip;
}

body {
  min-width: 0;
  overflow-x: clip;
}

img,
video,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

iframe {
  max-width: 100%;
  border: 0;
}

iframe[src*="maps"],
.contact-map iframe,
.map-embed iframe,
.contact-card iframe {
  display: block;
  width: 100% !important;
  min-height: 220px;
}

/* ── Header / navigation (≤980px) ── */
@media (max-width: 980px) {
  .nav-bar,
  .header-inner,
  .cafe-header .header-inner {
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    align-items: center;
    min-width: 0;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
  }

  .brand-text small {
    display: block;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Restore nav hidden by demo styles (Soez keeps hamburger menu) */
  body:not(.theme-yaprak) .main-nav {
    display: flex !important;
    flex: 1 1 100%;
    order: 10;
    width: 100%;
    min-width: 0;
    gap: 0.35rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.15rem;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  body:not(.theme-yaprak) .main-nav a {
    flex: 0 0 auto;
    padding: 0.35rem 0.55rem;
  }

  .nav-bar > .button-small,
  .nav-actions .button-small,
  .header-actions .button-small,
  .header-actions .button-primary,
  .header-inner > .button-cafe,
  .header-inner > .button.button-small {
    display: inline-flex !important;
    flex-shrink: 0;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .lang-select,
  .lang-select-control,
  select.lang-select {
    flex-shrink: 0;
    max-width: 4.25rem;
    font-size: 0.75rem;
  }

  .nav-actions,
  .header-actions {
    flex-shrink: 0;
    gap: 0.4rem;
    margin-left: auto;
  }

  /* Sticky bottom CTA on public pages */
  body:not(.admin-body):not(.theme-yaprak) .nav-bar > .button.button-small,
  body:not(.admin-body):not(.theme-yaprak) .header-inner > .button-cafe,
  body:not(.admin-body):not(.theme-yaprak) .header-actions > .button-primary {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    z-index: 850;
    justify-content: center;
    margin: 0;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  }

  body:not(.admin-body):not(.theme-yaprak) {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }
}

/* Nagelstudio hides nav at 768px */
@media (max-width: 768px) {
  body:not(.theme-yaprak) .main-nav {
    display: flex !important;
  }

  body:not(.admin-body):not(.theme-yaprak) .nav-bar > .button.button-small {
    display: inline-flex !important;
  }
}

/* Kaffee hides nav at 900px */
@media (max-width: 900px) {
  body.theme-cafe .main-nav {
    display: flex !important;
    flex: 1 1 100%;
    order: 10;
    width: 100%;
    min-width: 0;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  body.theme-cafe .cafe-header .header-inner {
    flex-wrap: wrap;
  }

  body.theme-cafe .header-inner > .button-cafe {
    display: inline-flex !important;
  }
}

@media (max-width: 430px) {
  .brand-text strong {
    font-size: 0.92rem;
  }

  .brand-text small {
    max-width: 9rem;
  }

  .brand-mark,
  .brand-icon,
  .brand-logo-wrap {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.8rem;
  }

  .brand-logo-wrap {
    padding: 0.3rem;
  }

  .container,
  .cafe-container {
    width: min(calc(100% - 1rem), var(--container, 72rem));
  }
}

/* ── Layout grids ── */
@media (max-width: 980px) {
  .hero-grid,
  .booking-grid,
  .contact-grid,
  .order-layout,
  .about-grid,
  .intro-grid,
  .story-grid,
  .feature-grid,
  .price-grid,
  .price-grid-stagger,
  .highlight-grid {
    grid-template-columns: 1fr !important;
  }

  .booking-panel {
    grid-template-columns: 1fr !important;
  }

  .hero-split {
    min-height: auto;
  }
}

/* ── Booking touch targets ── */
@media (max-width: 640px) {
  .day-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .day-selector button,
  .day-selector .day-chip,
  .slot-grid button,
  .slot-chip,
  .time-slot,
  .slot-grid .button {
    min-height: 44px;
  }

  .slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
}

/* ── Gallery horizontal scroll ── */
@media (max-width: 980px) {
  .gallery-scroll {
    padding-inline: 0.25rem 1rem;
    scroll-padding-inline: 1rem;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .gallery-scroll > * {
    scroll-snap-align: start;
    flex: 0 0 auto;
    min-width: min(78vw, 18rem);
  }
}

/* ── Hero visual frame (Podbi + similar) ── */
@media (max-width: 899px) {
  .hero-visual-frame {
    margin: 0.75rem 0 0;
    max-width: 100%;
  }

  body.theme-podbi .hero-visual-frame {
    margin: 0.75rem 0 0;
  }

  body.theme-podbi .hero-panel-visual {
    overflow: hidden;
  }
}

/* ── The Gentleman walk-in badge ── */
@media (max-width: 640px) {
  .walk-in-badge--hero {
    position: relative;
    top: auto;
    right: auto;
    margin-top: 0.75rem;
    display: inline-flex;
  }

  .walk-in-badge--inline {
    flex-wrap: wrap;
  }
}

/* ── Soez restaurant ── */
@media (max-width: 640px) {
  .theme-yaprak .nav-bar {
    gap: 0.4rem;
  }

  .theme-yaprak .nav-actions .button-small {
    display: inline-flex !important;
    padding: 0.4rem 0.65rem;
    font-size: 0.74rem;
  }

  .theme-yaprak .lang-select {
    max-width: 3.5rem;
    padding: 0.35rem 0.45rem;
    font-size: 0.72rem;
  }

  .theme-yaprak .qty-btn {
    min-width: 44px;
    min-height: 44px;
    width: 2.75rem;
    height: 2.75rem;
  }

  .theme-yaprak .cart-panel,
  .theme-yaprak .checkout-panel {
    padding: 1.1rem;
  }

  .theme-yaprak .menu-board {
    padding: 1rem 0.85rem 1.25rem;
    border-radius: var(--radius-md);
  }

  .theme-yaprak .menu-tabs {
    top: 3.75rem;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.35rem;
    padding-bottom: 0.85rem;
  }

  .theme-yaprak .menu-tabs::-webkit-scrollbar {
    display: none;
  }

  .theme-yaprak .menu-tab {
    flex-shrink: 0;
    font-size: 0.78rem;
    padding: 0.4rem 0.8rem;
  }

  .theme-yaprak .menu-row {
    gap: 0.55rem;
    padding: 0.9rem 0;
  }

  .theme-yaprak .menu-row-name {
    max-width: 100%;
    font-size: 0.95rem;
  }

  .theme-yaprak .menu-row-leader {
    display: none;
  }

  .theme-yaprak .menu-row-title-line {
    flex-wrap: wrap;
    gap: 0.2rem 0.65rem;
  }

  .theme-yaprak .menu-row-price {
    margin-left: auto;
  }

  .theme-yaprak .menu-row-add {
    align-self: center;
    padding: 0.25rem;
    opacity: 0.75;
  }

  .theme-yaprak .menu-row-add-text {
    display: none;
  }

  .theme-yaprak .order-layout {
    grid-template-columns: 1fr !important;
  }

  .theme-yaprak .cart-line {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
}

/* ── Admin areas ── */
@media (max-width: 980px) {
  .admin-nav-bar {
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    align-items: flex-start;
    min-width: 0;
  }

  .admin-nav-links {
    display: flex !important;
    width: 100%;
    order: 10;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 0.35rem;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }

  .admin-nav-links a {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.82rem;
    padding: 0.35rem 0.6rem;
  }

  .admin-header-actions {
    margin-left: auto;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .admin-stats-grid,
  .admin-grid,
  .admin-form-grid,
  .admin-shortcut-grid,
  .admin-dashboard-grid,
  .admin-auth-shell,
  .admin-auth-role-grid {
    grid-template-columns: 1fr !important;
  }

  .admin-form-grid > *,
  .admin-grid > * {
    min-width: 0;
  }

  .admin-table-wrap,
  .admin-table-scroll,
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .admin-table {
    min-width: 36rem;
  }

  .admin-calendar-shell,
  .admin-calendar-scroll,
  .admin-calendar-viewport,
  .admin-calendar-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .admin-calendar-grid {
    min-width: 720px;
  }

  .admin-dashboard-top {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-auth-card,
  .admin-card {
    padding: 1.15rem;
  }

  .admin-body input,
  .admin-body select,
  .admin-body textarea,
  .admin-input {
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  .header-actions .button-primary {
    display: inline-flex !important;
  }

  .admin-calendar-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-table th,
  .admin-table td {
    padding: 0.65rem 0.5rem;
    font-size: 0.82rem;
  }

  .admin-session-stack {
    justify-items: start;
  }
}

@media (max-width: 380px) {
  .admin-calendar-summary {
    grid-template-columns: 1fr;
  }
}

/* ── Yaprak Döner — mobile images ── */
body.theme-yaprak .hero-visual-stage,
body.theme-yaprak .hero-visual,
body.theme-yaprak .about-visual,
body.theme-yaprak .gallery-card,
body.theme-yaprak .gallery-scroll {
  min-width: 0;
  max-width: 100%;
}

body.theme-yaprak .hero-visual,
body.theme-yaprak .hero-visual-stage {
  overflow: hidden;
}

body.theme-yaprak .hero-visual img,
body.theme-yaprak .about-visual img {
  display: block;
  width: 100%;
  max-width: 100%;
  object-fit: cover;
}

body.theme-yaprak .gallery-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 980px) {
  body.theme-yaprak .gallery-scroll--animated .gallery-card {
    flex: 0 0 min(82vw, 18rem);
    scroll-snap-align: start;
  }
}

@media (max-width: 600px) {
  body.theme-yaprak .gallery-card {
    flex: 0 0 min(82vw, 17rem);
  }
}
