/* ==========================================================================
   CWT Booklist - Design System & Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Colors - Greys */
  --white: hsl(0, 0%, 100%);
  --grey-100: hsl(0, 0%, 96%);
  --grey-200: hsl(0, 0%, 88%);
  --grey-400: hsl(0, 0%, 62%);
  --grey-700: hsl(0, 0%, 26%);
  --grey-900: hsl(0, 0%, 7%);

  /* Colors - Accent */
  --accent-green-light: hsl(108, 63%, 67%);
  --accent-green: hsl(171, 100%, 29%);
  --accent-green-muted: hsl(171, 60%, 50%);
  --accent-blue-light: hsl(200, 76%, 60%);
  --accent-blue: hsl(215, 66%, 40%);

  /* Colors - Reserved (use sparingly) */
  --pink: hsl(352, 40%, 49%);
  --blue: hsl(220, 66%, 40%);

  /* Typography - Fonts */
  --font-display: 'Michroma', 'Inter', sans-serif;
  --font-body: 'Courier', 'Inter', monospace;
  --font-landing: 'Shadows Into Light', 'Inter', cursive;

  /* Typography - Sizes (comprehensive scale) */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */
  --text-5xl: 3rem;        /* 48px */
  --text-6xl: 3.75rem;     /* 60px */
  --text-7xl: 4.5rem;      /* 72px */
  --text-8xl: 6rem;        /* 96px */
  --text-9xl: 8rem;        /* 128px */
  --text-10xl: 10rem;      /* 160px */
  --text-11xl: 12rem;      /* 192px */

  /* Typography - Weights */
  --font-regular: 400;     /* Body text, default */
  --font-medium: 500;      /* Subtle emphasis: labels, interactive */
  --font-bold: 700;        /* Strong emphasis: headings, important */

  /* Spacing (comprehensive scale) */
  --space-xs: 0.25rem;     /* 4px */
  --space-sm: 0.5rem;      /* 8px */
  --space-md: 0.75rem;     /* 12px */
  --space-base: 1rem;      /* 16px */
  --space-lg: 1.5rem;      /* 24px */
  --space-xl: 2rem;        /* 32px */
  --space-2xl: 3rem;       /* 48px */
  --space-3xl: 4rem;       /* 64px */
  --space-4xl: 5rem;       /* 80px */
  --space-5xl: 6rem;       /* 96px */
  --space-6xl: 8rem;       /* 128px */
  --space-7xl: 10rem;      /* 160px */
  --space-8xl: 12rem;      /* 192px */

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-full: 9999px;

  /* Search Input */
  --search-input-letter-spacing: -0.035em;

  /* Layout - Vertical Line */
  --line-position: 16px;
  --line-width: 2px;
  --line-gap: 16px;
  --content-inset: calc(var(--line-position) + var(--line-width) + var(--line-gap));

  /* Book Stack Scale */
  --book-scale: 1.75;  /* 1 = 200px base, 1.75 = 350px */
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: var(--font-regular);
  color: var(--grey-700);
  background: var(--white);
  line-height: 1.5;
  letter-spacing: -0.03em;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: var(--line-position);
  width: var(--line-width);
  height: 100vh;
  background: var(--accent-green);
  z-index: -1;
}

a {
  color: var(--accent-green);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--grey-900);
  letter-spacing: -0.03em;
  font-weight: var(--font-regular);
  line-height: 1.2;
}

h1 {
  font-size: var(--text-2xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-base);
}

.text-secondary {
  color: var(--grey-400);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0;
  padding: 0 var(--content-inset);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.header {
  padding: var(--space-md) 0;
  text-align: center;
}

.header .container {
  max-width: none;
  padding: 0 var(--space-lg);
}

.header__logo {
  font-family: var(--font-landing);
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--accent-green);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  text-decoration: none;
}

.header__logo:hover {
  text-decoration: none;
  color: var(--accent-green-light);
}

/* --------------------------------------------------------------------------
   Search Section
   -------------------------------------------------------------------------- */
.search-section {
  padding: var(--space-xl) 0 var(--space-lg);
}

.search-section .container {
  max-width: 480px;
}

.search-section__title {
  font-family: var(--font-landing);
  font-size: var(--text-7xl);
  font-weight: var(--font-bold);
  text-transform: none;
  letter-spacing: 0.09em;
  line-height: 1.1;
  color: var(--grey-900);
  margin-bottom: var(--space-base);
}

.search-section__subtitle {
  font-family: var(--font-landing);
  font-size: var(--text-2xl);
  font-weight: var(--font-regular);
  color: var(--grey-900);
  letter-spacing: 0.09em;
  line-height: 1;
  margin-bottom: var(--space-base);
}

