/* Base Layout and Typography Stylesheet
   - Core HTML/body styling and background
   - Typography and general layout
   - Search form container styling
   - Error/progress messaging
   - Mobile responsive base layout
*/

/* Core HTML/Body styling */
html {
  background-color: #000;
  min-height: 100vh;
  height: 100%;
}

body {
  font-family: Helvetica, Arial, sans-serif;
  background: #000 url('../assets/images/background.jpg') no-repeat center center fixed;
  background-size: cover;
  margin: 0;
  padding: 0;
  color: #fff;
  min-height: 100vh;
  position: relative;
  overflow: auto !important;
  /* Temporarily comment out transparent background to debug */
  /* background: transparent !important; */
}

/* iOS Safari workaround for fixed wallpaper */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  width: 100vw;
  height: 100vh;
  background: #000 url('../assets/images/background.jpg') no-repeat center center;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  pointer-events: none;
}

@supports (-webkit-touch-callout: none) {
  body {
    overflow: auto !important;
    background: transparent !important;
  }
  body::before {
    position: fixed !important;
    width: 100vw !important;
    height: 100vh !important;
    background-attachment: scroll !important;
    will-change: transform;
  }
}

/* Title Styling */
#title {
  margin-bottom: 0.5em;
  font-size: 1.7em;
}

/* Clear Button Styling */
#clearBtn {
  position: absolute;
  right: 0.3em;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.7) !important;
  color: #8d8f90d6 !important;
  text-shadow: 0 2px 6px #7a8a99, 0 0px 2px #dbe6ee;
  font-size: 1.15em;
  font-weight: bold !important;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  transition: background 0.4s, color 0.4s, border 0.4s;
  box-shadow: 0 2px 8px 0 rgba(31,38,135,0.13), 0 0 0 1px rgba(255,255,255,0.08);
  width: 2em;
  height: 2em;
  min-width: 2em;
  min-height: 2em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
  backdrop-filter: blur(38px) saturate(180%) brightness(1.18);
  -webkit-backdrop-filter: blur(38px) saturate(180%) brightness(1.18);
}

/* Results Container */
#results {
  margin: 3em;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

/* Result Cards Base Styling */
.result {
  flex-basis: 11%;
  box-sizing: border-box;
  padding: 0.6em 0.4em 0.3em 0.4em;
  margin: 0.4em;
  min-width: 160px;
  max-width: 240px;
  overflow: hidden;
  border-radius: 0.3em;
  background: rgba(255,255,255,0.15);
  border-radius: 1em;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: none;
  transform: translateY(-12px) scale(1.04);
  transition: box-shadow 0.3s, transform 0.3s;
  cursor: pointer;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  backdrop-filter: blur(16px) saturate(180%) brightness(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(180%) brightness(1.1);
  overflow: hidden;
  border-top: 1px solid rgba(255,255,255,0.3);
  border-left: 1px solid rgba(255,255,255,0.3);
  border-right: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.result.selected {
  box-shadow:
    0 0 0 4px rgba(255,255,255,0.08),
    0 4px 16px 0 rgba(31,38,135,0.28),
    0 -4px 16px 0 rgba(255,0,128,0.12),
    4px 0 16px 0 rgba(0,255,255,0.12),
    0 4px 16px 0 rgba(255,255,0,0.12),
    -4px 0 16px 0 rgba(0,255,128,0.12),
    4px 4px 24px 0 rgba(128,0,255,0.12),
    -4px -4px 24px 0 rgba(255,128,0,0.12);
  z-index: 2;
}

.result:hover {
  box-shadow:
    0 0 0 4px rgba(255,255,255,0.18),
    0 4px 16px 0 rgba(31,38,135,0.28),
    0 -4px 16px 0 rgba(255,0,128,0.12),
    4px 0 16px 0 rgba(0,255,255,0.12),
    0 4px 16px 0 rgba(255,255,0,0.12),
    -4px 0 16px 0 rgba(0,255,128,0.12),
    4px 4px 24px 0 rgba(128,0,255,0.12),
    -4px -4px 24px 0 rgba(255,128,0,0.12);
  transform: translateY(-4px) scale(1.03);
  z-index: 2;
}

/* Result Card Content */
.result h2 {
  font-size: 0.85em;
  color: #fff;
  text-align: center;
  margin-top: 0.5em;
  margin-bottom: 0.3em;
  font-weight: bold;
}

.result h2 a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
  text-shadow:
    1.5px 1.5px 0px rgba(0,0,0,0.68),
    2px 2px 1px rgba(0,0,0,0.32);
}

.result h2 a:hover {
  color: #e9f8ffdb;
  text-shadow:
    1.5px 1.5px 0px rgba(0,0,0,0.78),
    2px 2px 1px rgba(0,0,0,0.38);
}

.result .artwork {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
}

.result .artwork img {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f0f0f0;
}

.result .links {
  position: static;
  margin-top: 4px;
  text-align: center;
  font-size: 0.6em;
  visibility: visible;
  margin-bottom: 0.1em;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.2em;
}

/* Error and Progress Messages */
#error, #progress {
  text-align: center;
  flex-basis: 100%;
  font-size: 24pt;
  font-weight: bold;
}

