/* ==========================================================================
   WRITING: the shareable copy of the opinions room

   Each essay has its own page here, so a link to it carries a title, a
   description and a card when it is pasted somewhere. The look is the
   opinions room's: newsprint ground, Newsreader and Spectral, a double rule
   under the masthead. The room inside brain/ keeps its own copy for the art;
   these pages are the canonical ones. Sections 1, 2 and 11 are copied from
   brain/brain.css; keep them in step when that file changes.
   ========================================================================== */

/* 1. Tokens ============================================================== */

:root {
  --f-display: "Newsreader", Georgia, "Times New Roman", serif;
  --f-text:    "Spectral", Georgia, serif;
  --f-ui:      "Inter", system-ui, -apple-system, sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  /* Brass, as on the front of the site. */
  --brass:        #7a5c15;
  --brass-lift:   #d4b25a;

  /* The one hue used to encode data, stepped to pass contrast and the
     categorical lightness/chroma bands against each ground it sits on.
     Brass proper is slightly too gray and slightly too light respectively,
     so the plots get their own step rather than repainting the brand. */
  --plot:         #8a6408;   /* on paper  */
  --plot-dark:    #b08f3c;   /* on black  */

  --ease:     cubic-bezier(0.22, 0.85, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}


*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: #eae6db;
  color: #17141a;
  font-family: var(--f-text);
  font-weight: 300;
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(122, 92, 21, 0.22); }

a { color: inherit; }

/* 2. Grain =============================================================== */

/* Paper, not a texture image: a tiled SVG of fractal noise at very low
   opacity. It sits over everything and catches nothing. */
.grain {
  position: fixed;
  inset: -10%;
  z-index: 9000;
  pointer-events: none;
  opacity: 0.4;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}


/* Page frame ============================================================== */

.wr-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  /* Same left and right edges as the text column below it. */
  width: calc(100% - 2 * clamp(1rem, 4vw, 2.5rem));
  max-width: 68rem;
  margin: 0 auto;
  padding: clamp(1.2rem, 3vw, 2rem) 0 0;
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.wr-top a { text-decoration: none; opacity: 0.72; }
.wr-top a:hover, .wr-top a:focus-visible { opacity: 1; text-decoration: underline; text-underline-offset: 0.2em; }

.wr {
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1rem, 4vw, 2.5rem) clamp(3rem, 8vw, 6rem);
}

.wr-date {
  margin: 0.9rem 0 0;
  font-family: var(--f-ui);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  opacity: 0.72;
}
.wr-index-date { margin-left: 0.8em; letter-spacing: 0.12em; }