.search-section__subtitle a {
  color: inherit;
  text-decoration: none;
}

.search-section__subtitle a:hover {
  text-decoration: underline;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.search-field {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-base);
}

.search-field__label {
  font-family: var(--font-landing);
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--grey-700);
  letter-spacing: 0.09em;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.search-field__input {
  flex: 1;
  min-width: 120px;
  padding: 0;
  margin-bottom: -1px;
  font-family: var(--font-body);
  font-weight: var(--font-medium);
  font-size: var(--text-3xl);
  line-height: 1.5;
  letter-spacing: var(--search-input-letter-spacing);
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--grey-900);
  caret-color: transparent;
  transition: border-color 0.15s, opacity 0.15s;
}

.search-field__input:focus {
  outline: none;
  background: transparent;
  border-color: var(--grey-700);
}

/* Custom cursor for input fields */
.search-field__cursor {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-3xl);
  width: 0.5em;
  height: 1.2em;
  background: var(--grey-900);
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
}

.search-field__cursor--visible {
  opacity: 1;
  animation: cursor-blink 1s step-end infinite;
}

.search-field__input::placeholder {
  color: var(--grey-400);
}

/* Animated placeholder text */
.search-field__placeholder {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--grey-400);
  font-family: var(--font-body);
  font-weight: var(--font-medium);
  font-size: var(--text-3xl);
  line-height: 1.5;
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: var(--search-input-letter-spacing);
  transition: transform 0.1s ease-out;
}

/* Wrapper for input + dropdown (needed for dropdown positioning) */
.search-field__input-wrapper {
  flex: 1;
  min-width: 150px;
  position: relative;
  line-height: 1.5;
  overflow-x: clip;
  overflow-y: visible;
  border-bottom: 1px solid var(--grey-400);
  margin-bottom: -1px;
  transition: border-color 0.15s;
}

.search-field__input-wrapper:focus-within {
  border-color: var(--grey-700);
}

/* When inside wrapper, input fills the wrapper */
.search-field__input-wrapper .search-field__input {
  flex: none;
  width: 100%;
}

/* Dropdown styles */
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
  margin-top: var(--space-xs);
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  list-style: none;
  display: none;
}

.dropdown--open {
  display: block;
}

.dropdown__item {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--grey-700);
}

.dropdown__item:hover,
.dropdown__item--selected {
  background: var(--grey-100);
}

.dropdown__empty {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  color: var(--grey-400);
  font-style: italic;
}

.search-field--inactive .search-field__label,
.search-field--inactive .search-field__input {
  opacity: 0.15;
}

/* --------------------------------------------------------------------------
   Book Stacks (Landing Page)
   -------------------------------------------------------------------------- */
.book-stacks {
  padding: var(--space-xl) 0;
}

