.office-directory {
  padding-top: 7rem;
  padding-bottom: 7rem;
  background-color: var(--night);
  color: var(--offwhite);
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .office-directory {
    padding-top: 9rem;
    padding-bottom: 9rem;
  }
}

.office-directory__wrapper {
  padding-left: 20px;
  padding-right: 20px;
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .office-directory__wrapper {
    padding-left: 32px;
    padding-right: 32px;
  }
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .office-directory__wrapper {
    padding-left: 40px;
    padding-right: 40px;
  }
}

/* ============================================ */
/* HEADER */
/* ============================================ */

.office-directory__header {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 4rem;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .office-directory__header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    gap: 4rem;
    margin-bottom: 5rem;
  }
}

.office-directory__header h2 {
  margin-top: 0;
  margin-bottom: 0;
  font-size: 40px;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .office-directory__header h2 {
    font-size: 56px;
  }
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .office-directory__header h2 {
    font-size: 72px;
  }
}

.office-directory__header p {
  max-width: 440px;
  margin-top: 0;
  margin-bottom: 0;
  color: rgba(244, 242, 236, 0.78);
  font-size: 17px;
  line-height: 1.6;
}

/* ============================================ */
/* LIST AND MAP */
/* ============================================ */

/* The map comes first: above the list on phones and tablets; from 900px on the right, staying in view */
.office-directory__body {
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .office-directory__body {
    flex-direction: row-reverse;
    align-items: flex-start;
    gap: 6vw;
  }
}

.office-directory__list {
  flex-grow: 1;
  min-width: 0;
}

/* The map shows the region with offices (mapCrop). On phones it is 2.5rem narrower than the column and set
   0.75rem in, so the outermost labels, "Pangasinan" on the left and "Cagayan de Oro" on the right, fit a
   320px screen; labels sit outside the map's clip */
.office-directory__map {
  position: relative;
  width: calc(100% - 2.5rem);
  max-width: 440px;
  margin-top: 0;
  margin-bottom: 0;
  margin-left: 0.75rem;
  margin-right: auto;
  aspect-ratio: var(--office-directory-map-ratio, 1000 / 1690);
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .office-directory__map {
    width: 440px;
    margin-left: auto;
  }
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .office-directory__map {
    position: sticky;
    top: 6rem;
    flex-shrink: 0;
    width: 40%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
}

/* Narrower desktops leave room on the right for the labels of the eastern offices */

/* Tablet Landscape Only - 900px to 1199px */
@media (min-width: 900px) and (max-width: 1199px) {
  .office-directory__map {
    margin-right: 3.5rem;
  }
}

/* From 1200px the map is sized to the screen's height, so it stays whole while it follows the list */

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .office-directory__map {
    width: auto;
    height: calc(100vh - 8rem);
    min-height: 560px;
    max-height: 940px;
  }
}

/* The crop fades out where it cuts through land: Palawan on the left, Batanes above, the Sulu islands below */
.office-directory__frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent, var(--black) 10%), linear-gradient(to bottom, transparent, var(--black) 4%, var(--black) 94%, transparent);
  mask-composite: intersect;
}

.office-directory__frame img {
  position: absolute;
  display: block;
  max-width: none;
  height: auto;
  opacity: 0.42;
}

.office-directory__points {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ============================================ */
/* MAP POINTS */
/* ============================================ */

/* The link sits on its place: 6px of padding plus half the 10px dot puts the dot's centre on the coordinate */
.office-directory-point {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 6px;
  border-radius: 999px;
  color: rgba(244, 242, 236, 0.86);
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transform: translate(-11px, -50%);
  transition: opacity 300ms ease, color 300ms ease;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .office-directory-point {
    font-size: 13px;
  }
}

.office-directory-point.is-left {
  flex-direction: row-reverse;
  transform: translate(calc(-100% + 11px), -50%);
}

.office-directory-point__dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--offwhite);
  box-shadow: 0 0 0 5px rgba(244, 242, 236, 0.14);
  transition: background-color 300ms ease, box-shadow 300ms ease, transform 300ms ease;
}

