:root {
  --color-cream: #fffdf9;
  --color-ink: #000000;
  --color-hotpink: #ff3366;
  --color-electric: #ffcc00;
  --color-mint: #00cc99;

  --shadow-sm: 3px 3px 0px #000000;
  --shadow: 4px 4px 0px #000000;
  --shadow-lg: 6px 6px 0px #000000;

  --font-heading: "Fredoka", sans-serif;
  --font-body: "Inter", sans-serif;

  --border-w: 3px;
}

@media (min-width: 768px) {
  :root {
    --border-w: 4px;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/*
 * Several component rules below (.hero__state, .card__thumb-placeholder,
 * .modal__image-state, .empty-state, img) set an unconditional `display`.
 * Author CSS always wins over the browser's default `[hidden] { display:
 * none }` rule regardless of selector specificity, so without this override
 * the JS toggling `el.hidden = true/false` would silently do nothing and
 * every state (loading/error/success) would render stacked on top of
 * each other at once.
 */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--color-cream);
  color: var(--color-ink);
  font-family: var(--font-body);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--color-hotpink);
  outline-offset: 2px;
}

.text-hotpink {
  color: var(--color-hotpink);
}

.tilt-left {
  transform: rotate(-1.5deg);
}

.tilt-right {
  transform: rotate(1deg);
}

.press-pop {
  transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 150ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.press-pop:hover {
  transform: translateY(-3px) scale(1.02);
}

.press-pop:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 2px 2px 0px #000;
}

.section-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);
}

.section-title--sm {
  font-size: clamp(1.5rem, 1.3rem + 1vw, 1.875rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Buttons & badges ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 1rem;
  padding: 1rem 1.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  box-shadow: var(--shadow);
  background: white;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.7;
}

.btn--mint {
  background: var(--color-mint);
}

.btn--electric {
  background: var(--color-electric);
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.btn--white {
  background: white;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 999px;
  background: white;
  padding: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  box-shadow: var(--shadow-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 2px solid var(--color-ink);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge--electric {
  background: var(--color-electric);
}

.badge--mint {
  background: var(--color-mint);
}

.badge--hotpink {
  background: var(--color-hotpink);
  color: white;
}

/* ---------- Hero ---------- */

.hero {
  border-bottom: 4px solid var(--color-ink);
  padding: 2.5rem 1rem 4rem;
  overflow: hidden;
}

@media (min-width: 768px) {
  .hero {
    padding: 4rem 2rem 6rem;
  }
}

.hero__inner {
  max-width: 72rem;
  margin: 0 auto;
  display: grid;
  gap: 2.5rem;
}

@media (min-width: 768px) {
  .hero__inner {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}

.hero__eyebrow {
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.hero__title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(2.25rem, 1.7rem + 2.5vw, 3.75rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero__title-accent {
  display: block;
  margin-top: 0.5rem;
  transform: rotate(-1deg);
  color: var(--color-hotpink);
}

.hero__lede {
  margin-top: 1.25rem;
  max-width: 28rem;
  font-size: 1.125rem;
  color: rgba(0, 0, 0, 0.8);
}

.hero__cta {
  margin-top: 2rem;
}

.hero__image-box {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 28rem;
  overflow: hidden;
  border-radius: 1.5rem;
  border: var(--border-w) solid var(--color-ink);
  background: white;
  box-shadow: var(--shadow-lg);
}

.hero__state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  color: rgba(0, 0, 0, 0.6);
}

.hero__state[data-state="error"] .hero__state-icon,
.hero__state[data-state="loading"] .hero__state-icon {
  color: var(--color-hotpink);
}

.hero__state-icon {
  font-size: 3rem;
}

.hero__state-icon--bounce {
  animation: bounce 1s infinite;
}

.hero__state-text {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.25rem;
}

.hero__state--image {
  position: relative;
  padding: 0;
  display: block;
  height: 100%;
}

/*
 * The random cat photos come in whatever aspect ratio TheCatAPI hands us,
 * but the box is a fixed square. A blurred, scaled-up copy of the same
 * photo fills the box edge-to-edge as a backdrop, while the crisp original
 * floats on top fully visible via object-fit: contain — so the border
 * never shows plain empty space, but no part of the cat gets cropped.
 */
.hero__image-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(24px) brightness(0.7) saturate(1.4);
  transform: scale(1.15);
}

.hero__state--image img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

.hero__caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 2;
  background: rgba(0, 0, 0, 0.8);
  color: var(--color-cream);
  padding: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.hero__caption-opener {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-electric);
}

@keyframes bounce {
  0%, 100% { transform: translateY(-15%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
  50% { transform: none; animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

/* ---------- Breeds directory ---------- */

.breeds {
  max-width: 72rem;
  margin: 0 auto;
  padding: 4rem 1rem;
}

@media (min-width: 640px) {
  .breeds {
    padding: 4rem 2rem;
  }
}

.breeds__header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .breeds__header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.breeds__count {
  margin-top: 0.5rem;
  color: rgba(0, 0, 0, 0.7);
}

.search {
  position: relative;
  display: block;
  width: 100%;
}

@media (min-width: 640px) {
  .search {
    width: 18rem;
  }
}

.search__icon {
  position: absolute;
  inset-inline-end: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.search__input {
  width: 100%;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 0.75rem;
  background: white;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font: inherit;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 1rem;
  background: white;
  padding: 2.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.empty-state__icon {
  font-size: 2.25rem;
  color: rgba(0, 0, 0, 0.4);
}

.empty-state__icon--bounce {
  animation: bounce 1s infinite;
  color: var(--color-hotpink);
}

.empty-state__text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
}

.breeds__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .breeds__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .breeds__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Breed card ---------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 1rem;
  background: white;
  padding: 1rem;
  text-align: start;
  box-shadow: var(--shadow);
}

.card__thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--color-ink);
  border-radius: 0.75rem;
  background: var(--color-cream);
}

.card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.card__thumb-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, 0.25);
  font-size: 1.75rem;
}

.card__thumb-placeholder--loading {
  color: rgba(0, 0, 0, 0.25);
  animation: bounce 1s infinite;
}

.card__origin-badge {
  position: absolute;
  inset-inline-end: 0.5rem;
  top: 0.5rem;
}

.card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.card__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
}

.card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.card__description {
  font-size: 0.875rem;
  color: rgba(0, 0, 0, 0.7);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Daily cat fact ---------- */

.fact {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1rem 5rem;
}

@media (min-width: 640px) {
  .fact {
    padding: 0 2rem 5rem;
  }
}

.fact__box {
  border: var(--border-w) solid var(--color-ink);
  border-radius: 1.5rem;
  background: var(--color-electric);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
  .fact__box {
    padding: 2rem;
  }
}

.fact__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.fact__error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.fact__label {
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.6);
}

.fact__text {
  font-size: 1.125rem;
  font-weight: 500;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 4px solid var(--color-ink);
  background: var(--color-ink);
  color: var(--color-cream);
  padding: 2rem 1rem;
  text-align: center;
}

@media (min-width: 640px) {
  .site-footer {
    padding: 2rem;
  }
}

.site-footer__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.125rem;
}

.site-footer__brand i {
  color: var(--color-electric);
}

.site-footer__credit {
  margin: 0.5rem auto 0;
  max-width: 28rem;
  font-size: 0.875rem;
  color: rgba(255, 253, 249, 0.7);
}

.site-footer__credit a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer__credit a:hover {
  color: var(--color-electric);
}

.site-footer__signature {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: rgba(255, 253, 249, 0.5);
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  max-height: 90vh;
  width: calc(100% - 2rem);
  max-width: 40rem;
  border: var(--border-w) solid var(--color-ink);
  border-radius: 1.5rem;
  background: var(--color-cream);
  padding: 0;
  box-shadow: var(--shadow-lg);

  /* Closed state for the pop-in transition; main.js flips .is-open after
     showModal() so the browser has a "from" state to animate away from. */
  opacity: 0;
  transform: scale(0.85) translateY(16px) rotate(-1.5deg);
  transition: opacity 200ms ease, transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.is-open {
  opacity: 1;
  transform: scale(1) translateY(0) rotate(0deg);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0);
  transition: background 220ms ease;
}

.modal.is-open::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  .modal {
    transform: none;
  }
}

.modal__scroll {
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.1rem;
  padding-inline-end: 0.9rem;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.modal__title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.375rem;
}

.modal__top {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.75rem;
}

@media (min-width: 480px) {
  .modal__top {
    grid-template-columns: 110px 1fr;
    gap: 1rem;
  }
}

.modal__image-box {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
  border: 2px solid var(--color-ink);
  border-radius: 1rem;
  background: white;
  box-shadow: var(--shadow-sm);
}

.modal__image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.modal__image-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: rgba(0, 0, 0, 0.5);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.5rem;
}