#error {
  color: #fff;
}

#progress {
  color: #ddd;
}

/* Basic button styling for cards - fallback only, specific colors defined in buttons.css */
.result .links a {
  background: rgba(255,255,255,0.16) !important;
  color: #fff !important;
  border-radius: 0.5em !important;
  border: 2px solid rgba(255,255,255,0.38) !important;
}

.result .links a:nth-child(1):hover {
  background: rgba(78,220,120,0.45) !important;
  color: #fff !important;
}
.result .links a:nth-child(2):hover {
  background: rgba(255,230,80,0.45) !important;
  color: #fff !important;
}
.result .links a:nth-child(3):hover {
  background: rgba(80,170,255,0.45) !important;
  color: #fff !important;
}
.result .links a:nth-child(4):hover {
  background: rgba(255,80,80,0.45) !important;
  color: #fff !important;
}
.result.audiobook .links a:nth-child(1):hover {
  background: rgba(78,220,120,0.45) !important;
  color: #fff !important;
}
.result.audiobook .links a:nth-child(2):hover {
  background: rgba(255,230,80,0.45) !important;
  color: #fff !important;
}
.result.ebook .links a:nth-child(1):hover {
  background: rgba(80,170,255,0.45) !important;
  color: #fff !important;
}
.result.ebook .links a:nth-child(2):hover {
  background: rgba(255,80,80,0.45) !important;
  color: #fff !important;
}

/* Button text styling */
.result .links a span {
  position: relative;
  z-index: 2;
  color: inherit !important;
  font-weight: inherit !important;
  font-size: inherit !important;
  text-shadow:
    1px 1.5px 1px rgba(34,34,34,0.65),
    1.5px 2px 1px rgba(68,68,68,0.38);
}

/* Ultra-wide screens (2000px+) - larger cards for better visibility */
@media (min-width: 2000px) {
  .result {
    flex-basis: 13%;
    min-width: 180px;
    max-width: 280px;
  }
  .result h2 {
    font-size: 1.1em;
  }
  .result .links {
    font-size: 0.75em;
    gap: 0.4em;
  }
  .result .links a {
    padding: 0.5em 0.9em;
    font-size: 1.05em;
  }
}

/* Very large screens (1600px-2000px) - medium-large cards */
@media (min-width: 1600px) and (max-width: 1999px) {
  .result {
    flex-basis: 12%;
    min-width: 170px;
    max-width: 260px;
  }
  .result h2 {
    font-size: 1.0em;
  }
  .result .links {
    font-size: 0.7em;
    gap: 0.35em;
  }
  .result .links a {
    padding: 0.48em 0.85em;
    font-size: 1.0em;
  }
}

@media (min-width: 1181px) and (max-width: 1400px) {
  body {
    background-attachment: fixed;
    min-height: 100vh;
    overflow: auto;
  }
  .result {
    flex-basis: 15%;
    max-width: 220px;
  }
  .result h2 {
    font-size: 0.9em;
  }
  .result .links {
    font-size: 0.65em;
    gap: 0.3em;
  }
  .result .links a {
    padding: 0.45em 0.8em;
    font-size: 0.95em;
  }
}


