@import '../mixins';
@import '../config/import';

:root {
  --content-font-size: var(--fs-l);
  --content-secondary-font-size: var(--fs-base);
  --content-tertiary-font-size: var(--fs-base);
  --content-rhythm: var(--content-font-size);

  @media (min-width: $breakpoint-s) {
    --content-secondary-font-size: var(--fs-l);
  }

  @media (min-width: $breakpoint-l) {
    --content-font-size: var(--fs-xl);
  }
}

@font-face {
  font-family: OpenDyslexic;
  @include font-src('OpenDyslexic-Regular.otf');
  font-style: normal;
  font-weight: normal;
}
@font-face {
  font-family: OpenDyslexic;
  @include font-src('OpenDyslexic-Italic.otf');
  font-style: italic;
  font-weight: normal;
}
@font-face {
  font-family: OpenDyslexic;
  @include font-src('OpenDyslexic-Bold.otf');
  font-weight: bold;
  font-style: normal;
}
@font-face {
  font-family: OpenDyslexic;
  @include font-src('OpenDyslexic-BoldItalic.otf');
  font-weight: bold;
  font-style: italic;
}

// Content fonts
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  &.serif-article-body {
    --content-font-family: var(--ff-serif);
  }

  &.sans-serif-article-body {
    --content-font-family: var(--ff-sans-serif);
  }

  &.comic-sans-article-body {
    --content-font-family: var(--ff-comic);
  }

  &.monospace-article-body {
    --content-font-family: var(--ff-monospace);
  }

  &.open-dyslexic-article-body {
    --content-font-family: var(--ff-dyslexic);
  }
}

