/* Breakthroughs section styles.
   Global tokens applied from Refined Basecamp theme.
*/

:root {
  --bg-main: #11130E;
  --bg-card: #1A1C15;
  --bg-card-hover: #22251D;

  --accentMain: #379392;
  --accentGold: #D8B67F;

  --textWhite: rgba(255, 255, 255, 0.90);
  --textMuted: rgba(255, 255, 255, 0.55);
  --borderDim: rgba(255, 255, 255, 0.08);
  --borderHighlight: #379392;
}

body {
  background-color: var(--bg-main);
  color: var(--textWhite);
}

/* Match Media/Discoveries layout primitives exactly */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }

.container-max {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(55, 147, 146, 0.6); }
  50%      { border-color: rgba(55, 147, 146, 0.1); }
}
.construction-banner { animation: pulse-border 2s infinite; }

.accent-bar { width: 40px; height: 4px; background: var(--accentMain); margin-bottom: 8px; }

/* Nav */
.navlink {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--textMuted);
  transition: color 140ms ease;
}
.navlink:hover { color: var(--textWhite); }
.navlink--active { color: var(--textWhite); }

.sr-only {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* -------------------------------------------------------------------------
   Controls Header (FIXED)
   Goals:
   - Keep search + sort on same row; sort to the right
   - Sort typography matches the rest of page controls
   - Filters wrap within the search column width (same width as search bar)
   - Backgrounds match section theme
   ---------------------------------------------------------------------- */
.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;       /* ✅ row 1: search/sort, row 2: filters */
  column-gap: 14px;
  row-gap: 12px;
  align-items: start;

  border: 1px solid var(--borderDim);
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px;
}

/* Search sits in col 1, row 1 */
.controls__left {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

/* Sort sits in col 2, row 1 */
.controls__right {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: stretch;
  gap: 10px;
}

/* Filters span BOTH columns (combined width), row 2 */
.chip-row {
  grid-column: 1 / -1;   /* ✅ spans search + sort */
  grid-row: 2;

  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 100%;
}

/* Left column: search + filters */
.controls__left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0; /* IMPORTANT: allow wrapping within column */
}

/* Right column: sort (aligned with search) */
.controls__right {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

/* Inputs / selects (unified typography + sizing) */
.control-input, .control-select {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--bg-main);
  color: var(--textWhite);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: all 140ms ease;

  /* Typography: match chips/meta (uniform across sections) */
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Search takes full width of left column */
.control-input { width: 100%; }
.control-input::placeholder {
  color: var(--textMuted);
  /* Keep placeholder readable even with uppercase tracking */
  text-transform: none;
  letter-spacing: 0.02em;
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
}

.control-input:focus, .control-select:focus {
  border-color: var(--accentMain);
  background-color: var(--bg-card-hover);
  box-shadow: 0 0 15px rgba(55, 147, 146, 0.15);
}

/* Keep sort visually aligned with the search bar height */
.control-select {
  min-width: 220px;
  width: 220px;

  /* ✅ match search bar height exactly */
  height: 40px;          /* same effective height as the input */
  padding: 0 14px;       /* keep text vertically centered */
  line-height: 40px;

  white-space: nowrap;
}

/* On smaller screens, drop sort under search (but still aligned to right) */
@media (max-width: 720px) {
  .controls {
    grid-template-columns: 1fr;
  }
  .controls__right {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-end;
  }
  .chip-row {
    grid-column: 1;
    grid-row: 3;
  }
  .control-select { width: 100%; min-width: 0; }
}

/* Filter chips */
.chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;

  /* Constrain to search column width (prevents “stretch wider than search”) */
  max-width: 100%;
}

/* If chip row is placed near wide layouts, keep it visually under search */
.controls__left .chip-row { align-self: stretch; }

.chip {
  border: 1px solid var(--borderDim);
  background: var(--bg-main);
  color: var(--textMuted);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: all 140ms ease;
  cursor: pointer;
}
.chip:hover {
  color: var(--textWhite);
  border-color: rgba(255, 255, 255, 0.2);
}
.chip--active,
.chip[aria-selected="true"] {
  background: rgba(55, 147, 146, 0.15);
  border-color: var(--accentMain);
  color: var(--textWhite);
}

.meta-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-top: 12px;
}
.meta-row__left, .meta-row__right { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.meta-text {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--textMuted);
}

