/* ========== FONTS ========== */
@font-face {
  font-family: 'Auckland';
  src: url("/resources/fonts/Auckland.otf") format('woff2');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Jacquard12';
  src: url("/resources/fonts/Jacquard12-Regular.woff2") format('woff2');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Fungis';
  src: url("/resources/fonts/FUNGIS-Regular.woff2") format('woff2');
  font-weight: normal;
  font-style: normal;
}

/* ========== VARIABLES ========== */
:root {
  --background-color: #A4A4A4;
  --overlay-color: white;
  --border-color: black;
  --shadow-color: black;
  --text-color: black;
  --link-color: purple;
  --accent-color: pink;
}

/* ========== BASE ========== */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-size: 14px;
}

body {
  font-family: 'Fungis', serif;
  font-size: 14px;
  background-color: #252525;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-color);
  opacity: 0.6;
  pointer-events: none;
  z-index: -1;
}

/* ========== TYPOGRAPHY & LINKS ========== */
a {
  color: var(--text-color);
  text-decoration: underline;
  text-decoration-thickness: 4px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

p {
  line-height: 1.6;
}

pre {
  line-height: 2;
  font-family: inherit;
  text-wrap: wrap;
  tab-size: 10;
  -moz-tab-size: 10;
  -o-tab-size: 10
}

:link,
:visited {
  color: var(--text-color);
}

:link:hover,
:visited:hover,
#handle a:hover,
#story-search:hover,
#list-link:hover {
  color: red;
  text-decoration: underline wavy;
  -webkit-text-decoration: underline wavy;
  text-decoration-thickness: 1.2px;
  cursor: pointer;
}

/* ========== NEWS TICKER ========== */
#news-ticker {
  padding-top: 2.8px;
  margin-bottom: -24.5px;
  width: 100%;
  overflow: visible;
  color: var(--text-color);
  font-family: 'Fungis', serif;
  font-size: 14px;
  white-space: nowrap;
}

.ticker-wrap {
  width: 100%;
  overflow: hidden;
}

.ticker-move {
  display: inline-block;
  padding-left: 100%;
  margin-right: 100%;
  width: fit-content;
  animation: scroll-left 11.5s linear infinite;
}

.ticker-item {
  display: inline-block;
  padding-right: 280px;
  height: 16.8px;
}

.ticker-item>text {
  transform: translate(2px, 1rem);
}

@keyframes scroll-left {
  0% {
    transform: translateX(0%);
  }

  100% {
    transform: translateX(-100%);
  }
}

/* ========== TITLE ========== */
#title {
  text-align: left;
  font-family: 'Auckland', serif;
  font-size: 28px;
  margin: 140px 28px 0;
  color: var(--text-color);
  text-underline-offset: 0.4rem;
  text-decoration-thickness: 4px;
  cursor: pointer;
}

#title:hover {
  color: red;
  text-decoration: underline;
  -webkit-text-decoration: underline;
  text-decoration-thickness: 4px;
}

/* ========== TOOLTIP ========== */
#book-tooltip {
  position: absolute;
  pointer-events: none;
  width: 48px;
  display: none;
  z-index: 999;
}

.tooltip .tooltiptext {
  visibility: hidden;
  display: flex;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  display: flex;
  margin-left: 2px;
}

/* ========== CONTENT BOXES ========== */
.content-box {
  background: var(--background-color);
  border: 2px solid var(--border-color);
  box-shadow: 5px 5px var(--shadow-color);
  padding: 0;
  max-width: 600px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 42px auto;
}

.inner-content-box {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 21px;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border-color);
  box-shadow: 3px 3px var(--shadow-color);
  background: var(--background-color);
}

#welcome_text {
  margin-bottom: 0;
  border: none;
  box-shadow: none;
  padding: 0;
}

#credits {
  padding: 70px;
}

#under-construction {
  margin: auto;
}

#under-construction>img {
  height: auto;
  width: 300px;
  image-rendering: pixelated;
}

#button-wrappers {
  display: flex;
  justify-content: space-between;
}

/* ========== FORMS & INPUTS ========== */
input {
  background-color: var(--background-color);
  border-color: var(--border-color);
  color: var(--text-color);
  font-size: 14px;
}

input::placeholder {
  color: var(--text-color);
  font-size: 14px;
}

#story-search,
#search-input-box>button,
button,
select {
  background-color: var(--background-color);
  border-color: var(--border-color);
  color: var(--text-color);
  font-size: 14px;
}

