/* =============================================================
   MOBILE OVERRIDES — Aktivstall Mannheims
   Target: < 900px (tablets / phones), special cases < 600px
   Strategy: use !important to override inline React styles.
   ============================================================= */

/* ─── Touch device baseline ─── */
@media (hover: none) and (pointer: coarse) {
  /* Hide custom cursor entirely on touch */
  #cursor-dot, #cursor-ring { display: none !important; }
  html, body { cursor: auto !important; }
}

/* ============================================================
   TABLET + MOBILE  (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {

  /* ─── NAV ─── */
  nav > div {
    padding: 14px var(--gutter) !important;
  }

  /* ─── HERO ─── */
  #top {
    height: 100vh !important;
    min-height: 600px !important;
  }
  /* Hero intro layer */
  #top > div:nth-of-type(2) {
    padding: 100px var(--gutter) 48px !important;
    grid-template-rows: 1fr auto !important;
  }
  /* Hero headline */
  #top h1 {
    font-size: clamp(48px, 12vw, 88px) !important;
    line-height: 1 !important;
    max-width: none !important;
  }
  /* Hero bottom row: stack vertically */
  #top > div:nth-of-type(2) > div:nth-of-type(2) {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
    padding-top: 40px !important;
  }
  #top > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) {
    justify-self: stretch !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  /* Hero paragraph */
  #top p { font-size: 15px !important; }

  /* Stats row in hero — wrap */
  #top div[style*="tabular-nums"] {
    flex-wrap: wrap !important;
    gap: 20px !important;
  }

  /* Hero scroll-revealed caption */
  #hero-scroll-track {
    height: 220vh !important;
  }
  .hero-pinned div[style*="placeItems"] > div > div:nth-of-type(2) {
    font-size: clamp(40px, 11vw, 80px) !important;
    max-width: none !important;
  }

  /* ─── KONZEPT ─── */
  #konzept {
    padding: 80px var(--gutter) !important;
  }
  /* Title row: stack eyebrow above title */
  #konzept > div > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    margin-bottom: 56px !important;
  }
  #konzept h2 {
    font-size: clamp(30px, 6.5vw, 44px) !important;
    max-width: none !important;
  }
  /* Number/title/body rows */
  .row-konzept {
    grid-template-columns: 60px 1fr !important;
    gap: 20px 24px !important;
    padding: 28px 0 !important;
  }
  .row-konzept > div:first-child {
    font-size: 32px !important;
    grid-row: 1 !important;
  }
  .row-konzept > h3 {
    grid-column: 2 !important;
    font-size: 20px !important;
  }
  .row-konzept > p {
    grid-column: 1 / 3 !important;
    font-size: 15px !important;
  }

  /* ─── ANLAGE ─── */
  #anlage {
    padding: 80px var(--gutter) !important;
  }
  #anlage > div > div {
    grid-template-columns: 1fr !important;
    gap: 48px !important;
  }
  #anlage > div > div > div:first-child {
    position: static !important;
    top: auto !important;
  }
  #anlage h2 {
    font-size: clamp(30px, 6.5vw, 44px) !important;
    max-width: none !important;
    margin: 16px 0 24px !important;
  }
  #anlage p { font-size: 15px !important; max-width: none !important; }
  /* Features list: stack to single column */
  #anlage ul {
    grid-template-columns: 1fr !important;
  }
  #anlage ul li {
    padding-left: 0 !important;
    padding-right: 0 !important;
    font-size: 16px !important;
  }

  /* ─── STATS ─── */
  section[style*="paper-2"]:not(#galerie) > div {
    grid-template-columns: 1fr 1fr !important;
    gap: 32px 24px !important;
  }
  section[style*="paper-2"]:not(#galerie) > div > div {
    border-left: none !important;
    padding-left: 0 !important;
  }

  /* ─── FAMILIE ─── */
  #familie {
    padding: 80px var(--gutter) !important;
  }
  #familie > div {
    grid-template-columns: 1fr !important;
    gap: 48px !important;
  }
  #familie h2 {
    font-size: clamp(30px, 7vw, 48px) !important;
    margin: 16px 0 32px !important;
  }
  #familie p[style*="italic"] {
    font-size: 18px !important;
  }
  /* Family photo collage: keep grid but smaller */
  #familie > div > div:nth-of-type(2) {
    gap: 10px !important;
  }
  #familie > div > div:nth-of-type(2) > div:nth-of-type(3) {
    margin-top: 0 !important;
  }

  /* ─── ANGEBOT — horizontal scroll breaks on mobile, switch to vertical stack ─── */
  #angebot-track {
    height: auto !important;
  }
  #angebot {
    position: static !important;
    height: auto !important;
    padding: 80px 0 !important;
    display: block !important;
    overflow: visible !important;
  }
  /* Header */
  #angebot > div:first-child {
    padding: 0 var(--gutter) !important;
    grid-template-columns: 1fr !important;
    gap: 32px !important;
    margin-bottom: 48px !important;
  }
  #angebot h2 {
    font-size: clamp(36px, 8vw, 60px) !important;
  }
  /* Horizontal track → vertical stack */
  #angebot > div:nth-of-type(2) {
    overflow: visible !important;
    display: block !important;
  }
  #angebot > div:nth-of-type(2) > div {
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    padding: 0 var(--gutter) !important;
  }
  .angebot-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .angebot-card > div:first-child {
    height: 200px !important;
  }
  .angebot-card > div:nth-child(2) {
    padding: 24px !important;
  }

  /* ─── GALERIE ─── */
  #galerie {
    padding: 80px var(--gutter) !important;
  }
  #galerie > div > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 16px !important;
    margin-bottom: 40px !important;
  }
  #galerie h2 {
    font-size: clamp(30px, 7vw, 44px) !important;
  }
  /* Mosaic → 2 columns */
  #galerie > div > div:nth-of-type(2) {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: 100px !important;
    gap: 10px !important;
  }
  #galerie > div > div:nth-of-type(2) > div {
    grid-column: span 1 !important;
    grid-row: span 2 !important;
  }

  /* ─── TEAM ─── */
  #team {
    padding: 80px var(--gutter) !important;
  }
  #team > div > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    margin-bottom: 48px !important;
  }
  #team h2 {
    font-size: clamp(30px, 6.5vw, 44px) !important;
    max-width: none !important;
  }
  #team > div > div:nth-of-type(2) {
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
  }

  /* ─── STIMMEN (Testimonials) ─── */
  #stimmen {
    padding: 80px var(--gutter) !important;
  }
  #stimmen > div > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    margin-bottom: 48px !important;
  }
  #stimmen > div > div:nth-of-type(2) {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* ─── KONTAKT ─── */
  #kontakt {
    padding: 80px var(--gutter) !important;
  }
  #kontakt > div > div {
    grid-template-columns: 1fr !important;
    gap: 56px !important;
  }
  #kontakt h2 {
    font-size: clamp(36px, 8vw, 60px) !important;
    max-width: none !important;
  }
  #kontakt p { font-size: 15px !important; max-width: none !important; }
  /* Address grid */
  #kontakt > div > div > div:first-child > div:last-child {
    grid-template-columns: 1fr !important;
    gap: 6px 0 !important;
  }
  #kontakt > div > div > div:first-child > div:last-child > span:nth-child(odd) {
    margin-top: 16px !important;
  }
  /* Form */
  #kontakt form {
    padding: 24px !important;
  }
  #kontakt form > div {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  #kontakt form > div > div {
    grid-column: span 1 !important;
  }
  #kontakt form button[type="submit"] {
    grid-column: span 1 !important;
    padding: 18px 24px !important;
    font-size: 12px !important;
  }
  #kontakt form p {
    grid-column: span 1 !important;
  }

  /* ─── FOOTER ─── */
  footer {
    padding: 60px var(--gutter) 32px !important;
  }
  footer > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
  }
  footer > div:last-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    text-align: left !important;
  }

  /* ─── LEGAL MODAL ─── */
  .legal-modal {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 90vh !important;
    padding: 32px 24px !important;
  }
}

