/* ===================================================================
   Sri Lankan Wildlife Guide — Polished Nature / Wildlife Design
   Mobile-first: base @ 375px → 768px → 1024px+
   =================================================================== */

/* Fonts loaded via <link> in base.html */

:root {
  /* Nature palette */
  --forest-deep: #1B4332;
  --forest-mid: #2D6A4F;
  --forest-light: #52B788;
  --earth: #D4A373;
  --earth-dark: #C08A55;
  --cream: #FEFAE0;
  --cream-dark: #F0E9C5;
  --amber: #D4A017;

  /* UI colors */
  --text: #1A2B20;
  --text-muted: #5C7260;
  --white: #FFFFFF;
  --border: #C8DDD0;
  --shadow-sm: 0 2px 8px rgba(27, 67, 50, 0.10);
  --shadow-md: 0 4px 16px rgba(27, 67, 50, 0.15);
  --shadow-lg: 0 8px 32px rgba(27, 67, 50, 0.20);

  --radius: 8px;
  --radius-lg: 14px;

  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --transition: 0.2s ease;
}

/* ========================
   Reset + Base
   ======================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.6;
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--forest-mid);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--forest-deep); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
}

/* ========================
   Layout
   ======================== */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

main {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

/* ========================
   Sticky Nav / Header
   ======================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(27, 67, 50, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: background var(--transition), box-shadow var(--transition);
}

.site-header.scrolled {
  background: rgba(27, 67, 50, 0.99);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.25);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
  gap: 1rem;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.site-title:hover { color: var(--earth); text-decoration: none; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
}

.main-nav a {
  color: rgba(255, 255, 255, 0.80);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.main-nav a:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.10);
  text-decoration: none;
}

/* ========================
   Buttons
   ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--earth);
  color: var(--forest-deep);
  border-color: var(--earth);
}
.btn-primary:hover {
  background: var(--earth-dark);
  border-color: var(--earth-dark);
  color: var(--forest-deep);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 163, 115, 0.40);
}

.btn-outline {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.45);
}
.btn-outline:hover {
  border-color: var(--white);
  color: var(--white);
  background: rgba(255, 255, 255, 0.10);
  text-decoration: none;
}

.btn-secondary {
  background: var(--cream);
  color: var(--forest-deep);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--cream-dark);
  border-color: var(--forest-light);
  color: var(--forest-deep);
  text-decoration: none;
}

.btn-danger {
  background: #C0392B;
  color: var(--white);
  border-color: #C0392B;
}
.btn-danger:hover {
  background: #A93226;
  border-color: #A93226;
  color: var(--white);
  text-decoration: none;
}

.btn-full {
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-lg {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

/* ========================
   Hero Section
   ======================== */
.hero {
  position: relative;
  background: linear-gradient(155deg, var(--forest-deep) 0%, var(--forest-mid) 58%, #3a8a62 100%);
  color: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 3.5rem 1.25rem;
  margin-bottom: 2.5rem;
  text-align: center;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 85%, rgba(82, 183, 136, 0.18) 0%, transparent 50%),
    radial-gradient(circle at 85% 15%, rgba(212, 163, 115, 0.12) 0%, transparent 50%);
  pointer-events: none;
}

.hero-content { position: relative; z-index: 1; }

.hero-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--earth);
  margin-bottom: 1rem;
  padding: 0.375rem 0.875rem;
  background: rgba(212, 163, 115, 0.15);
  border: 1px solid rgba(212, 163, 115, 0.30);
  border-radius: 2rem;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.hero p {
  font-size: 1rem;
  opacity: 0.85;
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  gap: 0.875rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ========================
   Section Header
   ======================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  font-size: 1.5rem;
  color: var(--forest-deep);
  font-weight: 700;
}

/* ========================
   Species Grid (mobile-first: 1 col)
   ======================== */
.species-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.species-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid rgba(200, 221, 208, 0.65);
  display: flex;
  flex-direction: column;
}

.species-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.species-thumb-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: #e8f2ec;
  flex-shrink: 0;
}