.book-stacks .container {
  max-width: none;
  padding: 0 var(--content-inset);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book-stack {
  position: relative;
  width: fit-content;
  margin-bottom: var(--space-xl);
}

.book-stack__image {
  width: calc(200px * var(--book-scale));
  height: auto;
}

.book-stack__note {
  position: absolute;
  top: 0;
  left: 5%;
  width: calc(170px * var(--book-scale));
  height: auto;
  transition: transform 0.1s ease;
  transform-origin: center;
}

.book-stack__note:hover {
  transform: scale(1.2);
}

.book-stack--alt .book-stack__note {
  left: 5%;
}

.book-stack__note-image {
  width: 100%;
  height: auto;
  display: block;
}

.book-stack__link {
  position: absolute;
  top: 26%;
  left: 12%;
  width: 70%;
  text-align: center;
  font-family: var(--font-landing);
  font-size: calc(1.5rem * var(--book-scale));
  font-weight: 800;
  letter-spacing: calc(0.1rem * var(--book-scale));
  color: var(--accent-green);
  text-decoration: none;
  line-height: 1.2;
  transform: rotate(-19deg);
}

.book-stack__link:hover {
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Desk (Landing Page - Large Viewport)
   -------------------------------------------------------------------------- */
.desk-section {
  display: none;
  padding: var(--space-xl) 0;
}

.desk {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.desk__image {
  width: 100%;
  height: auto;
  display: block;
}

.desk__note {
  position: absolute;
  transition: transform 0.1s ease;
  transform-origin: center;
}

.desk__note:hover {
  transform: scale(1.2);
}

.desk__note-image {
  width: 100%;
  height: auto;
  display: block;
}

.desk__note--left {
  top: 30%;
  left: 15%;
  width: 18%;
}

.desk__note--right {
  top: 15%;
  left: 60.5%;
  width: 18%;
}

.desk__note-link {
  position: absolute;
  top: 26%;
  left: 10%;
  width: 70%;
  text-align: center;
  font-family: var(--font-landing);
  font-weight: 800;
  font-size: calc((100vw - 2 * var(--content-inset)) * 0.18 * 0.13);
  letter-spacing: 0.15rem;
  color: var(--accent-green);
  text-decoration: none;
  line-height: 1.2;
  transform: rotate(-20deg);
}

.desk__note--right .desk__note-link {
  left: 11%;
  font-size: calc((100vw - 2 * var(--content-inset)) * 0.18 * 0.135);
}

.desk__note-link:hover {
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Book List Page
   -------------------------------------------------------------------------- */
.list-header {
  padding: var(--space-lg) 0;
}

.list-header__title {
  font-family: var(--font-landing);
  font-size: var(--text-4xl);
  letter-spacing: 0.09em;
  margin-bottom: var(--space-xs);
}

.list-header__count {
  font-size: var(--text-sm);
  color: var(--grey-400);
}

.book-list {
  padding-bottom: var(--space-2xl);
}

/* --------------------------------------------------------------------------
   Book Card
   -------------------------------------------------------------------------- */
.book-card {
  display: block;
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--grey-200);
  text-decoration: none;
  transition: background-color 0.2s;
}

.book-card:hover {
  text-decoration: none;
  background: var(--grey-100);
  margin: 0 calc(-1 * var(--space-base));
  padding-left: var(--space-base);
  padding-right: var(--space-base);
}

.book-card__title {
  font-family: var(--font-body);
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  color: var(--grey-900);
  margin-bottom: var(--space-sm);
  text-transform: none;
  letter-spacing: -0.03em;
}

.book-card__quote {
  font-size: var(--text-base);
  color: var(--grey-700);
  margin-bottom: var(--space-sm);
  font-style: italic;
}

.book-card__speaker {
  font-size: var(--text-sm);
  color: var(--grey-400);
  margin-bottom: var(--space-md);
}

.book-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Tags / Pills
   -------------------------------------------------------------------------- */
.tag {
  display: inline-block;
  font-size: var(--text-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--grey-100);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-full);
  color: var(--grey-700);
}

.tag--accent {
  background: var(--accent-green-light);
  border-color: var(--accent-green-light);
  color: var(--accent-green);
}

/* --------------------------------------------------------------------------
   Book Detail Page
   -------------------------------------------------------------------------- */
.back-link {
  display: inline-block;
  width: 16px;
  height: 16px;
  padding: var(--space-lg) 0;
  box-sizing: content-box;
}

.back-link::before {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  border-left: 3px solid var(--grey-400);
  border-bottom: 3px solid var(--grey-400);
  transform: rotate(45deg);
  transition: border-color 0.2s;
}

.back-link:hover::before {
  border-color: var(--accent-green);
}

.book-detail {
  padding-bottom: var(--space-2xl);
}

.book-detail__header {
  margin-bottom: var(--space-xl);
}

.book-detail__title {
  font-family: var(--font-body);
  font-weight: var(--font-bold);
  font-size: var(--text-3xl);
  color: var(--grey-900);
  margin-bottom: var(--space-sm);
  /* letter-spacing: 0.09em; */
}

.book-detail__amazon-link {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--accent-green);
  text-decoration: none;
  margin-bottom: var(--space-base);
}

.book-detail__amazon-link:hover {
  text-decoration: underline;
  color: var(--grey-700);
}

.book-detail__author {
  font-size: var(--text-lg);
  color: var(--grey-400);
  margin-bottom: var(--space-base);
}

.book-detail__description {
  font-size: var(--text-base);
  color: var(--grey-700);
  line-height: 1.6;
  margin-bottom: var(--space-lg);
}

.book-detail__link {
  display: inline-block;
  font-size: var(--text-base);
}

.book-detail__section {
  margin-top: var(--space-xl);
}

.book-detail__section-title {
  font-size: var(--text-lg);
  color: var(--grey-700);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-base);
}

.book-detail__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Episode Mentions
   -------------------------------------------------------------------------- */
.mention-card {
  background: var(--grey-100);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-base);
}

.mention-card__episode {
  font-size: var(--text-sm);
  color: var(--grey-400);
  margin-bottom: var(--space-sm);
}

.mention-card__quote {
  font-size: var(--text-base);
  color: var(--grey-700);
  font-style: italic;
  margin-bottom: var(--space-sm);
  line-height: 1.6;
}

.mention-card__speaker {
  font-size: var(--text-sm);
  color: var(--grey-400);
  margin-bottom: var(--space-md);
}

.mention-card__link {
  font-size: var(--text-sm);
}

/* Report a Problem Link */
.book-detail__report {
  margin-top: var(--space-xl);
}

