/* ==========================================================================
   "The story of Maddela" — history story timeline
   Applies only to src/app/legal-history/page.tsx (.hst-* classes) and
   src/components/history/HistoryTimeline.tsx.
   Tokens come from style.css :root; literal colors use the approved
   palette only. Evidence kinds are carried by typography (small caps,
   weight, color) and small square markers — never pill shapes
   (UX_PRINCIPLES hard rule 1). Mobile-first: single-column rail on the
   left; desktop widens the cards and typography.
   ========================================================================== */

/* Hero -------------------------------------------------------------------- */

.hst-hero {
  background: var(--color-primary-dark);
  color: #fffcf4;
  padding: 56px 0 48px;
}

.hst-hero h1 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #fffcf4;
}

.hst-arc {
  margin: 0 0 22px;
  max-width: 46ch;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  line-height: 1.5;
  color: rgba(255, 252, 244, 0.92);
}

.hst-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Hero facts: plain small-caps items separated by hairline rules. */
.hst-fact {
  padding-left: 10px;
  border-left: 1px solid rgba(255, 252, 244, 0.35);
  color: #fffcf4;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Section shell ------------------------------------------------------------ */

.hst-section {
  padding: 40px 0 72px;
}

.hst-body {
  margin: 0 0 12px;
  max-width: 62ch;
  line-height: 1.6;
  color: var(--color-text);
}

.hst-panel {
  background: #ffffff;
  border: 1px solid #e8dfc8;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 36px;
  box-shadow: 0 2px 10px rgba(34, 29, 20, 0.06);
}

.hst-panel-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #221d14;
}

.hst-note {
  margin: 12px 0 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #6b6353;
}

/* Evidence kind markers ------------------------------------------------------ */
/* The label is typography: small caps, weight, and color carry the kind.
   A small square marker fronts each label; its fill encodes the kind the
   way the old chip fills did. No pill shapes anywhere. */

.hst-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #3a2f1b;
}

.hst-chip::before {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  background: #6b6353;
}

/* Documented evidence: solid gold marker, deep amber label. */
.hst-chip--gold {
  color: #7a540d;
}

.hst-chip--gold::before {
  background: #f5b301;
}

/* Institutional descriptions: straw marker with a hairline amber edge. */
.hst-chip--straw {
  color: #7a540d;
}

.hst-chip--straw::before {
  background: #f7efd8;
  box-shadow: inset 0 0 0 1px #8a5e0f;
}

/* Weaker, attributed accounts: hollow slate marker, brown label. */
.hst-chip--outline {
  color: #3a2f1b;
}

.hst-chip--outline::before {
  background: transparent;
  box-shadow: inset 0 0 0 2px #6b6353;
}

/* Honest gap marker: recessive hollow marker, muted label. */
.hst-chip--quiet {
  color: #6b6353;
}

.hst-chip--quiet::before {
  background: transparent;
  box-shadow: inset 0 0 0 1px #e8dfc8;
}

/* Legend (how to read the markers) ------------------------------------------- */

.hst-legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.hst-legend-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text);
}

/* Timeline rail and nodes (mobile-first, line on the left) ------------------- */
/* The rail itself is a decorative bar; its fully-rounded ends are allowed. */

.hst-frame {
  position: relative;
  padding-left: 34px;
}

.hst-line {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 8px;
  width: 3px;
  border-radius: 999px;
  background: #e8dfc8;
  overflow: hidden;
}

.hst-line-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #f5b301 0%, #8a5e0f 100%);
  transform-origin: top;
}

.hst-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hst-item {
  position: relative;
  margin: 0 0 18px;
}

/* Node dots echo the evidence kind of their card. */
.hst-dot {
  position: absolute;
  left: -31px;
  top: 26px;
  box-sizing: border-box;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #f5b301;
  border: 2px solid #221d14;
}

.hst-item--tradition .hst-dot {
  background: #fffcf4;
  border-style: dashed;
}

.hst-item--context .hst-dot {
  background: #f7efd8;
}

