/* ==================================================================
   Astro Deep Search — editorial dark theme
   Instrument Serif (display) · Manrope (body) · JetBrains Mono (data)
   ================================================================== */

:root {
  /* Surfaces */
  --bg:           #0b0d12;
  --bg-2:         #0f1118;
  --surface:      #13161f;
  --surface-2:    #181b25;
  --border:       #232733;
  --border-2:     #2c3140;
  --hairline:     #1c1f2a;

  /* Text */
  --ink:          #ece8db;
  --ink-soft:     #b8b5a8;
  --ink-mute:     #6e6e66;
  --ink-faint:    #4a4a44;

  /* Accents */
  --gold:         #e0a449;    /* starlight gold — primary accent */
  --gold-deep:    #c98a2c;
  --gold-bg:      rgba(224,164,73,0.08);
  --teal:         #4ec9b0;    /* secondary accent */
  --teal-bg:      rgba(78,201,176,0.08);
  --rose:         #d97777;    /* errors */
  --rose-bg:      rgba(217,119,119,0.08);

  /* Fonts */
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-body:    'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;

  /* Sizing */
  --radius:       4px;
  --radius-lg:    8px;
  --content-w:    1100px;
  --gutter:       clamp(20px, 4vw, 56px);

  /* Motion */
  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv01', 'tnum';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  letter-spacing: -0.005em;
}

/* Star-field background — extremely subtle dot grain */
.starfield {
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 23% 17%, rgba(255,255,255,0.18), transparent),
    radial-gradient(1px 1px at 67% 81%, rgba(255,255,255,0.14), transparent),
    radial-gradient(1px 1px at 91% 33%, rgba(224,164,73,0.18), transparent),
    radial-gradient(1.5px 1.5px at 8% 71%, rgba(255,255,255,0.12), transparent),
    radial-gradient(1px 1px at 42% 48%, rgba(255,255,255,0.10), transparent),
    radial-gradient(1px 1px at 79% 12%, rgba(78,201,176,0.12), transparent),
    radial-gradient(1px 1px at 15% 91%, rgba(255,255,255,0.10), transparent),
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(224,164,73,0.04), transparent);
  background-size: 100% 100%;
  z-index: -1;
}

a {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(224,164,73,0.35);
  transition: color 120ms var(--ease), text-decoration-color 120ms var(--ease);
}
a:hover {
  color: var(--gold);
  text-decoration-color: var(--gold);
}

em {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
}

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
  border: 0.5px solid var(--border);
  color: var(--ink-soft);
}

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

.muted   { color: var(--ink-soft); }
.small   { font-size: 13px; }
.optional{ color: var(--ink-mute); font-weight: 400; font-size: 0.85em; letter-spacing: 0.02em; }

/* ----------------- Masthead ----------------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px var(--gutter);
  background: rgba(11,13,18,0.85);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 0.5px solid var(--hairline);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
}
.brand__name {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.masthead__nav {
  display: flex;
  gap: 22px;
  align-items: center;
}

.link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: color 120ms var(--ease);
}
.link:hover { color: var(--ink); }

/* ----------------- Hero ----------------- */
.hero {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: clamp(60px, 10vh, 110px) var(--gutter) 60px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 26px;
  display: inline-block;
  padding-bottom: 4px;
  border-bottom: 0.5px solid var(--gold);
}

.display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(48px, 8vw, 96px);
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin: 0 0 28px;
  color: var(--ink);
  max-width: 18ch;
}
.display em {
  color: var(--gold);
}

.standfirst {
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 62ch;
  margin: 0 0 44px;
  font-weight: 300;
}

/* Search bar */
.searchbar {
  display: flex;
  gap: 0;
  max-width: 760px;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.searchbar:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-bg);
}
.searchbar input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 18px 22px;
  font-family: var(--font-mono);
  font-size: 14.5px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.searchbar input::placeholder { color: var(--ink-mute); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}
.btn--primary {
  background: var(--gold);
  color: #1a1208;
  margin: 8px;
  padding: 12px 22px;
  border-radius: var(--radius);
}
.btn--primary:hover {
  background: #f0b25a;
}
.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 0.5px solid var(--border-2);
}
.btn--ghost:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--gold);
}

