/* Set base site font size */

html {
  font-size: @typography[site-font-size];
}

/* Set font size for the site */

body {
  font-size: @typography[base-font-size];
  font-weight: normal;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  * {
    /* Apply line height calculation to all descendant */
    line-height: @typography[base-line-height];
  }

  &.rtl {
    direction: rtl;
  }

  &.ltr {
    direction: ltr;
  }
}

/* Add typo features to common text elements */

p,
li,
pre,
h1,
h2,
h3,
h4 {
  /*  Help prevent overflow of long words/names/URLs */
  word-break: break-word;

  /*  Optional, not supported for all languages */
  hyphens: auto;

  /* Set base margin-bottom to all basic typo elements */
  margin-bottom: @typography[base-margin];
}

/* Tweek summary for webkit */

details {
  summary {
    &::-webkit-details-marker {
      /* Hide the twisties */
      display: none
    }
  }
}

/**
 * Get the specified font-weight number of a given font.
 * @wheight: <string> the font-weight name to look for
 * @font: the font name to lookup to
 */

.font-weight(
  @weight: regular,
  @font: primary
) {
  @selected-font: @fonts[@@font];
  font-weight: @selected-font[@weight][@@weight];
}

/**
 *
 * For each fonts defined if config @fonts,
 * and for each weights of theses fonts,
 * build a class whith the name of the font
 * followed by the name of the weights
 * for it to by applied.
 * eg: .primary-bold() class output
 * the weight value for bold of the primary font.
 */

/* Call detached ruleset @fonts and call the each
function on every children. */

each(@fonts, .(@data, @font) {
  /* Remove @ from variable name */
  @font-name: replace(@font, '@', '');
  @font-family: @data[@name];

  .@{font-name} {
    font-family: @font-family;
  }

  /* On each weights of the fonts */
  each(@data[@weight], {
    /* Remove @ from the varaible name */
    @weight: replace(@key, '@', '');

    /* Build a class  */
    .@{font-name}-@{weight} {
      .font-weight(@weight, @font-name);
    }
  });
});
