/* ================= Lexicon View Styling ================= */
.lex-page {
  max-width: 1240px;
  margin: 0 auto;
  padding-bottom: var(--space-xl);
}

.lex-header {
  margin-bottom: var(--space-m);
}
.lex-header h1 {
  font-size: var(--step-2);
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  color: var(--ink);
}
.lex-header p {
  margin: 0;
  font-size: var(--step-0);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 760px;
}

/* Lexicon Controls: Search & Category Filter */
.lex-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  flex-wrap: wrap;
  margin-bottom: var(--space-m);
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lex-cats {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.lex-cats::-webkit-scrollbar {
  display: none;
}
.lex-cat-pill {
  border: 0;
  background: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lex-cat-pill:hover {
  background: var(--hover);
  color: var(--ink);
}
.lex-cat-pill.is-active {
  background: var(--ink);
  color: var(--on-ink);
}
.lex-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  max-width: 340px;
}
.lex-search-wrap svg.search-ico {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--ink-3);
  pointer-events: none;
}
.lex-search-input {
  width: 100%;
  height: 34px;
  padding: 0 28px 0 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--step--1);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.lex-search-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px var(--focus);
}
.lex-search-clear {
  position: absolute;
  right: 8px;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
}
.lex-search-clear:hover {
  color: var(--ink);
  background: var(--hover);
}

/* Lexicon Grid: Differentiated, expansive layout */
.lex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: var(--space-l);
}

@media (max-width: 640px) {
  .lex-grid {
    grid-template-columns: 1fr;
    gap: var(--space-m);
  }
}

.lex-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--card-hairline, var(--line));
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: transform 0.22s var(--ease), border-color 0.22s, box-shadow 0.22s;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  position: relative;
  width: 100%;
}
.lex-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-2);
  box-shadow: var(--shadow-2);
}
.lex-card:active {
  transform: translateY(-1px);
}
.lex-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Thumbnail Visual Area (Exact styling match with test ideas) */
.lex-card .media {
  position: relative;
  aspect-ratio: 16 / 10;
  width: 100%;
  overflow: hidden;
  background-color: var(--canvas);
  border-bottom: 1px solid var(--line);
}
.lex-card .thumb-art {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.6s var(--ease);
}
.lex-card:hover .thumb-art {
  transform: scale(1.02);
}

/* Rich Card Body Content */
.lex-card-body {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  width: 100%;
  box-sizing: border-box;
}

