/* ==========================================================================
   Encyclopedia of Trousers for Women
   Design direction: a pattern-drafting studio, not a library shelf.
   Dot-grid pattern paper, denim indigo, kraft card stock, chalk and brass
   pin accents. Type stays Cormorant Garamond + Raleway (loaded by the
   shared header.php across the whole Dreams & Designs ebook series) —
   this book differentiates through palette, texture, and illustration
   rather than typeface, the same way two books from one imprint share a
   spine font but never share a cover.
   ========================================================================== */

:root {
  --denim-deep:  #202f42;
  --denim:       #34506e;
  --denim-light: #5478a0;
  --kraft:       #ddcfae;
  --kraft-light: #ece4cc;
  --kraft-dark:  #c7b78d;
  --chalk:       #f6f2e6;
  --ink:         #2a2724;
  --ink-soft:    #4a453d;
  --thread-red:  #9c3b2c;
  --pin-brass:   #a3823f;
  --muted:       #736a58;
  --line:        #b9a97c;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Raleway', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max: 1180px;
  --radius: 3px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.65;
  background-color: var(--kraft);
  background-image: radial-gradient(circle, rgba(42,39,36,0.10) 0.6px, transparent 0.6px);
  background-size: 18px 18px;
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--pin-brass); color: #fff; padding: 10px 16px; z-index: 200;
}
.skip-link:focus { left: 10px; top: 10px; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; color: var(--denim-deep); line-height: 1.2; }
a { color: var(--denim); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--thread-red); }

/* ---------- Header ---------- */
.site-header {
  background: var(--denim-deep);
  color: var(--chalk);
  position: sticky; top: 0; z-index: 100;
  border-bottom: 3px solid var(--pin-brass);
}
.header-inner {
  max-width: var(--max); margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--chalk); }
