:root {
  --red: #e0261e;
  --black: #1a1a1a;
  --gray: #6b6b6b;
  --light-gray: #ececec;
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --text: #1a1a1a;
  --text-body: #333333;
  --border: #ececec;
}

:root[data-theme="dark"] {
  --red: #ff5148;
  --black: #f2f2f2;
  --gray: #a0a0a0;
  --light-gray: #2a2a2a;
  --bg: #121212;
  --bg-subtle: #1c1c1c;
  --text: #f2f2f2;
  --text-body: #d4d4d4;
  --border: #2a2a2a;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

/* Header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 40px;
  border-bottom: 1px solid var(--light-gray);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

:root[data-theme="dark"] .logo {
  background: rgba(245, 245, 245, 0.4);
  border-radius: 50%;
  padding: 3px;
}

.brand-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-btn[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-btn[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.hamburger-btn[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-group {
  display: flex;
  align-items: center;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--gray);
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 20px;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover {
  color: var(--black);
  background: var(--light-gray);
}

.nav-link.active {
  color: var(--red);
  font-weight: 600;
}

.nav-item {
  position: relative;
}

.caret {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.nav-item.open .caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  min-width: 160px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 30;
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--light-gray);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

/* Pages */

main {
  flex: 1 0 auto;
}

.page {
  display: none;
  animation: fade 0.25s ease;
}

.page.active {
  display: block;
}

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

.page-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px;
}

.page-inner h2 {
  font-size: 28px;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

.page-inner p {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-body);
  margin-bottom: 16px;
}

/* Home / hero */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 120px 24px;
  max-width: 560px;
  margin: 0 auto;
}

.hero-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin-bottom: 28px;
}

:root[data-theme="dark"] .hero-logo {
  background: rgba(245, 245, 245, 0.4);
  border-radius: 50%;
  padding: 8px;
}

.hero h1 {
  font-size: 34px;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.tagline {
  font-size: 17px;
  color: var(--gray);
  line-height: 1.7;
  margin: 0;
}

.latest-story {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 160px;
  margin-top: 48px;
  text-decoration: none;
  color: inherit;
}

.latest-story-img {
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--gray);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

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

.latest-story-img svg {
  width: 36px;
  height: 36px;
}

.latest-story:hover .latest-story-img {
  border-color: var(--red);
}

.latest-story-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red);
  margin-top: 14px;
}

.latest-story-title {
  font-size: 14px;
  color: var(--text-body);
  margin-top: 4px;
  text-align: center;
}

/* Animals page */

.animal-link {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--gray);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.animal-link:hover {
  background: var(--light-gray);
  color: var(--text);
}

.animal-link.active {
  color: var(--red);
  font-weight: 600;
  background: var(--light-gray);
}

.animal-content {
  display: none;
}

.animal-content.active {
  display: block;
}

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

.thumb-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thumb-img {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--gray);
  overflow: hidden;
}

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

.thumb-img svg {
  width: 28px;
  height: 28px;
}

.thumb-title {
  font-size: 14px;
  color: var(--text-body);
  text-align: center;
}

.thumb-card.has-bio {
  cursor: pointer;
}

.thumb-card.has-bio .thumb-img {
  transition: border-color 0.15s ease;
}

.thumb-card.has-bio:hover .thumb-img {
  border-color: var(--red);
}

/* Story modal */

.story-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.story-modal.open {
  display: flex;
}

.story-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.story-modal-card {
  position: relative;
  background: var(--bg);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
}

.story-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.story-modal-close:hover {
  background: var(--light-gray);
}

.story-modal-img {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--gray);
  overflow: hidden;
}

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

.story-modal-img svg {
  width: 36px;
  height: 36px;
}

.story-modal-title {
  font-size: 20px;
  margin: 0 0 12px;
}

.story-modal-bio {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-body);
  white-space: pre-line;
  text-align: left;
  margin: 0;
}

/* Contact form */

#contact-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 24px;
}

#contact-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  margin-top: 14px;
}

#contact-form input,
#contact-form textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--light-gray);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--black);
  resize: vertical;
}

#contact-form input:focus,
#contact-form textarea:focus {
  outline: none;
  border-color: var(--red);
  background: var(--bg);
}

#contact-form button {
  margin-top: 24px;
  align-self: flex-start;
  background: var(--red);
  color: #fff;
  border: none;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 24px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

#contact-form button:hover {
  opacity: 0.85;
}

.form-note {
  font-size: 13px;
  color: var(--gray);
  margin-top: 16px;
}

/* Footer */

.site-footer {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  padding: 64px 40px 32px;
}

.footer-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  max-width: 1000px;
  margin: 0 auto;
}

.footer-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 28px 0 12px;
}

.footer-heading:first-child {
  margin-top: 0;
}

.footer-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-body);
  margin: 0 0 10px;
}

.footer-inline-link {
  color: var(--text-body);
  text-decoration: underline;
}

.footer-inline-link:hover {
  color: var(--red);
}

.subscribe-form {
  display: flex;
  margin-top: 16px;
}

.subscribe-form input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  background: var(--bg);
  color: var(--text);
}

.subscribe-form input:focus {
  outline: none;
  border-color: var(--red);
}

.subscribe-form button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--red);
  border: none;
  padding: 12px 20px;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.subscribe-form button:hover {
  opacity: 0.85;
}

.footer-note {
  font-size: 13px;
  color: var(--gray);
  margin: 10px 0 0;
  min-height: 18px;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1000px;
  margin: 48px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.footer-brand {
  font-weight: 600;
  font-size: 14px;
}

.footer-links {
  display: flex;
  gap: 8px;
}

.footer-link {
  color: var(--gray);
}

.footer-link.active {
  color: var(--red);
}

.footer-copy {
  font-size: 13px;
  color: var(--gray);
}

/* Responsive */

@media (max-width: 860px) {
  .site-header {
    padding: 16px 20px;
    flex-wrap: wrap;
  }

  .brand-name {
    font-size: 16px;
  }

  .hamburger-btn {
    display: flex;
  }

  .nav-group {
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .nav-group.open {
    max-height: 80vh;
    overflow-y: auto;
    margin-top: 16px;
  }

  .nav {
    flex-direction: column;
    gap: 0;
    width: 100%;
    border-top: 1px solid var(--border);
  }

  .nav-link {
    width: 100%;
    justify-content: space-between;
    border-radius: 0;
    padding: 16px 4px;
    border-bottom: 1px solid var(--border);
  }

  .nav-item {
    width: 100%;
  }

  .dropdown-menu {
    position: static;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    margin-top: 0;
    padding: 0 0 0 16px;
    background: var(--bg-subtle);
  }

  .nav-item.open .dropdown-menu {
    display: block;
  }

  .animal-link {
    border-radius: 0;
    padding: 14px 8px;
  }

  .theme-toggle {
    margin: 16px 4px;
  }

  .hero {
    padding: 80px 20px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .latest-story,
  .latest-story-img {
    width: 140px;
  }

  .latest-story-img {
    height: 140px;
  }

  .page-inner {
    padding: 60px 20px;
  }

  .story-modal {
    padding: 16px;
  }

  .story-modal-card {
    padding: 24px;
  }

  .site-footer {
    padding: 48px 20px 24px;
  }

  .footer-top {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}
