/* ==========================================================================
   Layout – Kinderarztpraxis Kohlscheid
   Breakpoints: mobile < 600px ≤ tablet < 960px ≤ desktop
   Tokens are defined in variables.css (:root)
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;

  @media (prefers-reduced-motion: reduce) {
    scroll-behavior: auto;
  }
}

body {
  min-height: 100dvh;
  background: var(--color-page-mobile);
  overflow-x: hidden;

  @media (width >= 960px) {
    /* light grey that fades into --color-page (formerly bg_body_default.png) */
    background:
      linear-gradient(
          to bottom,
          #f6f6f6 0,
          #f5f5f6 850px,
          #efeff0 1000px,
          #eaeaeb 1100px,
          #e4e5e6 1200px,
          #dcddde 1400px,
          var(--color-page) 1600px
        )
        0 var(--header-height) / 100% 1600px no-repeat,
      var(--color-page);
  }
}

img {
  max-width: 100%;
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;

  @media (width >= 960px) {
    padding-inline: 0;
  }
}

.clear {
  clear: both;
}

.corner {
  border-radius: var(--radius);
}

.corner_bottom {
  border-radius: 0 0 var(--radius) var(--radius);
}

.shadow {
  box-shadow: var(--shadow);
}

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  position: relative;
  z-index: 60;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);

  @media (width >= 960px) {
    height: var(--header-height);
    background: var(--color-page) url("../images/bg_header.png") repeat-x;
    border-bottom: 0;
  }
}

.header__inner {
  display: grid;
  grid-template-columns: 1fr;
  padding-top: 12px;

  @media (width >= 960px) {
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-top: 0;
    padding-bottom: 12px;
  }
}

.header__logo {
  display: block;
  justify-self: start;
  /* leave room for the Kontakt tab on the right */
  max-width: min(200px, 100% - 130px);

  @media (width >= 960px) {
    align-self: flex-start;
    max-width: none;
    margin-top: 30px;
  }

  & img.logo {
    display: block;
    width: 200px;
    height: auto;

    @media (width >= 960px) {
      width: 222px;
    }
  }
}

/* ---- main menu ---- */

.menu {
  & ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5rem;
    list-style: none;
  }

  & a {
    display: block;
    color: var(--color-text-strong);
    text-decoration: none;
    font-size: var(--font-size-larger);
    line-height: 1.2;
    padding-block: 0.6rem 0.2rem;
    border-bottom: 3px solid transparent;
    transition:
      color 0.15s,
      border-color 0.15s;
  }

  & a:hover,
  & a.current,
  & a.section {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
  }

  /* mobile: full-width row below the logo */
  @media (width < 960px) {
    margin-top: 12px;
    border-top: 1px solid var(--color-muted);
    padding-block: 4px 8px;

    & ul {
      gap: 0 1.25rem;
    }

    & a {
      font-size: 1.2rem;
      padding-block: 0.55rem 0.25rem;
    }
  }

  @media (width >= 960px) {
    & ul {
      gap: 0 35px;
    }

    & a {
      padding-block: 0 2px;
    }
  }
}

