/* ============================================================================
   Journal — the blog index and post pages.

   Loaded only by /blog/, on top of css/style.css, so the home page's
   render-blocking stylesheet does not carry any of this weight. It reuses
   style.css for the brand tokens, fonts, buttons, .wrap, .mandala and .orn;
   everything here is the chrome and typography those pages add.

   Two rules shape the whole file:

   1. Reveals are opt-in through html.cg-js, set by a one-line inline script in
      each page's <head>. style.css hides .fade until main.js lights it up, and
      these pages deliberately do not load main.js — so a copy of that pattern
      would leave every blog page blank for anyone whose JavaScript fails. Here
      the content is visible by default and only hidden once the script has
      confirmed it can bring it back.
   2. The letter unfold is pure CSS driven by one class on <body>, so it cannot
      strand the post behind a half-finished animation.
   ========================================================================= */

/* ---------- Page chrome ---------- */
.jbody{min-height:100vh;display:flex;flex-direction:column}
.jmain{flex:1}

/* A static header rather than the home page's .nav, which main.js drives. */
.jnav{position:sticky;top:0;z-index:60;display:flex;align-items:center;justify-content:space-between;
  gap:1rem;padding:.9rem clamp(1.1rem,4vw,2.4rem);
  background:rgba(49,7,15,.92);background:color-mix(in srgb,var(--burg) 92%,transparent);
  backdrop-filter:saturate(140%) blur(14px);-webkit-backdrop-filter:saturate(140%) blur(14px);
  border-bottom:1px solid rgba(220,187,126,.18)}
.jnav-logo{display:block;line-height:0}
.jnav-logo img{width:104px;height:auto}
.jnav-right{display:flex;align-items:center;gap:clamp(.9rem,3vw,1.8rem)}
.jnav-back{color:var(--gold-lt);text-decoration:none;font-size:.78rem;font-weight:600;
  letter-spacing:.14em;text-transform:uppercase;white-space:nowrap}
.jnav-back:hover{color:var(--ivory)}
.jnav .btn{padding:.72rem 1.3rem;font-size:.86rem}
@media (max-width:560px){
  .jnav{padding:.7rem 1.1rem}
  .jnav .btn{display:none}
  .jnav-logo img{width:88px}
  .jnav-back{font-size:.72rem}
}

/* Thin gold reading line along the top of the viewport. */
.jprog{position:fixed;left:0;top:0;height:2px;width:100%;transform:scaleX(0);transform-origin:0 50%;
  background:linear-gradient(90deg,var(--gold-dk),var(--gold-lt));z-index:120;pointer-events:none}

/* ---------- Masthead ---------- */
.jhead{position:relative;overflow:hidden;padding:clamp(3.4rem,9vw,6.4rem) 0 clamp(2.6rem,6vw,4rem);text-align:center}
.jhead::after{content:"";position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(62% 72% at 50% 0%,rgba(184,149,97,.2),transparent 68%)}
.jhead-in{position:relative;z-index:2;width:min(720px,100% - var(--pad)*2);margin-inline:auto}
.jhead-mandala{left:50%;top:-54%;width:min(760px,128vw);transform:translateX(-50%);opacity:.16}
.jhead .script{font-size:clamp(1.9rem,6vw,2.7rem);color:var(--accent);margin:0 0 .3rem}
.jhead h1{font-family:var(--serif);font-weight:500;letter-spacing:-.018em;line-height:1.06;
  font-size:clamp(2.3rem,7vw,4rem);margin:0 0 .9rem;color:var(--head)}
.jhead p{margin:0 auto;max-width:52ch;color:var(--muted)}
.jhead .orn{margin-inline:auto}

/* ---------- Index listing ---------- */
.jlist{display:grid;gap:clamp(1.6rem,4vw,2.2rem);
  width:min(var(--maxw),100% - var(--pad)*2);margin:0 auto;
  padding-bottom:clamp(3.4rem,8vw,6rem)}
@media (min-width:760px){.jlist{grid-template-columns:repeat(2,1fr)}}
@media (min-width:1080px){.jlist{grid-template-columns:repeat(3,1fr)}}
/* The index uses the same .jcard as the home page, but laid out in a grid
   rather than a slider, so the flex sizing from style.css is released. */
.jlist .jcard{flex:none;scroll-snap-align:none}

/* ---------- Reveals (only hidden once the script is known to work) ---------- */
html.cg-js .jr{opacity:0;transform:translateY(24px)}
html.cg-js .jr.in{opacity:1;transform:none;
  transition:opacity 1s var(--ease),transform 1s var(--ease)}