.hero__examples {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.hero__examples-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-right: 8px;
}
.chip {
  background: var(--surface);
  border: 0.5px solid var(--border);
  color: var(--ink-soft);
  padding: 5px 12px;
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 120ms var(--ease);
}
.chip:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-bg);
}

/* ----------------- Dossier ----------------- */
.dossier {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 var(--gutter) 140px;
}

/* Dossier head */
.dossier__head {
  border-top: 0.5px solid var(--border);
  padding: 40px 0 32px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 30px;
  align-items: start;
  position: relative;
}

.dossier__title-block .otype-line {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 14px;
}

.dossier__title {
  font-family: var(--font-display);
  font-size: clamp(40px, 5.5vw, 64px);
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.015em;
  margin: 0 0 16px;
  color: var(--ink);
}

.dossier__title .aliases {
  display: block;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 400;
  color: var(--ink-mute);
  margin-top: 16px;
  font-style: normal;
  letter-spacing: 0;
  max-width: 60ch;
  line-height: 1.5;
}

.dossier__coords {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--ink-soft);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
}
.dossier__coords b {
  color: var(--gold);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
}
.dossier__coords span {
  color: var(--ink);
}

.dossier__actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Sections */
.section {
  border-top: 0.5px solid var(--hairline);
  padding: 40px 0 12px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 30px;
}
.section__head {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.section__head .num {
  color: var(--gold);
  font-weight: 500;
}
.section__head .status {
  color: var(--ink-mute);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
  font-family: var(--font-body);
}
.section__head .status[data-state="loading"] { color: var(--teal); }
.section__head .status[data-state="ok"]      { color: var(--ink-soft); }
.section__head .status[data-state="error"]   { color: var(--rose); }
.section__head .status[data-state="empty"]   { color: var(--ink-mute); }

.section__body {
  min-width: 0;   /* allow grid child to shrink */
}

.section__title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.section__desc {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin: 0 0 22px;
  max-width: 60ch;
}

/* Identification table */
.dl {
  margin: 0;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 24px;
  font-size: 14.5px;
}
.dl dt {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  text-transform: uppercase;
  padding-top: 3px;
}
.dl dd {
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.dl dd .source-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-left: 8px;
  letter-spacing: 0.04em;
}

/* Cutouts grid */
.cutouts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.cutout {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 160ms var(--ease);
  text-decoration: none;
  color: var(--ink);
}
.cutout:hover { border-color: var(--gold); }
.cutout__img {
  width: 100%;
  aspect-ratio: 1/1;
  background: #000;
  display: block;
  object-fit: cover;
}
.cutout__img.loading {
  background:
    linear-gradient(90deg, transparent, rgba(224,164,73,0.06), transparent),
    var(--surface-2);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  0% { background-position: -100% 0; }
  100% { background-position: 100% 0; }
}
.cutout__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-soft);
  border-top: 0.5px solid var(--border);
}
.cutout__label .band {
  color: var(--gold);
}

/* Photometry / data tables */
.table-wrap {
  overflow-x: auto;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.table th, .table td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 0.5px solid var(--hairline);
  vertical-align: top;
  white-space: nowrap;
}
.table th {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  background: var(--surface-2);
  border-bottom-color: var(--border);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(224,164,73,0.025); }