.lex-card-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.lex-card-eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-family: var(--font-num);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}
.lex-dot {
  opacity: 0.45;
}
.lex-origin-tag {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.lex-card-title {
  font-size: var(--step-0);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.lex-card-tagline {
  font-size: var(--step--1);
  line-height: 1.45;
  color: var(--ink-2);
  margin: 0;
}

/* Substantive summary explaining why/how */
.lex-card-summary {
  font-size: var(--step--2);
  line-height: 1.45;
  color: var(--ink-2);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Rule of Thumb Box */
.lex-card-rule {
  padding: 10px 12px;
  background: var(--hover);
  border-radius: var(--radius-s);
  border-left: 3px solid var(--ink-2);
}
.lex-card-rule-label {
  font-size: 0.65rem;
  font-family: var(--font-num);
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.05em;
}
.lex-card-rule-label svg {
  width: 12px;
  height: 12px;
  flex: none;
  color: var(--ink-3);
}
.lex-card-rule-text {
  font-size: var(--step--2);
  line-height: 1.45;
  color: var(--ink);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Formula or Heuristic Specification */
.lex-card-formula {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  font-family: var(--font-num);
  font-size: 0.72rem;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lex-card-formula code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
  font-size: inherit;
}
.lex-formula-icon svg {
  width: 12px;
  height: 12px;
  flex: none;
  color: var(--ink-3);
}

/* Related Concepts Chips */
.lex-card-related {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.lex-card-related::-webkit-scrollbar {
  display: none;
}
.lex-related-label {
  font-size: 0.68rem;
  font-family: var(--font-num);
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.lex-related-chips {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}
.lex-chip {
  padding: 2px 7px;
  font-size: 0.7rem;
  font-family: var(--font-num);
  border-radius: 4px;
  white-space: nowrap;
  background: var(--hover);
  border: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lex-chip:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-2);
}

/* Card Footer: Strictly One-Line CTA */
.lex-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: var(--step--2);
  min-height: 38px;
}
.lex-card-origin {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
  color: var(--ink-3);
  font-size: var(--step--2);
}
.lex-card-cta {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: var(--step--1);
  color: var(--ink);
  transition: transform 0.15s var(--ease), color 0.15s;
}
.lex-card-cta span {
  white-space: nowrap !important;
}
.lex-card-cta svg {
  width: 14px;
  height: 14px;
  flex: none;
  transition: transform 0.15s var(--ease);
}
.lex-card:hover .lex-card-cta {
  color: var(--focus, var(--ink));
}
.lex-card:hover .lex-card-cta svg {
  transform: translateX(3px);
}

/* Single Term Detail Hero */
.lex-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}
.lex-detail-hero {
  background: var(--surface);
  border: 1px solid var(--card-hairline, var(--line));
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.lex-detail-plate {
  position: relative;
  width: 100%;
  aspect-ratio: 21 / 9;
  max-height: 280px;
  min-height: 200px;
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  display: block;
}
.lex-detail-plate svg {
  width: 100%;
  height: 100%;
  display: block;
}
.lex-detail-plate-overlay {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
}
.lex-detail-plate-overlay button {
  pointer-events: auto;
}
.lex-copy-btn {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow-1);
}
.lex-copy-btn:hover {
  background: var(--raised) !important;
  border-color: var(--line-2) !important;
}

.lex-detail-content {
  padding: clamp(20px, 2.5vw, 32px);
}
.lex-detail-title-group h1 {
  font-size: var(--step-2);
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  color: var(--ink);
}
.lex-detail-tagline {
  font-size: var(--step-0);
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink-2);
  margin: 0 0 var(--space-s) 0;
}

.lex-callout {
  padding: 14px 18px;
  background: var(--hover);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: var(--radius-s);
  margin-bottom: var(--space-m);
}
.lex-callout-label {
  font-size: 0.72rem;
  font-family: var(--font-num);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.lex-callout-text {
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}

/* Detail Content Columns */
.lex-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: var(--space-m);
}
@media (max-width: 820px) {
  .lex-detail-layout {
    grid-template-columns: 1fr;
  }
}

.lex-prose {
  font-size: var(--step--1);
  line-height: 1.6;
  color: var(--ink-2);
}
.lex-prose-block {
  margin-bottom: var(--space-m);
}
.lex-prose h3 {
  font-size: var(--step-0);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px 0;
}
.lex-prose p {
  margin: 0 0 12px 0;
}

.lex-rule-box {
  padding: 14px 18px;
  background: var(--hover);
  border: 1px solid var(--line);
  border-left: 3px solid var(--pos);
  border-radius: var(--radius-s);
  margin: 8px 0 16px;
}
.lex-rule-box-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.lex-rule-box-head svg {
  width: 14px;
  height: 14px;
  color: var(--pos);
  flex: none;
}
.lex-rule-box-head h4 {
  font-size: 0.72rem;
  font-family: var(--font-num);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pos);
  margin: 0;
}
.lex-rule-box-body {
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}

.lex-formula-box {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 14px 18px;
  margin: 8px 0 16px 0;
}
.lex-formula-box-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.lex-formula-box-head svg {
  width: 14px;
  height: 14px;
  color: var(--ink-2);
  flex: none;
}
.lex-formula-box-head h4 {
  font-size: 0.72rem;
  font-family: var(--font-num);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-2);
  margin: 0;
}
.lex-formula-code {
  margin: 0;
  font-family: var(--font-num);
  font-size: var(--step--1);
  color: var(--ink);
  overflow-x: auto;
}

.lex-aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}
.lex-meta-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lex-meta-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.lex-meta-k {
  font-size: 0.68rem;
  font-family: var(--font-num);
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.lex-meta-v {
  font-size: var(--step--1);
  color: var(--ink);
  line-height: 1.35;
}

.lex-links-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lex-record-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  height: auto !important;
  padding: 8px 12px !important;
  line-height: 1.35;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.lex-record-link:hover {
  background: var(--hover);
  border-color: var(--line-2);
}
.lex-link-title {
  font-weight: 600;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--step--1);
}
.lex-link-badge {
  font-size: 0.68rem;
  flex: none;
}

.lex-related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lex-adjacent-section {
  margin-top: var(--space-l);
  padding-top: var(--space-m);
  border-top: 1px solid var(--line);
}
