/* Omnicast news portal - structure mirrored from omarchy.org/news
 *
 * INDEX:  .pre > a > pre  →  header.header > h1  →  main.news-page
 *           → p.news-feed?  →  section.news-list > article.news-card…
 *
 * POST:   .pre.pre--news > a > pre  →  main.news-page > article.news-post
 *           → header.news-post__header  →  div.news-prose
 *
 * Reading text = system sans (HEY World scale). ASCII masthead = mono green.
 */

/* -- Masthead (.pre) - same role as omarchy.org -- */
.pre {
  display: grid;
  margin-top: var(--space-xx-large);
  padding-inline: max(var(--space-large), env(safe-area-inset-left), env(safe-area-inset-right));
}

.pre a {
  color: var(--color-green);
  font-weight: normal;
  justify-self: center;
  text-decoration: none;
}

.pre pre {
  margin: 0;
  color: var(--color-green);
  font-family: var(--font-family);
  /* ~66 glyph mark: scale with viewport so ASCII stays on all widths */
  font-size: clamp(0.22rem, calc((100vw - 2.5rem) / 72), 0.72rem);
  justify-self: center;
  letter-spacing: -0.0425em;
  line-height: 1.09375;
  transition: color var(--transition);
  white-space: pre;
  overflow: hidden; /* never show a scrollbar next to the mark */
  max-width: 100%;
}

@media (hover: hover) {
  .pre a:hover pre { color: var(--color-turquoise); }
}

@media (min-width: 64em) {
  .pre {
    margin-top: var(--space-xxxx-large);
    padding-inline: var(--space-xx-large);
  }
}

.pre--news {
  margin-top: var(--space-x-large);
}

.pre--news pre {
  font-size: clamp(0.2rem, calc((100vw - 2.5rem) / 78), 0.55rem);
}

@media (max-width: 40em) {
  .pre {
    margin-top: max(var(--space-x-large), env(safe-area-inset-top));
  }
}

/* -- Page title under masthead -- */
.header {
  display: grid;
  margin-top: var(--space-medium);
  padding-inline: max(var(--space-large), env(safe-area-inset-left), env(safe-area-inset-right));
}

.header h1 {
  margin: 0;
  font-size: var(--font-size-medium);
  text-align: center;
  text-wrap: balance;
  overflow-wrap: break-word;
}

@media (min-width: 64em) {
  .header { padding-inline: var(--space-xx-large); }
}

