/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Source+Sans+3:wght@300;400;500;600&display=swap');

/* ========================================
   Design tokens / color variables
======================================== */
:root {
    --white: #ffffff;
    --green: #27694d;
    --yellow: #daa520;
    --red: #ef4444;
    --brown: #383129;
    --black: #2a2622;
    
    --title: #2b2622;
    --text: #7c736a;
    --border: #E7E2DA;

    --background: #f7f4ef;
    --card: #fcfaf7;
    --secondary: #eeebe4;
    --shadow: #c4b8a8;
    --favorite: #eaf0ed;
}

/* ========================================
   Base / reset
======================================== */
*,
*::before,
*::after {
  box-sizing: border-box; 
}

body {
  background-color: var(--background);
  margin: 0;
  padding: 0;
  font-family: "Source Sans 3", sans-serif;
  color: var(--text);
  font-optical-sizing: auto;
}

h1, h2, h3 {
  font-family: "Playfair Display", serif;
}

p {
  font-family: inherit;
}

/* Utility class used to hide elements such as the author filter */
.is-hidden {
  display: none;
}

/* ========================================
   Header
======================================== */
.header {
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.header__logo {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header__icon {
  width: 42px;
  height: 42px;
  margin: 20px 0 0 0;
  background-color: var(--green);
  background-image: url('src/assets/book.svg');
  background-size: 24px;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
  border-radius: 10px;
}

.header__title {
  font-size: 1.3rem;
  color: var(--title);
  margin: 20px 0 0 0;
}

.header__subtitle {
  font-size: 0.8rem;
  color: var(--text);
  margin: 0;
}

/* ========================================
   Hero section
======================================== */
.hero {
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
}

.hero__title {
  font-size: 2.1rem;
  color: var(--title);
  margin: 0;
}

.hero__text {
  font-size: 0.9rem;
  color: var(--text);
  max-width: 480px;
  margin: 0;
}

/* ========================================
   Search area
======================================== */
.search {
  display: flex;
  flex-direction: row;
  gap: 20px;
}

.search__input {
  min-width: 480px;
  width: min(100%, 480px);
  min-height: 48px;
  padding: 0.9rem 0.75rem 0.9rem 2.25rem;
  border-radius: 8px;
  border: 0.5px solid var(--border);
  background-image: url('src/assets/search.svg');
  background-size: 16px;
  background-repeat: no-repeat;
  background-position: 13px center;
  font-size: 0.8rem;
}

.search__input:focus {
  outline: 2px solid transparent;
  border-color: var(--green);
}

.search__button {
  background-color: var(--green);
  font-size: 0.8rem;
  border: none;
  color: var(--white);
  padding: 0 25px;
  border-radius: 10px;
  cursor: pointer;
}

.search__button:hover {
  opacity: 0.88;
}

.search__clear {
  background-color: var(--red);
  font-size: 0.8rem;
  border: none;
  color: var(--white);
  padding: 0 20px;
  border-radius: 10px;
  cursor: pointer;
}

.search__clear:hover {
  opacity: 0.88;
}

/* Author filter shown after results are loaded */
.search__filter {
  min-height: 48px;
  padding: 0 0.75rem;
  border-radius: 8px;
  border: 0.5px solid var(--border);
  background-color: var(--white);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

/* Shared transition for search controls */
.search__input,
.search__button,
.search__clear,
.search__filter {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

/* ========================================
   Main results layout
   Left: search results grid
   Right: favorites panel
======================================== */
.results {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(180px, 1fr);
  max-width: 1220px;
  gap: 10px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
  align-items: start;
}

.results__list {
  max-width: 1000px;
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(180px, 1fr));
  gap: 20px;
}

/* Favorites panel container */
.results__favorites {
  margin-top: 2rem;
  width: 200px;
  min-height: 250px;
  border-radius: 10px;
  background-color: var(--card);
  box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
}

/* ========================================
   Search result cards
======================================== */
.results__card {
  position: relative;
  background-color: var(--card);
  width: 100%;
  max-width: 180px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
}

.results__card img,
.results__no-cover {
  width: 100%;
  height: 280px;
  object-fit: cover;
}

.results__card-title {
  font-size: 0.9rem;
  color: var(--title);
  font-family: "Source Sans 3", sans-serif;
  text-align: left;
}

.results__card-text {
  font-size: 0.8rem;
  color: var(--text);
  text-align: left;
}

.results__card-content {
  padding: 0 1rem;
}

/* Placeholder shown when a search result has no cover */
.results__no-cover {
  background-color: var(--text);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}


/* ========================================
   Favorite button on result cards
   Default: outline
   Active: filled red
======================================== */
.card__favorite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  padding: 0;
  background-color: var(--favorite);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  transition: transform 0.2s ease, color 0.2s ease;
}

.card__favorite-btn--active {
  color: var(--red);
}

.card__favorite-icon {
  width: 20px;
  height: 20px;
}

.card__favorite-btn:active {
  transform: scale(0.9);
}

/* Outline heart */
.card__favorite-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Filled heart when active */
.card__favorite-btn--active .card__favorite-path {
  fill: currentColor;
  stroke: none;
  transition: fill 0.2s ease;
}

/* ========================================
   Favorites panel
======================================== */
.favorites {
  padding: 1rem 0;
}

/* Favorites header */
.favorites__header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.2rem;
}

.favorites__header-inner {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 1rem 1rem 1rem;
  gap: 0.75rem;
}

.favorites__header-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.favorites__header-icon {
  width: 32px;
  height: 32px;
  background-image: url('src/assets/heart.svg');
  background-color: var(--secondary);
  background-size: 18px 18px;
  background-repeat: no-repeat;
  background-position: center;
  display: inline-block;
  border-radius: 10px;
  flex-shrink: 0;
}

.favorites__title {
  font-size: 1.1rem;
  color: var(--title);
  margin: 0;
}

.favorites__count {
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text);
}