/* -------------------------------------------------------------------------
   Feed grid
   ---------------------------------------------------------------------- */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 24px;
}
@media (min-width: 900px) {
  .feed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* -------------------------------------------------------------------------
   Cards
   ---------------------------------------------------------------------- */
.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--borderDim);
  background: var(--bg-card);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--borderHighlight);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* Top border color-coded by breakthroughKind */
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--borderDim);
  transition: background 160ms ease;
}
.card[data-kind="imaging"]::before            { background: #379392; } /* Teal */
.card[data-kind="biomechanics"]::before       { background: #5D9C59; } /* Green */
.card[data-kind="genetics"]::before           { background: #9C27B0; } /* Purple */
.card[data-kind="new-species"]::before        { background: #E67E22; } /* Orange */
.card[data-kind="taxonomy-revision"]::before  { background: #3498DB; } /* Blue */
.card[data-kind="climate-environment"]::before{ background: #D8B67F; } /* Gold */
.card[data-kind="taphonomy"]::before          { background: #7F8C8D; } /* Grey */
.card[data-kind="review"]::before             { background: #D26666; } /* Red */

.card__header {
  padding: 16px 20px 12px;
  border-bottom: 1px dashed var(--borderDim);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
}
.card__header-left { display: flex; flex-direction: column; gap: 4px; }

.ref-code {
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--textMuted);
  text-transform: uppercase;
}

/* -------------------------------------------------------------------------
   Badges — one per breakthroughKind + recency labels
   ---------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--borderDim);
  white-space: nowrap;
}

/* breakthroughKind badges */
.badge--imaging           { background: rgba(55,147,146,0.10);  border-color: rgba(55,147,146,0.4);   color: #80CBC4; }
.badge--biomechanics      { background: rgba(93,156,89,0.10);   border-color: rgba(93,156,89,0.4);    color: #A5D6A7; }
.badge--genetics          { background: rgba(156,39,176,0.10);  border-color: rgba(156,39,176,0.4);   color: #CE93D8; }
.badge--new-species       { background: rgba(230,126,34,0.10);  border-color: rgba(230,126,34,0.4);   color: #FFCC80; }
.badge--taxonomy          { background: rgba(52,152,219,0.10);  border-color: rgba(52,152,219,0.4);   color: #90CAF9; }
.badge--climate           { background: rgba(216,182,127,0.10); border-color: rgba(216,182,127,0.4);  color: #FFE0B2; }
.badge--taphonomy         { background: rgba(127,140,141,0.10); border-color: rgba(127,140,141,0.4);  color: #CFD8DC; }
.badge--review            { background: rgba(210,102,102,0.10); border-color: rgba(210,102,102,0.4);  color: #EF9A9A; }

/* Recency labels */
.recency-label {
  display: inline-flex;
  align-items: center;
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
}
.recency-label--new    { background: rgba(55,147,146,0.2); border: 1px solid rgba(55,147,146,0.6); color: #80CBC4; }
.recency-label--recent { background: rgba(216,182,127,0.15); border: 1px solid rgba(216,182,127,0.4); color: #D8B67F; }

.date {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accentMain);
  white-space: nowrap;
}

.card__body { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }

.title {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 17px;
  line-height: 1.3;
  margin: 0 0 16px 0;
  color: var(--textWhite);
}

.abstract-label {
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--textMuted);
  margin-bottom: 6px;
  display: block;
  text-transform: uppercase;
}

.desc {
  color: var(--textMuted);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 24px;
  flex-grow: 1;
}

.card__footer {
  padding-top: 16px;
  border-top: 1px solid var(--borderDim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card__links { display:flex; gap:16px; flex-wrap:wrap; }

.link {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accentMain);
  text-decoration: none;
  transition: opacity 140ms ease, color 140ms ease;
}
.link:hover { opacity: 0.8; color: var(--textWhite); }
.link--muted { color: var(--textMuted); }
.link--muted:hover { color: var(--accentMain); }

.load-more {
  border: 1px solid var(--borderDim);
  background: var(--bg-card);
  color: var(--textWhite);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: all 140ms ease;
  cursor: pointer;
}
.load-more:hover:not(:disabled) {
  border-color: var(--accentMain);
  background: var(--bg-card-hover);
}
.load-more:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  border-color: var(--borderDim);
  background: transparent;
}

/* Utility */
.hidden { display: none !important; }

/* -------------------------------------------------------------------------
   Detail page wrapper — replaces misused .controls class
   ---------------------------------------------------------------------- */
.detail-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--borderDim);
  border-radius: 12px;
  padding: 40px;
}

@media (max-width: 720px) {
  .detail-card {
    padding: 24px 16px;
  }
}
