/* ==========================================================================
   winkler-ki.de — mobile / responsive overrides
   Loaded after styles.css. Desktop layout untouched above 1100px.
   ========================================================================== */

/* Prevent horizontal overflow on narrow screens */
html, body { max-width: 100%; overflow-x: hidden; }

/* Mobile nav toggle button — hidden on desktop */
.nav-toggle { display: none; }

/* Drawer & backdrop hidden by default on all breakpoints; only the mobile
   media query re-enables them. Without this, the drawer's children render
   as a flat link list under the sticky nav on desktop. */
.nav-drawer,
.nav-backdrop { display: none; }

/* Helper: only show on mobile */
.nav-mobile-only { display: none; }

/* ---------------- ≤ 1100px : tablet / mobile ---------------------------- */
@media (max-width: 1100px) {
  :root { --gutter: 20px; }

  /* --- Nav: replace inline links with hamburger drawer --- */
  .nav-inner { height: 60px; }
  .nav-links { display: none; }
  .nav-cta .nav-kontakt-btn { display: none; }      /* hide "Kontakt" button — moved into drawer */

  .nav-cta .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--ink);
    padding: 0;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .nav-cta .nav-toggle:hover,
  .nav-cta .nav-toggle:focus-visible {
    border-color: var(--ink);
    background: color-mix(in oklab, var(--ink) 6%, transparent);
    outline: none;
  }
  .nav-toggle .bars { display: grid; gap: 4px; }
  .nav-toggle .bars span {
    display: block; width: 18px; height: 2px; background: currentColor;
    transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
  }
  .nav-toggle[aria-expanded="true"] .bars span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"] .bars span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] .bars span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* Backdrop overlay — clickable area outside the drawer */
  .nav-backdrop {
    display: block;
    position: fixed; inset: 60px 0 0 0;
    background: color-mix(in oklab, var(--bg) 60%, transparent);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
    z-index: 48;
  }
  .nav-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  /* Drawer slides down from the top */
  .nav-drawer {
    display: block;
    position: fixed;
    top: 60px; right: 0;
    width: min(360px, 100vw);
    height: calc(100dvh - 60px);
    max-height: calc(100dvh - 60px);
    background: var(--bg);
    border-left: 1px solid var(--line);
    box-shadow: -10px 0 40px -20px rgba(0,0,0,.5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    transition: transform var(--dur) var(--ease);
    z-index: 49;
    visibility: hidden;
  }
  .nav-drawer.open {
    transform: translateX(0);
    visibility: visible;
  }
  .nav-drawer-inner { padding: 8px 20px 40px; }
  .nav-drawer a {
    display: block;
    padding: 16px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 17px;
    color: var(--ink);
  }
  .nav-drawer a:last-of-type { border-bottom: 0; }
  .nav-drawer .nav-drawer-cta {
    display: block;
    margin-top: 24px;
    text-align: center;
    background: var(--ink); color: var(--bg);
    border: 1px solid var(--ink);
    border-radius: 4px;
    padding: 14px 18px;
    font-weight: 500;
  }
  .nav-drawer .nav-drawer-cta:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

  /* lock body scroll when drawer open */
  body.nav-open { overflow: hidden; touch-action: none; }

  /* --- Layout primitives --- */
  section { padding: 64px 0; }
  .section-head {
    grid-template-columns: 1fr; gap: 16px; margin-bottom: 32px;
  }
  .section-head h2 { font-size: 36px; }

  /* --- Hero --- */
  .hero { padding: 32px 0 56px; }
  .hero-inner { grid-template-columns: 1fr; gap: 32px; }
  .hero h1,
  :root[data-hero="terminal"] .hero h1,
  :root[data-hero="editorial"] .hero h1 {
    font-size: 40px !important;
    line-height: 1.05;
    max-width: none;
  }
  .hero-lede { font-size: 16px; margin-bottom: 24px; }
  .hero-ctas { flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-ctas .btn { width: 100%; }
  .hero-strip {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 24px; padding-top: 20px;
  }
  .hero-strip-item .v { font-size: 24px; }
  .hero-promo-img { max-width: 100%; }
  .hero-console { max-width: 100% !important; justify-self: stretch !important; }

  /* --- Services / process / kit / certs grids → single column --- */
  .services-grid,
  .process-grid,
  .kit-grid,
  .ki-trio,
  .secblock-grid,
  .stack-grid,
  .whynow-grid,
  .nemo-grid,
  .team-grid,
  .certs-inner,
  .contact-grid,
  .painpair-grid {
    grid-template-columns: 1fr !important;
    gap: 0;
  }
  .nemo { padding: 64px 0; }
  .nemo h2 { font-size: 40px; }
  .nemo-card { padding: 20px; }
  .certs-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Industries rows */
  .ind-row {
    grid-template-columns: 1fr;
    gap: 8px; padding: 24px 0;
  }
  .ind-row .n { font-size: 11px; }
  .ind-row .t { font-size: 24px; }
  .ind-row .tags { display: none; }

  /* Process steps → stacked */
  .process-step { padding: 20px; }
  .process-step .n { margin-bottom: 16px; }

  /* KI cards in single column */
  .kit-cta {
    grid-template-columns: 1fr; gap: 24px;
    padding: 28px;
  }
  .kit-card > .kit-head,
  .kit-card > .kit-title,
  .kit-card > .kit-desc,
  .kit-card > .kit-bullets {
    margin-left: 24px; margin-right: 24px;
  }

  /* Painpair: stack before/after */
  .painpair { grid-template-columns: 1fr; border-right: 0; }
  .painpair:nth-child(2n) { border-right: 0; }

  /* Generic: borders that only made sense in multi-col → off */
  .secblock, .whynow-item, .stack-item,
  .nis2-measure, .pd-process-step, .project-metric {
    border-right: 0 !important;
  }
  .secblock, .whynow-item, .stack-item {
    border-bottom: 1px solid var(--line);
  }

  /* --- Team --- */
  .team-quote { font-size: 28px; }
  .team-fact { grid-template-columns: 1fr; gap: 4px; }

  /* --- Contact --- */
  .contact { padding: 64px 0; }
  .contact h2 { font-size: 40px; }
  .contact-channel {
    grid-template-columns: 100px 1fr auto;
    gap: 12px; padding: 14px 0;
  }
  .contact-channel .v { font-size: 14px; }
  .form { padding: 20px; }
  .form-duo { grid-template-columns: 1fr; gap: 0; }
  .form-submit {
    flex-direction: column; align-items: stretch; gap: 14px;
  }
  .form-submit .btn { width: 100%; }
  .form-note { text-align: center; }

  /* --- Message section --- */
  .message { padding: 64px 0; }
  .message-headline { font-size: 32px; }
  .message-lede { font-size: 16px; margin-bottom: 32px; }
  .message-pillars { grid-template-columns: 1fr; }
  .message-pillar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 24px 20px;
  }
  .message-pillar:last-child { border-bottom: 0; }

  /* --- NIS-2 --- */
  .nis2-hero { padding: 64px 0 48px; }
  .nis2-hero-title { font-size: 40px; }
  .nis2-hero-lede { font-size: 16px; }
  .nis2-scope-row, .nis2-tl-row, .nis2-roadmap-row {
    grid-template-columns: 1fr; gap: 8px;
  }
  .nis2-measures-grid { grid-template-columns: 1fr; }
  .nis2-measure { padding: 18px 20px; border-right: 0; }
  .nis2-faq-item > summary {
    grid-template-columns: 36px 1fr 20px;
    font-size: 16px;
    gap: 12px;
    padding: 18px 0;
  }
  .nis2-faq-a { padding-left: 48px; padding-right: 4px; font-size: 14.5px; }
  .nis2-cta-card { grid-template-columns: 1fr; padding: 28px; gap: 24px; }
  .nis2-advantage { padding: 64px 0; }
  .nis2-advantage-h { font-size: 36px; }

  /* --- Project list cards --- */
  .project-card {
    grid-template-columns: 1fr;
    gap: 24px; padding: 40px 0;
  }
  .project-head {
    position: static;
    flex-direction: row; align-items: baseline; gap: 16px;
  }
  .project-num { font-size: 36px; }
  .project-title { font-size: 26px; }
  .project-metrics { grid-template-columns: 1fr 1fr; }
  .project-metric { padding: 14px 16px; }
  .project-metric:nth-child(odd)  { border-right: 1px solid var(--line) !important; }
  .project-metric:nth-child(even) { border-right: 0 !important; }
  .project-metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .project-bullets li { grid-template-columns: 32px 1fr; gap: 10px; font-size: 14px; }

  /* --- Project detail pages --- */
  .pd-hero { padding: 56px 0 40px; }
  .pd-title { font-size: clamp(32px, 9vw, 48px); }
  .pd-lede { font-size: 16px; }
  .pd-hero-meta { grid-template-columns: 1fr 1fr; }
  .pd-hero-meta-cell { border-right: 1px solid var(--line); }
  .pd-hero-meta-cell:nth-child(2n) { border-right: 0; }
  .pd-hero-meta-cell:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .pd-section { padding: 56px 0; }
  .pd-section-head { grid-template-columns: 1fr; gap: 16px; margin-bottom: 32px; }
  .pd-section-head h2 { font-size: 32px; }
  .pd-mockup { grid-template-columns: 1fr; gap: 20px; padding: 28px 0; }
  .pd-process { grid-template-columns: 1fr; }
  .pd-process-step {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 24px 20px;
  }
  .pd-process-step:last-child { border-bottom: 0; }
  .pd-outcomes { grid-template-columns: 1fr; gap: 20px; }
  .pd-outcome .v { font-size: 40px; }
  .ui-kpi-grid { grid-template-columns: 1fr; }
  .ui-kpi { border-right: 0; border-bottom: 1px solid var(--line); }
  .ui-kpi:last-child { border-bottom: 0; }
  .ui-sidebar-layout { grid-template-columns: 1fr; }
  .ui-sidebar { display: none; }
  .ui-node-map { grid-template-columns: repeat(4, 1fr); }

  /* --- Events --- */
  .event-card { grid-template-columns: 1fr; gap: 8px; padding: 32px 0; }
  .event-title { font-size: 24px; }
  .webinar-form { padding: 16px; gap: 14px; }
  .webinar-row { grid-template-columns: 1fr; }

  /* --- Footer --- */
  footer { padding: 32px 0 28px; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; margin-bottom: 28px; }
  .footer-bottom {
    flex-direction: column; align-items: flex-start; gap: 8px;
  }

  /* --- Tweaks panel: smaller, bottom-center --- */
  .tweaks {
    bottom: 12px; right: 12px; left: 12px;
    min-width: 0;
  }

  /* Form / button minimums for touch */
  .btn { min-height: 48px; padding: 14px 18px; font-size: 15px; }
  .form-row input,
  .form-row textarea,
  .form-row select {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 14px;
  }

  /* Tap targets large enough for fingers */
  a, button { -webkit-tap-highlight-color: color-mix(in oklab, var(--accent) 25%, transparent); }

  /* Hide things that don't make sense on small screens */
  .hero-grid-bg { background-size: 32px 32px; opacity: .25; }

  /* Tables / pre / wide content: scroll instead of overflow */
  table, pre { max-width: 100%; overflow-x: auto; }

  /* Images responsive by default */
  img, video { max-width: 100%; height: auto; }
}