.hst-item--gap .hst-dot {
  background: #fffcf4;
  border-color: #e8dfc8;
  width: 11px;
  height: 11px;
}

/* Story cards --------------------------------------------------------------- */

.hst-card {
  background: #fffcf4;
  border: 1px solid #e8dfc8;
  border-left: 4px solid #f5b301;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(34, 29, 20, 0.06);
}

/* Honest gap state: a quiet panel with a dashed left border, no shadow.
   Never a pill — the dashed rule marks the missing evidence. */
.hst-item--gap .hst-card {
  border-left: 4px dashed #e8dfc8;
  box-shadow: none;
}

.hst-item--tradition .hst-card {
  border-left-color: #6b6353;
}

.hst-item--context .hst-card {
  border-left-color: #e8dfc8;
}

.hst-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 2px;
}

.hst-period {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #221d14;
}

.hst-period time {
  color: inherit;
}

.hst-heading {
  margin: 2px 0 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: #3a2f1b;
}

.hst-gap-text {
  margin: 0;
  color: #6b6353;
}

/* Details (depth on demand) -------------------------------------------------- */
/* Toggle is a quiet rectangular control, not a pill. */

.hst-details-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  background: transparent;
  border: 1px solid #e8dfc8;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-primary);
  transition: background-color 160ms ease;
}

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

.hst-details-summary:hover {
  background: #f7efd8;
}

.hst-chevron {
  font-size: 0.72rem;
  transition: transform 160ms ease;
}

.hst-details[open] .hst-chevron {
  transform: rotate(180deg);
}

.hst-details-body {
  margin-top: 16px;
  padding-top: 4px;
}

/* Legal instrument blocks inside expanded chapters ---------------------------- */

.hst-instrument {
  padding: 16px 0;
  border-top: 1px dashed #e8dfc8;
}

.hst-instrument:first-child {
  border-top: none;
  padding-top: 12px;
}

.hst-instrument-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.hst-instrument-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #221d14;
}

.hst-instrument-date {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b6353;
}

.hst-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 0;
}

.hst-exact-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
  color: #7a540d;
}

.hst-instrument p {
  margin: 0 0 10px;
  max-width: 62ch;
  line-height: 1.6;
  color: var(--color-text);
}

.hst-source-link a {
  font-weight: 600;
  color: var(--color-primary);
}

/* Epilogue: community today --------------------------------------------------- */

.hst-panel--epilogue {
  margin-top: 40px;
}

.hst-themes {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.hst-theme {
  background: #f7efd8;
  border-radius: 12px;
  padding: 14px 16px;
}

.hst-theme-label {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #221d14;
}

.hst-theme p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #3a2f1b;
}

/* Record-meta link clearance inside padded cards ------------------------------- */

.hst-card .record-meta,
.hst-panel .record-meta {
  margin: 0;
}

.hst-card .record-meta a,
.hst-panel .record-meta a {
  display: inline-block;
  padding: 12px;
  margin: -12px;
}

/* Focus visibility -------------------------------------------------------------- */

.hst-card a:focus-visible,
.hst-panel a:focus-visible,
.hst-details-summary:focus-visible {
  outline: 2px solid #7a540d;
  outline-offset: 2px;
}

/* Reduced motion ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .hst-chevron,
  .hst-details-summary {
    transition: none;
  }
}

/* Desktop: widen the rail, cards and typography ------------------------------------ */

@media (min-width: 760px) {
  .hst-frame {
    padding-left: 64px;
    max-width: 860px;
  }

  .hst-line {
    left: 18px;
    width: 4px;
  }

  .hst-item {
    margin-bottom: 24px;
  }

  .hst-dot {
    left: -51px;
    top: 30px;
    width: 15px;
    height: 15px;
  }

  .hst-item--gap .hst-dot {
    width: 13px;
    height: 13px;
  }

  .hst-card {
    padding: 26px 30px;
  }

  .hst-period {
    font-size: 1.8rem;
  }

  .hst-heading {
    font-size: 1.15rem;
  }

  .hst-legend {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }

  .hst-themes {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }

  .hst-panel {
    padding: 28px 32px;
  }
}