/* iPad Air landscape and larger tablets */
@media (min-width: 1025px) and (max-width: 1180px) {
  body {
    background-attachment: fixed;
    min-height: 100vh;
    overflow: auto;
  }
  #results {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.8em;
  }
  .result {
    flex-basis: 18%;
    margin: 0.6em;
    padding: 0.6em 0.4em 0.3em 0.4em;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 160px;
    max-width: 200px;
  }
}

/* iPad Mini landscape and medium tablets */
@media (min-width: 821px) and (max-width: 1024px) {
  body {
    background-attachment: fixed;
    min-height: 100vh;
    overflow: auto;
  }
  #results {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.7em;
  }
  .result {
    flex-basis: 22%;
    margin: 0.7em;
    padding: 0.6em 0.4em 0.3em 0.4em;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 170px;
    max-width: 210px;
  }
}

/* iPad Air portrait and small tablets */
@media (min-width: 769px) and (max-width: 820px) {
  body {
    background-attachment: fixed;
    min-height: 100vh;
    overflow: auto;
  }
  #results {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6em;
  }
  .result {
    flex-basis: 28%;
    margin: 0.6em;
    padding: 0.6em 0.4em 0.3em 0.4em;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 180px;
    max-width: 220px;
  }
}

/* iPad Mini portrait */
@media (min-width: 601px) and (max-width: 768px) {
  body {
    background-attachment: fixed;
    min-height: 100vh;
    overflow: auto;
  }
  #results {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5em;
  }
  .result {
    flex-basis: 32%;
    margin: 0.5em;
    padding: 0.6em 0.4em 0.3em 0.4em;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 160px;
    max-width: 200px;
  }
  .result h2 {
    font-size: 0.82em;
  }
  .result .links {
    font-size: 0.56em;
    gap: 0.2em;
  }
  .result .links a {
    padding: 0.34em 0.58em;
    font-size: 0.84em;
    max-width: 23.5%;
  }
}
  .result .artwork {
    width: 100%;
    padding-bottom: 100%;
    position: relative;
  }
  .result .artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
  }
  .result .links {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 0.5em;
    margin-top: 8px;
    margin-bottom: 0.1em;
    font-size: 8pt;
    position: static;
    visibility: visible;
  }
  .result .links a {
    flex: 0 0 auto;
    padding: 0.45em 0.8em;
    font-size: 0.95em;
    white-space: nowrap;
  }
  .result h2 {
    font-size: 0.95em;
  }

/* iPad Air landscape font sizing */
@media (min-width: 1025px) and (max-width: 1180px) {
  .result h2 {
    font-size: 0.9em;
  }
  .result .links {
    font-size: 0.62em;
    gap: 0.3em;
  }
  .result .links a {
    padding: 0.4em 0.7em;
    font-size: 0.9em;
    max-width: 23%;
  }
}

/* iPad Mini landscape font sizing */
@media (min-width: 821px) and (max-width: 1024px) {
  .result h2 {
    font-size: 0.88em;
  }
  .result .links {
    font-size: 0.6em;
    gap: 0.25em;
  }
  .result .links a {
    padding: 0.38em 0.65em;
    font-size: 0.88em;
    max-width: 23%;
  }
}

/* iPad Air portrait font sizing */
@media (min-width: 769px) and (max-width: 820px) {
  .result h2 {
    font-size: 0.85em;
  }
  .result .links {
    font-size: 0.58em;
    gap: 0.22em;
  }
  .result .links a {
    padding: 0.36em 0.6em;
    font-size: 0.86em;
    max-width: 23%;
  }
}

/* iPad Mini portrait font sizing */
@media (min-width: 601px) and (max-width: 768px) {
  .result h2 {
    font-size: 0.82em;
  }
  .result .links {
    font-size: 0.56em;
    gap: 0.2em;
  }
  .result .links a {
    padding: 0.34em 0.58em;
    font-size: 0.84em;
    max-width: 23.5%;
  }
}