/* ==========================================================================
   The HiddenBotanist — Herbarium UI
   Register: Archival Scrapbook (parchment, serifs, handwritten feel)
   Palette: straight from the Visual Register Guide.
   ========================================================================== */

:root {
  /* Core palette */
  --ink: #1a1613;
  --shadow: #2a221d;
  --moss: #4a5a3f;
  --sage: #7b8f6b;
  --brass: #b89968;
  --cream: #c9bfa8;
  --bone: #e8e0d0;
  --terra: #8a4f3a;
  --parchment: #f4efe4;
  --parchment-dark: #e8dfc9;
  --warning: #a85a3a;
  --success: #5a7a4a;

  /* Rarity accents */
  --r-common: #6b6b5a;
  --r-uncommon: #5a7a4a;
  --r-rare: #4a6a8a;
  --r-ultra: #7a4a6a;
  --r-legendary: #a8703a;

  /* Type */
  --display-font: 'Cormorant Garamond', Georgia, serif;
  --body-font: 'Crimson Pro', Georgia, serif;
  --mono-font: 'IBM Plex Mono', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--body-font);
  color: var(--ink);
  background: var(--parchment);
  background-image:
    radial-gradient(at 20% 10%, rgba(184, 153, 104, 0.08) 0%, transparent 40%),
    radial-gradient(at 80% 80%, rgba(138, 79, 58, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.06'/></svg>");
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: multiply;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ==== Typography ==== */

.kicker {
  font-family: var(--mono-font);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--brass);
  font-weight: 500;
}

.display {
  font-family: var(--display-font);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 400;
  font-style: italic;
  color: var(--ink);
  line-height: 1.05;
  margin: 0.5rem 0 1rem;
}

.section-title {
  font-family: var(--display-font);
  font-size: 2rem;
  font-weight: 500;
  color: var(--moss);
  margin: 0.25rem 0 1rem;
  font-style: italic;
}

.lede {
  font-size: 1.05rem;
  color: var(--shadow);
  opacity: 0.85;
  max-width: 44ch;
  line-height: 1.65;
}

.whisper {
  font-style: italic;
  color: var(--moss);
  font-size: 1.1rem;
  font-family: var(--display-font);
  margin-bottom: 0.5rem;
}

.credit {
  font-family: var(--mono-font);
  font-size: 0.8rem;
  color: var(--terra);
  letter-spacing: 0.1em;
}

/* ==== Brand header (landing) ==== */

.brand-header {
  text-align: center;
  padding: 3rem 0 2rem;
}

.brand-header .lede {
  margin: 1rem auto 0;
  text-align: center;
}

.monogram {
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
  display: block;
}

.monogram-sm {
  width: 36px;
  height: 36px;
}

/* ==== Auth card ==== */

.auth-card {
  background: var(--parchment-dark);
  border: 1px solid rgba(184, 153, 104, 0.3);
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: 0 2px 8px rgba(26, 22, 19, 0.06);
  position: relative;
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(184, 153, 104, 0.3);
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.75rem 0;
  font-family: var(--mono-font);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink);
  opacity: 0.55;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab.active {
  opacity: 1;
  color: var(--terra);
  border-bottom-color: var(--brass);
}

.tab:hover:not(.active) { opacity: 0.85; }

/* ==== Forms ==== */

form label {
  display: block;
  margin-bottom: 1rem;
}

.label {
  display: block;
  font-family: var(--mono-font);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--brass);
  margin-bottom: 0.4rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  background: var(--parchment);
  border: 1px solid rgba(74, 90, 63, 0.3);
  padding: 0.75rem 0.9rem;
  font-family: var(--body-font);
  font-size: 1rem;
  color: var(--ink);
  transition: all 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--moss);
  box-shadow: 0 0 0 3px rgba(74, 90, 63, 0.12);
}

button.primary {
  width: 100%;
  background: var(--moss);
  color: var(--bone);
  border: none;
  padding: 0.9rem 1.5rem;
  font-family: var(--mono-font);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: all 0.2s;
}

button.primary:hover { background: var(--shadow); }
button.primary:disabled { opacity: 0.6; cursor: wait; }

button.ghost {
  background: transparent;
  color: var(--terra);
  border: 1px solid rgba(138, 79, 58, 0.4);
  padding: 0.4rem 0.9rem;
  font-family: var(--mono-font);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: all 0.2s;
}