/* ==========================================================================
   Kontakt panel (slides down from the top of the header)
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(255 255 255 / 0.7);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;

  .kontakt-open & {
    opacity: 1;
    visibility: visible;
  }
}

.kontakt {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 100;
}

.kontakt__panel {
  display: grid;
  grid-template-rows: 0fr;
  background: var(--color-surface);
  border-radius: 0 0 var(--radius) var(--radius);
  transition:
    grid-template-rows 0.5s ease,
    box-shadow 0.5s;

  .kontakt.is-open & {
    grid-template-rows: 1fr;
    box-shadow: var(--shadow);
  }

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

.kontakt__clip {
  min-height: 0;
  overflow: hidden;
}

.kontakt__content {
  display: grid;
  gap: 1.5rem 30px;
  margin: 0 10px 10px;
  padding: 30px 15px;
  background: var(--color-muted-light);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow-wrap: anywhere;
  opacity: 0;
  transition: opacity 0.3s;

  .kontakt.is-open & {
    opacity: 1;
    transition-delay: 0.2s;
  }

  & h3 {
    color: var(--color-primary);
  }

  & img {
    height: auto;
  }

  @media (width >= 600px) {
    grid-template-columns: repeat(2, 1fr);
  }

  @media (width >= 960px) {
    grid-template-columns: repeat(3, 1fr);
  }

  /* mobile: scroll inside the panel if it is taller than the screen */
  @media (width < 960px) {
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.kontakt__logo {
  display: block;
  width: 100%;
  max-width: 220px;
  margin-bottom: 1.5rem;
}

.kontakt__tab {
  position: absolute;
  top: 100%;
  right: var(--gutter);
  padding: 5px 10px;
  background: var(--color-surface);
  /* hide the shadow on top so the tab blends into the panel */
  clip-path: inset(0 -10px -10px -10px);

  @media (width >= 960px) {
    right: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
  }
}

.kontakt__toggle {
  display: block;
  min-width: 95px;
  padding: 0 12px;
  line-height: 30px;
  text-align: center;
  font-weight: bold;
  color: #fff;
  text-decoration: none;
  background: var(--color-accent);
  border-radius: var(--radius);
  transition: background-color 0.15s;

  &:hover,
  &:focus-visible {
    color: #fff;
    background: var(--color-text);
  }
}

/* ==========================================================================
   Main / content
   ========================================================================== */

.main {
  padding-block: 25px;

  @media (width < 960px) {
    padding-block: 0;
    .wrap {
      padding: 0;
      --radius: 0;
      --shadow: none;

    }
    .sidebar__box:not(:last-child) {
      padding-bottom: 0;
    }
    .sidebar {
      gap: 0px;
    }
  }
}

.content-and-sidebar {
  display: grid;
  gap: var(--gap);

  @media (width >= 960px) {
    grid-template-columns: minmax(0, 1fr) var(--sidebar);
    align-items: start;
  }
}

.main div.left {
  background: var(--color-surface);
  min-width: 0;
}

.main .content {
  position: relative;
  padding: 20px;
  overflow-wrap: break-word;

  @media (width < 600px) {
    padding: 16px;
  }

  /* CMS images: keep aspect ratio */
  & img {
    max-width: 100% !important;
    height: auto !important;
  }

  & img.left {
    float: left;
    margin: 0 1rem 1rem 0;
  }

  & img.right {
    float: right;
    margin: 0 0 1rem 1rem;
  }

  & img.leftAlone,
  & img.center {
    display: block;
    margin-block: 0.5rem 1rem;
  }

  & img.center {
    margin-inline: auto;
  }

  @media (width < 600px) {
    & img.left,
    & img.right {
      float: none;
      display: block;
      margin: 0 0 1rem;
    }
  }

  & ul li a {
    background: url("../images/button_to.jpg") left center no-repeat;
    padding-left: 20px;
  }

  /* CMS image with caption gets an inline width */
  & .captionImage {
    max-width: 100% !important;
  }

  & table {
    max-width: 100%;
  }

  & iframe,
  & video {
    max-width: 100%;
  }
}

/* decorative penguins next to the content (desktop only, below the sidebar) */
.pinguin_praxis,
.pinguin_leistungen,
.mr_ping {
  display: none;
}

@media (width >= 960px) {
  .main .content img.pinguin_praxis,
  .main .content img.pinguin_leistungen {
    display: block;
    position: absolute;
    bottom: 0;
    right: -200px;
  }

  body.service .content .mr_ping {
    display: block;
    position: absolute;
    width: 180px;
    height: 370px;
    bottom: 0;
    right: -200px;
    background: url("../images/pinguin_service.png") no-repeat;
  }
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  display: grid;
  gap: 2px;
  align-content: start;

  @media (600px <= width < 960px) {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap);

    & .sidebar_headline {
      grid-column: 1 / -1;
    }
  }
}

.sidebar__box {
  position: relative;
  background: var(--color-surface);
  padding: 10px;
}