.modal__image-icon {
  font-size: 1.25rem;
}

.modal__image-icon--bounce {
  animation: bounce 1s infinite;
}

.modal__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
}

.modal__badges .badge {
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

.modal__info {
  min-width: 0;
}

.modal__description {
  font-size: 0.85rem;
  line-height: 1.45;
  color: rgba(0, 0, 0, 0.8);
}

.modal__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.5rem;
}

.modal__wiki {
  margin-top: 0.4rem;
}

.stat-bar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.stat-bar__label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stat-bar__value {
  flex-shrink: 0;
  color: rgba(0, 0, 0, 0.5);
}

.stat-bar__track {
  height: 0.65rem;
  width: 100%;
  overflow: hidden;
  border-radius: 999px;
  border: 2px solid var(--color-ink);
  background: white;
}

.stat-bar__fill {
  height: 100%;
  transition: width 500ms ease-out;
}

.stat-bar__fill--hotpink { background: var(--color-hotpink); }
.stat-bar__fill--electric { background: var(--color-electric); }
.stat-bar__fill--mint { background: var(--color-mint); }

/* Interactive scrollbar: invisible at rest, fades in on hover/scroll. */
.brutal-scroll {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 200ms ease;
}

.brutal-scroll:hover,
.brutal-scroll.is-scrolling {
  scrollbar-color: rgba(51, 65, 85, 0.45) transparent;
}

.brutal-scroll::-webkit-scrollbar {
  width: 8px;
}

.brutal-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.brutal-scroll::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 999px;
  transition: background-color 200ms ease;
}

.brutal-scroll:hover::-webkit-scrollbar-thumb,
.brutal-scroll.is-scrolling::-webkit-scrollbar-thumb {
  background-color: rgba(51, 65, 85, 0.45);
}

.brutal-scroll::-webkit-scrollbar-thumb:hover {
  background-color: rgba(51, 65, 85, 0.7);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
