/* =========================================================================
   Carter & Co. Publishing, Design System
   ========================================================================= */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;0,6..72,800;1,6..72,300;1,6..72,400;1,6..72,500;1,6..72,600;1,6..72,700&family=Noto+Serif+SC:wght@300;400;500;600;700;900&family=Noto+Serif+TC:wght@300;400;500;600;700;900&family=Open+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=JetBrains+Mono:wght@300;400;500&display=swap');

/* ---------- Tokens ---------- */
:root {
  /* Paper system */
  --paper:        #F7F7F5;
  --paper-deep:   #ECECE8;
  --paper-edge:   #D8D8D2;
  --ink:          #15171C;
  --ink-soft:     #2A2A2E;
  --muted:        #6E665B;
  --muted-2:      #948B7C;
  --rule:         #2A2A2E;
  --rule-soft:    rgba(21,23,28,0.18);

  /* Brand color, Carter & Co. publisher's ink */
  --primary:      #1B2D80;          /* deep ultramarine / publisher's blue */
  --primary-hot:  #213AA8;
  --primary-cool: #142060;

  /* Accents (used sparingly in main shell, more on imprint pages) */
  --oxblood:      #7C2018;
  --burnt:        #C4571E;

  /* Imprint accents (only on imprint pages) */
  --imp-particle:    #E8A33D;
  --imp-particle-2:  #D77A8E;
  --imp-particle-bg: #FDF4DF;

  --imp-lake:        #A53024;
  --imp-lake-2:      #1A2D6B;
  --imp-lake-bg:     #F4E9DC;

  --imp-sapientia:   #1F4D2A;
  --imp-sapientia-2: #C8A574;
  --imp-sapientia-bg:#EFE9DD;

  --imp-velvet:      #8B5A6B;
  --imp-velvet-2:    #4A3340;
  --imp-velvet-bg:   #F1E6DC;

  /* Spacing scale */
  --gutter: 32px;
  --col:    72px;
  --rule-w: 1px;

  /* Motion, one shared easing + duration across the core shell */
  --ease: cubic-bezier(.2,.6,.2,1);
  --dur:  180ms;

  /* Type scale (modular, classical) */
  --t-mono:  'JetBrains Mono', ui-monospace, Menlo, monospace;
  --t-sans:  'Open Sans', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --t-serif: 'Newsreader', 'Times New Roman', Times, serif;
  --t-cn:    'Noto Serif SC', 'Noto Serif TC', 'Newsreader', serif;

  /* UI typeface for nav links + buttons */
  --t-ui:    var(--t-sans);

  /* Chrome label letter-spacing, tightened for the sans default */
  --t-label-spacing: 0.14em;
}

/* ---------- Chrome typeface (Tweak) ----------
   UMN-Press style: clean humanist sans (Open Sans) for all label/meta/UI chrome,
   paired with the Newsreader serif for editorial display. "mono" restores the
   original JetBrains Mono letterpress feel. */
body[data-chrome="sans"] {
  --t-mono: var(--t-sans);
  --t-label-spacing: 0.13em;
}
body[data-chrome="mono"] {
  --t-label-spacing: 0.16em;
  --t-ui: var(--t-serif);
}

/* ---------- Color presets (applied to <body data-preset="..."> via Tweak) ---------- */
body[data-preset="ink"] {
  --primary:      #1B2D80;
  --primary-hot:  #213AA8;
  --primary-cool: #142060;
}
body[data-preset="oxblood"] {
  --primary:      #7C2018;
  --primary-hot:  #9B2D20;
  --primary-cool: #5C140F;
}
body[data-preset="forest"] {
  --primary:      #1F4D2A;
  --primary-hot:  #2E6B3B;
  --primary-cool: #143820;
}

/* ---------- Type theme (Tweak) ---------- */
body[data-type-theme="modern"] {
  --t-serif: 'Newsreader', 'Times New Roman', serif;
  --t-display-weight: 500;
  --t-display-spacing: -0.02em;
}
body[data-type-theme="classic"] {
  --t-display-weight: 700;
  --t-display-spacing: -0.005em;
}