.species-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
  display: block;
}

.species-card:hover .species-thumb {
  transform: scale(1.06);
}

.species-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f5ee, #cde8d8);
  font-size: 2.75rem;
  width: 100%;
  height: 100%;
}

.species-card-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.species-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--forest-mid);
  font-weight: 600;
  display: block;
  margin-bottom: 0.375rem;
}

.species-card-body h3 {
  font-size: 1.05rem;
  margin-bottom: auto;
  padding-bottom: 0.5rem;
}

.species-card-body h3 a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}
.species-card-body h3 a:hover { color: var(--forest-mid); }

.species-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.species-meta { font-size: 0.78rem; color: var(--text-muted); }

.card-read-more {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--forest-mid);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.card-read-more:hover { color: var(--forest-deep); }

/* ========================
   Empty State
   ======================== */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { margin-bottom: 1.25rem; font-size: 1rem; }

/* ========================
   Auth Pages
   ======================== */
.auth-page {
  min-height: 68vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem;
  border: 1px solid var(--border);
}

.auth-container h1 {
  font-size: 1.75rem;
  color: var(--forest-deep);
  margin-bottom: 0.375rem;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.auth-footer {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ========================
   Form Elements
   ======================== */
.form-group { margin-bottom: 1.125rem; }

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--forest-light);
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.18);
}

.form-group textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.65;
}

/* ========================
   Alerts
   ======================== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.alert-error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}
.alert-success {
  background: #F0FDF4;
  color: var(--forest-deep);
  border: 1px solid #BBF7D0;
}

/* ========================
   Dashboard
   ======================== */
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-header h1 {
  font-size: 1.75rem;
  color: var(--forest-deep);
}

.dashboard-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.pages-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.pages-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  min-width: 500px;
}

.pages-table thead { background: var(--forest-deep); }

.pages-table th {
  color: var(--white);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--font-body);
}

.pages-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.pages-table tr:last-child td { border-bottom: none; }
.pages-table tbody tr:hover td { background: #F7FCF9; }

.pages-table .actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pages-table a { color: var(--forest-mid); font-weight: 500; }
.pages-table a:hover { color: var(--forest-deep); }

/* ========================
   Species Detail
   ======================== */
.species-hero {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  background: var(--forest-deep);
  max-height: 440px;
}

.species-hero-img {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  display: block;
}

.species-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(27, 67, 50, 0.80) 0%, rgba(27, 67, 50, 0.10) 55%);
  display: flex;
  align-items: flex-end;
  padding: 1.5rem;
}

.species-hero-text { color: var(--white); }

.species-hero-text h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.species-hero-text .scientific {
  font-style: italic;
  font-size: 0.95rem;
  opacity: 0.88;
}

.species-detail {
  max-width: 760px;
  margin: 0 auto;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--forest-mid); }
.breadcrumb a:hover { color: var(--forest-deep); }

.species-detail-header { margin-bottom: 1.5rem; }

.species-detail-header h1 {
  font-size: 1.9rem;
  color: var(--forest-deep);
  margin-bottom: 0.25rem;
}

.species-detail-header .scientific {
  font-style: italic;
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-heading);
}

.species-detail-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.owner-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Back link (species detail) */
.back-link {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  transition: color var(--transition);
}
.back-link:hover { color: var(--forest-mid); }

/* ========================
   Markdown Body
   ======================== */
.species-body {
  line-height: 1.8;
  font-size: 1rem;
}

.species-body h1, .species-body h2,
.species-body h3, .species-body h4 {
  font-family: var(--font-heading);
  color: var(--forest-deep);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.species-body h1 { font-size: 1.7rem; }
.species-body h2 { font-size: 1.4rem; }
.species-body h3 { font-size: 1.15rem; }

.species-body p { margin-bottom: 1.1rem; }

.species-body ul, .species-body ol {
  padding-left: 1.75rem;
  margin-bottom: 1.1rem;
}
.species-body li { margin-bottom: 0.35rem; }

.species-body blockquote {
  border-left: 4px solid var(--earth);
  padding: 0.75rem 1.25rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  background: rgba(212, 163, 115, 0.08);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}

.species-body pre {
  background: #1A2B20;
  color: #D4EDDA;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.1rem;
  font-size: 0.85rem;
}

.species-body code {
  font-family: 'Fira Mono', 'Consolas', monospace;
  font-size: 0.87em;
}

.species-body :not(pre) > code {
  background: rgba(27, 67, 50, 0.08);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--forest-deep);
}

