/* Independent writing: editorial layout within the portfolio's own design system.
   All typography and colors inherit the same site tokens used by Research. */

.writing-section.independent-writing {
  margin: 0;
  padding: clamp(64px, 7vw, 100px) clamp(22px, 5vw, 74px) clamp(70px, 8vw, 112px);
  background: var(--white);
  color: var(--ink);
  border-top: 1px solid var(--line);
  scroll-margin-top: 90px;
}
.independent-writing > .writing-header,
.independent-writing > .writing-intro,
.independent-writing > .writing-snapshot,
.independent-writing > .writing-posts,
.independent-writing > .writing-fallback,
.independent-writing > .writing-all {
  width: 100%;
  max-width: 1080px;
  margin-left: auto;
  margin-right: auto;
}
.writing-header { margin-bottom: 16px; }
.writing-header .eyebrow { margin: 0 0 15px; }
.writing-header h2 {
  display: flex;
  align-items: center;
  gap: .22em;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.6rem, 5vw, 4.5rem);
  font-weight: 590;
  line-height: 1;
  letter-spacing: -.065em;
}
.substack-mark {
  width: .36em;
  height: .44em;
  flex: none;
  fill: #ec5b28; /* Substack's original orange brand mark */
}
.writing-intro {
  margin-top: 0;
  margin-bottom: 37px;
  color: var(--muted);
  font-family: var(--body);
  font-size: clamp(.95rem, 1.4vw, 1.06rem);
  line-height: 1.7;
}
.writing-snapshot {
  margin-top: -15px;
  margin-bottom: 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .68rem;
  line-height: 1.5;
}
.writing-posts {
  display: block;
  border-top: 1px solid var(--line);
}
.writing-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: clamp(22px, 3vw, 40px);
  min-width: 0;
  padding: 30px 0 34px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
}
.writing-copy { min-width: 0; }
.writing-card h3 {
  margin: 0 0 13px;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 570;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1.17;
  letter-spacing: -.045em;
  text-align: left;
  overflow-wrap: anywhere;
}
.writing-card h3 a { color: inherit; text-decoration: none; }
.writing-card h3 a:hover,
.writing-card h3 a:focus-visible { text-decoration: underline; text-underline-offset: .18em; }
.writing-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px 18px;
  margin: 0 0 17px;
}
.writing-meta time,
.writing-duration {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .69rem;
  font-weight: 500;
  line-height: 1.55;
}
.writing-meta time {
  text-transform: uppercase;
  letter-spacing: .065em;
}
.writing-card .writing-excerpt {
  margin: 0 0 16px;
  max-width: 67ch;
  color: var(--muted);
  font-family: var(--body);
  font-size: .96rem;
  line-height: 1.75;
}
.writing-read,
.writing-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 0 6px;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--body);
  font-size: .77rem;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
  text-underline-offset: .2em;
}
.writing-read:hover,
.writing-all:hover { color: var(--blue); border-bottom-color: var(--blue); }
.independent-writing a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}
.writing-image { display: block; overflow: hidden; }
.writing-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}
.writing-all {
  display: table;
  width: auto !important;
  max-width: 1080px;
  margin-top: 27px;
  margin-right: auto;
  margin-left: calc(max(0px, (100% - 1080px) / 2));
}
.writing-fallback { padding: 25px 0; }
.writing-fallback p { margin: 0 0 15px; color: var(--muted); }

/* The featured essay is a centered longform composition, not a promotional card.
   The original artwork remains uncropped; text wraps naturally around it. */
.writing-card.writing-featured {
  display: flow-root;
  min-height: 0;
  padding: 34px 0 48px;
}
.writing-featured .writing-copy {
  display: flow-root;
  width: 100%;
}
.writing-featured .writing-image {
  float: right;
  width: 38%;
  max-width: 400px;
  margin: 0 0 20px clamp(22px, 3.5vw, 44px);
  shape-outside: margin-box;
}
.writing-featured h3 {
  max-width: none;
  margin-bottom: 22px;
  font-size: clamp(2rem, 3.25vw, 3rem);
  line-height: 1.12;
  font-weight: 590;
  letter-spacing: -.058em;
  text-wrap: balance;
}
.writing-featured .writing-excerpt {
  max-width: none;
  margin-bottom: 19px;
  font-size: clamp(1rem, 1.28vw, 1.08rem);
  line-height: 1.82;
}
.writing-featured .writing-opening { display: contents; }
.writing-featured .writing-excerpt-fade {
  /* Fade the end of the excerpt in place, without moving it below the image. */
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}
.writing-featured .writing-read { clear: none; }

/* Subsequent articles remain editorial rows separated by fine rules. */
.writing-card.writing-older.has-image {
  grid-template-columns: minmax(0, 1fr) clamp(108px, 14vw, 176px);
}
.writing-older .writing-copy { grid-column: 1; grid-row: 1; }
.writing-older .writing-image { grid-column: 2; grid-row: 1; align-self: start; }

/* Responsive composition: the title always precedes the image on phones. */
@media (max-width: 720px) {
  .writing-section.independent-writing {
    padding: 57px 22px 76px;
  }
  .writing-header h2 { font-size: clamp(2.3rem, 8vw, 3.3rem); }
  .writing-intro { margin-bottom: 29px; }
  .writing-card.writing-featured { padding: 29px 0 38px; }
  .writing-featured .writing-copy {
    display: flex;
    flex-direction: column;
  }
  .writing-featured .writing-meta { order: 0; margin-bottom: 13px; }
  .writing-featured h3 {
    order: 1;
    margin-bottom: 23px;
    font-size: clamp(1.8rem, 6.3vw, 2.35rem);
  }
  .writing-featured .writing-image {
    order: 2;
    float: none;
    width: 100%;
    max-width: 460px;
    margin: 0 0 24px;
    shape-outside: none;
  }
  .writing-featured .writing-opening { display: block; order: 3; }
  .writing-featured .writing-continuation { order: 4; }
  .writing-featured .writing-excerpt {
    font-size: 1rem;
    line-height: 1.76;
  }
  .writing-featured .writing-read { order: 5; align-self: flex-start; }
  .writing-older.has-image { gap: 20px; }
  .writing-card.writing-older.has-image {
    grid-template-columns: minmax(0, 1fr) clamp(78px, 22vw, 125px);
  }
  .writing-older h3 { font-size: clamp(1.25rem, 4.2vw, 1.6rem); }
  .writing-card .writing-excerpt { line-height: 1.68; }
  .writing-all { margin-left: 0; }
}
@media (max-width: 420px) {
  .writing-card.writing-older.has-image {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 14px;
  }
  .writing-older .writing-meta { margin-bottom: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .writing-read, .writing-all { transition: none; }
}