.favorites__empty {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0;
}

.favorites__list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 10px;
}

.favorites__item {
  display: grid;
  grid-template-columns: 50px 1fr 24px;
  min-height: 72px;
  align-items: stretch;
  gap: 0.55rem;
  padding: 10px 5px;
  border-bottom: 1px solid var(--border);
}

/* cover area inside favorites */
.favorites__cover-box {
  width: 50px;
  height: 72px;
  display: flex;
  flex-shrink: 0;
}

.favorites__cover,
.favorites__no-cover {
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.favorites__cover {       
  object-fit: cover;
  display: block;
}

/* Placeholder shown when a favorite item has no cover */
.favorites__no-cover {
  background-color: var(--secondary);
  color: var(--text);
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
}

.favorites__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
}

.favorites__book-title,
.favorites__book-author,
.favorites__book-year {
  font-size: 0.7rem;
  color: var(--text);
  margin: 0;
  text-align: left;
}

/* Limit title length so the favorites list stays compact */
.favorites__book-title {
  color: var(--title);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Remove-from-favorites button */
.favorites__button {
  border: none;
  background: transparent;
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.favorites__icon {
  width: 18px;
  height: 18px;
}

.favorites__button:hover {
  transform: scale(1.08);
}

/* ========================================
   Footer
======================================== */
.footer {
  font-size: 0.9rem;
  width: 100%;
  margin: 1.5rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer__link a {
  text-decoration: none;
  cursor: pointer;
  color: var(--green);
  margin-left: 0.2rem;
}

/* ========================================
   Responsive: tablet / small laptop
======================================== */
@media (max-width: 1024px) {
  .header__logo {
    padding: 0 1rem 1rem 1rem;
  }

  .results {
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: start;
  }

  .results__list {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .search {
    flex-wrap: wrap;
    justify-content: center;
  }

  .search__input {
    min-width: 0;
    width: 100%;
    max-width: 480px;
  }

  .search__button,
  .search__clear {
    min-height: 48px;
  }
}

/* ========================================
   Responsive: tablet / large mobile
======================================== */
@media (max-width: 768px) {
  .hero {
    padding: 1.5rem 1rem;
    gap: 16px;
  }

  .hero__title {
    font-size: 1.8rem;
  }

  .hero__text {
    max-width: 100%;
    font-size: 0.95rem;
  }

  .search {
    width: 100%;
    flex-direction: column;
    gap: 12px;
  }

  .search__input,
  .search__button,
  .search__clear {
    width: 100%;
    max-width: 100%;
  }

  .search__button,
  .search__clear {
    min-height: 48px;
  }

  .results {
    grid-template-columns: 1fr;
    gap: 16px;
    justify-items: center;
  }

  .results__list {
    margin-top: 1.5rem;
    max-width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .results__favorites {
    width: 100%;
    max-width: 360px;
    min-height: auto;
    margin: 0 auto;
  }

  .favorites__header-inner {
    padding: 0 1rem 1rem 1rem;
  }
}

/* ========================================
   Responsive: small mobile
======================================== */
@media (max-width: 480px) {
  .header__logo {
    gap: 0.6rem;
  }

  .header__icon {
    width: 36px;
    height: 36px;
    background-size: 20px;
  }

  .header__title {
    font-size: 1.1rem;
    margin-top: 16px;
  }

  .header__subtitle {
    font-size: 0.75rem;
  }

  .hero {
    padding: 1.25rem 1rem;
  }

  .hero__title {
    font-size: 1.55rem;
    line-height: 1.2;
  }

  .hero__text {
    font-size: 0.9rem;
  }

  .results {
    padding: 0 0.75rem;
  }

  .results__list {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .results__card {
    max-width: 100%;
  }

  .results__card img,
  .results__no-cover {
    height: 240px;
  }

  .results__card-content {
    padding: 0.75rem;
  }

  .favorites__item {
    grid-template-columns: 44px 1fr 32px;
    gap: 0.5rem;
    padding: 8px 4px;
    align-items: center;
  }

  .favorites__cover-box {
    width: 44px;
    height: 64px;
  }

  .favorites__title {
    font-size: 1rem;
  }

  .favorites__count {
    font-size: 0.75rem;
  }

  .favorites__book-title,
  .favorites__book-author,
  .favorites__book-year {
    font-size: 0.68rem;
  }

  .favorites__button {
    width: 28px;
    height: 28px;
    padding: 0;
  }

  .favorites__icon {
    width: 28px;
    height: 28px;
  }

  .footer {
    margin: 1rem 0;
    padding-top: 1rem;
    font-size: 0.8rem;
    text-align: center;
  }
}