/* ============================================================================
   The letter

   A post opens the way a folded letter does: it arrives as a sealed band, the
   wax seal lifts, and the paper unfolds downward and upward to full height
   while it tilts back to flat. clip-path does the unfolding, so it works at any
   content length and never clips text out of the flow once it has finished.
   ========================================================================= */
.letter-stage{perspective:1700px;perspective-origin:50% 12%;
  width:min(880px,100% - var(--pad)*2);margin:0 auto clamp(3rem,7vw,5rem);
  padding-top:clamp(2.4rem,6vw,4.5rem)}

.letter{position:relative;transform-origin:50% 0;--fold:clamp(150px,26vh,230px);
  background:
    radial-gradient(120% 80% at 50% 0%,rgba(255,255,255,.5),transparent 60%),
    linear-gradient(176deg,#F7EFE0,var(--parch) 42%,#E4D3B6);
  color:var(--esp);border-radius:4px;
  padding:clamp(2.6rem,7vw,4.6rem) clamp(1.5rem,5vw,4rem) clamp(2.8rem,7vw,4.4rem);
  box-shadow:0 2px 0 rgba(255,255,255,.5) inset,0 40px 90px -20px rgba(0,0,0,.55),
    0 0 0 1px rgba(142,106,58,.22)}
/* The crease the paper was folded along. It sits a fixed distance from the top,
   because that is where the fold is, and fades out once the letter lies flat. */
.letter::before{content:"";position:absolute;left:0;right:0;top:var(--fold);height:1px;
  background:linear-gradient(90deg,transparent,rgba(142,106,58,.32) 12%,rgba(142,106,58,.32) 88%,transparent);
  opacity:0;transition:opacity 1.1s var(--ease)}

/* The seal sits on the fold and is the first thing to go. */
.letter-seal{position:absolute;left:50%;top:var(--fold);width:76px;height:76px;margin:-38px 0 0 -38px;
  z-index:4;border-radius:50%;display:grid;place-items:center;
  background:radial-gradient(circle at 34% 30%,#C9603F,#8E2E22 62%,#6A1F17);
  box-shadow:0 10px 22px rgba(0,0,0,.4),0 0 0 1px rgba(255,255,255,.18) inset;
  pointer-events:none;opacity:0}
.letter-seal span{font-family:var(--serif);font-size:1.6rem;font-weight:600;color:#F2D9A8;
  letter-spacing:.02em;line-height:1}

/* Content inside the letter settles in after the paper has opened. */
.letter-in{opacity:1}

/* --- The animated state. Everything above stays the open, finished layout, so
       a page with no script, or with reduced motion asked for, simply shows
       the letter already open. --- */
/* The fold is a fixed distance from the TOP of the paper, not a share of its
   height: a post is several thousand pixels tall, so a fold at 50% would open
   somewhere far below the viewport and the reader would watch an empty screen. */
html.cg-js .letter{opacity:0;transform:rotateX(26deg) scale(.975);transform-origin:50% 0;
  clip-path:inset(0 0 calc(100% - var(--fold)) 0 round 4px)}
html.cg-js .letter-in{opacity:0;transform:translateY(16px)}
html.cg-js .letter-seal{opacity:1;transform:scale(1) rotate(-6deg);
  animation:sealIn .5s cubic-bezier(.3,1.4,.5,1) both}
@keyframes sealIn{from{opacity:0;transform:scale(.55) rotate(-22deg)}
  to{opacity:1;transform:scale(1) rotate(-6deg)}}

body.unfold .letter{opacity:1;transform:none;clip-path:inset(0 0 0 0 round 4px);
  transition:clip-path 1.6s cubic-bezier(.62,.03,.2,1) .55s,
    transform 1.8s cubic-bezier(.22,.8,.2,1) .55s,opacity .5s ease 0s}
body.unfold .letter::before{opacity:1;transition-delay:.5s}
body.unfold .letter.flat::before{opacity:0}
body.unfold .letter-seal{opacity:0;transform:scale(1.9) rotate(16deg);animation:none;
  transition:opacity .55s ease,transform .9s cubic-bezier(.3,1.5,.5,1)}
body.unfold .letter-in{opacity:1;transform:none;
  transition:opacity 1.1s var(--ease) 1.1s,transform 1.1s var(--ease) 1.1s}

@media (prefers-reduced-motion:reduce){
  html.cg-js .letter{opacity:1;transform:none;clip-path:none}
  html.cg-js .letter-in{opacity:1;transform:none}
  html.cg-js .letter-seal,.letter::before{display:none}
  html.cg-js .jr{opacity:1;transform:none}
  .jprog{display:none}
}

/* ---------- Letter contents ---------- */
.letter-kicker{margin:0 0 1rem;font-size:.72rem;font-weight:700;letter-spacing:.17em;
  text-transform:uppercase;color:#9A4038;text-align:center}
.letter h1{font-family:var(--serif);font-weight:500;letter-spacing:-.018em;line-height:1.08;
  font-size:clamp(2rem,5.4vw,3.2rem);margin:0 0 1rem;color:var(--burg);text-align:center}
.letter-byline{margin:0 0 2rem;text-align:center;font-size:.86rem;color:rgba(42,26,27,.72)}
.letter-byline span{color:#7A5A2B}
.letter-fig{margin:0 0 2.2rem;border-radius:3px;overflow:hidden;
  box-shadow:0 18px 40px -16px rgba(0,0,0,.42)}
.letter-fig img{width:100%;height:auto;aspect-ratio:4/3;object-fit:cover}

.prose{font-size:1.04rem;line-height:1.78;color:rgba(42,26,27,.84)}
.prose>p:first-of-type{font-family:var(--serif);font-size:1.3rem;line-height:1.55;
  color:var(--burg)}
.prose p{margin:0 0 1.15rem}
.prose h2{font-family:var(--serif);font-weight:500;letter-spacing:-.01em;line-height:1.18;
  font-size:clamp(1.45rem,3.4vw,1.95rem);margin:2.4rem 0 .8rem;color:var(--burg)}
.prose h3{font-family:var(--sans);font-weight:600;font-size:1rem;letter-spacing:.01em;
  margin:1.8rem 0 .5rem;color:var(--burg)}
.prose ul,.prose ol{margin:0 0 1.3rem;padding-left:1.25rem}
.prose li{margin-bottom:.5rem}
.prose li::marker{color:var(--gold-dk)}
.prose strong{color:var(--esp);font-weight:600}
.prose a{color:var(--wine);text-underline-offset:3px;text-decoration-color:var(--gold)}
.prose blockquote{margin:2rem 0;padding:0 0 0 1.4rem;border-left:2px solid var(--gold);
  font-family:var(--serif);font-size:1.26rem;line-height:1.5;color:var(--burg)}
.prose blockquote p:last-child{margin-bottom:0}
.prose hr{border:0;height:1px;margin:2.6rem 0;
  background:linear-gradient(90deg,transparent,rgba(142,106,58,.35),transparent)}
.letter-end{display:block;width:150px;height:26px;color:var(--gold-dk);margin:2.6rem auto 0}

/* The enquiry nudge at the foot of a post, on the letter's own paper. */
.letter-cta{margin-top:2.4rem;padding-top:2rem;border-top:1px solid rgba(142,106,58,.28);
  text-align:center}
.letter-cta p{margin:0 0 1.2rem;font-family:var(--serif);font-size:1.22rem;color:var(--burg)}
/* .btn-wine is full width in style.css, where it is a form button; here it is a link. */
.letter-cta .btn-wine{width:auto;padding:1rem 2rem}

/* ---------- More from the journal ---------- */
.jmore{padding:0 0 clamp(3.4rem,8vw,5.5rem);text-align:center}
.jmore h2{font-family:var(--serif);font-weight:500;font-size:clamp(1.6rem,4vw,2.3rem);
  margin:0 0 .4rem;color:var(--head)}
.jmore .orn{margin:1rem auto 2rem}
/* Two cross-links, so two columns -- a three-column grid would leave a hole. */
.jmore .jlist{max-width:860px;padding-bottom:clamp(2.4rem,6vw,3.4rem)}
@media (min-width:760px){.jmore .jlist{grid-template-columns:repeat(2,1fr)}}
@media (min-width:1080px){.jmore .jlist{grid-template-columns:repeat(2,1fr)}}

/* ---------- Footer ---------- */
.jfoot{position:relative;overflow:hidden;background:var(--burg);color:var(--ivory);
  text-align:center;padding:clamp(3rem,7vw,4.6rem) 0 clamp(3.4rem,7vw,4.6rem)}
/* Same correction as the main footer ring -- see style.css. */
.jfoot-mandala{left:50%;bottom:-38%;width:min(860px,130vw);transform:translateX(-50%);opacity:.32}
.jfoot-mandala i:nth-child(1){animation-duration:20s}
.jfoot-mandala i:nth-child(2){animation-duration:32s}
.jfoot-mandala i:nth-child(3){animation-duration:48s}
.jfoot-in{position:relative;z-index:2}
.jfoot img{width:150px;height:auto;margin:0 auto 1.2rem}
.jfoot .footer-links{margin-bottom:1.4rem}
/* Paragraphs carry a max-width from style.css, so centre the box as well as the text. */
.jfoot p,.jhead p{margin-inline:auto}
