/*
 * TradeMax Editorial
 * A modern publication layer for Publii's Simple theme primitives.
 * Radius rule: surfaces 12px, media 10px, interactive controls 999px.
 * Layer scale: content 0, sticky header 20, mobile navigation 30, overlays 40.
 */

:root {
  --ed-bg: #f5f7f8;
  --ed-surface: #fbfcfc;
  --ed-surface-strong: #ffffff;
  --ed-ink: #171b1d;
  --ed-muted: #5f696f;
  --ed-soft: #e9eef0;
  --ed-line: #d4dcdf;
  --ed-accent: var(--color);
  --ed-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
  --ed-shadow: 0 18px 50px rgb(26 43 49 / 0.09);
  --ed-radius: 12px;
  --ed-media-radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ed-bg: #111719;
    --ed-surface: #161e21;
    --ed-surface-strong: #1c2629;
    --ed-ink: #eef3f2;
    --ed-muted: #a8b3b6;
    --ed-soft: #202c30;
    --ed-line: #334145;
    --ed-shadow: 0 20px 60px rgb(0 0 0 / 0.25);
  }
}

html {
  scroll-padding-top: 5.5rem;
}

body {
  background: var(--ed-bg);
  color: var(--ed-ink);
  font-family: var(--body-font);
  font-size: 1rem;
  font-variation-settings: "wght" 400;
  letter-spacing: -0.008em;
  line-height: 1.65;
}

a {
  text-underline-offset: 0.18em;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--ed-ink);
  font-family: var(--heading-font);
  font-style: normal;
  font-variation-settings: "wght" 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  text-transform: none;
}

.wrapper {
  box-sizing: border-box;
  max-width: 82rem;
  padding-inline: clamp(1.25rem, 4vw, 3.5rem);
  width: 100%;
}

.entry-wrapper {
  box-sizing: border-box;
  max-width: 45rem;
  padding-inline: 0;
  width: 100%;
}

.skip-link {
  background: var(--ed-ink);
  border-radius: 0 0 8px 8px;
  color: var(--ed-bg);
  left: 1rem;
  padding: 0.7rem 1rem;
  position: fixed;
  top: -5rem;
  transition: top 160ms ease;
  z-index: 40;
}

.skip-link:focus {
  color: var(--ed-bg);
  top: 0;
}

/* Header */
.top {
  background: color-mix(in srgb, var(--ed-bg) 94%, transparent);
  display: block;
  height: auto;
  padding: 0;
  position: relative;
  width: 100%;
  z-index: 20;
}

.top.sticky {
  animation: none;
  background: color-mix(in srgb, var(--ed-bg) 94%, transparent);
  border-bottom: 1px solid var(--ed-line);
  box-shadow: 0 10px 32px rgb(22 38 43 / 0.08);
  position: sticky;
  top: 0;
}

.top.sticky .utility-bar,
.top.sticky .masthead {
  display: none;
}

.utility-bar {
  background: #1a2326;
  color: #eaf0ef;
  font-size: 0.74rem;
  letter-spacing: 0.035em;
}

.utility-bar__inner {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 2.25rem;
}

.masthead {
  align-items: center;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr auto 1fr;
  min-height: 6.4rem;
}

.logo {
  color: var(--ed-ink) !important;
  font-family: var(--heading-font);
  font-size: clamp(1.75rem, 3.5vw, 3rem);
  font-variation-settings: "wght" 750;
  grid-column: 2;
  grid-row: 1;
  letter-spacing: -0.055em;
  line-height: 1;
  margin: 0;
  text-align: center;
}

.logo > img {
  height: 3.5rem;
  padding: 0;
}

.masthead__promise {
  color: var(--ed-muted);
  font-size: 0.78rem;
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  margin: 0;
}

.masthead .search {
  grid-column: 3;
  justify-self: end;
}

.nav-row {
  border-bottom: 1px solid var(--ed-line);
  border-top: 1px solid var(--ed-line);
}

.nav-row__inner {
  align-items: center;
  display: flex;
  min-height: 3.35rem;
}

.navbar {
  margin: 0 auto;
  order: initial;
}

