/* ============================================================
   MyJurassic — stylesheet
   Palette:
     chalk       #F1F2ED  (page background — cool stone white)
     paper       #FBFBF8  (cards)
     basalt      #211E19  (ink / header)
     graphite    #57534B  (secondary text)
     amber       #B4791B  (accent — fossilized resin)
     amber-deep  #8F5F12
     hairline    #DDDCD4
   Type:
     Spectral        — display serif (museum labels)
     Public Sans     — body
     IBM Plex Mono   — catalog numbers, geological data
   ============================================================ */

:root {
  --chalk: #F1F2ED;
  --paper: #FBFBF8;
  --basalt: #211E19;
  --graphite: #57534B;
  --amber: #B4791B;
  --amber-deep: #8F5F12;
  --hairline: #DDDCD4;
  --danger: #A33B2E;
  --ok: #3E6B4F;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(33,30,25,.06), 0 4px 14px rgba(33,30,25,.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--chalk);
  color: var(--basalt);
  font: 16px/1.6 "Public Sans", system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }

main.wrap { flex: 1; padding-block: 2.2rem 3.5rem; }

h1, h2, h3 { font-family: "Spectral", Georgia, serif; line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); font-weight: 600; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem;  font-weight: 600; }

a { color: var(--amber-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono, .cat-no {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .82rem;
  letter-spacing: .02em;
}

.muted { color: var(--graphite); }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------------- Header ---------------- */

.site-header {
  background: var(--basalt);
  color: #EDEAE3;
  border-bottom: 3px solid var(--amber);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: .8rem; flex-wrap: wrap;
}

.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: "Spectral", serif; font-size: 1.3rem; font-weight: 700;
  color: #F4F1E8;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--amber); display: inline-flex; }

.main-nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.main-nav a { color: #D8D4CA; font-size: .93rem; font-weight: 500; }
.main-nav a:hover { color: #fff; text-decoration: none; }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-block; border: 1px solid var(--basalt);
  background: var(--basalt); color: #F4F1E8;
  padding: .55rem 1.1rem; border-radius: var(--radius);
  font: 500 .92rem "Public Sans", sans-serif;
  cursor: pointer; transition: background .15s, color .15s;
}
.btn:hover { background: #3A362E; text-decoration: none; }

.btn-accent { background: var(--amber); border-color: var(--amber); color: #fff !important; }
.btn-accent:hover { background: var(--amber-deep); border-color: var(--amber-deep); }

.btn-ghost { background: transparent; color: var(--basalt); }
.btn-ghost:hover { background: rgba(33,30,25,.06); }

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #832E23; }

.btn-sm { padding: .35rem .8rem; font-size: .85rem; }

/* ---------------- Flash messages ---------------- */

.flash {
  padding: .7rem 1rem; border-radius: var(--radius);
  margin-bottom: 1.2rem; font-size: .93rem;
  border: 1px solid; background: var(--paper);
}
.flash-success { border-color: var(--ok); color: var(--ok); }
.flash-error   { border-color: var(--danger); color: var(--danger); }
.flash-info    { border-color: var(--amber-deep); color: var(--amber-deep); }

/* ---------------- Strata band (signature element) ---------------- */

.strata-band { display: flex; height: 6px; border-radius: 3px; overflow: hidden; }
.strata-band span { flex: 1; }

/* ---------------- Hero (homepage) ---------------- */

.hero {
  background: var(--basalt); color: #EDEAE3;
  margin: -2.2rem calc(50% - 50vw) 2.6rem;
  padding: 3.6rem 0 0;
}
.hero-inner { width: min(1120px, 100% - 2.5rem); margin-inline: auto; padding-bottom: 3rem; }
.hero .eyebrow {
  font-family: "IBM Plex Mono", monospace; font-size: .78rem;
  letter-spacing: .18em; text-transform: uppercase; color: var(--amber);
  margin-bottom: .8rem;
}
.hero h1 { color: #F7F4EC; font-size: clamp(2rem, 5vw, 3.1rem); max-width: 17ch; }
.hero p  { color: #B9B4A8; max-width: 52ch; font-size: 1.05rem; }
.hero-strata { display: flex; height: 14px; }
.hero-strata span { flex: 1; }
.hero-actions { margin-top: 1.6rem; display: flex; gap: .8rem; flex-wrap: wrap; }

/* ---------------- Specimen cards ---------------- */

.grid {
  display: grid; gap: 1.3rem;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.card {
  background: var(--paper); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(33,30,25,.12); }

.card .era-strip { height: 5px; background: var(--hairline); }

.card .photo {
  aspect-ratio: 4 / 3; background: #E9E8E1; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-photo { color: #B9B5A9; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }

.card-body { padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.card-body .cat-no { color: var(--graphite); }
.card-body h3 { margin: 0; font-size: 1.02rem; }
.card-body h3 a { color: var(--basalt); }
.card-meta { font-size: .84rem; color: var(--graphite); margin-top: auto; }

.tag {
  display: inline-block; font-size: .74rem; font-weight: 600;
  padding: .12rem .55rem; border-radius: 99px;
  background: rgba(33,30,25,.07); color: var(--graphite);
  text-transform: uppercase; letter-spacing: .05em;
}
.tag-era { color: var(--basalt); }

/* ---------------- Section headings ---------------- */

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap;
}
.section-head h2 { margin: 0; }

/* ---------------- Forms ---------------- */

.form-card {
  background: var(--paper); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.8rem; max-width: 720px;
}
.form-card.narrow { max-width: 440px; margin-inline: auto; }

label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.hint { font-size: .8rem; color: var(--graphite); margin-top: .25rem; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: .55rem .7rem;
  border: 1px solid #C9C7BD; border-radius: var(--radius);
  background: #fff; font: inherit; color: var(--basalt);
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--amber); outline: none; }

.field { margin-bottom: 1.1rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

.form-actions { display: flex; gap: .8rem; align-items: center; margin-top: 1.4rem; flex-wrap: wrap; }

/* ---------------- Tables (admin) ---------------- */

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
th {
  font-family: "IBM Plex Mono", monospace; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .1em; color: var(--graphite);
  background: #F4F3EE;
}
tr:last-child td { border-bottom: 0; }
td form { display: inline; }

.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); vertical-align: -4px; margin-right: .4rem; }

/* ---------------- Specimen detail ---------------- */

.detail-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; }
@media (max-width: 860px) { .detail-layout { grid-template-columns: 1fr; } }

.gallery-main {
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.gallery-main img { width: 100%; display: block; max-height: 540px; object-fit: contain; background: #E9E8E1; }
.gallery-main .no-photo { aspect-ratio: 4/3; }

.thumbs { display: flex; gap: .6rem; margin-top: .7rem; flex-wrap: wrap; }
.thumbs img {
  width: 76px; height: 76px; object-fit: cover; border-radius: 4px;
  border: 2px solid transparent; cursor: pointer;
}
.thumbs img.active { border-color: var(--amber); }

.spec-sheet {
  background: var(--paper); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 1.6rem;
}
.spec-sheet .cat-no { color: var(--graphite); }
.spec-sheet h1 { margin: .2rem 0 .8rem; }

.spec-table { width: 100%; font-size: .92rem; border-collapse: collapse; margin-top: .8rem; }
.spec-table th {
  background: none; padding: .45rem 0; width: 42%;
  font-family: "IBM Plex Mono", monospace; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .08em; color: var(--graphite);
  border-bottom: 1px solid var(--hairline);
}
.spec-table td { padding: .45rem 0; border-bottom: 1px solid var(--hairline); }

.era-chip {
  display: inline-flex; align-items: center; gap: .45rem; font-weight: 600;
}
.era-chip i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.12); }

.description { margin-top: 1.4rem; }
.description p { white-space: pre-line; }

/* ---------------- Profile ---------------- */

.profile-head {
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.6rem 1.8rem; margin-bottom: 2rem;
  display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap;
}
.avatar {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--basalt); color: var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-family: "Spectral", serif; font-size: 1.9rem; font-weight: 700; flex-shrink: 0;
}
.profile-head h1 { margin: 0 0 .15rem; font-size: 1.6rem; }
.profile-stats { margin-left: auto; display: flex; gap: 1.8rem; text-align: center; }
.profile-stats b { display: block; font-family: "Spectral", serif; font-size: 1.5rem; }
.profile-stats span { font-size: .78rem; color: var(--graphite); text-transform: uppercase; letter-spacing: .07em; }

/* ---------------- Filters bar ---------------- */

.filters {
  display: flex; gap: .8rem; margin-bottom: 1.6rem; flex-wrap: wrap; align-items: end;
}
.filters .field { margin: 0; min-width: 170px; }
.filters label { font-size: .78rem; }

/* ---------------- Admin ---------------- */

.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 2rem; }
@media (max-width: 760px) { .admin-layout { grid-template-columns: 1fr; } }

.admin-nav { display: flex; flex-direction: column; gap: .15rem; }
.admin-nav a {
  padding: .5rem .8rem; border-radius: var(--radius);
  color: var(--basalt); font-size: .93rem; font-weight: 500;
}
.admin-nav a:hover { background: rgba(33,30,25,.06); text-decoration: none; }
.admin-nav a.active { background: var(--basalt); color: #F4F1E8; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1.2rem; margin-bottom: 2rem; }
.stat {
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.3rem;
}
.stat b { display: block; font-family: "Spectral", serif; font-size: 1.9rem; }
.stat span { font-size: .78rem; color: var(--graphite); text-transform: uppercase; letter-spacing: .07em; }

.inline-form { display: flex; gap: .7rem; flex-wrap: wrap; align-items: end; background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.4rem; }
.inline-form .field { margin: 0; }
.inline-form input[type=text], .inline-form select, .inline-form input[type=number] { width: auto; min-width: 150px; }
.inline-form input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid #C9C7BD; border-radius: var(--radius); background: #fff; }

/* ---------------- Photo manager ---------------- */

.photo-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
.photo-manage figure {
  margin: 0; background: var(--paper); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden;
}
.photo-manage img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo-manage figcaption { padding: .5rem; display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; }
.primary-badge { font-size: .7rem; font-weight: 700; color: var(--amber-deep); text-transform: uppercase; letter-spacing: .06em; align-self: center; }

/* ---------------- Footer ---------------- */

.site-footer { background: var(--basalt); color: #A6A196; margin-top: auto; }
.footer-inner { padding-block: 0 1.4rem; }
.footer-inner .strata-band { height: 8px; border-radius: 0; margin: 0 calc(50% - 50vw) 1.2rem; }
.footer-inner p { font-size: .85rem; margin: 0; }

/* ---------------- Misc ---------------- */

.empty {
  border: 1px dashed #C9C7BD; border-radius: var(--radius);
  padding: 2.4rem; text-align: center; color: var(--graphite); background: rgba(255,255,255,.5);
}

.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 2rem; }
.pagination a, .pagination span {
  padding: .35rem .75rem; border: 1px solid var(--hairline); border-radius: var(--radius);
  background: var(--paper); color: var(--basalt); font-size: .9rem;
}
.pagination .current { background: var(--basalt); color: #F4F1E8; border-color: var(--basalt); }

/* ---------- Specimen lookup (search existing on the add form) ---------- */
.lookup-panel {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--shadow);
}
.lookup-panel > label {
  display: block;
  margin-bottom: .55rem;
  font-size: .95rem;
  color: var(--graphite);
}
.lookup-panel > label b { color: var(--basalt); }
.lookup-panel input[type="text"] {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
}
.lookup-panel .hint { margin: .5rem 0 0; }
.lookup-results {
  margin-top: .6rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.lookup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .55rem .7rem;
  border-top: 1px solid var(--hairline);
}
.lookup-item:first-child { border-top: none; }
.lookup-item:hover { background: var(--chalk); }
.lookup-info { min-width: 0; }
.lookup-name {
  font-family: 'Spectral', Georgia, serif;
  font-weight: 600;
  color: var(--basalt);
  text-decoration: none;
}
.lookup-name:hover { color: var(--amber-deep); text-decoration: underline; }
.lookup-meta {
  font-size: .82rem;
  color: var(--graphite);
  margin-top: .1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lookup-empty {
  padding: .7rem;
  color: var(--graphite);
  font-size: .9rem;
}

/* ---------- Evolution timeline (homepage) ---------- */
.evo { margin: 2.6rem 0 1rem; }
.evo .section-head { align-items: baseline; }
.evo-scalenote { font-size: .82rem; }
.evo-scroll { overflow-x: auto; overflow-y: visible; padding-bottom: .4rem; }
.evo-track {
  display: flex;
  align-items: stretch;
  gap: 3px;
  min-width: 720px;
}
.evo-era {
  flex-basis: 0;
  min-width: 74px;
  display: flex;
  flex-direction: column;
}
.evo-era-head { padding: 0 .1rem .4rem; }
.evo-era-name {
  display: block;
  font-family: 'Spectral', Georgia, serif;
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.1;
  color: var(--basalt);
}
.evo-era-range { display: block; font-size: .68rem; color: var(--graphite); }
.evo-era-body {
  position: relative;
  flex: 1;
  min-height: 84px;
  border-radius: var(--radius);
  background: var(--paper);
  background: color-mix(in srgb, var(--era) 16%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--era) 45%, var(--hairline));
  border-bottom: 4px solid var(--era);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.evo-creatures {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: center;
  align-items: center;
  padding: .5rem .35rem;
}
.evo-creature {
  position: relative;
  width: 34px; height: 34px;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--era) 40%, var(--hairline));
  border-radius: 50%;
  background: var(--paper);
  color: var(--basalt);
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  animation: evo-float 4.5s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
.evo-creature svg { width: 100%; height: 100%; display: block; }
.evo-creature:hover, .evo-creature:focus-visible {
  transform: translateY(-3px) scale(1.12);
  background: #fff;
  box-shadow: var(--shadow);
  outline: none;
  z-index: 5;
}
@keyframes evo-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
/* Tooltip */
.evo-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: 190px;
  background: var(--basalt);
  color: #F3F0E8;
  padding: .5rem .6rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  opacity: 0; visibility: hidden;
  transition: opacity .15s ease, transform .15s ease;
  pointer-events: none;
  z-index: 10;
}
.evo-tip b { display: block; font-size: .85rem; font-family: 'Spectral', Georgia, serif; }
.evo-tip-when { display: block; color: var(--amber); font-size: .72rem; margin: .1rem 0 .2rem; }
.evo-tip-blurb { display: block; font-size: .76rem; color: #C9C4B8; line-height: 1.35; }
.evo-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--basalt);
}
.evo-creature:hover .evo-tip, .evo-creature:focus-visible .evo-tip {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.evo-axis {
  display: flex; justify-content: space-between;
  min-width: 720px;
  margin-top: .5rem;
  font-size: .74rem; color: var(--graphite);
  font-family: 'IBM Plex Mono', monospace;
}
.evo-now {
  color: var(--basalt); font-weight: 600;
  padding: .05rem .5rem; border-radius: 999px;
  background: var(--amber); color: #241a06;
}
@media (prefers-reduced-motion: reduce) {
  .evo-creature { animation: none; }
}

/* ---------- Deep-time fact ribbon ---------- */
.factoid {
  display: flex; align-items: center; gap: .7rem;
  margin: 1.4rem 0 .4rem;
  padding: .7rem .9rem;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  font-size: .95rem;
}
.factoid svg { flex: none; color: var(--amber-deep); }
.factoid b { font-family: 'Spectral', Georgia, serif; }
