/* ===========================================================================
   Hellstern Schwegler Press — site stylesheet
   Palette note: the accent is not a decorative choice. #333C56 is sampled
   from the blue-black ballpoint ink in Bhante Rewatha's own notebook pages.
   =========================================================================== */

:root {
  /* light — cool Swiss paper stock, neutrals biased toward the ink */
  --paper:      #F3F3F4;
  --paper-2:    #E9EAEE;
  --ink:        #15161A;
  --ink-soft:   #5B5E6A;
  --pen:        #333C56;
  --pen-hover:  #1F2740;
  --rule:       #D3D4DA;
  --cover:      #FBFBFC;
  --cover-rule: #DBDCE2;
  --book-shadow: 0 1px 1px rgba(21,22,26,.05), 0 20px 44px -20px rgba(21,22,26,.30);
  --logo-invert: 0;
  color-scheme: light;

  --measure: 34rem;
  --frame: 62rem;
  --label-col: 10rem;

  --step--1: 0.8125rem;
  --step-0:  1.0625rem;
  --step-1:  1.1875rem;
  --step-2:  clamp(1.5rem, 1.1rem + 1.6vw, 2rem);
  --step-3:  clamp(2rem, 1.3rem + 3vw, 3.25rem);

  --serif: "Spectral", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --grotesk: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #131418;
    --paper-2:    #1C1E24;
    --ink:        #E8E8EA;
    --ink-soft:   #9B9EAB;
    --pen:        #A9B2CC;
    --pen-hover:  #C7CEE4;
    --rule:       #2C2E36;
    --cover:      #1E212A;
    --cover-rule: #363A47;
    --book-shadow: 0 1px 1px rgba(0,0,0,.45), 0 20px 44px -20px rgba(0,0,0,.8);
    --logo-invert: 1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper:      #131418;
  --paper-2:    #1C1E24;
  --ink:        #E8E8EA;
  --ink-soft:   #9B9EAB;
  --pen:        #A9B2CC;
  --pen-hover:  #C7CEE4;
  --rule:       #2C2E36;
  --cover:      #1E212A;
  --cover-rule: #363A47;
  --book-shadow: 0 1px 1px rgba(0,0,0,.45), 0 20px 44px -20px rgba(0,0,0,.8);
  --logo-invert: 1;
  color-scheme: dark;
}

:root[data-theme="light"] { color-scheme: light; }

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--pen); text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
a:hover { color: var(--pen-hover); }

:focus-visible {
  outline: 2px solid var(--pen);
  outline-offset: 3px;
  border-radius: 1px;
}

/* --- frame + section grid ------------------------------------------------ */

