/* writing.css — Writing section (#blog). Loaded after refine.css.
   The section stays on the night sky, so Gallery -> Writing -> Workspace is
   one dark run with no light break. Left: five notebooks. Right: the open
   notebook, whose text types itself out (static/js/writing.js). */

#blog {
  position: relative;
  margin-top: 0;
  padding: clamp(3.6rem, 7vw, 5.6rem) clamp(1.15rem, 5.4vw, 7vw) clamp(1rem, 2vw, 1.6rem);
  background: var(--night-3, #070b12);   /* no-JS fallback */
  color: var(--dark-ink);
}
.flow-js #blog { background: none; }
#blog::before { content: none; }
#blog .stars-layer {
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
}
#blog .sec-label { margin-bottom: 1.5rem; color: rgba(240, 240, 248, .4); }
#blog .sec-label::after { background: rgba(255, 255, 255, .1); }

.wr-inner { position: relative; z-index: 2; max-width: 1180px; margin: 0 auto; }
.wr-head { margin-bottom: clamp(2.2rem, 4.6vw, 3.6rem); }
.wr-hed {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 4.4vw, 3.9rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -.034em;
  color: var(--dark-ink);
}
.wr-hed em { font-style: italic; color: var(--seq-metal); }
.wr-sub { margin-top: 1rem; max-width: 44ch; font-size: .98rem; line-height: 1.7; color: rgba(228, 232, 240, .62); }

.wr-body {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.5fr);
  gap: clamp(2rem, 5vw, 4.6rem);
  align-items: stretch;
}

/* ── index of notebooks ──────────────────────────────────────────── */
.wr-index { border-top: 1px solid rgba(255, 255, 255, .1); }
.wr-tab {
  position: relative;
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: .15rem 0;
  width: 100%;
  padding: 1.05rem 0 1.05rem 1rem;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.wr-tab::before {                      /* marker for the open notebook */
  content: '';
  position: absolute;
  left: 0;
  top: 1.05rem;
  bottom: 1.05rem;
  width: 1.5px;
  background: var(--seq-metal);
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform .5s var(--out, cubic-bezier(.2, .75, .2, 1));
}
.wr-tab.is-on::before { transform: scaleY(1); }
.wr-tab-no {
  grid-row: 1 / span 2;
  padding-top: .5rem;
  font-family: var(--font-ui);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .12em;
  color: rgba(228, 232, 240, .32);
  transition: color .3s ease;
}
.wr-tab-name {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 2.2vw, 1.85rem);
  line-height: 1.15;
  letter-spacing: -.018em;
  color: rgba(240, 240, 248, .46);
  transition: color .3s ease, transform .5s var(--out, cubic-bezier(.2, .75, .2, 1));
}
.wr-tab-what {
  font-family: var(--font-ui);
  font-size: .76rem;
  color: rgba(228, 232, 240, .34);
  transition: color .3s ease;
}
.wr-tab:hover .wr-tab-name { color: rgba(240, 240, 248, .82); }
.wr-tab.is-on .wr-tab-name { color: #f4f1ea; }
.wr-tab.is-on .wr-tab-no { color: var(--seq-metal); }
.wr-tab.is-on .wr-tab-what { color: rgba(228, 232, 240, .56); }
.wr-tab:focus-visible { outline: 1px solid var(--seq-metal); outline-offset: 3px; }

/* ── the open notebook ───────────────────────────────────────────── */
.wr-pane {
  display: grid;
  min-width: 0;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .04) 0%, rgba(255, 255, 255, .014) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
/* every notebook sits in the same cell, so the pane never changes height */
.wr-note { grid-area: 1 / 1; min-width: 0; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s .25s; }
.wr-note.is-on { opacity: 1; visibility: visible; transition: opacity .35s ease .08s, visibility 0s; }
.wr-note-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-ui);
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(228, 232, 240, .4);
}
.wr-note-top span:first-child { color: var(--seq-metal); }
.wr-note-title {
  margin-top: 1.1rem;
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 3.4vw, 2.9rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -.03em;
  color: #f4f1ea;
}
.wr-note-copy {
  margin-top: 1rem;
  max-width: 52ch;
  font-size: 1.02rem;
  line-height: 1.7;
  color: rgba(228, 232, 240, .72);
}
.wr-note-list { list-style: none; margin: 1.9rem 0 0; padding: 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.wr-note-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.4rem;
  padding: .95rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.wr-note-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.wr-note-line { font-family: var(--font-serif); font-size: clamp(1.05rem, 1.5vw, 1.22rem); line-height: 1.35; color: rgba(240, 240, 248, .9); }
.wr-note-soon {
  flex: none;
  font-family: var(--font-ui);
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(228, 232, 240, .4);
  transition: opacity .4s ease;
}
.wr-note-list li.is-wait .wr-note-soon { opacity: 0; }

/* typing: the part not yet written keeps its space, so lines never jump */
.wr-off { color: transparent; }
.wr-caret { position: relative; display: none; width: 0; }
.is-typing > .wr-caret { display: inline-block; }
.wr-caret::after {
  content: '';
  position: absolute;
  left: 2px;
  bottom: -.14em;
  width: 2px;
  height: 1.05em;
  border-radius: 1px;
  background: var(--seq-metal);
  animation: wrBlink .9s steps(1) infinite;
}
@keyframes wrBlink { 50% { opacity: 0; } }

/* ── tablets and phones ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .wr-body { grid-template-columns: 1fr; gap: 1.3rem; }
  /* notebooks become one row you swipe */
  .wr-index {
    display: flex;
    gap: 1.5rem;
    margin: 0 calc(-1 * clamp(1.15rem, 5.4vw, 7vw));
    padding: 0 clamp(1.15rem, 5.4vw, 7vw);
    border-top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    /* without this the first tab snaps flush to the screen edge on phones */
    scroll-padding-inline: clamp(1.15rem, 5.4vw, 7vw);
  }
  .wr-index::-webkit-scrollbar { display: none; }
  .wr-tab { display: block; flex: none; width: auto; padding: .2rem 0 .85rem; border-bottom: 0; scroll-snap-align: start; }
  .wr-tab-no, .wr-tab-what { display: none; }
  .wr-tab-name { font-size: 1.3rem; white-space: nowrap; }
  .wr-tab::before { top: auto; bottom: -1px; left: 0; right: 0; width: auto; height: 1.5px; transform: scaleX(0); transform-origin: 0 50%; }
  .wr-tab.is-on::before { transform: scaleX(1); }
}
@media (max-width: 600px) {
  .wr-pane { padding: 1.3rem 1.15rem 1.4rem; border-radius: 18px; }
  .wr-note-copy { font-size: .95rem; }
  .wr-note-list { margin-top: 1.4rem; }
  .wr-note-list li { gap: .9rem; padding: .8rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  .wr-note, .wr-tab::before, .wr-tab-name { transition: none; }
  .wr-caret::after { animation: none; }
}
