/* ==========================================================================
   Inkle Weaving Selvedges Guide Stylesheet
   Scope: /inkle-weaving-selvedges/
   ========================================================================== */

/* Layout & Typography */
.selvedges-guide {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

@media (max-width: 640px) {
  .selvedges-guide {
    width: calc(100% - 24px);
    padding: 16px 0 48px;
  }
}

/* Hero Section */
.selvedges-hero {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line, rgba(23, 59, 52, 0.17));
}

.selvedges-hero .eyebrow {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--madder, #b64d3c);
  margin: 0 0 8px;
}

.selvedges-hero h1 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: clamp(2rem, 3.8vw, 2.9rem);
  font-weight: 700;
  line-height: 1.18;
  color: var(--ink, #173b34);
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.selvedges-hero .hero-intro {
  font-size: clamp(1.05rem, 1.8vw, 1.22rem);
  color: var(--ink, #173b34);
  line-height: 1.55;
  margin: 0 0 18px;
  max-width: 820px;
}

/* Jump Navigation Pills */
.jump-nav {
  margin: 20px 0 0;
}

.jump-nav p {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--ink-soft, #49635c);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.jump-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.jump-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--paper, #fbf7ed);
  border: 1px solid var(--line-strong, rgba(23, 59, 52, 0.35));
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink, #173b34);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.jump-pill:hover,
.jump-pill:focus-visible {
  background: var(--linen-deep, #e4d8be);
  border-color: var(--ink, #173b34);
  color: var(--ink, #173b34);
}

/* Callout & Scope Boxes */
.scope-callout {
  background: #f4ede0;
  border-left: 4px solid var(--madder, #b64d3c);
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  margin: 28px 0;
  font-size: 0.96rem;
  line-height: 1.55;
}

.scope-callout strong {
  color: var(--ink, #173b34);
}

.definition-box {
  background: var(--paper, #fbf7ed);
  border: 1px solid var(--line, rgba(23, 59, 52, 0.17));
  border-radius: 8px;
  padding: 20px 24px;
  margin: 24px 0 36px;
}

.definition-box h2 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: 1.35rem;
  color: var(--ink, #173b34);
  margin: 0 0 10px;
}

.definition-box p {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.6;
}

.definition-box p:last-child {
  margin-bottom: 0;
}

/* Section Headings */
.guide-section {
  margin: 48px 0;
}

.section-header {
  margin-bottom: 20px;
}

.section-header .section-tag {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft, #49635c);
  margin: 0 0 6px;
}

.section-header h2 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: clamp(1.5rem, 2.5vw, 1.95rem);
  font-weight: 700;
  color: var(--ink, #173b34);
  margin: 0 0 8px;
}

.section-header .section-desc {
  font-size: 1.02rem;
  color: var(--ink-soft, #49635c);
  margin: 0;
  line-height: 1.5;
}

/* Vector Schematic */
.schematic-wrapper {
  background: #fdfbf7;
  border: 1px solid var(--line-strong, rgba(23, 59, 52, 0.35));
  border-radius: 10px;
  padding: 20px;
  margin: 24px 0;
  box-shadow: 0 4px 16px rgba(47, 36, 25, 0.05);
}

.schematic-svg {
  width: 100%;
  height: auto;
  max-height: 380px;
  display: block;
}

.schematic-caption {
  font-size: 0.88rem;
  color: var(--ink-soft, #49635c);
  margin: 12px 0 0;
  line-height: 1.45;
  text-align: center;
}

/* Symptoms Grid */
.symptom-card {
  background: var(--paper, #fbf7ed);
  border: 1px solid var(--line, rgba(23, 59, 52, 0.17));
  border-radius: 10px;
  margin: 28px 0;
  padding: 24px;
  scroll-margin-top: 80px;
  box-shadow: 0 2px 10px rgba(47, 36, 25, 0.04);
}

.symptom-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line, rgba(23, 59, 52, 0.17));
}

.symptom-header h3 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: 1.32rem;
  color: var(--ink, #173b34);
  margin: 0;
}

.symptom-badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 12px;
  background: #e6dfcf;
  color: var(--ink, #173b34);
}

.symptom-badge.badge-loops {
  background: #fbe6cb;
  color: #8c4710;
}

.symptom-badge.badge-narrow {
  background: #f7dcd8;
  color: #8b2518;
}

.symptom-badge.badge-waver {
  background: #e2ece8;
  color: #1a4a40;
}

.symptom-badge.badge-uneven {
  background: #ece3f5;
  color: #4b2b73;
}

/* Structured Check Table within Symptom Card */
.check-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.95rem;
}

.check-table th,
.check-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--line, rgba(23, 59, 52, 0.17));
}

.check-table th {
  background: #ede3ce;
  color: var(--ink, #173b34);
  font-weight: 700;
  width: 25%;
}

.check-table td {
  background: #faf6ed;
  line-height: 1.55;
}

@media (max-width: 680px) {
  .check-table,
  .check-table tbody,
  .check-table tr,
  .check-table th,
  .check-table td {
    display: block;
    width: 100%;
  }
  .check-table tr {
    margin-bottom: 12px;
    border-bottom: 2px solid var(--line-strong, rgba(23, 59, 52, 0.35));
  }
  .check-table th {
    background: #ede3ce;
    border-bottom: none;
    padding-bottom: 6px;
  }
  .check-table td {
    border-top: none;
    padding-top: 6px;
  }
}

.symptom-note {
  font-size: 0.9rem;
  color: var(--ink-soft, #49635c);
  margin: 12px 0 0;
  font-style: italic;
}

/* Sequence Section */
.sequence-card {
  background: #faf4e8;
  border: 2px solid var(--saffron, #d0a039);
  border-radius: 10px;
  padding: 24px;
  margin: 28px 0;
}

.sequence-card h3 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: 1.35rem;
  color: var(--ink, #173b34);
  margin: 0 0 12px;
}

.sequence-attribution {
  font-size: 0.88rem;
  color: var(--ink-soft, #49635c);
  margin: 0 0 18px;
  line-height: 1.45;
}

.sequence-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: grid;
  gap: 12px;
}

.sequence-step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: baseline;
  background: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--line, rgba(23, 59, 52, 0.17));
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink, #173b34);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

.step-body strong {
  display: block;
  color: var(--ink, #173b34);
  margin-bottom: 2px;
}

.step-body p {
  margin: 0;
  font-size: 0.93rem;
  color: var(--ink, #173b34);
  line-height: 1.5;
}

.sequence-caveat {
  font-size: 0.88rem;
  color: var(--ink-soft, #49635c);
  margin: 12px 0 0;
  line-height: 1.45;
  border-top: 1px dashed var(--line-strong, rgba(23, 59, 52, 0.35));
  padding-top: 12px;
}

/* Printable Worksheet Section */
.worksheet-section {
  margin: 48px 0;
  scroll-margin-top: 80px;
}

.worksheet-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  background: #eee6d4;
  padding: 16px 20px;
  border-radius: 8px;
}

.worksheet-controls p {
  margin: 0;
  font-size: 0.94rem;
  color: var(--ink, #173b34);
  max-width: 600px;
  line-height: 1.45;
}

.print-sheet-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink, #173b34);
  color: #fff;
  border: 1px solid var(--ink, #173b34);
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.print-sheet-btn:hover {
  background: #25554b;
}

.print-sheet-btn:focus-visible {
  outline: 3px solid var(--saffron, #d0a039);
  outline-offset: 2px;
}

/* Worksheet Presentation (Screen View) */
.printable-worksheet {
  background: #fff;
  border: 1px solid #b5a995;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 4px 18px rgba(47, 36, 25, 0.08);
  color: #111;
  font-family: var(--sans, "DM Sans", sans-serif);
}

.ws-header {
  border-bottom: 2px solid #222;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.ws-title-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.ws-title-row h3 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: 1.35rem;
  margin: 0;
  color: #111;
}

.ws-source-mark {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.ws-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 18px;
  font-size: 0.88rem;
  margin-top: 10px;
}

.ws-field {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.ws-field-label {
  font-weight: 700;
  color: #333;
  white-space: nowrap;
}

.ws-field-line {
  flex: 1;
  border-bottom: 1px solid #444;
  height: 18px;
}

/* Observation Grid Table */
.ws-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.86rem;
}

.ws-table th,
.ws-table td {
  border: 1px solid #777;
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

.ws-table th {
  background: #f2ede4;
  color: #111;
  font-weight: 700;
  text-align: center;
}

.ws-table .col-obs { width: 8%; text-align: center; }
.ws-table .col-symptom { width: 22%; }
.ws-table .col-change { width: 28%; }
.ws-table .col-width { width: 14%; text-align: center; }
.ws-table .col-notes { width: 28%; }

.ws-table tr.blank-row td {
  height: 38px;
}

.ws-footer-note {
  font-size: 0.8rem;
  color: #555;
  margin-top: 12px;
  line-height: 1.4;
  border-top: 1px solid #ccc;
  padding-top: 8px;
}

/* FAQ Details */
.faq-grid {
  display: grid;
  gap: 14px;
  margin: 20px 0;
}

.faq-card {
  background: var(--paper, #fbf7ed);
  border: 1px solid var(--line, rgba(23, 59, 52, 0.17));
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}

.faq-card summary {
  padding: 16px 20px;
  font-family: var(--serif, "Fraunces", serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink, #173b34);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.faq-card summary::-webkit-details-marker {
  display: none;
}

.faq-card summary::after {
  content: "+";
  font-family: var(--sans, "DM Sans", sans-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink-soft, #49635c);
  margin-left: 12px;
}

.faq-card[open] summary::after {
  content: "−";
}

.faq-body {
  padding: 0 20px 18px;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--ink, #173b34);
}

.faq-body p {
  margin: 0 0 10px;
}

.faq-body p:last-child {
  margin-bottom: 0;
}

/* Related Tools Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.tool-card {
  background: var(--paper, #fbf7ed);
  border: 1px solid var(--line, rgba(23, 59, 52, 0.17));
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(47, 36, 25, 0.08);
}

.tool-card h3 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: 1.15rem;
  color: var(--ink, #173b34);
  margin: 0 0 8px;
}

.tool-card p {
  font-size: 0.91rem;
  color: var(--ink-soft, #49635c);
  margin: 0 0 14px;
  line-height: 1.5;
}

.tool-link {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink, #173b34);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tool-link:hover {
  text-decoration: underline;
}

/* Sources Section */
.sources-box {
  background: #f7f2e7;
  border-top: 1px solid var(--line-strong, rgba(23, 59, 52, 0.35));
  padding: 24px;
  border-radius: 8px;
  margin: 48px 0 0;
  font-size: 0.92rem;
}

.sources-box h2 {
  font-family: var(--serif, "Fraunces", serif);
  font-size: 1.25rem;
  margin: 0 0 12px;
  color: var(--ink, #173b34);
}

.sources-list {
  padding-left: 20px;
  margin: 0 0 14px;
  line-height: 1.6;
}

.sources-list li {
  margin-bottom: 8px;
}

.sources-list a {
  color: var(--ink, #173b34);
  font-weight: 700;
}

.sources-meta {
  font-size: 0.85rem;
  color: var(--ink-soft, #49635c);
  margin: 0;
}

/* ==========================================================================
   PRINT STYLESHEET
   Crucial Constraint: ONLY output the single compact width observation record.
   Hide site header, navigation, hero, teaching sections, FAQ, sources, buttons,
   and any FAB or unrelated page content. Safe Letter/A4 portrait margins.
   ========================================================================== */
@media print {
  @page {
    size: portrait;
    margin: 12mm 15mm;
  }

  /* Reset body and hide all non-worksheet elements */
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt !important;
    line-height: 1.35 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Hide complete site chrome and all guide sections */
  .site-header,
  .selvedges-hero,
  .scope-callout,
  .definition-box,
  .schematic-section,
  .symptoms-section,
  .sequence-section,
  .faq-section,
  .next-steps-section,
  .sources-box,
  footer,
  .worksheet-controls,
  .worksheet-section > .section-header,
  .print-hide,
  .print-sheet-btn,
  whatsapp-feedback-fab,
  .whatsapp-feedback-fab {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .selvedges-guide {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .worksheet-section {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }

  .printable-worksheet {
    display: block !important;
    width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
    page-break-inside: avoid;
  }

  .ws-header {
    border-bottom: 2pt solid #000 !important;
    padding-bottom: 6pt !important;
    margin-bottom: 8pt !important;
  }

  .ws-title-row h3 {
    font-size: 14pt !important;
    color: #000 !important;
  }

  .ws-source-mark {
    font-size: 8.5pt !important;
    color: #333 !important;
  }

  .ws-meta-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6pt 10pt !important;
    font-size: 9.5pt !important;
    margin-top: 6pt !important;
  }

  .ws-field-line {
    border-bottom: 0.75pt solid #000 !important;
    height: 12pt !important;
  }

  .ws-table {
    margin: 8pt 0 !important;
    font-size: 9pt !important;
    border: 1pt solid #000 !important;
  }

  .ws-table th,
  .ws-table td {
    border: 0.75pt solid #000 !important;
    padding: 5pt 6pt !important;
    color: #000 !important;
  }

  .ws-table th {
    background: #eaeaea !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-weight: 700 !important;
    font-size: 8.5pt !important;
  }

  .ws-table tr.blank-row td {
    height: 32pt !important;
  }

  .ws-footer-note {
    font-size: 8pt !important;
    color: #333 !important;
    margin-top: 6pt !important;
    border-top: 0.5pt solid #666 !important;
    padding-top: 4pt !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .selvedges-page *, .selvedges-page *::before, .selvedges-page *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Keep diagrams readable and the worksheet within narrow viewports. */
.selvedges-page .edge-profile-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.selvedges-page .edge-profile { margin: 0; min-width: 0; }
.selvedges-page .edge-profile figcaption { margin-top: 8px; font-weight: 700; font-size: .9rem; text-align: center; }
.selvedges-page .worksheet-section { display: block; width: 100%; min-width: 0; }
.selvedges-page .ws-source-mark { overflow-wrap: anywhere; min-width: 0; }
.selvedges-page .worksheet-table-scroll { max-width: 100%; overflow-x: auto; }
.selvedges-page .worksheet-table-scroll:focus-visible { outline: 3px solid var(--saffron, #d0a039); }
@media screen and (max-width: 680px) {
 .selvedges-page .edge-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
 .selvedges-page .schematic-wrapper { padding: 12px; }
 .selvedges-page .printable-worksheet { padding: 14px; min-width: 0; }
 .selvedges-page .ws-table { min-width: 600px; }
 .selvedges-page .ws-meta-grid { grid-template-columns: minmax(0, 1fr); }
}
@media print {
 .selvedges-page .worksheet-table-scroll { overflow: visible; }
 .selvedges-page .ws-table { min-width: 0; table-layout: fixed; }
 .selvedges-page .ws-title-row h3 { font-size: 13pt !important; }
}
