/* ===========================
   Base layout & typography
   =========================== */

html {
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  padding: 0 20px;
  margin: 2rem;
  font-family: Arial, sans-serif;
  background-color: #f9f9f9;
  color: #333;
}

/* Keep content from stretching too wide on large screens */
header,
main,
footer {
  max-width: 960px;
  margin: 0 auto;
}

h1 {
  color: #0066cc;
  margin-top: 0;
}

a {
  color: #324143;
  text-decoration: none;
}

a:hover,
a:focus {
  color: #7B8D3B;
}

/* Image + figure */
figure {
  margin: 1rem 0;
}

img {
  display: block;
  margin-top: 1rem;
  max-width: 300px;
  height: auto;
}

/* Footer spacing */
footer {
  margin-top: 2rem;
  border-top: 1px solid #ddd;
  padding-top: 0.75rem;
  font-size: 0.9rem;
}

/* ===========================
   Desktop / default menu
   (>= 768px)
   =========================== */

/* Menu base */
#jsddm,
#jsddm ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Horizontal top-level */
#jsddm > li {
  float: left;
  position: relative;
}

/* Top-level menu items */
#jsddm > li > a {
  display: block;
  padding: 8px 12px;
  background: #eee;
  border: 1px solid #ccc;
  margin-right: 6px;
}

/* Hover/focus state for better accessibility */
#jsddm > li > a:hover,
#jsddm > li > a:focus {
  background: #e3e3e3;
}

/* Submenu: hidden by default; shown via JS with visibility: visible */
#jsddm li ul {
  position: absolute;
  left: 0;
  top: 100%;
  visibility: hidden;
  background: #fff;
  border: 1px solid #ccc;
  min-width: 180px;
  z-index: 999;
}

/* Submenu items */
#jsddm li ul li a {
  display: block;
  padding: 8px 12px;
  white-space: nowrap;
  background: #fff;
  border-bottom: 1px solid #eee;
  text-decoration: none;
  color: #333;
}

#jsddm li ul li a:hover,
#jsddm li ul li a:focus {
  background: #f5f5f5;
}

/* Clear floats after top menu */
#jsddm::after {
  content: "";
  display: block;
  clear: both;
}

/* Add some space below the menu */
#jsddm {
  margin-bottom: 1.5rem;
}

/* ===========================
   Mobile layout
   (<= 767px)
   =========================== */

@media (max-width: 767px) {

  body {
    margin: 0.75rem 1rem;
    padding: 0;
  }

  header,
  main,
  footer {
    max-width: 100%;
    margin: 0;
  }

  /* Make the menu vertical and full-width */
  #jsddm > li {
    float: none;
  }

  #jsddm > li > a {
    margin-right: 0;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-bottom: none;
  }

  /* Last top-level item gets bottom border */
  #jsddm > li:last-child > a {
    border-bottom: 1px solid #ccc;
  }

  /* Submenus appear in the flow instead of overlaying content */
  #jsddm li ul {
    position: static;
    border-top: 1px solid #ccc;
    /* still uses visibility: hidden/visible via JS */
  }

  #jsddm li ul li a {
    padding-left: 20px; /* indent sub-items slightly */
  }

  /* Make image responsive and centered on mobile */
  figure {
    text-align: center;
  }

  img {
    margin: 1rem auto 0 auto;
    width: 100%;
    max-width: 350px;
    height: auto;
  }

  footer {
    text-align: center;
    margin-top: 1.5rem;
  }
}
