:root {
  --paper: #e9dec4;
  --paper-card: #f8f1e0;
  --paper-shadow: #d8c9a3;
  --ink: #2a2118;
  --ink-soft: #5c5140;
  --ink-faint: #8a7c65;
  --forest: #2f4a3a;
  --forest-dark: #1c2f24;
  --rust: #ad4e2a;
  --rust-dark: #7f3a1f;
  --line: rgba(42, 33, 24, 0.32);
  --line-soft: rgba(42, 33, 24, 0.14);

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Book Antiqua", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  position: relative;
  overflow-x: hidden;
}

/* subtle paper grain */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.045 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

a {
  color: var(--forest);
  text-decoration-color: var(--line);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--rust);
}

header {
  max-width: 900px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 1.2rem;
  text-align: center;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--rust-dark);
  margin: 0 0 0.9rem;
}

h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 480;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 1.08rem;
  color: var(--ink-soft);
  max-width: 40ch;
  margin: 0 auto 0.9rem;
  line-height: 1.5;
}

.dateline {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: inline-block;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
}

#cards {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.75rem;
}

@media (max-width: 960px) {
  #cards {
    grid-template-columns: 1fr;
    max-width: 560px;
  }
}

.card {
  position: relative;
  min-width: 0;
  background: var(--paper-card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--paper-shadow), 0 18px 34px -22px rgba(28, 22, 14, 0.45);
  padding: 2.1rem 2.1rem 2.3rem;
  display: flex;
  flex-direction: column;
  opacity: 0;
  animation: reveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.18s; }
.card:nth-child(3) { animation-delay: 0.31s; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.corner {
  position: absolute;
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.corner.tl { top: 6px; left: 6px; border-top: 1px solid var(--ink-faint); border-left: 1px solid var(--ink-faint); }
.corner.tr { top: 6px; right: 6px; border-top: 1px solid var(--ink-faint); border-right: 1px solid var(--ink-faint); }
.corner.bl { bottom: 6px; left: 6px; border-bottom: 1px solid var(--ink-faint); border-left: 1px solid var(--ink-faint); }
.corner.br { bottom: 6px; right: 6px; border-bottom: 1px solid var(--ink-faint); border-right: 1px solid var(--ink-faint); }

.eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}

.entry-no {
  color: var(--ink-faint);
}

.class-name {
  color: var(--rust-dark);
  font-weight: 600;
}

.photo-frame {
  aspect-ratio: 4 / 3;
  background: var(--paper-shadow);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Text blocks below the photo get fixed heights (clamped/reserved) rather
   than sizing to content, so a longer name or credit line on one card - or
   after a reroll - never pushes that card's (or its row-mates') button
   position around. */

.status {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-style: italic;
  color: var(--ink-faint);
  margin: 0.9rem 0 0;
  min-height: 1.1em;
}

.species-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 440;
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 0.55rem 0 0.2rem;
  min-height: calc(1.25 * 2em);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.species-name a {
  color: inherit;
  text-decoration-color: var(--line);
}

.species-name a:hover {
  color: var(--rust);
}

.species-latin {
  font-family: var(--font-mono);
  font-style: italic;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink-faint);
  margin: 0 0 0.7rem;
  min-height: 1.4em;
}

/* Credit text (photographer/license) can be any length, so it truncates with
   an ellipsis on one line - it's supplementary. The links line below it
   never truncates, so it's always present and clickable regardless. */
.credit {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  line-height: 1.5;
  margin: 0 0 0.15rem;
  min-height: 1.5em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.links {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
  margin: 0 0 1.3rem;
  min-height: 1.5em;
}

.credit a,
.links a {
  color: var(--ink-faint);
}

.credit a:hover,
.links a:hover {
  color: var(--rust);
}

.actions {
  margin-top: auto;
  display: flex;
  gap: 0.6rem;
}

.reroll,
.back {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--forest-dark);
  background: transparent;
  border: 1px solid var(--forest-dark);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.reroll {
  flex: 1;
}

.back {
  flex: 0 0 auto;
  padding-left: 0.85rem;
  padding-right: 0.85rem;
}

.reroll:hover,
.back:hover:not(:disabled) {
  background: var(--forest-dark);
  color: var(--paper-card);
}

.reroll:active,
.back:active:not(:disabled) {
  transform: scale(0.97);
}

.reroll:disabled,
.back:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
  color: var(--forest-dark);
}

.reroll-icon {
  display: inline-block;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.reroll.spinning .reroll-icon {
  transform: rotate(360deg);
}

footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  text-align: center;
  border-top: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  line-height: 1.6;
}