/* ---------- Paper background (Tweak) ---------- */
body[data-paper="textured"] {
  background-image:
    radial-gradient(circle at 25% 35%, rgba(80,80,76,0.04) 0%, transparent 40%),
    radial-gradient(circle at 75% 65%, rgba(80,80,76,0.035) 0%, transparent 40%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.35  0 0 0 0 0.34  0 0 0 0.07 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
body[data-paper="plain"] {
  background-image: none;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }

/* ---------- Body ---------- */
body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--t-serif);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01", "kern", "liga";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Default paper texture */
body {
  background-image:
    radial-gradient(circle at 25% 35%, rgba(80,80,76,0.04) 0%, transparent 40%),
    radial-gradient(circle at 75% 65%, rgba(80,80,76,0.035) 0%, transparent 40%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.35  0 0 0 0 0.34  0 0 0 0.07 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--t-serif);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.display {
  font-family: var(--t-serif);
  font-weight: var(--t-display-weight, 600);
  font-size: clamp(48px, 6vw, 88px);
  line-height: 0.96;
  letter-spacing: var(--t-display-spacing, -0.01em);
}
.headline {
  font-family: var(--t-serif);
  font-weight: 600;
  font-size: clamp(32px, 3.6vw, 52px);
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.display { text-wrap: balance; }
.title {
  font-family: var(--t-serif);
  font-weight: 600;
  font-size: 28px;
  line-height: 1.1;
  text-wrap: balance;
}
.lede {
  font-size: 22px;
  line-height: 1.45;
  font-weight: 400;
  color: var(--ink-soft);
  text-wrap: pretty;
}
p { margin: 0 0 1em; text-wrap: pretty; }
em, i { font-style: italic; }

/* Editorial labels, small caps */
.label {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: var(--t-label-spacing, 0.16em);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink);
}
.label--muted { color: var(--muted); }
.label--brand { color: var(--primary); }

/* Meta line (mono) */
.meta {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Chinese text */
.cn, [lang="zh"] {
  font-family: var(--t-cn);
  font-weight: 400;
}

/* Drop cap for editor's letter */
.drop-first::first-letter {
  font-family: var(--t-serif);
  font-weight: 700;
  font-size: 5em;
  line-height: 0.85;
  float: left;
  padding: 0.05em 0.1em 0 0;
  color: var(--primary);
}

/* ---------- Top metadata strip ---------- */
.topstrip {
  border-bottom: var(--rule-w) solid var(--rule);
  padding: 8px var(--gutter);
  font-family: var(--t-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}
.topstrip__group { display: flex; gap: 24px; flex-wrap: wrap; }
.topstrip__item { white-space: nowrap; }
.topstrip__item--dot::before { content: "·"; padding-right: 12px; }

/* ---------- Masthead ---------- */
.masthead {
  position: relative;
  z-index: 200;
  border-bottom: 2px solid var(--rule);
  padding: 28px var(--gutter) 22px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 24px;
}
.masthead__left, .masthead__right { display: flex; gap: 28px; }
.masthead__right { justify-content: flex-end; }
.masthead__wordmark {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--ink);
}
.masthead__wordmark .name {
  font-family: var(--t-serif);
  font-weight: 700;
  font-size: clamp(36px, 4.4vw, 56px);
  line-height: 1;
  letter-spacing: -0.015em;
}
.masthead__wordmark .name em {
  font-weight: 400;
  font-style: italic;
}
.masthead__wordmark .tag {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-link {
  font-family: var(--t-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.nav-link:hover { color: var(--primary); border-bottom-color: var(--primary); }
.nav-link.is-active { color: var(--primary); font-style: italic; }

/* ---------- Imprints nav dropdown ---------- */
.nav-dd { position: relative; display: inline-flex; }
.nav-dd > .nav-link::after {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 7px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.55;
  transition: transform .2s ease, opacity .2s ease;
}
.nav-dd.is-open > .nav-link::after { transform: translateY(0) rotate(-135deg); opacity: 1; }
.nav-dd__menu {
  position: absolute;
  top: calc(100% + 16px);
  right: 0;
  width: 312px;
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 22px 48px -28px rgba(21,23,28,0.55);
  padding: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-7px);
  transition: opacity .17s ease, transform .17s ease, visibility .17s;
  z-index: 250;
}
.nav-dd.is-open .nav-dd__menu { opacity: 1; visibility: visible; transform: translateY(0); }
/* invisible bridge so the gap between link and menu stays hoverable */
.nav-dd__menu::before {
  content: ""; position: absolute; top: -20px; left: 0; right: 0; height: 22px;
}
.nav-dd__head {
  display: block;
  font-family: var(--t-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 10px 11px;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 5px;
}
.nav-dd__item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: none;
  transition: background .12s ease;
}
.nav-dd__item:hover { background: var(--paper-deep); }
.nav-dd__dot {
  width: 9px; height: 9px; border-radius: 50%;
  margin-top: 5px; flex: none;
  box-shadow: 0 0 0 1px rgba(21,23,28,0.12) inset;
}
.nav-dd__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-dd__name {
  font-family: var(--t-serif);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
}
.nav-dd__name em {
  font-style: normal;
  font-family: var(--t-cn);
  font-size: 14px;
  color: var(--muted);
  margin-left: 2px;
}
.nav-dd__desc {
  font-family: var(--t-ui);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}
.nav-dd__all {
  display: block;
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--primary);
  text-decoration: none;
  padding: 12px 10px 7px;
  border-top: 1px solid var(--rule-soft);
  border-bottom: none;
  margin-top: 5px;
}
.nav-dd__all:hover { color: var(--primary-hot); }

/* ---------- Layout ---------- */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.container--narrow { max-width: 920px; }
.container--reading { max-width: 720px; }

.divider {
  border: 0;
  border-top: 1px solid var(--rule-soft);
  margin: 48px 0;
}
.divider--strong { border-top: 1px solid var(--rule); }

/* Editorial multi-rule (double-rule like a newspaper) */
.rule-double {
  border-top: 1px solid var(--rule);
  border-bottom: 3px double var(--rule);
  height: 5px;
}

/* Section heading: small label + headline */
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
}
.sec-head__label { color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  white-space: nowrap;
  font-family: var(--t-ui);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--paper);
}
.btn--primary:hover { background: var(--primary-hot); border-color: var(--primary-hot); color: var(--paper); }
.btn--ghost { border-color: var(--rule-soft); color: var(--ink); }
.btn--ghost:hover { background: var(--paper-deep); color: var(--ink); }
.btn--small { padding: 7px 14px; font-size: 14px; }
.btn .arrow { display: inline-block; transition: transform var(--dur) var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

/* ---------- Book card ---------- */
.book {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.book__cover {
  position: relative;
  aspect-ratio: 5 / 7;
  background: var(--paper-deep);
  border: 1px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 18px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06), 0 10px 30px -18px rgba(0,0,0,0.25);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.book:hover .book__cover {
  transform: translateY(-3px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.05), 0 22px 44px -20px rgba(0,0,0,0.34);
}

/* Image-cover variant, jacket art with title baked into the image. */
.book__cover--image,
.book__cover.book__cover--image,
.book__cover.book__cover--image.ifeatured__cover {
  aspect-ratio: 2 / 3;
  padding: 0;
  background: #14110d;
}
.book__cover--image > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.book__cover .imp {
  font-family: var(--t-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
}
.book__cover .ttl {
  font-family: var(--t-serif);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.book__cover .sub {
  font-size: 13px;
  font-style: italic;
  margin-top: 6px;
  opacity: 0.85;
  line-height: 1.3;
}
.book__cover .auth {
  font-family: var(--t-serif);
  font-size: 14px;
  font-weight: 400;
}
.book__meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--t-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.book__meta > span:first-child {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book__meta > span:last-child { flex: none; white-space: nowrap; }
.book__title {
  font-family: var(--t-serif);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.2;
}
/* Even breathing room around the bilingual " / " separator */
.book__title em,
.hero-pick__title em { margin-left: 0.12em; }
.book__author {
  font-family: var(--t-serif);
  font-style: italic;
  font-size: 15px;
  color: var(--muted);
}

/* Cover variants (so each "cover" looks distinct without real art) */
.cv-ruijin {
  background: #8B3A1F url('covers/ruijin.png') center/cover no-repeat;
  color: transparent;
}
.cv-ruijin > * { visibility: hidden; }
.cv-hongzongma {
  background: #A8483A url('covers/hongzongma.png') center/cover no-repeat;
  color: transparent;
}
.cv-hongzongma > * { visibility: hidden; }
.cv-chinese-women {
  background: #8B1414 url('covers/chinese-women.jpg') center/cover no-repeat;
  color: transparent;
}
.cv-chinese-women > * { visibility: hidden; }
.cv-lyrebird {
  background: #5DA89A url('covers/lyrebird.jpg') center/cover no-repeat;
  color: transparent;
}
.cv-lyrebird > * { visibility: hidden; }
.cv-kitchen {
  background: #8B2018 url('covers/kitchen.png') center/cover no-repeat;
  color: transparent;
}
.cv-kitchen > * { visibility: hidden; }
.cv-anran {
  background: #DCE5DB url('covers/anran.png') center/cover no-repeat;
  color: transparent;
}
.cv-anran > * { visibility: hidden; }
.cv-miantiao {
  background: #DD7A3E url('covers/miantiao.png') center/cover no-repeat;
  color: transparent;
  aspect-ratio: 1 / 1 !important;
}
.cv-miantiao > * { visibility: hidden; }
.cv-naturalis { background: #F8F4EC; color: #15171C; border: 1px solid rgba(0,0,0,0.12); }
.cv-hulan { background: #2C3A2A; color: #C9A968; }
.cv-sophie { background: #8C846F; color: #1F1B14; }
.cv-garden {
  background: #B0C4A8 url('covers/garden.png') center/cover no-repeat;
  color: transparent;
}
.cv-garden > * { visibility: hidden; }
.cv-zuleika {
  background: #D7B98A url('covers/zuleika.png') center/cover no-repeat;
  color: transparent;
}
.cv-zuleika > * { visibility: hidden; }
.cv-herland {
  background: #C8B594 url('covers/herland.png') center/cover no-repeat;
  color: transparent;
}
.cv-herland > * { visibility: hidden; }
.cv-frazer { background: linear-gradient(135deg, #4A2D6B 0%, #6B3A2D 50%, #8B5A3D 100%); color: #F4E9DC; }
.cv-park { background: linear-gradient(135deg, #6B3D2D 0%, #8B5A3D 50%, #C8A574 100%); color: #2A1410; }
.cv-durkheim { background: linear-gradient(135deg, #4A1F2D 0%, #6B3A2D 50%, #C8A574 100%); color: #F4E9DC; }

/* When a book card uses an external image (img file) */
.book__cover--img { padding: 0; }
.book__cover--img img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Footer ---------- */
.foot {
  margin-top: 120px;
  border-top: 2px solid var(--rule);
  padding: 56px var(--gutter) 40px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 48px;
}
.foot__col h4 {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 18px;
  color: var(--primary);
}
.foot__col ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.foot__col a:hover { color: var(--primary); }
.foot__brand { font-family: var(--t-serif); font-size: 22px; font-weight: 600; }
.foot__brand em { font-weight: 400; font-style: italic; }
.foot__colophon {
  margin-top: 24px;
  font-family: var(--t-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.7;
}
.foot__bottom {
  grid-column: 1 / -1;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  justify-content: space-between;
  font-family: var(--t-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.gap-4 { gap: 32px; }
.gap-6 { gap: 48px; }
.gap-8 { gap: 64px; }
.mt-8 { margin-top: 64px; }
.mt-12 { margin-top: 96px; }
.mb-4 { margin-bottom: 32px; }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.italic { font-style: italic; }
.no-break { white-space: nowrap; }
.hide-cn { }
.hide-en { }
body[data-lang="en"] .hide-en { display: none !important; }
body[data-lang="zh"] .hide-zh { display: none !important; }
body[data-lang="en"] [lang="zh"]:not(.show-always) { display: none !important; }
body[data-lang="zh"] [data-en]:not(.show-always) { display: none !important; }

/* ---------- Language switch button ---------- */
.lang-switch {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  gap: 6px;
}
.lang-switch button.is-on { color: var(--primary); font-weight: 600; }

/* ---------- Reader / Author mode ---------- */
body[data-mode="author"] .reader-only { display: none !important; }
body[data-mode="reader"] .author-only { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .masthead {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .masthead__left, .masthead__right { justify-content: center; flex-wrap: wrap; gap: 18px; }
  .nav-dd__menu { right: 50%; transform: translate(50%, -7px); width: min(312px, calc(100vw - 40px)); }
  .nav-dd.is-open .nav-dd__menu { transform: translate(50%, 0); }
  .foot { grid-template-columns: 1fr 1fr; }
  .topstrip { font-size: 9.5px; gap: 14px; }
  :root { --gutter: 20px; }
}
@media (max-width: 600px) {
  .foot { grid-template-columns: 1fr; }
  .topstrip__group { gap: 12px; }
  body { font-size: 16px; }
}