.species-body img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1rem 0;
}

.species-body table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.1rem;
  overflow-x: auto;
  display: block;
}

.species-body th, .species-body td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.875rem;
  text-align: left;
}

.species-body th {
  background: rgba(27, 67, 50, 0.06);
  font-weight: 600;
}

.codehilite pre {
  background: #1A2B20;
  color: #D4EDDA;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.1rem;
}

.toc {
  background: rgba(27, 67, 50, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.75rem;
}
.toc ul { padding-left: 1.25rem; }

/* ========================
   Page Editor
   ======================== */
.editor-container { max-width: 780px; margin: 0 auto; }

.editor-container h1 {
  font-size: 1.75rem;
  color: var(--forest-deep);
  margin-bottom: 1.75rem;
}

.upload-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.upload-status { font-size: 0.82rem; color: var(--forest-mid); }

.current-thumb { margin-top: 0.5rem; }

.thumb-preview {
  max-height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.label-hint {
  font-size: 0.77rem;
  color: var(--text-muted);
  font-weight: 400;
}

.markdown-hint {
  background: rgba(27, 67, 50, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  line-height: 1.5;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

/* ========================
   Footer
   ======================== */
.site-footer {
  background: var(--forest-deep);
  color: rgba(255, 255, 255, 0.50);
  padding: 2rem 0 1.5rem;
  font-size: 0.82rem;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.footer-brand {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 0.125rem;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.82rem;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--earth); }

.footer-copy { margin-top: 0.25rem; }

/* ========================
   Hamburger / Mobile Nav
   ======================== */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 2rem;
  height: 1.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  gap: 0;
  flex-shrink: 0;
}

.burger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.90);
  border-radius: 2px;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.nav-toggle[aria-expanded="true"] .burger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .burger-bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav-toggle[aria-expanded="true"] .burger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 767px) {
  .nav-toggle { display: flex; }

  .site-header .container { position: relative; }

  .main-nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(27, 67, 50, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.75rem 1rem 1rem;
    gap: 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 99;
  }

  .main-nav.nav-open { display: flex; }

  .main-nav a {
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
    width: 100%;
    text-align: left;
  }

  .main-nav .btn {
    text-align: center;
    margin-top: 0.25rem;
  }
}

/* ========================
   Responsive — Tablet 768px
   ======================== */
@media (min-width: 768px) {
  .container { padding: 0 1.5rem; }

  .site-title { font-size: 1.3rem; }

  main { padding: 2rem 0 4rem; }

  .hero { padding: 5rem 2.5rem; }
  .hero h1 { font-size: 2.75rem; }
  .hero p { font-size: 1.1rem; }

  .species-grid { grid-template-columns: repeat(2, 1fr); }

  .species-hero-text h1 { font-size: 2.1rem; }
  .species-detail-header h1 { font-size: 2.2rem; }

  .auth-container { padding: 2.5rem 2.25rem; }

  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* ========================
   Responsive — Desktop 1024px
   ======================== */
@media (min-width: 1024px) {
  .container { padding: 0 2rem; }

  .hero { padding: 6rem 3rem; }
  .hero h1 { font-size: 3.25rem; }

  .species-grid { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

  .species-hero-text h1 { font-size: 2.5rem; }
}

@media (min-width: 1280px) {
  .species-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ========================
   Print
   ======================== */
@media print {
  .site-header, .site-footer, .owner-actions, .breadcrumb { display: none; }
  body { background: white; color: black; }
  .species-body a::after { content: ' (' attr(href) ')'; font-size: 0.75em; }
}