/* ============================================================
   SMALL PHONE  (≤ 600px) — fine-tuning
   ============================================================ */
@media (max-width: 600px) {

  /* Tighter gutter */
  :root {
    --gutter: 20px;
  }

  /* Nav: brand smaller */
  nav a[href="#top"] span {
    font-size: 14px !important;
    letter-spacing: 0.2em !important;
  }

  /* Hero — make CTAs full-width and stack */
  #top a[href="#kontakt"], #top a[href="#konzept"] {
    width: 100% !important;
    justify-content: center !important;
    padding: 16px 20px !important;
    font-size: 11px !important;
  }
  #top div[style*="flexWrap"] {
    flex-direction: column !important;
    width: 100% !important;
  }

  /* Hero stats: 2-up */
  #top div[style*="tabular-nums"] {
    width: 100% !important;
    justify-content: space-between !important;
  }
  #top div[style*="tabular-nums"] > div {
    flex: 1 !important;
    min-width: 80px !important;
  }
  #top div[style*="tabular-nums"] span[style*="font-serif"],
  #top div[style*="tabular-nums"] span[style*="var(--font-serif)"] {
    font-size: 28px !important;
  }

  /* Galerie: 1 column on very small screens */
  #galerie > div > div:nth-of-type(2) {
    grid-template-columns: 1fr !important;
    grid-auto-rows: 220px !important;
  }
  #galerie > div > div:nth-of-type(2) > div {
    grid-row: span 1 !important;
  }

  /* Team: 1 column */
  #team > div > div:nth-of-type(2) {
    grid-template-columns: 1fr !important;
  }

  /* Stats: 1 column */
  section[style*="paper-2"]:not(#galerie) > div {
    grid-template-columns: 1fr !important;
  }

  /* Ensure no horizontal overflow */
  body, html {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* All buttons get min 44px touch target */
  button, a.btn-primary, a[href="#kontakt"], a[href="#konzept"] {
    min-height: 44px !important;
  }

  /* Reduce section padding further */
  section {
    padding-top: 64px !important;
    padding-bottom: 64px !important;
  }

  /* Headings on small phones */
  h2 {
    font-size: clamp(28px, 8vw, 36px) !important;
  }
}

/* Safe-area for iPhone notch */
@supports (padding: max(0px)) {
  nav > div {
    padding-left: max(var(--gutter), env(safe-area-inset-left)) !important;
    padding-right: max(var(--gutter), env(safe-area-inset-right)) !important;
  }
  footer {
    padding-bottom: max(32px, env(safe-area-inset-bottom)) !important;
  }
}