#signup-link {
  text-decoration-thickness: 1.3px;
}

#signup-link:hover {
  text-underline-offset: 3px;
}

#theme-button {
  position: fixed;
  bottom: 10px;
  right: 12px;
}


textarea {
  background-color: var(--background-color);
  color: var(--text-color);
  border: 2px solid var(--border-color);
}

*::placeholder {
  color: var(--text-color);
  opacity: 50%;
}

/* ========== NAV LINKS ========== */
#list-link {
  color: var(--text-color);
  text-decoration: none;
  font-size: 1.125rem;
}

#search-link-wrapper {
  max-width: 460px;
}
#story-search {
  border: none;
  min-width: 62px;
  max-width: 460px;
  field-sizing: content;
}

#story-search::placeholder {
  opacity: 1;
  font-size: 1.125rem;
  text-align: center;
}
#story-search:focus::placeholder {
  opacity: 50%;
  font-size: 1.125rem;
  text-align: center;
}

#story-search:hover::placeholder,
#list-link:hover {
  color: red;
  text-decoration: underline wavy;
  -webkit-text-decoration: underline wavy;
  text-decoration-thickness: 1.2px;
}

#search-input-box {
  max-width: 567px;
  justify-content: center;
  display: flex;
  align-items: center;;
}

#search-list {
  display: inline;
  height: auto;
}

#story-list,
#table-of-contents {
  display: inline;
  height: auto;
}

#search-link-wrapper,
#sort-by-wrapper,
#list-link-wrapper,
.chapter-button-wrapper {
  justify-content: center;
  align-items: center;
  width: fit-content;
  display: flex;
}

/* ========== HANDLE SECTION ========== */
#handle {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px 0;
  width: 100%
}

#login-link {
  position: absolute;
  right: 30px
}

.handle-gif {
  width: 48px;
  height: auto;
  image-rendering: pixelated;
  position: relative;
  left: 1px;
}

/* ========== STORY & CHAPTERS ========== */
.story-wrapper {
  display: block;
}

.story-content p {
  text-indent: 10px;
}

.story,
.table-of-contents,
.chapter,
#new-chapter-form,
#loading-text {
  display: flex;
  max-width: 567px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.story button {
  position: relative;
  top: 10px;
  font-size: 14px;
}

@media screen and (max-width: 670px) {

  .story,
  .table-of-contents,
  .chapter,
  #new-chapter-form,
  #loading-text,
  #search-input-box {
    width: min(567px, 85vw);
  }
}

@media screen and (max-width: 490px) {

  .story,
  .table-of-contents,
  .chapter,
  #new-chapter-form,
  #loading-text,
  #search-input-box {
    width: min(85vw, 83vw);
  }
}

.story-data {
  position: relative;
  display: flex;
  flex-direction: column;
  top: 3px;
  gap: 0.2rem;
}

.chapter {
  display: flex;
  height: 30px;
}

.story .author-text,
.story .genres-text {
  position: relative;
  margin: unset;
  text-wrap: nowrap;
  width: 0px;
}

.story a {
  text-decoration-thickness: 1.3px;
}

.story a:hover {
  text-decoration-thickness: 1.2px;
}

.chapter-link {
  text-decoration-thickness: 1.4px;
}

.likes {
  cursor: pointer;
}

.likes:hover {
  transform: scale(1.1);
  opacity: 1;
  /* If you're dimming it normally */
}

.likes g {
  transition: transform 0.2s ease;
}

.likes:hover g {
  transform: scale(1.2) rotate(-5deg);
}

.likes:active {
  transform: scale(1.2);
  transition: transform 0.2s ease;
  color: var(--accent-color, red) !important;
}

.likes:active g {
  fill: var(--accent-color, red) !important;
  stroke: var(--accent-color, red) !important;
}

#table-of-contents>h3 {
  margin-bottom: 10px;
}

#table-of-contents-button {
  position: relative;
  top: 1.69px;
}

.chapters-wrapper-top,
.chapters-wrapper-bottom {
  display: flex;
  justify-content: space-between;
  position: relative;
  right: 4px;
}

.next-chapter,
.previous-chapter,
#table-of-contents-button {
  font-size: 1.2rem;
  text-decoration-thickness: auto;
}

/* ========== DESCRIPTION ========== */
.description {
  margin: auto;
  width: 420px;
  display: block;
}