/* "Im Notfall" button (formerly bg_sidebar_headline_main*.png) */
.sidebar_headline h2 {
  margin: 0;
  font-size: var(--font-size-large);

  & a {
    display: block;
    padding: 0 15px;
    line-height: 68px;
    color: var(--color-text);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: linear-gradient(
      to bottom,
      #fbfbfb 0%,
      #ececed 55%,
      #d4d5d6 100%
    );
    box-shadow:
      inset 0 1px 0 #fff,
      inset 0 -1px 0 rgb(255 255 255 / 0.6),
      0 1px 2px rgb(0 0 0 / 0.12);
    transition:
      background 0.2s,
      color 0.2s;

    @media (width < 960px) {
      line-height: 52px;
    }
  }

  & a:hover,
  & a:focus-visible {
    color: var(--color-text-strong);
    background: linear-gradient(
      to bottom,
      #e2e3e4 0%,
      #eeeff0 45%,
      #f9f9f9 100%
    );
    box-shadow:
      inset 0 1px 2px rgb(0 0 0 / 0.12),
      0 1px 0 #fff;
  }
}

.sidebar .content {
  height: 100%;
  padding: 20px 15px;
  overflow-wrap: anywhere;
}

.widget_1 .content {
  background: var(--color-accent);
  color: #fff;

  & a,
  & h3 {
    color: #fff;
  }
}

.widget_2 .content {
  background: var(--color-muted);
}

.sidebar .text p {
  line-height: var(--line-height);
}

/* ==========================================================================
   Home
   ========================================================================== */

.main .image_wide {
  position: relative;
  height: 290px;
  margin-bottom: 25px;
  background: var(--color-surface) var(--background-image-url) center / cover
    no-repeat;
  border: 10px solid var(--color-surface);

  @media (width < 600px) {
    height: 200px;
    border-width: 6px;
    margin-bottom: 30px;
  }

  & .quote {
    position: absolute;
    right: 70px;
    bottom: 150px;
    width: 210px;
    padding: 10px;
    background: var(--color-surface);

    @media (width < 600px) {
      right: auto;
      left: 10px;
      top: 10px;
      bottom: auto;
      width: min(190px, 60%);
      padding: 6px;

      & .text p {
        font-size: 0.875rem;
      }
    }
  }

  & .quote .text {
    position: relative;
    padding: 15px;
    background: var(--color-primary);

    @media (width < 600px) {
      padding: 10px;
    }

    & p,
    & a {
      color: #fff;
      font-size: var(--font-size-medium);
      text-decoration: none;
      line-height: 1.5;
    }

    & a:hover {
      text-decoration: underline;
    }
  }

  & .quote__arrow {
    position: absolute;
    bottom: -30px;
    right: 20px;
  }

  & .pinguin {
    position: absolute;
    right: -11px;
    bottom: -36px;
    z-index: 10;

    @media (width < 600px) {
      width: 60px;
      right: -4px;
      bottom: -24px;
    }
  }
}

.content.home {
  display: grid;
  gap: 2rem;

  @media (width >= 600px) {
    grid-template-columns: minmax(12em, 17em) 1fr;
  }

  & .home__image {
    display: block;
    max-width: min(100%, 450px) !important;
    margin-bottom: 0.5rem;
  }

  & h2.team {
    background: url("../images/icon_bubble.png") 0 5px no-repeat;
    padding-left: 30px;
  }
}

/* ==========================================================================
   Team
   ========================================================================== */

.team-members {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  gap: 50px 30px;

  @media (width < 600px) {
    grid-template-columns: 1fr;
    gap: 30px;
  }
}

.team_member {
  & img {
    display: block;
    width: 100%;
    max-width: 210px;
    height: auto;
    border-radius: var(--radius);
  }

  & h4 {
    margin-top: 20px;
    margin-bottom: 10px;
  }

  & .column {
    font-size: var(--font-size-smaller);
    line-height: var(--line-height);
    hyphens: auto;
  }

  /* mobile: photo left, text right */
  @media (width < 600px) {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0 1rem;
    align-items: start;

    & img {
      grid-row: span 2;
    }

    & h4 {
      margin-top: 0;
    }
  }
}