.navbar .navbar__menu {
  align-items: center;
  flex-wrap: nowrap;
  gap: clamp(1.2rem, 3vw, 2.8rem);
}

.navbar .navbar__menu li {
  font-size: 0.78rem;
  font-variation-settings: "wght" 650;
  letter-spacing: 0.045em;
  white-space: nowrap;
}

.navbar .navbar__menu li a,
.navbar .navbar__menu li span[role="button"] {
  color: var(--ed-ink);
  padding: 1rem 0;
  position: relative;
}

.navbar .navbar__menu > li > a::after,
.navbar .navbar__menu > li > span[role="button"]::after {
  background: var(--ed-accent);
  bottom: 0.65rem;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.navbar .navbar__menu > li > a:hover::after,
.navbar .navbar__menu > li > a:focus-visible::after,
.navbar .navbar__menu > li > span[role="button"]:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.navbar--empty a {
  color: var(--ed-ink);
  font-size: 0.82rem;
  font-variation-settings: "wght" 650;
}

.navbar .navbar__toggle {
  background: var(--ed-ink);
  border-radius: 10px;
  height: 2.85rem;
  margin: 0;
  width: 2.85rem;
}

.search__btn {
  background: var(--ed-surface-strong);
  border-color: var(--ed-line);
  color: var(--ed-ink);
}

.reading-time::before {
  color: var(--ed-line);
  content: "·";
  margin-inline: 0.55rem;
}

/* Homepage */
.frontpage {
  overflow: clip;
}

.frontpage__intro {
  padding-block: clamp(3.5rem, 7vw, 6.5rem) clamp(2rem, 4vw, 3.4rem);
}

.frontpage__label {
  color: var(--ed-accent);
  font-size: 0.78rem;
  font-variation-settings: "wght" 700;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
  text-transform: uppercase;
}

.frontpage__intro h1 {
  font-size: clamp(3rem, 6vw, 4.8rem);
  letter-spacing: -0.065em;
  margin: 0;
  max-width: 11ch;
}

.frontpage__intro > p:last-child {
  color: var(--ed-muted);
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  margin: 1.25rem 0 0;
  max-width: 42rem;
}

.magazine {
  padding-bottom: clamp(4rem, 8vw, 7rem);
}

.magazine__grid {
  display: grid;
  gap: 1.15rem 2rem;
  grid-template-columns: minmax(0, 1.8fr) minmax(17rem, 1fr);
}

.feed__item {
  align-content: start;
  display: grid;
  gap: 1rem;
  margin: 0;
  min-width: 0;
}

.magazine__grid > .feed__item:first-child {
  background: var(--ed-surface-strong);
  border: 1px solid var(--ed-line);
  border-radius: var(--ed-radius);
  box-shadow: var(--ed-shadow);
  grid-row: span 4;
  overflow: hidden;
}

.magazine__grid > .feed__item:first-child .feed__content {
  padding: clamp(1.3rem, 3vw, 2.4rem);
}

.magazine__grid > .feed__item:not(:first-child) {
  border-bottom: 1px solid var(--ed-line);
  grid-column: 2;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  padding: 0.85rem 0 1.25rem;
}

.magazine__grid > .feed__item:only-child {
  align-items: stretch;
  grid-column: 1 / -1;
  grid-row: auto;
  grid-template-columns: minmax(0, 1.28fr) minmax(20rem, 0.72fr);
}

.magazine__grid > .feed__item:only-child:not(:has(.feed__image)) .feed__content {
  grid-column: 1 / -1;
  max-width: 54rem;
}

.feed__image {
  aspect-ratio: 16 / 10;
  background: var(--ed-soft);
  border-radius: var(--ed-media-radius);
  display: block;
  height: auto;
  margin: 0;
  overflow: hidden;
  width: 100%;
}

.magazine__grid > .feed__item:first-child > .feed__image {
  border-radius: 0;
}

.magazine__grid > .feed__item:not(:first-child) > .feed__image {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
}

.feed__image img {
  display: block;
  height: 100%;
  object-fit: cover;
  transition: transform 480ms cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.feed__item:hover .feed__image img {
  transform: scale(1.025);
}

.feed__content {
  max-width: none;
  min-width: 0;
}

.feed__meta {
  color: var(--ed-muted);
  font-size: 0.72rem;
  gap: 0.55rem;
  letter-spacing: 0.02em;
  margin: 0 0 0.75rem;
}

.feed__author {
  color: var(--ed-muted);
  font-variation-settings: "wght" 600;
}

.feed__date {
  color: var(--ed-muted);
  font-style: normal;
}

.feed__author + .feed__date::before {
  background: var(--ed-line);
  margin-right: 0.4rem;
  width: 0.8rem;
}

.feed__title {
  font-size: clamp(1.15rem, 2vw, 1.7rem);
  letter-spacing: -0.035em;
  margin: 0;
}

.magazine__grid > .feed__item:first-child .feed__title {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  max-width: 18ch;
}

.magazine__grid > .feed__item:not(:first-child) .feed__title {
  font-size: 1.02rem;
  line-height: 1.2;
}

.feed__title a {
  color: var(--ed-ink);
}

.feed__title a:hover {
  color: var(--ed-accent);
}

.feed__excerpt {
  color: var(--ed-muted);
  font-size: 0.96rem;
  line-height: 1.65;
  margin-top: 1rem;
  max-width: 62ch;
}

.feed__excerpt p {
  margin: 0;
}

.magazine__grid > .feed__item:not(:first-child) .feed__excerpt,
.magazine__grid > .feed__item:not(:first-child) .feed__readmore {
  display: none;
}

.feed__readmore {
  align-items: center;
  border-bottom: 1px solid var(--ed-accent);
  color: var(--ed-accent);
  display: inline-flex;
  font-size: 0.82rem;
  font-variation-settings: "wght" 700;
  margin-top: 1.35rem;
  padding-bottom: 0.15rem;
  white-space: nowrap;
}

.feed__readmore:active {
  transform: translateY(1px);
}

.editorial-standard {
  border-left: 3px solid var(--ed-accent);
  margin-top: 2.5rem;
  max-width: 44rem;
  padding: 0.25rem 0 0.25rem 1.25rem;
}

.editorial-standard p {
  color: var(--ed-muted);
  margin: 0;
}

.editorial-standard__title {
  color: var(--ed-ink) !important;
  font-size: 0.85rem;
  font-variation-settings: "wght" 700;
  margin-bottom: 0.35rem !important;
}

.editorial-compact .frontpage__intro {
  padding-block: 3.5rem 2rem;
}

.editorial-compact .magazine__grid {
  gap: 0.75rem 1.5rem;
}

.editorial-visual .magazine__grid {
  grid-template-columns: minmax(0, 2.15fr) minmax(16rem, 0.85fr);
}

/* Article */
.reading-progress {
  background: var(--ed-accent);
  height: 3px;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  transform: scaleX(0);
  transform-origin: left;
  z-index: 40;
}

@supports (animation-timeline: scroll()) {
  .reading-progress {
    animation: reading-progress linear;
    animation-timeline: scroll(root);
  }
}

@keyframes reading-progress {
  to { transform: scaleX(1); }
}

.post .content {
  overflow: visible;
}

.post .hero {
  padding-top: clamp(3.5rem, 6vw, 5rem);
}

.post .hero--noimage::after {
  display: none;
}

.post .hero__content {
  padding-bottom: clamp(2.5rem, 5vw, 4.5rem);
}

.post .hero__content .wrapper {
  max-width: 68rem;
}

.post .hero__content h1 {
  font-size: clamp(2.7rem, 5.2vw, 4.2rem);
  letter-spacing: -0.06em;
  margin: 0;
  max-width: 20ch;
}

.post .content__meta {
  color: var(--ed-muted);
  margin-top: 1.5rem;
}

.post .hero__image {
  margin: 0 auto;
  max-width: 82rem;
  padding-inline: clamp(1.25rem, 4vw, 3.5rem);
}

.post .hero__image-wrapper {
  aspect-ratio: 16 / 8.5;
  background: var(--ed-soft);
  border-radius: var(--ed-media-radius);
  box-shadow: var(--ed-shadow);
  height: auto;
  overflow: hidden;
}

.post .hero__image-wrapper img {
  height: 100%;
  object-fit: cover;
}

.article-layout {
  align-items: start;
  display: grid;
  gap: clamp(3rem, 6vw, 6rem);
  grid-template-columns: minmax(0, 45rem) minmax(12rem, 15rem);
  justify-content: center;
  margin-top: clamp(3.5rem, 7vw, 6.5rem);
}

.content__entry {
  color: color-mix(in srgb, var(--ed-ink) 92%, var(--ed-muted));
  font-family: var(--ed-serif);
  font-size: clamp(1.04rem, 1.2vw, 1.16rem);
  letter-spacing: -0.006em;
  line-height: 1.82;
  margin: 0;
}

.content__entry > :first-child {
  margin-top: 0;
}

.content__entry h2,
.content__entry h3,
.content__entry h4 {
  font-family: var(--heading-font);
  scroll-margin-top: 6rem;
}

.content__entry h2 {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  letter-spacing: -0.045em;
  margin-top: clamp(3.5rem, 7vw, 5.5rem);
}

.content__entry h3 {
  font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  margin-top: 3rem;
}

.content__entry p,
.content__entry ol,
.content__entry ul {
  margin-top: 1.15rem;
}

.content__entry ol,
.content__entry ul {
  margin-left: 1.35rem;
}

.content__entry li {
  padding: 0 0 0.45rem 0.25rem;
}

.content__entry a:not(.btn) {
  color: var(--ed-accent);
  text-decoration-color: color-mix(in srgb, var(--ed-accent) 45%, transparent);
  text-decoration-thickness: 1px;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.content__entry a:not(.btn):hover {
  color: var(--ed-ink);
  text-decoration-color: var(--ed-ink);
}

.content__entry blockquote {
  background: var(--ed-surface-strong);
  border: 0;
  border-left: 4px solid var(--ed-accent);
  border-radius: 0 var(--ed-radius) var(--ed-radius) 0;
  box-shadow: var(--ed-shadow);
  color: var(--ed-ink);
  font-family: var(--ed-serif);
  font-size: 1.12rem;
  font-style: normal;
  padding: 1.5rem 1.65rem;
}

.content__entry table {
  background: var(--ed-surface-strong);
  border: 1px solid var(--ed-line);
  border-radius: var(--ed-radius);
  border-spacing: 0;
  display: block;
  font-family: var(--body-font);
  font-size: 0.86rem;
  line-height: 1.45;
  overflow-x: auto;
}

.content__entry thead {
  background: var(--ed-soft);
}

.content__entry th,
.content__entry td {
  border: 0;
  border-bottom: 1px solid var(--ed-line);
  min-width: 8rem;
  padding: 0.8rem 0.9rem;
}

.content__entry tr:last-child td {
  border-bottom: 0;
}

.content__entry h3[id*="evidence-confidence"] {
  border-top: 1px solid var(--ed-line);
  color: var(--ed-accent);
  padding-top: 2rem;
}

.article-rail {
  font-family: var(--body-font);
  min-width: 0;
}

.article-rail__inner {
  position: sticky;
  top: 5.2rem;
}

.article-rail__title {
  color: var(--ed-ink);
  font-size: 0.75rem;
  font-variation-settings: "wght" 700;
  letter-spacing: 0.07em;
  margin: 0 0 1rem;
  text-transform: uppercase;
}

.article-toc {
  border-left: 1px solid var(--ed-line);
  display: grid;
  gap: 0.1rem;
}

.article-toc a {
  color: var(--ed-muted);
  display: block;
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 0.45rem 0 0.45rem 1rem;
  transition: color 160ms ease, border-color 160ms ease;
}

.article-toc__link--h3 {
  padding-left: 1.75rem;
}

.article-toc a:hover,
.article-toc a[aria-current="location"] {
  color: var(--ed-accent);
}

.article-toc a[aria-current="location"] {
  border-left: 2px solid var(--ed-accent);
  margin-left: -1px;
}

.content__footer {
  border-top: 1px solid var(--ed-line);
  margin-top: clamp(4rem, 8vw, 7rem);
  padding-top: 2rem;
}

.content__footer > .entry-wrapper {
  max-width: 45rem;
}

.content__tag > li > a {
  background: var(--ed-surface-strong);
  border-color: var(--ed-line);
  border-radius: 999px;
  color: var(--ed-ink);
}

.content__related {
  background: var(--ed-soft);
}

/* Footer */
.footer {
  background: var(--ed-surface);
  border-top: 1px solid var(--ed-line);
  margin: 0;
  max-width: none;
  padding: 3rem 0;
  text-align: left;
}

.footer .wrapper {
  align-items: center;
  display: flex;
  gap: 2rem;
  justify-content: space-between;
}

.footer__nav ul {
  margin: 0;
}

.footer__copyright {
  display: grid;
  gap: 0.1rem;
  margin: 0;
}

.footer__copyright strong {
  color: var(--ed-ink);
  font-family: var(--heading-font);
  font-size: 1rem;
  font-variation-settings: "wght" 700;
}

.footer__copyright span {
  color: var(--ed-muted);
  font-size: 0.76rem;
}

.footer__bttop {
  background: var(--ed-surface-strong);
  border-color: var(--ed-line);
  color: var(--ed-ink);
}

/* Archive and utility pages inherit the publication rhythm. */
.tag-template .hero,
.author-template .hero,
.tags-template .hero,
.posts .hero,
.page-template .hero {
  padding-top: clamp(2.5rem, 6vw, 5rem);
}

.tag-template .feed,
.author-template .feed,
.posts .feed {
  padding-bottom: 5rem;
}

.tag-template .feed__item,
.author-template .feed__item,
.posts .feed__item {
  border-bottom: 1px solid var(--ed-line);
  grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr);
  margin-top: 0;
  padding-block: 2rem;
}

@media (max-width: 56.1875em) {
  .utility-bar {
    display: none;
  }

  .masthead {
    grid-template-columns: 1fr auto;
    min-height: 4.8rem;
  }

  .logo {
    font-size: 1.55rem;
    grid-column: 1;
    justify-self: start;
    text-align: left;
  }

  .masthead__promise,
  .masthead .search {
    display: none;
  }

  .nav-row {
    border-top: 0;
  }

  .nav-row__inner {
    justify-content: flex-end;
    min-height: 0;
    padding: 0;
  }

  .navbar {
    margin: 0;
    position: absolute;
    right: 1.25rem;
    top: 0.95rem;
  }

  .navbar--empty {
    display: none;
  }

  .magazine__grid {
    grid-template-columns: 1fr;
  }

  .magazine__grid > .feed__item:first-child,
  .magazine__grid > .feed__item:not(:first-child),
  .magazine__grid > .feed__item:only-child {
    grid-column: 1;
    grid-row: auto;
  }

  .article-layout {
    display: block;
    max-width: 48rem;
  }

  .article-rail {
    display: none;
  }

  .post .hero__content .wrapper {
    max-width: 48rem;
  }
}

@media (max-width: 42rem) {
  .frontpage__intro {
    padding-block: 3.2rem 2rem;
  }

  .frontpage__intro h1 {
    font-size: clamp(2.65rem, 14vw, 4rem);
  }

  .magazine__grid > .feed__item:first-child,
  .magazine__grid > .feed__item:only-child {
    display: block;
  }

  .magazine__grid > .feed__item:not(:first-child) {
    grid-template-columns: 5.25rem minmax(0, 1fr);
  }

  .magazine__grid > .feed__item:not(:first-child) .feed__meta {
    display: none;
  }

  .post .hero {
    padding-top: 3rem;
  }

  .post .hero__content h1 {
    font-size: clamp(2.25rem, 11vw, 3.2rem);
  }

  .post .hero__image {
    padding-inline: 1rem;
  }

  .post .hero__image-wrapper {
    aspect-ratio: 4 / 3;
  }

  .article-layout {
    margin-top: 3rem;
    padding-inline: 1.25rem;
  }

  .content__entry {
    font-size: 1.04rem;
    line-height: 1.78;
  }

  .footer .wrapper {
    align-items: flex-start;
    flex-direction: column;
  }

  .tag-template .feed__item,
  .author-template .feed__item,
  .posts .feed__item {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .reading-progress {
    display: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .top,
  .top.sticky {
    background: var(--ed-bg);
  }
}