.book-detail__report-link {
  font-size: var(--text-sm);
  color: var(--grey-400);
  text-decoration: none;
}

.book-detail__report-link:hover {
  color: var(--accent-green);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer {
  padding: var(--space-lg) 0;
  text-align: center;
}

.footer .container {
  max-width: none;
  padding: 0 var(--space-lg);
}

.footer__text {
  font-size: var(--text-base);
  color: var(--grey-400);
}

.footer__text a {
  color: var(--grey-400);
  text-decoration: none;
}

.footer__text a:hover {
  color: var(--grey-700);
  text-decoration: underline;
}

.footer__separator {
  margin: 0 var(--space-sm);
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Medium Viewport (768px - 1023px)
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  :root {
    --line-position: 5rem;      /* 80px */
    --line-gap: 5rem;           /* 80px */
  }

  .container {
    max-width: 800px;
  }

  .search-section .container {
    max-width: 800px;
  }

  .header__logo {
    font-size: var(--text-2xl);
  }

  .search-section__title {
    font-size: var(--text-9xl);
    margin-bottom: var(--space-lg);
  }

  .search-section__subtitle {
    font-size: var(--text-3xl);
    line-height: 1.1;
    margin-bottom: var(--space-base);
  }

  .search-field__label {
    font-size: var(--text-4xl);
  }

  .search-field__input {
    font-size: var(--text-4xl);
  }

  .search-field__placeholder {
    font-size: var(--text-4xl);
  }

  .search-field__cursor {
    font-size: var(--text-4xl);
  }

  .search-field__input-wrapper {
    min-width: 200px;
  }

  .search-field {
    gap: var(--space-lg);
  }

  /* List/Detail page titles */
  .list-header__title {
    font-size: var(--text-5xl);
  }

  .book-detail__title {
    font-size: var(--text-5xl);
  }

  /* Show desk, hide book stacks at medium viewport */
  .book-stacks {
    display: none;
  }

  .desk-section {
    display: block;
    padding-top: var(--space-base);
  }

  .desk-section .container {
    max-width: none;
    padding: 0 var(--content-inset);
  }

  .desk {
    max-width: none;
  }
}

/* --------------------------------------------------------------------------
   Large Viewport (1024px - 1439px)
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  :root {
    --line-position: 7rem;      /* 112px - interpolated */
    --line-gap: 7rem;           /* 112px - interpolated */
  }

  .container {
    max-width: 1200px;
  }

  .search-section .container {
    max-width: 1200px;
  }

  .header__logo {
    font-size: var(--text-2xl);
  }

  .search-section__title {
    font-size: var(--text-9xl);
    margin-bottom: var(--space-lg);
  }

  .search-section__subtitle {
    font-size: var(--text-4xl);
    line-height: 1.1;
    margin-bottom: var(--space-base);
  }

  .search-field__label {
    font-size: var(--text-5xl);
  }

  .search-field__input {
    font-size: var(--text-5xl);
  }

  .search-field__placeholder {
    font-size: var(--text-5xl);
  }

  .search-field__cursor {
    font-size: var(--text-5xl);
  }

  .search-field__input-wrapper {
    min-width: 240px;
  }

  .search-field {
    gap: var(--space-xl);
  }

  /* List/Detail page titles */
  .list-header__title {
    font-size: var(--text-6xl);
  }

  .book-detail__title {
    font-size: var(--text-6xl);
  }
}

/* --------------------------------------------------------------------------
   XL Viewport (1440px+)
   -------------------------------------------------------------------------- */
@media (min-width: 1440px) {
  :root {
    --line-position: 10rem;     /* 160px */
    --line-gap: 10rem;          /* 160px */
  }

  .container {
    max-width: 1400px;
  }

  .search-section .container {
    max-width: 1400px;
  }

  .header__logo {
    font-size: var(--text-3xl);
  }

  .search-section__title {
    font-size: var(--text-10xl);
    margin-bottom: var(--space-xl);
  }

  .search-section__subtitle {
    font-size: var(--text-4xl);
    line-height: 1.1;
    margin-bottom: var(--space-lg);
  }

  .search-field__label {
    font-size: var(--text-5xl);
  }

  .search-field__input {
    font-size: var(--text-5xl);
  }

  .search-field__placeholder {
    font-size: var(--text-5xl);
  }

  .search-field__cursor {
    font-size: var(--text-5xl);
  }

  .search-field__input-wrapper {
    min-width: 280px;
  }

  .search-field {
    gap: var(--space-xl);
  }

  /* List/Detail page titles */
  .list-header__title {
    font-size: var(--text-7xl);
  }

  .book-detail__title {
    font-size: var(--text-7xl);
  }
}