.table td .ref {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-mute);
}
.table .band-radio   { color: #b8a3ff; }
.table .band-mm      { color: #ffb3a3; }
.table .band-ir      { color: #ffd680; }
.table .band-optical { color: #b3e8b3; }
.table .band-uv      { color: #a3c8ff; }
.table .band-xray    { color: #ff9eb3; }
.table .band-gamma   { color: #d28aff; }

/* Literature */
.papers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.paper {
  border-top: 0.5px solid var(--hairline);
  padding: 18px 0;
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 18px;
  align-items: baseline;
}
.paper:first-child { border-top: 0; padding-top: 4px; }
.paper__year {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.paper__title {
  font-family: var(--font-body);
  font-size: 15.5px;
  font-weight: 500;
  margin: 0 0 4px;
  line-height: 1.35;
  color: var(--ink);
}
.paper__title a { color: var(--ink); text-decoration-color: rgba(224,164,73,0.25); }
.paper__title a:hover { color: var(--gold); }
.paper__meta {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.paper__meta .authors {
  font-style: italic;
  color: var(--ink-soft);
}
.paper__meta .journal {
  color: var(--ink-mute);
}
.paper__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-self: start;
  padding-top: 2px;
}
.badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 100px;
  border: 0.5px solid var(--border-2);
  color: var(--ink-mute);
  white-space: nowrap;
}
.badge--gold { color: var(--gold); border-color: var(--gold); background: var(--gold-bg); }
.badge--teal { color: var(--teal); border-color: var(--teal); background: var(--teal-bg); }

/* Empty / error states */
.empty-state {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-mute);
  font-style: italic;
  padding: 12px 0;
}
.error-state {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--rose);
  background: var(--rose-bg);
  border: 0.5px solid var(--rose);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.error-state .retry {
  background: transparent;
  border: 0.5px solid var(--rose);
  color: var(--rose);
  padding: 4px 12px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.error-state .retry:hover { background: var(--rose-bg); }

/* Loading shimmer for sections */
.skeleton {
  background:
    linear-gradient(90deg, transparent, rgba(224,164,73,0.04), transparent),
    var(--surface);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  height: 1.2em;
  border-radius: 3px;
  margin: 8px 0;
}

/* ----------------- Drawers ----------------- */
dialog.drawer {
  position: fixed;
  top: 0; right: 0;
  margin: 0;
  height: 100vh;
  max-height: 100vh;
  width: min(440px, 100vw);
  background: var(--bg-2);
  color: var(--ink);
  border: 0;
  border-left: 0.5px solid var(--border);
  padding: 0;
  overflow: hidden;
}
dialog.drawer::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}
.drawer__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 26px;
  border-bottom: 0.5px solid var(--hairline);
}
.drawer__title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  margin: 0;
}
.drawer__body {
  padding: 22px 26px;
  overflow-y: auto;
  max-height: calc(100vh - 80px);
}
.drawer__body h3 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.005em;
  margin: 0 0 6px;
}
.setting {
  padding: 14px 0 22px;
  border-bottom: 0.5px solid var(--hairline);
}
.setting:last-child { border-bottom: 0; }
.setting p { font-size: 13px; }
.input-row { display: flex; gap: 6px; align-items: center; margin: 10px 0; }
.input-row input {
  flex: 1;
  background: var(--surface);
  border: 0.5px solid var(--border);
  color: var(--ink);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
}
.input-row input:focus { outline: 0; border-color: var(--gold); }
.status {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 4px 0 0;
  min-height: 1.2em;
}
.status.ok { color: var(--teal); }
.status.err { color: var(--rose); }

.selftest {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  color: var(--ink-soft);
}
.selftest .pass { color: var(--teal); }
.selftest .fail { color: var(--rose); }
.selftest .head { color: var(--gold); }

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--hairline);
  cursor: pointer;
  transition: color 120ms var(--ease);
}
.history-item:hover { color: var(--gold); }
.history-item .name { font-family: var(--font-body); font-size: 15px; }
.history-item .when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}

/* ----------------- Toast ----------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  color: var(--ink);
  border: 0.5px solid var(--gold);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----------------- Footer ----------------- */
.footer {
  border-top: 0.5px solid var(--hairline);
  padding: 28px var(--gutter);
  max-width: var(--content-w);
  margin: 0 auto;
  font-size: 12px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer__data { color: var(--ink-mute); }
.footer__data a { color: var(--ink-soft); text-decoration-color: rgba(184,181,168,0.2); }
.footer__data a:hover { color: var(--gold); }

/* ----------------- Responsive ----------------- */
@media (max-width: 760px) {
  .dossier__head {
    grid-template-columns: 1fr;
  }
  .dossier__coords { text-align: left; width: max-content; }
  .section {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .section__head {
    flex-direction: row;
    align-items: baseline;
    gap: 14px;
    padding-top: 0;
  }
  .dl {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  .dl dt { padding-top: 12px; }
  .dl dd { padding-bottom: 4px; }
  .paper {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .searchbar {
    flex-direction: column;
    border-radius: var(--radius-lg);
  }
  .btn--primary { margin: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); justify-content: center; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print — publication-grade printable dossier */
@media print {
  body { background: white; color: black; }
  .starfield, .masthead, .hero, .footer, .drawer, .toast, .dossier__actions { display: none !important; }
  .dossier { max-width: 100%; padding: 0; }
  .section { page-break-inside: avoid; }
  .table { font-size: 10px; }
  a { color: black; text-decoration: underline; }
}