.brand:hover { text-decoration: none; opacity: .9; }
.brand-mark { color: var(--pin-brass); display: inline-flex; }
.brand-text { font-family: var(--serif); font-size: 1.3rem; letter-spacing: .03em; }
.brand-text em { font-style: italic; color: #e8cf8e; font-weight: 500; }

.nav-toggle {
  display: none;
  background: none; border: 1px solid #3a4a68; border-radius: 4px;
  width: 38px; height: 34px; cursor: pointer; padding: 0;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.nav-toggle span { width: 20px; height: 2px; background: var(--chalk); display: block; }

.header-search { flex: 1; position: relative; max-width: 520px; }
.header-search input {
  width: 100%; padding: 9px 14px; border-radius: 20px; border: 1px solid #2a3b5c;
  background: #16233a; color: var(--chalk); font-family: var(--sans); font-size: .92rem;
}
.header-search input::placeholder { color: #8a93a8; }
.header-search input:focus { outline: 2px solid var(--pin-brass); }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--chalk); color: var(--ink); border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(16,20,30,.4); max-height: 420px; overflow-y: auto; z-index: 150;
}
.search-results a {
  display: block; padding: 10px 14px; border-bottom: 1px dashed var(--line); color: var(--ink);
}
.search-results a:hover { background: var(--kraft-light); text-decoration: none; }
.search-results .sr-title { font-weight: 700; color: var(--denim-deep); display: block; font-family: var(--serif); font-size: 1.08rem; }
.search-results .sr-part { font-size: .76rem; color: var(--muted); font-family: var(--sans); letter-spacing: .02em; }
.search-results .sr-excerpt { font-size: .85rem; color: var(--ink); display: block; margin-top: 2px; }
.search-results .sr-empty { padding: 14px; color: var(--muted); font-size: .9rem; font-style: italic; }
mark { background: #e8cf8e; color: var(--denim-deep); padding: 0 2px; }

.top-links { display: flex; gap: 16px; white-space: nowrap; }
.top-links a { color: var(--chalk); font-size: .9rem; font-family: var(--sans); }
.top-links a:hover { color: #e8cf8e; }

/* ---------- Layout ---------- */
.layout { display: flex; max-width: var(--max); margin: 0 auto; align-items: flex-start; }
.sidebar {
  width: 300px; flex-shrink: 0; padding: 22px 18px; border-right: 1px solid var(--line);
  position: sticky; top: 58px; max-height: calc(100vh - 58px); overflow-y: auto;
}
.sidebar-title {
  font-family: var(--sans); font-weight: 700; font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; margin-bottom: 12px; color: var(--pin-brass);
  padding-bottom: 10px; border-bottom: 1.5px dashed var(--line);
}
.toc-part { margin-bottom: 16px; }
.toc-part-title { font-family: var(--serif); font-weight: 700; font-size: .96rem; margin: 12px 0 4px; color: var(--denim); }
.toc-chapters { list-style: none; margin: 0; padding: 0; }
.toc-chapters li a {
  display: flex; gap: 8px; padding: 5px 6px; border-radius: 2px; color: var(--ink); font-size: .88rem;
}
.toc-chapters li a:hover { background: var(--kraft-light); text-decoration: none; }
.toc-chapters li a.active { background: var(--denim-deep); color: #fff; }
.chnum { color: var(--pin-brass); font-weight: 700; width: 1.5em; flex-shrink: 0; font-family: var(--sans); }
.toc-chapters li a.active .chnum { color: #e8cf8e; }

.content { flex: 1; min-width: 0; padding: 0 0 60px; }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(circle, rgba(255,255,255,.05) 0.6px, transparent 0.6px) 0 0/18px 18px,
    linear-gradient(155deg, var(--denim-deep), #16202e 75%);
  color: var(--chalk); padding: 52px 20px; position: relative;
}
.hero-inner { max-width: var(--max); margin: 0 auto; display: flex; gap: 42px; align-items: center; }
.hero-cover { width: 250px; flex-shrink: 0; border-radius: var(--radius); box-shadow: 0 22px 52px rgba(0,0,0,.5); }
.eyebrow { color: var(--pin-brass); text-transform: uppercase; letter-spacing: .1em; font-size: .78rem; margin: 0 0 12px; font-family: var(--sans); font-weight: 600; }
.hero h1 { font-size: 2.6rem; margin: 0 0 14px; color: #fff; }
.hero h1 span { color: #e8cf8e; font-style: italic; font-weight: 500; }
.lede { font-size: 1.08rem; color: #cad0dc; max-width: 60ch; }
.hero-ctas { display: flex; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.btn { padding: 11px 22px; border-radius: 26px; font-size: .9rem; font-weight: 700; display: inline-block; font-family: var(--sans); }
.btn-primary { background: var(--pin-brass); color: #17223a; }
.btn-primary:hover { background: #bb9550; text-decoration: none; }
.btn-ghost { border: 1px solid #55617a; color: var(--chalk); }
.btn-ghost:hover { background: #1c2942; text-decoration: none; }

/* ---------- Sections ---------- */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.how-to-use, .stitch-preview, .toc-section { padding: 48px 20px; }
.how-to-use { background: var(--kraft-light); }
.how-to-use h2, .stitch-preview h2, .toc-section h2 { text-align: center; font-size: 1.9rem; margin-bottom: 28px; }
.use-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.use-card { background: var(--chalk); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; border-top: 4px solid var(--pin-brass); }
.use-card h3 { margin-top: 0; color: var(--denim); }
.use-card a { font-size: .88rem; font-weight: 600; }

.stitch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stitch-card { text-align: center; background: var(--chalk); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.stitch-card img { width: 100%; height: 110px; object-fit: contain; }
.stitch-card h4 { margin: 12px 0 4px; color: var(--denim); }
.stitch-card p { font-size: .84rem; color: var(--muted); margin: 0; }

.toc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px 44px; }
.toc-part-card h3 { color: var(--denim); border-bottom: 2px dashed var(--pin-brass); padding-bottom: 6px; font-size: 1.15rem; }
.toc-part-card ol { padding-left: 20px; margin: 10px 0; }
.toc-part-card li { margin-bottom: 4px; font-size: .95rem; }

/* ---------- Chapter page ---------- */
.chapter-wrap { max-width: 840px; margin: 0 auto; padding: 40px 24px 20px; }
.chapter-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  text-transform: uppercase; letter-spacing: .06em; font-size: .74rem; color: var(--ink-soft);
  font-weight: 700; margin: 0 0 14px; font-family: var(--sans);
  background: var(--chalk); border: 1.5px solid var(--ink-soft);
  padding: 5px 12px 5px 8px; border-radius: 2px;
}
.chapter-eyebrow::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--kraft); border: 1.5px solid var(--ink-soft); flex: none;
}
.chapter-title { font-size: 2.15rem; margin: 0 0 28px; border-bottom: 3px dashed var(--pin-brass); padding-bottom: 16px; }

.chapter-body h2 { font-size: 1.5rem; color: var(--denim); margin-top: 2.2em; padding-bottom: 8px; border-bottom: 1.5px dashed var(--line); }
.chapter-body h3 { font-size: 1.2rem; color: var(--denim); margin-top: 1.8em; }
.chapter-body p { margin: 1em 0; }
.chapter-body ul, .chapter-body ol { padding-left: 1.4em; }
.chapter-body li { margin-bottom: .5em; }
.chapter-body table {
  width: 100%; border-collapse: collapse; margin: 1.6em 0; font-size: .92rem;
}
.chapter-body th, .chapter-body td {
  border: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top;
}
.chapter-body th { background: var(--denim); color: var(--chalk); font-family: var(--sans); font-weight: 700; font-size: .82rem; letter-spacing: .03em; text-transform: uppercase; }
.chapter-body tr:nth-child(even) td { background: rgba(163,130,63,.06); }
.chapter-body em { color: var(--muted); }
.chapter-body code { background: var(--kraft-light); padding: 1px 5px; border-radius: 3px; }

.chapter-body > p:first-of-type::first-letter {
  font-family: var(--serif); font-weight: 700; font-size: 3.3em; line-height: .78;
  float: left; padding: .04em .08em 0 0; color: var(--pin-brass);
}

blockquote.img-placeholder {
  border: 2px dashed var(--pin-brass);
  background: var(--kraft-light);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 1.6em 0;
  font-size: .88rem;
  color: var(--muted);
}
blockquote.img-placeholder p { margin: 4px 0; }
blockquote.img-placeholder strong { color: var(--denim); }

.chapter-pager {
  max-width: 840px; margin: 40px auto 0; padding: 24px; display: flex; justify-content: space-between;
  gap: 18px; border-top: 2px dashed var(--line);
}
.pager-link { max-width: 45%; padding: 12px 14px; border-radius: var(--radius); transition: background .15s ease; }
.pager-link:hover { background: var(--kraft-light); text-decoration: none; }
.pager-label { display: block; font-size: .75rem; text-transform: uppercase; color: var(--pin-brass); font-weight: 700; font-family: var(--sans); }
.pager-title { display: block; font-family: var(--serif); font-size: 1.05rem; color: var(--ink); }
.pager-next { text-align: right; margin-left: auto; }

/* ---------- Footer ---------- */
.site-footer { background: var(--denim-deep); color: #b9c0d4; padding: 34px 20px; }
.footer-inner { max-width: var(--max); margin: 0 auto; font-size: .88rem; }
.footer-links a { color: #e8cf8e; }
.footer-note { color: #7c86a3; font-size: .8rem; margin-top: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .use-grid { grid-template-columns: 1fr; }
  .stitch-grid { grid-template-columns: repeat(2, 1fr); }
  .toc-grid { grid-template-columns: 1fr; }
  .hero-inner { flex-direction: column; text-align: center; }
  .hero-cover { width: 200px; }
}
@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .top-links { display: none; }
  .sidebar {
    position: fixed; left: -320px; top: 0; height: 100vh; background: var(--kraft);
    width: 300px; z-index: 300; transition: left .25s ease; box-shadow: 6px 0 24px rgba(16,20,30,.25);
  }
  .sidebar.open { left: 0; }
  .header-search { order: 3; width: 100%; max-width: none; margin-top: 8px; }
  .header-inner { flex-wrap: wrap; }
}