.description-text {
  margin-left: 14px;
  margin-right: 14px;
}

/* ========== GENRE SECTION ========== */
.genre-section {
  max-width: 1200px;
  margin-left: 0.0rem;
  margin-top: 2rem;
  align-self: flex-start;
}

.genre-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 1rem;
  margin-left: 0;
  cursor: pointer;
  width: fit-content;
  border-radius: 5px;

  transition: transform 0.3s ease;
  /* GPU-powered smoothness, no lag */
}

.genre-title:hover {
  transform: scale(1.05);
  /* Slight grow, like your ego trying to get noticed */
}


/* By default: horizontal scroll, no wrapping */
.story-row {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: hidden;
  margin-bottom: 1rem;
  gap: 1rem;
  padding-bottom: 0.5rem;
  padding-left: 0.5rem;
  margin-right: 0rem;
  scroll-snap-type: x mandatory;
}

/* STORY CARD (Default) */
.story-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 225px;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
  cursor: pointer;
  scroll-snap-align: start;

}

.story-card:hover {
  transform: scale(1.05);
  /*box-shadow: 0 4px 14px rgba(255, 255, 255, 0.12); will readd later to reflect dark mode... */
}

/* Press effect */
.story-card:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
}

.cover-placeholder {
  width: 225px;
  height: 327px;
  background-color: var(--border-color);
  border-radius: 3px;

}

.story-title {
  font-size: 0.95rem;
  color: #444;
  max-width: 100%;
  text-align: center;
  word-wrap: break-word;
}

/* SCROLLBAR STYLE */
.story-row::-webkit-scrollbar {
  height: 8px;
}

.story-row::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* =================== RESPONSIVENESS =================== */

/* Show max 8 by default (on big screens) */
@media (max-width: 3000px) {
  .story-card:nth-child(n+6) {
    display: none;
  }
}

@media (max-width: 1268px) {
  .story-card:nth-child(n+5) {
    display: none;
  }
}

@media (max-width: 1000px) {
  .story-card:nth-child(n+4) {
    display: none;
  }
}

@media (max-width: 820px) {
  .story-card:nth-child(n+3) {
    display: none;
  }
}

@media (max-width: 500px) {
  .story-card:nth-child(n+3) {
    display: none;
  }
}

@media (max-width: 320px) {
  .story-card:nth-child(n+2) {
    display: none;
  }
}

/* =================== GENRE FOCUS MODE =================== */

/* If user focuses on a single genre, turn into a grid */
.genre-section.grid-mode .story-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  overflow-x: hidden;
  margin-bottom: 1rem;
  gap: 1rem;
  padding-bottom: 0.5rem;
  padding-left: 0.5rem;
  margin-right: 0rem;
  scroll-snap-type: x mandatory;
  align-self: center;
}

.genre-section.grid-mode .genre-title {
  cursor: pointer;
  user-select: none;

  text-align: center;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
}


/* Reset hidden overflow in grid mode */
.genre-section.grid-mode .story-card {
  display: flex !important;
}

.story-title {
  font-size: 0.95rem;
  color: #444;
  width: 94%;
  text-align: center;
  word-wrap: break-word;

  background-color: var(--background-color);
  padding: 0.3rem 0.5rem;
  border-radius: 0 0 8px 8px;
  /* Only bottom corners rounded */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);

  margin-top: -0.3rem;
  /* Pulls it upward to touch the cover */
  margin-bottom: 0.5rem;
}

.story-views {
  display: flex;
  align-items: center;
  justify-content: left;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-color);
  opacity: 0.8;
  margin-top: 0.3rem;
}

.stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.story-views {
  display: flex;
  border-radius: 8rem;
  justify-content: left;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-color);
  opacity: 0.8;
  margin-top: 0.3rem;
}

.story-likes {
  display: flex;
  justify-content: right;
  align-items: center;
  border-radius: 16rem;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-color);
  opacity: 0.8;
}

.story-likes:hover {
  transform: scale(1.1);
  opacity: 1;
  /* If you're dimming it normally */
}

.story-likes svg {
  transition: transform 0.2s ease;
}

.story-likes:hover svg {
  transform: scale(1.2) rotate(-5deg);
  fill: var(--accent-color, hotpink);
  /* optional, for hover color effect */
}



.story-likes.liked {
  transform: scale(1.2);
  transition: transform 0.2s ease;
}