/*
 * Reusable story-content contract.
 *
 * The article template owns the hero, cover, metadata, contents navigation
 * and related links. Gutenberg owns only the rich-text body below, keeping
 * future image-and-copy articles flexible without surrendering responsive
 * layout to arbitrary editor markup.
 */

.timy-story-editorial .journal-body-grid,
.timy-story-editorial .journal-copy,
.timy-story-editorial .article-layout,
.timy-story-editorial .article-aside,
.timy-story-editorial .article-toc,
.timy-story-editorial .article-body,
.timy-story-richtext {
  min-width: 0;
  max-width: 100%;
}

.timy-story-editorial .journal-body-grid--without-toc {
  grid-template-columns: minmax(0, 760px);
}

.timy-story-richtext > * {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.timy-story-richtext > :first-child {
  margin-top: 0;
}

.timy-story-richtext > h2:not(:first-child),
.timy-story-richtext > h2.wp-block-heading:not(:first-child) {
  scroll-margin-top: 110px;
  margin-top: 64px;
  padding-top: 58px;
  border-top: 1px solid var(--line);
}

.timy-story-richtext h2,
.timy-story-richtext h3,
.timy-story-richtext h4 {
  scroll-margin-top: 110px;
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  text-wrap: balance;
}

.timy-story-richtext h3,
.timy-story-richtext h4 {
  font-family: var(--serif);
  letter-spacing: -.02em;
}

.timy-story-richtext h3 {
  margin-top: 38px;
  font-size: 25px;
  line-height: 1.38;
}

.timy-story-richtext h4 {
  margin-top: 30px;
  font-size: 19px;
  line-height: 1.45;
}

.timy-story-richtext strong {
  color: var(--ink);
  font-weight: 700;
}

.timy-story-richtext a:not(.button):not(.wp-block-button__link) {
  color: var(--essay-accent, #d74d49);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
}

.timy-story-richtext ul,
.timy-story-richtext ol {
  margin: 22px 0 0;
  padding-left: 1.35em;
}

.timy-story-richtext li + li {
  margin-top: .55em;
}

.timy-story-richtext img,
.timy-story-richtext video,
.timy-story-richtext iframe {
  display: block;
  max-width: 100%;
  height: auto;
}

.timy-story-richtext figure,
.timy-story-richtext .wp-block-image,
.timy-story-richtext .wp-block-video,
.timy-story-richtext .wp-block-gallery,
.timy-story-richtext .wp-block-table,
.timy-story-richtext .wp-block-media-text,
.timy-story-richtext .wp-block-columns,
.timy-story-richtext .wp-block-cover {
  max-width: 100%;
  margin: 36px 0;
}

.timy-story-richtext figure > figcaption,
.timy-story-richtext .wp-element-caption {
  margin: 0;
  padding-top: 11px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.timy-story-richtext .wp-block-gallery.has-nested-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
}

.timy-story-richtext .wp-block-gallery.has-nested-images > figure {
  width: auto !important;
  margin: 0 !important;
}

.timy-story-richtext .wp-block-gallery.is-cropped img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.timy-story-richtext .wp-block-media-text {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 46px);
  align-items: center;
}

.timy-story-richtext .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media {
  grid-column: 2;
  grid-row: 1;
}

.timy-story-richtext .wp-block-media-text.has-media-on-the-right .wp-block-media-text__content {
  grid-column: 1;
  grid-row: 1;
}

.timy-story-richtext .wp-block-media-text__media,
.timy-story-richtext .wp-block-media-text__content {
  min-width: 0;
  margin: 0;
  padding: 0;
}

.timy-story-richtext .wp-block-media-text__media img {
  width: 100%;
}

.timy-story-richtext .wp-block-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.timy-story-richtext .wp-block-column {
  min-width: 0;
}

.timy-story-richtext .wp-block-quote,
.timy-story-richtext .wp-block-pullquote {
  margin: 34px 0;
  padding: 24px 28px;
  border: 0;
  border-left: 3px solid var(--essay-accent, #e75b52);
  background: var(--paper);
}

.timy-story-richtext .wp-block-quote p,
.timy-story-richtext .wp-block-pullquote p {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.65;
}

.timy-story-richtext cite {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.6;
}

.timy-story-richtext .wp-block-separator,
.timy-story-richtext hr {
  height: 1px;
  margin: 42px 0;
  border: 0;
  background: var(--line);
}

.timy-story-richtext .wp-block-table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.timy-story-richtext table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.65;
}

.timy-story-richtext th,
.timy-story-richtext td {
  padding: 13px 14px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.timy-story-richtext th {
  color: var(--ink);
  background: var(--paper);
  font-weight: 700;
}

.timy-story-richtext pre {
  max-width: 100%;
  margin: 32px 0;
  padding: 20px;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--dark);
  color: #fffaf4;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre;
}

.timy-story-richtext code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.timy-story-richtext :not(pre) > code {
  padding: .12em .34em;
  background: var(--paper-deep);
  font-size: .9em;
}

.timy-story-richtext .wp-block-video video,
.timy-story-richtext .wp-block-embed__wrapper,
.timy-story-richtext iframe {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

.timy-story-richtext .wp-block-video,
.timy-story-richtext .wp-block-embed {
  min-width: 0;
  overflow: hidden;
}

.timy-story-richtext .wp-block-cover {
  min-height: 360px;
  padding: clamp(24px, 5vw, 48px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.timy-story-richtext .wp-block-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.timy-story-richtext .wp-block-button__link {
  max-width: 100%;
  min-height: 44px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: #fffaf4;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
}

@media (max-width: 900px) {
  .timy-story-editorial {
    --story-mobile-gutter: clamp(20px, 5.6vw, 24px);
  }

  .timy-story-editorial .journal-essay-hero-grid,
  .timy-story-editorial .journal-body-grid,
  .timy-story-editorial .journal-end-grid,
  .timy-story-editorial .article-hero-inner,
  .timy-story-editorial .article-layout {
    width: calc(100vw - (var(--story-mobile-gutter) * 2));
    max-width: none;
    margin-inline: auto;
  }

  .timy-story-editorial .journal-body {
    padding: 52px 0 88px;
  }

  .timy-story-editorial .journal-body-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 44px;
  }

  .timy-story-editorial--native .journal-essay-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin-top: 26px;
    border-bottom: 1px solid rgba(255, 250, 244, .3);
  }

  .timy-story-editorial--native .journal-essay-meta div {
    min-width: 0;
    display: block;
    padding: 12px 10px 11px;
    border-right: 1px solid rgba(255, 250, 244, .3);
    border-bottom: 0;
  }

  .timy-story-editorial--native .journal-essay-meta div:first-child {
    padding-left: 0;
  }

  .timy-story-editorial--native .journal-essay-meta div:last-child {
    padding-right: 0;
    border-right: 0;
  }

  .timy-story-editorial--native .journal-essay-meta dt,
  .timy-story-editorial--native .journal-essay-meta dd {
    min-width: 0;
    text-align: left;
  }

  .timy-story-editorial--native .journal-essay-meta dd {
    margin-top: 6px;
    overflow-wrap: anywhere;
  }

  .timy-story-editorial .journal-toc,
  .timy-story-editorial .article-toc {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    padding: 0;
    border: 0;
  }

  .timy-story-editorial .journal-toc a,
  .timy-story-editorial .article-toc a {
    min-width: 0;
    min-height: 84px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
    background: var(--paper);
    color: var(--ink-2);
    font-size: 11px;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .timy-story-editorial .journal-toc > p,
  .timy-story-editorial .article-toc > p {
    grid-column: 1 / -1;
    margin: 0 0 4px;
  }

  .timy-story-editorial .journal-toc a span,
  .timy-story-editorial .article-toc a span {
    color: var(--essay-accent, #e75b52);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
  }

  .timy-story-editorial .journal-copy h2,
  .timy-story-editorial .article-body h2 {
    font-size: clamp(29px, 7.8vw, 32px);
    line-height: 1.32;
    letter-spacing: -.025em;
    text-wrap: balance;
  }

  .timy-story-editorial .journal-copy p,
  .timy-story-editorial .journal-copy li,
  .timy-story-editorial .article-body p,
  .timy-story-editorial .article-body li {
    font-size: 15px;
    line-height: 1.95;
    text-wrap: pretty;
  }

  .timy-story-richtext > h2:not(:first-child),
  .timy-story-richtext > h2.wp-block-heading:not(:first-child) {
    scroll-margin-top: calc(var(--header-h, 66px) + 20px);
    margin-top: 48px;
    padding-top: 48px;
  }

  .timy-story-richtext h2,
  .timy-story-richtext h3,
  .timy-story-richtext h4 {
    scroll-margin-top: calc(var(--header-h, 66px) + 24px);
  }

  .timy-story-richtext h3 {
    margin-top: 32px;
    font-size: 23px;
    line-height: 1.4;
  }

  .timy-story-richtext h4 {
    margin-top: 28px;
    font-size: 18px;
    line-height: 1.45;
  }

  .timy-story-richtext figure,
  .timy-story-richtext .wp-block-image,
  .timy-story-richtext .wp-block-video,
  .timy-story-richtext .wp-block-gallery,
  .timy-story-richtext .wp-block-table,
  .timy-story-richtext .wp-block-media-text,
  .timy-story-richtext .wp-block-columns,
  .timy-story-richtext .wp-block-cover {
    margin: 28px 0;
  }

  .timy-story-richtext figure > figcaption,
  .timy-story-richtext .wp-element-caption {
    font-size: 12px;
    line-height: 1.7;
  }

  .timy-story-richtext .wp-block-image img,
  .timy-story-richtext .wp-block-video video,
  .timy-story-richtext .wp-block-media-text__media img {
    height: auto;
    max-width: 100%;
  }

  .timy-story-richtext .wp-block-media-text,
  .timy-story-richtext .wp-block-columns {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 20px;
  }

  .timy-story-richtext .wp-block-media-text__media,
  .timy-story-richtext .wp-block-media-text__content,
  .timy-story-richtext .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media,
  .timy-story-richtext .wp-block-media-text.has-media-on-the-right .wp-block-media-text__content {
    grid-column: 1 !important;
    grid-row: auto !important;
  }

  .timy-story-richtext .wp-block-quote,
  .timy-story-richtext .wp-block-pullquote {
    margin: 28px 0;
    padding: 20px;
  }

  .timy-story-richtext .wp-block-quote p,
  .timy-story-richtext .wp-block-pullquote p {
    font-size: 20px;
  }

  .timy-story-richtext .wp-block-cover {
    min-height: 260px;
    padding: 24px 20px;
  }

  .timy-story-richtext pre {
    margin: 26px 0;
    padding: 16px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .timy-story-editorial .journal-toc,
  .timy-story-editorial .article-toc {
    grid-template-columns: minmax(0, 1fr);
  }

  .timy-story-editorial .journal-toc a,
  .timy-story-editorial .article-toc a {
    min-height: 0;
  }
}