.wr-foot {
  max-width: 68rem;
  margin: clamp(2.4rem, 6vw, 3.6rem) auto 0;
  padding-top: 1.2rem;
  border-top: 3px double rgba(26, 23, 16, 0.4);
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.wr-foot p { margin: 0 0 0.7rem; }
.wr-foot a { text-decoration: none; opacity: 0.72; margin-right: 1.2rem; }
.wr-foot a:hover, .wr-foot a:focus-visible { opacity: 1; text-decoration: underline; text-underline-offset: 0.2em; }
.wr-share button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0.3rem 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
}
.wr-share button:hover, .wr-share button:focus-visible { text-decoration: underline; text-underline-offset: 0.2em; }
.wr-share__status { margin-left: 0.8rem; opacity: 0.72; text-transform: none; letter-spacing: 0; }
:focus-visible { outline: 2px solid #6f4f06; outline-offset: 2px; }

/* 11. Opinions =========================================================== */

.op {
  max-width: 68rem;
  margin: 0 auto;
  color: #1a1710;
}

.op__masthead {
  padding-bottom: 1.4rem;
  border-bottom: 3px double rgba(26, 23, 16, 0.4);
  margin-bottom: 2rem;
}

.op__no {
  margin: 0 0 0.7rem;
  font-family: var(--f-ui);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  opacity: 0.68;           /* 5.4:1 on the paper; 0.5 was 3.2:1 */
}

.op__hed {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 300;
  font-size: clamp(1.9rem, 5.2vw, 3.3rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.op__dek {
  margin: 0.8rem 0 0;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 1rem;
  opacity: 0.68;           /* 0.62 sat just under AA on the rendered paper */
}

.op__cols {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  gap: clamp(1.6rem, 4vw, 3.2rem);
  align-items: start;
}

.op__essay p { margin: 0 0 1.05rem; font-size: 1rem; }

.op__lede::first-letter {
  float: left;
  font-family: var(--f-display);
  font-size: 3.6rem;
  line-height: 0.82;
  padding: 0.12em 0.1em 0 0;
  font-weight: 300;
}

.op__claim {
  margin: 1.4rem 0 !important;
  padding: 0.9rem 0;
  border-top: 1px solid rgba(26, 23, 16, 0.22);
  border-bottom: 1px solid rgba(26, 23, 16, 0.22);
  font-size: 1.06rem !important;
}

.op__kicker {
  margin-top: 1.6rem !important;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(26, 23, 16, 0.22);
  font-style: italic;
  opacity: 0.75;
}

.op__margin {
  padding-left: clamp(0.9rem, 2vw, 1.4rem);
  border-left: 1px solid rgba(26, 23, 16, 0.22);
  font-size: 0.82rem;
  line-height: 1.62;
}
.op__margin p { margin: 0 0 0.9rem; }
.op__margin hr {
  border: 0;
  border-top: 1px solid rgba(26, 23, 16, 0.22);
  margin: 1.4rem 0;
}

.op__cite {
  font-family: var(--f-ui);
  font-size: 0.58rem !important;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 0.35rem !important;
  color: #6f4f06;          /* --plot, stepped down: 9px on newsprint needs it */
}
.op__cite span { opacity: 0.6; margin-right: 0.3em; }
.op__cite--against { color: #1a1710; opacity: 0.78; margin-top: 1.3rem !important; }

.op__caveat { font-style: italic; }
.op__caveats {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.6;
}
.op__caveats li { margin-bottom: 0.5rem; }

.op__rm {
  margin-top: 1.2rem !important;
  padding: 0.7rem 0.8rem;
  background: rgba(138, 100, 8, 0.1);
  font-style: italic;
  font-size: 0.8rem !important;
}
.op__rm[hidden] { display: none; }

.op__essay code {
  font-family: var(--f-mono);
  font-size: 0.88em;
}

/* The index and the pieces ---------------------------------------------- */

/* #/opinions shows the index; #/opinions/<no> shows one piece. */
.op__index[hidden], .op__piece[hidden] { display: none; }

.op__list { list-style: none; margin: 0; padding: 0; max-width: 44rem; }

.op__item {
  display: block;
  padding: 1.5rem 0 1.4rem;
  border-bottom: 1px solid rgba(26, 23, 16, 0.22);
  color: inherit;
  text-decoration: none;
}
.op__item .op__no { display: block; margin-bottom: 0.55rem; }
.op__item-hed {
  display: block;
  font-family: var(--f-display);
  font-weight: 300;
  font-size: clamp(1.45rem, 3.4vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.op__item .op__dek { display: block; margin-top: 0.45rem; }
.op__item:hover .op__item-hed,
.op__item:focus-visible .op__item-hed {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

/* Same register as the room's own [ back to the map ]. */
.op__back {
  display: inline-block;
  margin: 0 0 1.6rem;
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: inherit;
  opacity: 0.72;
}
.op__back:hover, .op__back:focus-visible { opacity: 1; }
.op__back--foot { margin: clamp(2.4rem, 6vw, 3.6rem) 0 0; }
.op__perma { margin-left: 1.4rem; }

/* The exhibit ------------------------------------------------------------ */

.exh {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1.6rem;
  border-top: 3px double rgba(26, 23, 16, 0.4);
}

.exh__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.4rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.exh__q {
  margin: 0;
  font-family: var(--f-ui);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.exh__filters { display: flex; gap: 0.4rem; }

.exh__f {
  appearance: none;
  background: none;
  border: 1px solid rgba(26, 23, 16, 0.28);
  padding: 0.34rem 0.7rem;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: inherit;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.exh__f.is-on {
  background: #1a1710;
  border-color: #1a1710;
  color: #eae6db;
}

.exh__pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: clamp(1.2rem, 3vw, 2.4rem);
}

.exh__one { margin: 0; }

.exh__one figcaption {
  margin-bottom: 0.7rem;
  font-family: var(--f-ui);
  font-size: 0.72rem;
  line-height: 1.5;
  opacity: 0.7;
}

.exh__tag {
  display: inline-block;
  margin-right: 0.45rem;
  padding: 0.16rem 0.44rem;
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.exh__tag--bad  { background: rgba(26, 23, 16, 0.12); }
.exh__tag--good { background: var(--plot); color: #f6f2e6; }

.exh__plot { position: relative; }
.exh__plot svg { display: block; width: 100%; height: auto; }

.bar {
  fill: var(--plot);
  opacity: 0.82;
  transition: opacity 0.18s linear;
}
.bar.is-hot { opacity: 1; }

.plot__axis   { stroke: rgba(26, 23, 16, 0.35); stroke-width: 1; }
.plot__grid   { stroke: rgba(26, 23, 16, 0.11); stroke-width: 1; }
.plot__tick   { fill: rgba(26, 23, 16, 0.6); font-family: var(--f-mono); font-size: 9px; }
.plot__vlabel { fill: #1a1710; font-family: var(--f-mono); font-size: 9.5px; font-weight: 500; }
.plot__hit    { fill: transparent; }

.tip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -115%);
  padding: 0.35rem 0.55rem;
  background: #1a1710;
  color: #eae6db;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.14s linear;
}
.tip.is-on { opacity: 1; }
.tip b { display: block; font-weight: 500; opacity: 0.6; }

/* Act headings, so the concession and the claim are visibly separate. */
.exh__act {
  margin: 0 0 1rem;
  font-family: var(--f-ui);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  opacity: 0.8;
}
.exh__act--two {
  margin-top: clamp(2.2rem, 5vw, 3.4rem);
  padding-top: 1.2rem;
  border-top: 1px solid rgba(26, 23, 16, 0.22);
  opacity: 0.9;
}

.exh__ask {
  margin: -0.5rem 0 1.2rem;
  font-family: var(--f-display);
  font-size: 1.05rem;
  font-style: italic;
}

/* The bar currently being taken apart. */
.bar.is-picked { opacity: 1; stroke: #1a1710; stroke-width: 1.5px; }

.plot__hit { cursor: pointer; }

/* ---- the derivation ---------------------------------------------------- */

.deriv[hidden] { display: none; }
.deriv {
  margin-top: 1.2rem;
  padding: clamp(1rem, 3vw, 1.6rem);
  border: 1px solid rgba(26, 23, 16, 0.28);
  background: rgba(255, 253, 248, 0.5);
}

.deriv__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.deriv__eyebrow {
  margin: 0 0 0.2rem;
  font-family: var(--f-ui);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  opacity: 0.82;
}

.deriv__title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 300;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  line-height: 1.1;
}

.deriv__ctl { display: flex; gap: 0.5rem; }
.deriv__ctl button {
  appearance: none;
  background: none;
  border: 1px solid rgba(26, 23, 16, 0.28);
  padding: 0.3rem 0.66rem;
  font-family: var(--f-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: inherit;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.deriv__ctl button:hover,
.deriv__ctl button:focus-visible { background: #1a1710; color: #eae6db; }

.deriv__plot svg { display: block; width: 100%; height: auto; }

.wf {
  fill: var(--plot);
  opacity: 0.85;
  transition: opacity 0.2s linear;
}
.wf--down  { fill: #1a1710; opacity: 0.45; }
.wf--total { fill: var(--plot); opacity: 1; }

.wf__val {
  fill: #1a1710;
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  transition: opacity 0.25s var(--ease);
}
.wf__val--total { font-size: 12px; }

.wf__name {
  fill: rgba(26, 23, 16, 0.72);
  font-family: var(--f-ui);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: opacity 0.25s var(--ease);
}

.wf__link {
  stroke: rgba(26, 23, 16, 0.38);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  transition: opacity 0.25s var(--ease);
}

/* The arithmetic in writing, which is what survives reduced motion, a
   screen reader, and a printout. */
.deriv__steps {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.12rem 1.1rem;
  margin: 1.3rem 0 0;
  font-size: 0.82rem;
}
.deriv__steps dt {
  font-family: var(--f-ui);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.6;
  padding-top: 0.2rem;
}
.deriv__steps dd {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.9rem;
  align-items: baseline;
  margin: 0 0 0.3rem;
}
.deriv__steps dt.is-total,
.deriv__steps dd.is-total {
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(26, 23, 16, 0.22);
  opacity: 1;
}
.deriv__v {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  min-width: 4.5rem;
}
.deriv__run {
  font-family: var(--f-mono);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
  min-width: 7rem;
}
.deriv__why { font-style: italic; opacity: 0.72; }

.deriv__note {
  margin: 1.2rem 0 0;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(26, 23, 16, 0.18);
  font-size: 0.78rem;
  line-height: 1.6;
  opacity: 0.78;
}

.exh__table {
  margin-top: 1.6rem;
  font-size: 0.8rem;
}
.exh__table summary {
  cursor: pointer;
  font-family: var(--f-ui);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  opacity: 0.7;
}
.exh__table table {
  margin-top: 0.9rem;
  border-collapse: collapse;
  font-family: var(--f-mono);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}
.exh__table th, .exh__table td {
  padding: 0.24rem 0.9rem 0.24rem 0;
  text-align: left;
  border-bottom: 1px solid rgba(26, 23, 16, 0.14);
}
.exh__table th { font-weight: 500; opacity: 0.6; }

.exh__stamp {
  margin: 1.4rem 0 0;
  font-family: var(--f-mono);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.72;
}


/* Responsive ============================================================== */

@media (max-width: 860px) {
  .op__cols { grid-template-columns: minmax(0, 1fr); }
  .op__margin { border-left: 0; padding-left: 0; border-top: 1px solid rgba(26,23,16,0.22); padding-top: 1.2rem; }
  .deriv__steps { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  .deriv__steps dt { padding-top: 0.6rem; }
  .deriv__run { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