.text-styles {
  font-size: var(--content-font-size);
  font-family: var(--content-font-family);
  overflow-wrap: break-word;

  &--billboard {
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    img,
    p {
      margin-top: 0 !important;
    }
  }

  &--secondary {
    font-size: var(--content-secondary-font-size);
  }

  &--tertiary {
    font-size: var(--content-tertiary-font-size);
  }

  > :last-child {
    margin-bottom: 0;
  }

  a {
    text-decoration: underline;
    color: var(--link-branded-color);

    &:hover {
      color: var(--link-branded-color-hover);
    }
  }

  // TODO: Hack to target all links in .text-styles except ones used in liquid tags...
  // Liquid tags styling is still pretty random and overwriting what's been
  // implemented there makes some things look worse. We should circle back
  // when/if we "redesign" liquid tags.
  [class*='ltag'] a {
    text-decoration: none;
    &:hover {
      color: var(--color-hover);
    }
  }

  a[class*='ltag'] {
    text-decoration: none;
    &:hover {
      color: var(--color-hover);
    }
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--ff-sans-serif);
    margin: calc(var(--content-rhythm) / 2) 0;
    padding: 0;
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
  }

  h1 {
    font-size: 1.75em;
  }

  h2 {
    font-size: 1.5em;
  }

  h3 {
    font-size: 1.25em;
  }

  h4 {
    font-size: 1em;
  }

  h5 {
    font-size: 0.875em;
  }

  h6 {
    font-size: 0.85em;
    color: var(--base-60);
  }

  hr {
    width: 25%;
    opacity: 0.1;
    border-radius: var(--radius);
    border: 1px solid var(--body-color);
    margin: calc(var(--content-rhythm) * 2) auto;
  }

  p {
    margin: 0 0 var(--content-rhythm) 0;
  }

  dl {
    margin: 0 0 var(--content-rhythm) 0;

    dt,
    dd {
      display: block;
    }

    dt {
      font-weight: var(--fw-medium);
    }

    dd {
      margin-inline-start: var(--su-7);
    }
  }

  ul,
  ol {
    padding-left: var(--su-6);
    margin: 0 0 var(--content-rhythm) 0;

    br {
      line-height: 0;
      margin: 0;
      padding: 0;
    }
  }

  ul {
    list-style-type: disc;

    p {
      margin: 0;
      padding: 0;
    }

    ul {
      margin: 0 0 0 var(--content-rhythm);
      list-style-type: square;

      ul {
        list-style-type: circle;
      }
    }
  }

  figure {
    margin: 0;
  }

  figcaption {
    font-style: italic;
    text-align: center;
    font-size: 0.8em;
    color: var(--body-color);
    opacity: 0.75;
    display: block;
  }

  p + figcaption {
    margin-top: -0.8em;
  }

  blockquote {
    border-left: 4px solid var(--base-20);
    padding: 0 0 0 var(--content-rhythm);
    margin: 0 0 var(--content-rhythm) 0;

    &.twitter-tweet {
      font-family: var(--ff-sans-serif);
      background: var(--body-color-inverted);
      max-width: 550px;
      border: 1px solid #cfd9de;
      font-size: 0.75em;
      line-height: 1.35em;
      border-radius: 12px;
      margin: 1.6em auto;
      padding: 60px 250px 18px 10px;
      padding: 33px 15px 8px;

      @media screen and (min-width: $breakpoint-s) {
        padding: 60px 22px 18px;
        min-height: 105px;
      }
    }
  }

  .tweet-embed {
    display: block;
    margin: var(--content-rhythm) auto !important;
    width: 550px;
    max-width: 100%;
    min-height: 350px;
    border-radius: 13px;
    box-shadow: var(--shadow-smooth), inset 0px 0px 0px 1px var(--card-border);
    overflow: hidden;
  }

  kbd {
    display: inline-block;
    padding: 3px 5px;
    font-size: 11px;
    line-height: 10px;
    color: #444d56;
    vertical-align: middle;
    background-color: #fafbfc;
    border: solid 1px #c6cbd1;
    border-bottom-color: #959da5;
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 #959da5;
  }

  pre:not(.highlight),
  div:not(.highlight) > pre.highlight,
  div.highlight {
    margin: 0 0 var(--content-rhythm) 0;
  }

  // This .ff-container classname is added by the freezeframe library we use to play/pause animated images
  img,
  video,
  .ff-container {
    height: auto;
    object-fit: contain;
    display: block;
    margin: var(--content-rhythm) auto;
    max-width: 100%;
    max-height: calc(50vh + 180px);
    border-radius: var(--radius);
  }

  .article-body-image-wrapper {
    cursor: zoom-in;
  }

  iframe {
    width: 100%;
    border: 0;
    margin: 0 0 var(--content-rhythm) 0;
    border-radius: var(--radius);
  }

  .fluidvids {
    margin: 0 0 var(--content-rhythm) 0;

    iframe {
      margin: 0;
    }
  }

  .table-wrapper-paragraph {
    width: 100%;
    overflow-x: auto;
    margin: 0 0 var(--content-rhythm) 0;

    table {
      margin: 0;
    }
  }

  table {
    margin: 0 0 var(--content-rhythm) 0;
    border-collapse: collapse;
    border-spacing: 0;

    th,
    td {
      padding: var(--su-2);
      border: 1px solid var(--base-20);
    }

    th {
      background: var(--body-bg);
      text-align: left;
    }
  }

  .twitter-tweet {
    margin: 0 auto;
  }

  .c-embed {
    margin: 0 0 var(--content-rhythm) 0;
  }
}

// This class should eventually have its own dedicated file
.c-embed {
  padding: var(--su-3);
  border: 1px solid var(--form-border);
  box-shadow: var(--shadow-smooth) !important;
  @media screen and (min-width: $breakpoint-s) {
    padding: var(--su-5);
  }

  &__content {
    display: flex;
    align-items: flex-start;
    gap: var(--su-4);
  }

  &__cover {
    margin-bottom: var(--su-4);
    flex-shrink: 0;
    
    // New horizontal layout styles
    .c-embed__content & {
      margin-bottom: 0;
      width: 80px;
      height: 80px;
      text-align: center;
      
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: var(--radius);
      }
    }
  }

  &__body {
    flex: 1;
    min-width: 0; // Allows text to truncate properly
  }

  h2,
  p {
    margin: 0;
    margin-bottom: var(--su-2);
  }

  &__favicon {
    display: none !important;
  }
}
