<spicy-sections>

  <h2>Veggie Dippers</h2>
  <div>
    <h3>Are McDonald's veggie dippers gluten free?</h3>
    <p>Yes, but only without the bun of course. The Pepper & Pesto Dipper itself has no gluten containing ingredients and is cooked in a separate fryer, away from other ingredients containing gluten. However, due to our kitchen set up, we cannot guarantee that cross-contamination will not occur.</p>
  </div>

  <h2>Breakfast</h2>
  <div>
    <h3>Why do you only serve breakfast until 11:00?</h3>
    <p>
      Items on our breakfast menu are cooked slightly differently and at a different temperature from items on our main menu. This means we don't have enough space in our kitchens to accommodate the cooking and preparation of our breakfast and main menus at the same time. The 11am cut off enables us to accommodate our breakfast lovers, whilst allowing the customers who enjoy our main menu to get their food before 11:30am.
    </p>
  </div>

  <h2>Sauces</h2>
  <div>
    <h3>What dips do you have?</h3>
    <p>We have a wide range of dips and sauces available, to see the full range and their nutritional information you can click here and select the Condiments and Sauces group.</p>
  </div>

</spicy-sections>
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@100;400;800&display=swap");

spicy-sections {
  display: block;

  /* prettier-ignore */
  --const-mq-affordances: 
    [screen and (max-width: 30em) ] collapse | 
    [screen and (min-width: 50em) ] tab-bar; /* another type is exclusive-collapse */

  > h2,
  > div {
    background: white;
  }
  > h2 {
    font-weight: 800;
    margin: 1rem 0 0 0;
    padding: 1rem;
    box-shadow: var(--shadow-elevation-medium);
  }
  > div {
    padding: 0 1rem 1rem 1rem;
    box-shadow: var(--shadow-elevation-medium);
  }
}

spicy-sections[affordance="tab-bar"] {
  h2[aria-selected="true"] {
    border-bottom: 3px solid orange;
  }
  &::part(tab-list) {
  }
  > div {
    padding: 2rem;
  }
}

spicy-sections {
}

spicy-sections[affordance="collapse"] {
  > h2,
  > div {
    background: #fff6ee;
    border-left: 3px solid #ffc48c;
    box-shadow: var(--shadow-elevation-low);
  }
  > h2 {
    &::before {
      content: "+";
      background: none;
      width: auto;
      height: auto;
      display: inline-block;
      font-weight: 100;
      transition: transform 0.2s;
    }
    &[expanded] {
      background: white;
      box-shadow: var(--shadow-elevation-medium);
    }
    &[expanded]::before {
      transform: rotate(45deg) !important;
    }
  }
  > div {
    background: white;
    box-shadow: var(--shadow-elevation-medium);
  }
}

spicy-sections[affordance="tab-bar"] {
}

* {
  margin: 0;
  box-sizing: border-box;
}
h3 {
  margin: 0 0 0.5rem 0;
}
body {
  margin: 2rem;
  background: #f5eee0;
  font-family: "Outfit", sans-serif;
  line-height: 1.35;

  --shadow-color: 40deg 19% 57%;
  --shadow-elevation-low: 0.1px 0.7px 0.8px hsl(var(--shadow-color) / 0.34),
    0.2px 1.2px 1.4px -1.2px hsl(var(--shadow-color) / 0.34),
    0.6px 2.8px 3.2px -2.5px hsl(var(--shadow-color) / 0.34);
  --shadow-elevation-medium: 0.1px 0.7px 0.8px hsl(var(--shadow-color) / 0.36),
    0.5px 2.3px 2.6px -0.8px hsl(var(--shadow-color) / 0.36),
    1.1px 5.8px 6.6px -1.7px hsl(var(--shadow-color) / 0.36),
    2.8px 14px 16.1px -2.5px hsl(var(--shadow-color) / 0.36);
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://assets.codepen.io/3/SpicySections-2.js