/* Modal shell */
.letter-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(10, 12, 16, 0.6);
  backdrop-filter: blur(2px);
}
.letter-modal[aria-hidden="false"] { display: flex; }

/* Dialog */
.letter-dialog {
  width: min(1000px, 96vw);
  max-height: 90vh;
  background: #fff;
  color: #111;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* Header */
.letter-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #eee;
}
.letter-title {
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: .2px;
}
.letter-sub {
  font-size: 13px;
  color: #666;
  margin-top: .35rem;
}
.letter-close {
  border: 0;
  background: #f4f4f5;
  color: #111;
  font-size: 14px;
  border-radius: 10px;
  padding: .5rem .75rem;
  cursor: pointer;
}
.letter-close:hover { background: #e9e9eb; }

/* Body: two-column on desktop, single column on mobile */
.letter-body {
  overflow: auto;
  padding: 1.25rem 1.5rem 1.5rem;
}
.letter-grid {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 1.25rem;
}
@media (max-width: 880px) {
  .letter-grid { grid-template-columns: 1fr; }
}

/* Left column blocks */
.block {
  background: #fff;
  border: 1px solid #f0f0f1;
  border-radius: 12px;
  padding: 1rem;
}
.block h3 {
  margin: 0 0 .6rem;
  font-size: 14px;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: #555;
}

/* Concept */
.concept {
  font-size: 15px;
  line-height: 1.6;
}

/* Roles grid */
.roles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}
.role-card {
  border: 1px solid #efeff2;
  border-radius: 10px;
  padding: .75rem;
  font-size: 14px;
}
.role-card b { display: block; margin-bottom: .35rem; }

/* Usage */
.usage { font-size: 14px; line-height: 1.6; }

/* Right column: quick facts, vignettes, story */
.quick-facts {
  display: grid;
  gap: .6rem;
  font-size: 14px;
}
.fact {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: .5rem;
}
.fact .k { color: #666; }
.fact .v { color: #111; }

.badges {
  display: flex; flex-wrap: wrap; gap: .4rem;
}
.badge {
  font-size: 12px;
  padding: .3rem .5rem;
  border-radius: 999px;
  background: #f5f5f7;
  border: 1px solid #eee;
}

/* Vignettes list */
.vignettes {
  display: grid; gap: .75rem;
  font-size: 14px; line-height: 1.55;
}
.vignettes li { list-style: disc; margin-left: 1rem; }

/* Story (“sigilists-path”) with clamp + expand */
.story {
  position: relative;
  font-size: 14px; line-height: 1.65;
}
.story.clamped {
  max-height: 12.5rem;
  overflow: hidden;
  mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.story-toggle {
  margin-top: .5rem;
  font-size: 13px;
  border: 0;
  background: #f4f4f5;
  padding: .45rem .6rem;
  border-radius: 8px;
  cursor: pointer;
}

/* Footer buttons */
.letter-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  border-top: 1px solid #eee;
  padding: .9rem 1.2rem;
}
.foot-left, .foot-right { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn {
  border: 0; cursor: pointer;
  padding: .6rem .85rem; border-radius: 10px; font-size: 14px;
  background: #111; color: #fff;
}
.btn.ghost { background: #f4f4f5; color: #111; }
.btn.ghost:hover { background: #e9e9eb; }

/* Mini glyph slot (optional canvas / img) */
.mini {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: .75rem; align-items: center;
  font-size: 13px; color: #555;
}
.mini canvas, .mini img {
  width: 68px; height: 68px; border-radius: 10px;
  border: 1px solid #eee; background: #fafafa;
}
.story-wrap { display: flex; flex-direction: column; gap: .5rem; }
.story-title { font-weight: 600; letter-spacing: .02em; }
.story { line-height: 1.6; }
.story.clamped {
  max-height: 12rem;
  overflow: hidden;
  mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.story-maxim { margin-top: .25rem; font-style: italic; opacity: .8; }
.story-toggle { margin-top: .5rem; }
@media print {
  .story.clamped { max-height: unset; mask: none; }
  .story-toggle { display: none !important; }
}
/* Preserve newlines, still wrap long lines */
.letter-modal .concept,
.letter-modal .usage,
.letter-modal .roles .role-card div,
.letter-modal #qStory {
  white-space: pre-line;   /* turns \n into visual breaks */
  line-height: 1.45;
}

/* If you’re line-clamping the story, this still works with pre-line */
.letter-modal #qStory.clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 10;   /* tweak as you like */
  overflow: hidden;
}