.office-directory-point:hover,
.office-directory-point.is-active {
  color: var(--secondary-color-lighter);
}

.office-directory-point:hover .office-directory-point__dot,
.office-directory-point.is-active .office-directory-point__dot {
  background-color: var(--secondary-color-lighter);
  box-shadow: 0 0 0 9px rgba(230, 189, 120, 0.26);
  transform: scale(1.25);
}

/* Other points step back while one is lit, still legible at 5:1 */
.office-directory__map.is-pointing .office-directory-point:not(.is-active) {
  opacity: 0.6;
}

.office-directory-point:focus-visible {
  outline: 2px solid var(--secondary-color-lighter);
  outline-offset: 2px;
}

/* ============================================ */
/* ISLAND GROUPS */
/* ============================================ */

.office-directory-group {
  margin-bottom: 4rem;
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .office-directory-group {
    margin-bottom: 5rem;
  }
}

.office-directory-group:last-child {
  margin-bottom: 0;
}

.office-directory-group__name {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--secondary-color-lighter);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
}

.office-directory-group__offices {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid rgba(244, 242, 236, 0.18);
  list-style: none;
}

/* ============================================ */
/* OFFICE ROW */
/* ============================================ */

/* Phones stack name, address and numbers; from 600px the name sits beside the address and numbers */
.office-directory-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  border-top: 1px solid rgba(244, 242, 236, 0.18);
  scroll-margin-top: 7rem;
  transition: background-color 600ms ease;
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .office-directory-item {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 1rem 2rem;
  }
}

/* Tablet Landscape Up - Min 900px */
@media (min-width: 900px) {
  .office-directory-item {
    padding-top: 1.75rem;
    padding-bottom: 1.75rem;
  }
}

.office-directory-item:focus {
  outline: none;
}

.office-directory-item.is-active .office-directory-item__name {
  color: var(--secondary-color-lighter);
}

/* A row reached from the map is marked for a moment */
.office-directory-item.is-selected {
  background-color: rgba(244, 242, 236, 0.07);
}

.office-directory-item__details {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .office-directory-item__details {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 2rem;
  }
}

.office-directory-item__name {
  margin-top: 0;
  margin-bottom: 0;
  font-family: var(--header-font-family);
  font-size: 26px;
  transition: color 300ms ease;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

/* Desktop Up - Min 1200px */
@media (min-width: 1200px) {
  .office-directory-item__name {
    font-size: 32px;
  }
}

.office-directory-item__name span {
  display: block;
  margin-top: 0.5rem;
  color: var(--secondary-color-lighter);
  font-family: var(--body-font-family);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

.office-directory-item__address {
  color: rgba(244, 242, 236, 0.8);
  font-size: 16px;
  line-height: 1.55;
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .office-directory-item__address {
    padding-top: 0.35rem;
  }
}

.office-directory-item__address p {
  max-width: 380px;
  margin-top: 0;
  margin-bottom: 0;
}

.office-directory-item__contact {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  font-size: 16px;
  line-height: 1.5;
  list-style: none;
}

/* Tablet Portrait Up - Min 600px */
@media (min-width: 600px) {
  .office-directory-item__contact {
    padding-top: 0.35rem;
  }
}

.office-directory-item__contact a {
  color: var(--offwhite);
  text-decoration: none;
  transition: color 300ms ease;
}

.office-directory-item__contact a:hover {
  color: var(--secondary-color-lighter);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.office-directory-item__contact .is-fax {
  color: rgba(244, 242, 236, 0.72);
}

.office-directory-item__contact .is-fax span {
  margin-right: 0.35rem;
  color: var(--secondary-color-lighter);
  font-size: 13px;
  font-weight: 500;
}

.office-directory-item__directions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  color: var(--offwhite);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

.office-directory-item__directions svg {
  width: 14px;
  height: 14px;
}

.office-directory-item__directions:hover {
  color: var(--secondary-color-lighter);
}