.frame {
  max-width: var(--frame);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.section {
  padding-block: clamp(3rem, 7vw, 5.25rem);
  border-top: 1px solid var(--rule);
}
.section:first-of-type { border-top: 0; }

/* Marginal running head — a Swiss editorial device, and it encodes the real
   section name rather than an invented number. Stacks above content on phones. */
.section__label {
  font-family: var(--grotesk);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.section__body { max-width: var(--measure); }
/* the author block carries a portrait beside its text and needs the extra room */
.section__body--wide { max-width: 42rem; }
.section__body > :first-child { margin-top: 0; }
.section__body > :last-child { margin-bottom: 0; }

@media (min-width: 60rem) {
  .section {
    display: grid;
    grid-template-columns: var(--label-col) minmax(0, 1fr);
    column-gap: 3.5rem;
  }
  .section__label { margin-bottom: 0; padding-top: 0.5rem; }
}

/* --- typography ---------------------------------------------------------- */

h1, h2, h3 { font-weight: 300; text-wrap: balance; }

.t-display {
  font-size: var(--step-3);
  font-weight: 200;
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0;
}

.t-head {
  font-size: var(--step-2);
  font-weight: 300;
  line-height: 1.24;
  margin: 0 0 1rem;
}

p { margin: 0 0 1.35em; }

.lede {
  font-size: var(--step-1);
  font-weight: 300;
  line-height: 1.62;
  color: var(--ink);
}

.muted { color: var(--ink-soft); }

.meta {
  font-family: var(--grotesk);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- masthead ------------------------------------------------------------ */

.masthead {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-block: 1.75rem 0;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}
.mark img {
  width: 2.35rem;
  height: 2.35rem;
  filter: invert(var(--logo-invert));
}
.mark__name {
  font-family: var(--grotesk);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.35;
}

.masthead__nav {
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
}
.masthead__nav a {
  font-family: var(--grotesk);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
}
.masthead__nav a:hover,
.masthead__nav a[aria-current="page"] { color: var(--ink); }

/* --- hero ---------------------------------------------------------------- */

.hero {
  padding-block: clamp(3.5rem, 9vw, 7rem) clamp(3rem, 6vw, 4.5rem);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.75rem;
}

/* Bhante's own hand, lifted from the notebook pages of the illustrations. */
.hero__hand {
  width: min(100%, 30rem);
  filter: invert(var(--logo-invert));
}
.hero__byline {
  font-size: var(--step-1);
  font-weight: 300;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0;
}

/* The one moving element on the page: a hairline that rises and falls at the
   pace of a slow breath — 4s in, 5.5s out. It is the book's title, drawn. */
.breath {
  width: 7rem;
  height: 1px;
  background: var(--ink-soft);
  opacity: 0.55;
  transform-origin: center;
  animation: breath 9.5s ease-in-out infinite;
}

@keyframes breath {
  0%   { transform: translateY(5px);  opacity: 0.30; }
  42%  { transform: translateY(-5px); opacity: 0.70; }
  100% { transform: translateY(5px);  opacity: 0.30; }
}

@media (prefers-reduced-motion: reduce) {
  .breath { animation: none; opacity: 0.55; transform: none; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.status {
  font-family: var(--grotesk);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-block;
  font-family: var(--grotesk);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.9rem 1.9rem;
  border: 1px solid var(--pen);
  background: var(--pen);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.btn:hover { background: var(--pen-hover); border-color: var(--pen-hover); color: var(--paper); }

.link-arrow {
  font-family: var(--grotesk);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.link-arrow::after { content: "→"; transition: transform 160ms ease; }
.link-arrow:hover::after { transform: translateX(3px); }

/* --- excerpt ------------------------------------------------------------- */

.excerpt {
  border-left: 1px solid var(--rule);
  padding-left: clamp(1.25rem, 4vw, 2.25rem);
  font-size: var(--step-1);
  font-weight: 300;
  line-height: 1.78;
}
.excerpt p:last-of-type { margin-bottom: 0; }

/* --- author -------------------------------------------------------------- */

.author {
  display: grid;
  gap: 1.75rem clamp(1.5rem, 4vw, 2.5rem);
  grid-template-columns: 1fr;
  align-items: start;
  max-width: 40rem;
}
@media (min-width: 34rem) {
  .author { grid-template-columns: 11rem minmax(0, 1fr); }
}

.portrait {
  aspect-ratio: 4 / 5;
  max-width: 100%;
  background: var(--paper-2);
  object-fit: cover;
}

.portrait--empty {
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: var(--grotesk);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  padding: 1rem;
  line-height: 1.6;
}

/* --- publication data ---------------------------------------------------- */

.coldata {
  display: grid;
  grid-template-columns: minmax(6.5rem, 9rem) minmax(0, 1fr);
  gap: 0.3rem 1.5rem;
  margin: 0;
  font-size: var(--step--1);
}
.coldata dt {
  font-family: var(--grotesk);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 0.28rem;
}
.coldata dd {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
}

/* --- signup -------------------------------------------------------------- */

.signup { max-width: var(--measure); }

.signup__form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.signup__form input[type="email"] {
  flex: 1 1 15rem;
  min-width: 0;
  font-family: var(--serif);
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 0.85rem 1rem;
}
.signup__form input[type="email"]::placeholder { color: var(--ink-soft); opacity: 1; }
.signup__form input[type="email"]:focus { border-color: var(--pen); }

.signup__note {
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin: 1rem 0 0;
  font-family: var(--grotesk);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

.signup__status {
  margin: 1rem 0 0;
  font-size: var(--step-0);
  font-style: italic;
  color: var(--ink);
}
.signup__status[data-state="error"] { color: var(--ink); font-style: normal; }

/* honeypot */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* --- catalogue entry (press home) --------------------------------------- */

.entry {
  display: block;
  text-decoration: none;
  color: inherit;
  padding-block: 0.5rem;
}
.entry__hand {
  width: min(100%, 22rem);
  filter: invert(var(--logo-invert));
  margin-bottom: 1.1rem;
}
.entry:hover .link-arrow::after { transform: translateX(3px); }

/* --- colophon ------------------------------------------------------------ */

.colophon {
  border-top: 1px solid var(--rule);
  padding-block: 2.5rem 3.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3rem;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--grotesk);
  font-size: var(--step--1);
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.colophon a { color: var(--ink-soft); text-decoration: none; }
.colophon a:hover { color: var(--ink); }
.colophon__name {
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}


/* --- the book -------------------------------------------------------------
   Trim is 2:3 — the real 6 × 9 inch page size of the printed edition. Cover
   text is sized in container units, so one piece of markup holds up at hero
   size and at catalogue size without a second set of rules. */

.book {
  position: relative;
  width: min(100%, 21.5rem);
  margin: 0;
  container-type: inline-size;
}

.book--sm { width: min(100%, 13.5rem); }

.book__cover {
  position: relative;
  aspect-ratio: 2 / 3;
  max-width: 100%;
  background: var(--cover);
  border: 1px solid var(--cover-rule);
  box-shadow: var(--book-shadow);
}

/* the inset keyline a bound cover is usually blinded or foiled with */
.book__inner {
  position: absolute;
  inset: 6.5%;
  border: 1px solid var(--cover-rule);
  padding: 8% 7%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 4cqw;
  text-align: center;
}

.book__spacer { height: 0; }

.book__title { margin: 0; font-weight: 300; line-height: 1; width: 100%; }

.book__hand {
  width: 88%;
  margin: 0 auto;
  filter: invert(var(--logo-invert));
}

.book__sub {
  display: block;
  margin: 6cqw auto 0;
  max-width: 24ch;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-size: 3.4cqw;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.book__foot {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book__author {
  margin: 0;
  font-family: var(--grotesk);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink);
  font-size: 0.58rem;
  font-size: 2.9cqw;
  line-height: 1.6;
}

.book__mark {
  width: 12cqw;
  margin-top: 7cqw;
  opacity: 0.7;
  filter: invert(var(--logo-invert));
}

/* --- hero built around the book ------------------------------------------ */

.hero--book {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2.25rem, 5vw, 3.25rem);
  align-items: center;
  justify-items: start;
}

@media (min-width: 52rem) {
  .hero--book {
    grid-template-columns: minmax(0, 21.5rem) minmax(0, 1fr);
    gap: clamp(3rem, 7vw, 5rem);
  }
}

.hero__aside {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.75rem;
  max-width: 27rem;
}

/* --- catalogue entry, cover beside the note ------------------------------ */

.entry--book {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}

@media (min-width: 38rem) {
  .entry--book {
    grid-template-columns: 13.5rem minmax(0, 1fr);
    gap: 2.5rem;
  }
}


/* --- theme toggle ---------------------------------------------------------
   Half-filled disc: it turns over to show the other half. No stored choice
   means the page keeps following the reader's system setting. */

.masthead__end {
  display: flex;
  align-items: center;
  gap: 1.25rem 1.75rem;
  flex-wrap: wrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  flex: none;
  transition: color 160ms ease;
}
.theme-toggle:hover { color: var(--ink); }

.theme-toggle__icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
  transition: transform 420ms cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon { transform: rotate(180deg); }
}
:root[data-theme="dark"] .theme-toggle__icon { transform: rotate(180deg); }
:root[data-theme="light"] .theme-toggle__icon { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .theme-toggle__icon { transition: none; }
}


/* --- mobile menu ----------------------------------------------------------
   Below 46rem the three links no longer sit beside the wordmark, so they
   collapse into a panel. The nav ships marked collapsed and JS owns the state;
   the <noscript> block in each page unhides it when scripting is off, so the
   site is never left without navigation. */

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  flex: none;
  transition: color 160ms ease;
}
.nav-toggle:hover { color: var(--ink); }

.nav-toggle__icon { width: 1.1rem; height: 1.1rem; display: block; }
.nav-toggle__icon line {
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  transform-origin: 12px 12px;
  transition: transform 260ms cubic-bezier(.4, 0, .2, 1), opacity 160ms ease;
}

/* the three rules fold into a cross */
.nav-toggle[aria-expanded="true"] .nav-toggle__icon line:nth-of-type(1) {
  transform: translateY(5px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle__icon line:nth-of-type(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon line:nth-of-type(3) {
  transform: translateY(-5px) rotate(-45deg);
}

@media (max-width: 45.999rem) {
  .masthead__nav {
    position: absolute;
    top: calc(100% + 0.85rem);
    right: 1.5rem;
    z-index: 20;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    min-width: 12.5rem;
    padding-block: 0.4rem;
    background: var(--paper);
    border: 1px solid var(--rule);
    box-shadow: var(--book-shadow);
  }
  .masthead__nav[data-collapsed] { display: none; }
  .masthead__nav a {
    padding: 0.75rem 1.35rem;
  }
  .masthead__nav a[aria-current="page"] { color: var(--ink); }
}

@media (min-width: 46rem) {
  .nav-toggle { display: none; }
  /* the attribute is JS state for the panel only; inline links ignore it */
  .masthead__nav[data-collapsed] { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle__icon line { transition: none; }
}