/* ==========================================================================
   Praxis – slideshow
   ========================================================================== */

.slideshow {
  position: relative;
  max-width: 690px;
  aspect-ratio: 3 / 2;
  margin: 0 auto 20px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--color-muted);
}

.slideshow__slides > img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1s ease;

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

.slideshow__slides > img.is-active,
.slideshow:not(.is-ready) .slideshow__slides > img:first-child {
  opacity: 1;
}

.slideshow__btn {
  position: absolute;
  top: 50%;
  z-index: 10;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent center / contain no-repeat;
  cursor: pointer;
  translate: 0 -50%;
  transition: scale 0.15s;

  &:hover {
    scale: 1.1;
  }

  .slideshow:not(.is-ready) & {
    display: none;
  }
}

.slideshow__btn--prev {
  left: 10px;
  background-image: url("../images/button_prev.png");
}

.slideshow__btn--next {
  right: 10px;
  background-image: url("../images/button_next.png");
}

/* ==========================================================================
   Leistungen
   ========================================================================== */

.leistungen__grid {
  display: grid;
  gap: 25px;

  @media (width >= 600px) {
    grid-template-columns: minmax(140px, 210px) minmax(0, 1fr);
    align-items: start;
  }
}

.leistungen .images_left {
  display: grid;
  gap: 20px;

  & img {
    display: block;
    width: 100%;
  }

  /* mobile: compact 3-column thumbnail grid below the text */
  @media (width < 600px) {
    order: 2;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;

    & img {
      aspect-ratio: 210 / 270;
      object-fit: cover;
      height: 100% !important;
      border-radius: var(--radius);
    }
  }
}

.leistungen .content_right {
  min-width: 0;
}


/* ==========================================================================
   Jugendmedizin
   ========================================================================== */

body.jugendmedizin {
  background: url("../images/bg_body_jugendmedizin.png") repeat;

  @media (width >= 960px) {
    & .wrap_wide {
      background: url("../images/bg_wrap_wide_jugendmedizin.png") no-repeat top
        center;
      min-height: 1050px;
    }
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  padding-bottom: 30px;
  margin-top: 5px;
  @media (width < 960px) {
    margin: 0;
    padding: 15px 0;
  }
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;

  @media (width < 600px) {
    flex-direction: column;
  }

  & ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 25px;
    list-style: none;
  }

  & a {
    color: var(--color-text);
    text-decoration: none;

    &:hover {
      color: var(--color-primary);
    }
  }

  & li.Notfall {
    display: none;
  }
}

/* ==========================================================================
   Notfall dialog (native <dialog>, replaces jQuery UI dialog)
   ========================================================================== */

.dialog {
  width: min(960px, 100% - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 5px 30px rgb(0 0 0 / 0.25);
  color: var(--color-text);
  background: var(--color-surface);

  /* fade in/out */
  opacity: 0;
  transition:
    opacity 0.3s,
    overlay 0.3s allow-discrete,
    display 0.3s allow-discrete;

  &[open] {
    opacity: 1;

    @starting-style {
      opacity: 0;
    }
  }

  &::backdrop {
    background: rgb(255 255 255 / 0);
    transition:
      background-color 0.3s,
      overlay 0.3s allow-discrete,
      display 0.3s allow-discrete;
  }

  &[open]::backdrop {
    background: rgb(255 255 255 / 0.7);

    @starting-style {
      background: rgb(255 255 255 / 0);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    transition: none;

    &::backdrop {
      transition: none;
    }
  }
}

.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-muted);
}

.dialog__title {
  margin: 0;
  font-size: var(--font-size-larger-2);
}

.dialog__close {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--color-text);
  background: var(--color-muted-light);
  border: 0;
  border-radius: 50%;
  cursor: pointer;

  &:hover {
    color: #fff;
    background: var(--color-accent);
  }
}

.dialog__body {
  padding: 1.25rem;
  overflow-wrap: anywhere;
}