button.ghost:hover {
  background: rgba(138, 79, 58, 0.08);
}

.message {
  margin-top: 1rem;
  font-style: italic;
  font-size: 0.95rem;
  min-height: 1.5rem;
  color: var(--shadow);
  font-family: var(--display-font);
}

.message.success { color: var(--success); }
.message.error { color: var(--warning); }

/* ==== Top bar (dashboard) ==== */

.top-bar {
  background: var(--bone);
  border-bottom: 1px solid rgba(184, 153, 104, 0.3);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.top-bar-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-email {
  font-family: var(--mono-font);
  font-size: 0.75rem;
  color: var(--shadow);
  opacity: 0.75;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==== Herbarium sections ==== */

.herbarium-header {
  text-align: center;
  padding: 3rem 0 2rem;
  border-bottom: 1px solid rgba(184, 153, 104, 0.2);
  margin-bottom: 2rem;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
}

.stat { text-align: center; }

.stat-number {
  display: block;
  font-family: var(--display-font);
  font-size: 2.5rem;
  font-weight: 500;
  font-style: italic;
  color: var(--terra);
  line-height: 1;
}

.stat-label {
  display: block;
  font-family: var(--mono-font);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--brass);
  margin-top: 0.3rem;
}

.redemption {
  background: var(--parchment-dark);
  border-left: 4px solid var(--brass);
  padding: 2rem;
  margin: 2rem 0;
}

.redeem-form {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0 0;
}

.redeem-form input {
  flex: 1;
  font-family: var(--mono-font);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.redeem-form button {
  width: auto;
  padding: 0 1.5rem;
  margin-top: 0;
  white-space: nowrap;
}

/* ==== Sticker grid ==== */

.collection {
  padding: 2rem 0;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.sticker-card {
  aspect-ratio: 3 / 4;
  background: var(--bone);
  border: 1px solid rgba(184, 153, 104, 0.4);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  transition: all 0.25s;
  cursor: default;
}

.sticker-card.missing {
  background: transparent;
  border-style: dashed;
  border-color: rgba(184, 153, 104, 0.25);
  opacity: 0.55;
}

.sticker-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26, 22, 19, 0.08);
}

.sticker-img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display-font);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--ink);
  position: relative;
  overflow: hidden;
  padding: 0.5rem;
}

.sticker-card.missing .sticker-img {
  background: transparent;
  border: 2px dashed rgba(184, 153, 104, 0.3);
}

.sticker-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sticker-name {
  font-family: var(--display-font);
  font-size: 0.95rem;
  color: var(--ink);
  margin-top: 0.5rem;
  line-height: 1.25;
  font-style: italic;
}

.sticker-card.missing .sticker-name {
  color: var(--shadow);
  opacity: 0.6;
}

.sticker-rarity {
  font-family: var(--mono-font);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 0.3rem;
}

.sticker-rarity.common { color: var(--r-common); }
.sticker-rarity.uncommon { color: var(--r-uncommon); }
.sticker-rarity.rare { color: var(--r-rare); }
.sticker-rarity.ultra_rare { color: var(--r-ultra); }
.sticker-rarity.legendary { color: var(--r-legendary); }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  font-style: italic;
  color: var(--shadow);
  opacity: 0.7;
  font-family: var(--display-font);
  font-size: 1.05rem;
}

/* ==== Footer ==== */

.page-footer {
  text-align: center;
  padding: 4rem 0 2rem;
  border-top: 1px solid rgba(184, 153, 104, 0.2);
  margin-top: 3rem;
}

/* ==== Links ==== */

a {
  color: var(--terra);
  text-decoration: underline;
  text-decoration-color: rgba(138, 79, 58, 0.3);
  text-underline-offset: 2px;
  transition: all 0.15s;
}

a:hover { text-decoration-color: var(--terra); }

a.primary {
  display: inline-block;
  background: var(--moss);
  color: var(--bone);
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  font-family: var(--mono-font);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-top: 1rem;
}

a.primary:hover { background: var(--shadow); }

/* ==== Responsive ==== */

@media (max-width: 480px) {
  .stats { gap: 1.2rem; }
  .stat-number { font-size: 2rem; }
  .auth-card { padding: 1.5rem; }
  .redemption { padding: 1.5rem; }
  .redeem-form { flex-direction: column; }
  .redeem-form button { width: 100%; }
  .top-bar-inner { padding: 0 1rem; }
  .user-email { display: none; }
}

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