/* ---------------- ≤ 600px : phones --------------------------------------- */
@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .hero h1,
  :root[data-hero="terminal"] .hero h1,
  :root[data-hero="editorial"] .hero h1 { font-size: 34px !important; }
  .section-head h2 { font-size: 28px; }
  .nemo h2 { font-size: 32px; }
  .contact h2 { font-size: 32px; }
  .nis2-hero-title { font-size: 32px; }
  .message-headline { font-size: 26px; }
  .pd-title { font-size: clamp(28px, 8vw, 40px); }
  .pd-section-head h2 { font-size: 26px; }

  .certs-grid { grid-template-columns: 1fr; }
  .project-metrics { grid-template-columns: 1fr; }
  .project-metric:nth-child(odd) { border-right: 0 !important; }
  .project-metric { border-bottom: 1px solid var(--line); }
  .project-metric:last-child { border-bottom: 0; }

  .pd-hero-meta { grid-template-columns: 1fr; }
  .pd-hero-meta-cell { border-right: 0; border-bottom: 1px solid var(--line); }
  .pd-hero-meta-cell:last-child { border-bottom: 0; }

  .ui-node-map { grid-template-columns: repeat(3, 1fr); }

  /* Topic chips: tighter wrap */
  .topic { font-size: 11px; padding: 6px 10px; }

  /* Drawer width = full screen on phones */
  .nav-drawer { width: 100vw; border-left: 0; }
}

/* Reduced motion: skip slide-in animations */
@media (prefers-reduced-motion: reduce) {
  .nav-drawer, .nav-backdrop, .nav-toggle .bars span { transition: none !important; }
}