/* -- News body (HEY World type on Tokyo Night) -- */
.news-body {
  --news-font-family: -apple-system, BlinkMacSystemFont, Aptos, Roboto, "Segoe UI", Helvetica, Arial, sans-serif;
  --news-font-size: 1.1rem;
  --news-font-size-small: 0.825rem;
  --news-font-size-title: 2.3375rem;
  --news-font-size-heading: 1.65rem;
  --news-measure: 51.5rem;
  --news-space: 2.75rem;
  --news-space-tight: 0.5rem;
  --news-border-color: rgb(var(--rgb-border) / 0.8);
  --news-border-width: max(1px, 0.0625em);
  --news-pad-inline: max(1.1rem, env(safe-area-inset-left), env(safe-area-inset-right));

  background: var(--color-background-night);
  color: var(--color-terminal-white);
  font-family: var(--news-font-family);
  font-size: var(--news-font-size);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.news-body .pre {
  font-family: var(--font-family);
}

.news-body a {
  color: var(--color-terminal-cyan);
  text-decoration-thickness: from-font;
  text-underline-offset: 0.14em;
  transition: color var(--transition);
}

.news-page {
  margin-inline: auto;
  max-width: var(--news-measure);
  padding-block: var(--news-space);
  padding-inline: var(--news-pad-inline);
}

.news-body .header {
  font-size: var(--font-size);
}

.news-body .header h1 {
  color: var(--color-terminal-blue);
  font-family: var(--font-family);
  font-weight: 400;
  line-height: var(--line-height);
}

/* Centred masthead block, left-aligned reading column - as on HEY World / Omarchy news */

.news-post__header {
  margin-bottom: var(--news-space);
  text-align: center;
}

.news-meta {
  color: var(--color-terminal-blue);
  font-size: var(--news-font-size-small);
  margin: 0;
}

.news-meta a { color: inherit; }

.news-post__title {
  color: var(--color-terminal-white);
  font-size: clamp(1.55rem, 6.5vw, var(--news-font-size-title));
  font-weight: 700;
  line-height: 1.15;
  margin: var(--news-space-tight) 0 0;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.news-prose {
  text-wrap: pretty;
  overflow-wrap: break-word;
}

.news-feed {
  color: var(--color-terminal-blue);
  font-family: var(--font-family);
  font-size: var(--font-size);
  margin-block: calc(var(--news-space-tight) - var(--news-space)) calc(var(--news-space) / 2);
  text-align: center;
}

.news-feed a { color: inherit; }

.news-list {
  display: grid;
  gap: 1.25em;
}

.news-card {
  border: var(--news-border-width) solid var(--news-border-color);
  border-radius: 0.2em;
  box-shadow: 0.3em 0.3em 0.45em rgb(0 0 0 / 0.2);
  padding: 1.25em;
  position: relative;
}

.news-card header { text-align: center; }

.news-card__title {
  font-size: clamp(1.35rem, 5.5vw, var(--news-font-size-heading));
  font-weight: 700;
  line-height: 1.15;
  margin-block: var(--news-space-tight) 1.1rem;
  text-wrap: balance;
  overflow-wrap: break-word;
  color: var(--color-terminal-white);
}

.news-card__excerpt {
  text-wrap: pretty;
  overflow-wrap: break-word;
}

.news-card__link {
  inset: 0;
  overflow: hidden;
  position: absolute;
  text-indent: -100vw;
  z-index: 1;
}

.news-card .news-meta a {
  position: relative;
  z-index: 2;
}

.news-card__more {
  margin-top: 1.5em;
  text-align: center;
}

.news-card__button {
  border: var(--news-border-width) solid var(--news-border-color);
  border-radius: 3rem;
  color: var(--color-terminal-blue);
  display: inline-block;
  font-size: var(--news-font-size-small);
  min-height: 2.25rem;
  line-height: 2.25rem;
  padding: 0 0.9em;
  transition: color var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.news-prose > * + * { margin-top: 1.4em; }

.news-prose p { margin: 0; }

.news-prose h2,
.news-prose h3,
.news-prose h4 {
  color: var(--color-terminal-white);
  font-weight: 700;
  line-height: 1.2;
  margin-top: 2em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.news-prose h2 { font-size: 1.4em; }
.news-prose h3 { font-size: 1.2em; }

.news-prose strong {
  color: var(--color-white);
  font-weight: 700;
}

.news-prose em { font-style: italic; }

.news-prose ul,
.news-prose ol { padding-left: 1.25em; margin: 0; }

.news-prose ul { list-style: disc; }
.news-prose ol { list-style: decimal; }

.news-prose li + li { margin-top: 0.35em; }

.news-prose blockquote {
  border-left: 0.25rem solid var(--news-border-color);
  font-style: italic;
  margin-inline: 0;
  padding-left: 1rem;
}

.news-prose code,
.news-prose pre { font-family: var(--font-family); }

.news-prose code {
  background: var(--color-background-storm);
  color: var(--color-turquoise);
  font-size: 0.9em;
  padding: 0.12em 0.3em;
  overflow-wrap: anywhere;
}

.news-prose pre {
  background: var(--color-background-storm);
  color: var(--color-turquoise);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 0.9rem;
  margin: 0;
  border-radius: 0.25em;
  font-size: 0.88em;
  line-height: 1.55;
}

.news-prose pre code {
  background: transparent;
  padding: 0;
  overflow-wrap: normal;
}

.news-prose img {
  height: auto;
  width: 100%;
}

.news-back {
  border-top: var(--news-border-width) solid var(--news-border-color);
  margin-top: var(--news-space);
  padding-top: var(--news-space);
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  text-align: center;
}

.news-back a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.35rem 0.75rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: hover) {
  .news-body a:hover { color: var(--color-white); }
  .news-card:hover .news-card__button { color: var(--color-white); }
}

@media (max-width: 40em) {
  .news-body {
    --news-font-size: 1.0625rem;
    --news-space: 2rem;
  }

  .news-page {
    padding-block: 1.75rem;
  }

  .news-prose pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .news-card__more { margin-top: 1.25em; }
}

@media (min-width: 40em) {
  .news-card { padding: 2em; }
  .news-card__more { margin-top: 2em; }
}

@media (min-width: 60em) {
  .news-body {
    --news-font-size: 1.2375rem;
    --news-font-size-small: 0.9625rem;
    --news-font-size-title: 2.75rem;
    --news-font-size-heading: 1.925rem;
    --news-space: 3.09rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
