/* ============================================================
   Bookshelf Service — style.css
   Aesthetic: warm editorial, like a well-loved independent bookshop
   Fonts: Playfair Display (display) + Lora (body)
   ============================================================ */

/* ── Custom properties ──────────────────────────────────────── */
:root {
  --cream:      #f5f0e8;
  --cream-dark: #ede7d8;
  --ink:        #1a1612;
  --ink-mid:    #3d3530;
  --ink-light:  #6b5f57;
  --rust:       #b34a2a;
  --rust-light: #d9694a;
  --rust-pale:  #f5e0d9;
  --gold:       #c8922a;
  --gold-pale:  #faf0dc;
  --sage:       #4a6741;
  --sage-pale:  #e2ede1;
  --border:     rgba(26,22,18,.12);
  --shadow-sm:  0 2px 8px rgba(26,22,18,.08);
  --shadow-md:  0 6px 24px rgba(26,22,18,.12);
  --radius:     8px;
  --radius-lg:  14px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Lora', Georgia, serif;
  --transition:   .18s ease;
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(200,146,42,.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(179,74,42,.06) 0%, transparent 60%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--rust); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--rust-light); }

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  background: var(--ink);
  border-bottom: 3px solid var(--rust);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--cream) !important;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.brand-icon { font-size: 1.4rem; }
.brand:hover { color: var(--gold) !important; }

.site-nav { display: flex; align-items: center; gap: 1.5rem; }

.nav-link {
  color: rgba(245,240,232,.7);
  font-size: .9rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: color var(--transition);
}
.nav-link:hover,
.nav-link.active { color: var(--cream); }

.nav-cta {
  background: var(--rust);
  color: var(--cream) !important;
  padding: .45rem 1.1rem;
  border-radius: 100px;
  font-size: .85rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 500;
  transition: background var(--transition), transform var(--transition);
}
.nav-cta:hover { background: var(--rust-light); transform: translateY(-1px); }

/* ── Main ───────────────────────────────────────────────────── */
.site-main { flex: 1; }

/* ── Flash messages ─────────────────────────────────────────── */
.flash-container { max-width: 1100px; margin: 1.5rem auto 0; padding: 0 2rem; }

.flash {
  padding: .85rem 1.2rem;
  border-radius: var(--radius);
  border-left: 4px solid;
  font-size: .9rem;
  margin-bottom: .75rem;
}
.flash--success { background: var(--sage-pale); border-color: var(--sage); color: var(--sage); }
.flash--error   { background: var(--rust-pale); border-color: var(--rust); color: var(--rust); }
.flash--info    { background: var(--gold-pale); border-color: var(--gold); color: #7a5510; }

/* ── Hero ───────────────────────────────────────────────────── */
.page-hero {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to right, var(--cream), var(--cream-dark));
  padding: 3.5rem 2rem 2.5rem;
}

.hero-inner { max-width: 1100px; margin: 0 auto; }

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}

.hero-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background: var(--rust);
  margin-top: .6rem;
  border-radius: 2px;
}

.hero-sub {
  font-size: .95rem;
  color: var(--ink-light);
  margin-top: .5rem;
  font-style: italic;
}

/* ── Controls bar ───────────────────────────────────────────── */
.controls-bar {
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  padding: 1rem 2rem;
  position: sticky;
  top: 64px;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.controls-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: .9rem;
  color: var(--ink-light);
  font-size: 1rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: .6rem 2.4rem .6rem 2.4rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: white;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  outline: none;
  border-color: var(--rust);
  box-shadow: 0 0 0 3px rgba(179,74,42,.12);
}
.search-input::placeholder { color: var(--ink-light); }

.search-clear {
  position: absolute;
  right: .75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-light);
  font-size: 1.1rem;
  line-height: 1;
  padding: .1rem .3rem;
  border-radius: 50%;
  transition: color var(--transition), background var(--transition);
}
.search-clear:hover { color: var(--rust); background: var(--rust-pale); }

.filter-label {
  font-size: .8rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-light);
  white-space: nowrap;
}

.filter-wrap, .sort-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.filter-select {
  padding: .5rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  font-family: var(--font-body);
  font-size: .875rem;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus { outline: none; border-color: var(--rust); }

/* ── Book grid ──────────────────────────────────────────────── */
.book-section {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 2rem 4rem;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

/* ── Book card ──────────────────────────────────────────────── */
.book-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  animation: cardIn .3s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.book-card.hidden { display: none; }

.book-spine {
  width: 8px;
  background: var(--rust);
  flex-shrink: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: linear-gradient(180deg, var(--rust) 0%, var(--gold) 100%);
}

.book-body {
  padding: 1.2rem 1.2rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.book-meta-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .3rem;
}

.book-year {
  font-size: .8rem;
  color: var(--ink-light);
  font-style: italic;
}

.book-rating {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .8rem;
  color: var(--gold);
}

.book-rating--none {
  color: var(--ink-light);
  font-size: .78rem;
  font-style: italic;
}

/* Star rating display */
.star-fill {
  display: inline-block;
  position: relative;
  color: var(--cream-dark);
  letter-spacing: 1px;
}
.star-fill::before {
  content: '★★★★★';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--gold);
  width: var(--pct);
  overflow: hidden;
  white-space: nowrap;
}

.rating-val {
  color: var(--ink-light);
  font-size: .78rem;
}

.book-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.book-author {
  font-size: .875rem;
  color: var(--ink-light);
  font-style: italic;
}

.book-actions {
  display: flex;
  gap: .5rem;
  margin-top: auto;
  padding-top: .8rem;
}

.inline-form { display: inline; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary {
  background: var(--rust);
  color: white;
  border-color: var(--rust);
}
.btn--primary:hover {
  background: var(--rust-light);
  border-color: var(--rust-light);
  color: white;
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-mid);
  border-color: var(--border);
}
.btn--ghost:hover {
  background: var(--cream-dark);
  color: var(--ink);
  border-color: rgba(26,22,18,.2);
}

.btn--danger {
  background: transparent;
  color: var(--rust);
  border-color: rgba(179,74,42,.3);
}
.btn--danger:hover {
  background: var(--rust-pale);
  border-color: var(--rust);
}

.btn--sm { padding: .35rem .85rem; font-size: .8rem; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--ink-light);
}

.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

.empty-msg {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-style: italic;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* ── Form page ──────────────────────────────────────────────── */
.form-page {
  max-width: 700px;
  margin: 3rem auto;
  padding: 0 2rem 4rem;
}

.form-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
}

.form-header { margin-bottom: 2rem; }

.back-link {
  font-size: .85rem;
  color: var(--ink-light);
  display: inline-block;
  margin-bottom: .75rem;
  transition: color var(--transition);
}
.back-link:hover { color: var(--rust); }

.form-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}
.form-title em { color: var(--rust); }

/* ── Fields ─────────────────────────────────────────────────── */
.field {
  margin-bottom: 1.5rem;
  position: relative;
}

.field--half {
  display: inline-block;
  width: calc(50% - .5rem);
  vertical-align: top;
}
.field--half + .field--half { margin-left: 1rem; }

.field-label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-mid);
  margin-bottom: .4rem;
}

.required { color: var(--rust); }
.optional { color: var(--ink-light); font-size: .75rem; text-transform: none; letter-spacing: 0; }

.field-input {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--ink);
  background: var(--cream);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -moz-appearance: textfield;
}
.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.field-input:focus {
  outline: none;
  border-color: var(--rust);
  box-shadow: 0 0 0 3px rgba(179,74,42,.1);
  background: white;
}

/* Validation states */
.field.is-valid .field-input   { border-color: var(--sage); background: white; }
.field.is-invalid .field-input { border-color: var(--rust); background: white; }

.field-feedback {
  font-size: .8rem;
  min-height: 1.2rem;
  margin-top: .3rem;
  transition: color var(--transition);
}
.field.is-valid   .field-feedback { color: var(--sage); }
.field.is-invalid .field-feedback { color: var(--rust); }

.field-counter {
  font-size: .75rem;
  color: var(--ink-light);
  text-align: right;
  margin-top: .15rem;
}

/* Rating wrap */
.rating-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.star-preview {
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: 2px;
}

/* Form actions */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--ink-light);
  font-style: italic;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .controls-inner { flex-direction: column; align-items: stretch; }
  .filter-wrap, .sort-wrap { justify-content: space-between; }
  .field--half { width: 100%; display: block; }
  .field--half + .field--half { margin-left: 0; }
  .form-wrap { padding: 1.5rem; }
  .form-actions { flex-direction: column-reverse; }
  .btn { width: 100%; justify-content: center; }
}


/* ── Auth pages (login / signup) ────────────────────────────────────────────── */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 4rem 1.5rem 6rem;
  min-height: calc(100vh - 64px - 56px);
}

.auth-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-icon {
  font-size: 2.4rem;
  display: block;
  margin-bottom: .5rem;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.auth-sub {
  font-size: .9rem;
  color: var(--ink-light);
  font-style: italic;
  margin-top: .3rem;
}

.auth-switch {
  text-align: center;
  font-size: .875rem;
  color: var(--ink-light);
  margin-top: 1.25rem;
}
.auth-switch a { color: var(--rust); font-weight: 500; }
.auth-switch a:hover { color: var(--rust-light); }

/* Full-width button variant */
.btn--full { width: 100%; justify-content: center; margin-top: .5rem; }

/* Show / hide password toggle */
.toggle-pw {
  float: right;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: .75rem;
  color: var(--rust);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: color var(--transition);
}
.toggle-pw:hover { color: var(--rust-light); }

/* Field hint (below input, lighter) */
.field-hint {
  font-size: .75rem;
  color: var(--ink-light);
  margin-top: .2rem;
}

/* Password strength bar */
.pw-strength {
  margin-top: .4rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 1rem;
}

.pw-strength-bar {
  flex: 1;
  height: 4px;
  background: var(--cream-dark);
  border-radius: 2px;
  overflow: hidden;
}

.pw-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width .3s ease, background .3s ease;
}
.pw-strength-fill.s0 { width: 0%;   background: transparent; }
.pw-strength-fill.s1 { width: 25%;  background: var(--rust); }
.pw-strength-fill.s2 { width: 50%;  background: var(--gold); }
.pw-strength-fill.s3 { width: 75%;  background: #7aaf38; }
.pw-strength-fill.s4 { width: 100%; background: var(--sage); }

.pw-strength-label {
  font-size: .72rem;
  color: var(--ink-light);
  white-space: nowrap;
  min-width: 48px;
}

/* Nav user area */
.nav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: .25rem;
  padding-left: 1rem;
  border-left: 1px solid rgba(245,240,232,.2);
}

.nav-username {
  font-size: .82rem;
  color: rgba(245,240,232,.65);
  font-style: italic;
  letter-spacing: .02em;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(245,240,232,.25);
  color: rgba(245,240,232,.7);
  font-family: var(--font-body);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .3rem .8rem;
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-logout:hover {
  background: rgba(245,240,232,.1);
  color: var(--cream);
  border-color: rgba(245,240,232,.5);
}

@media (max-width: 640px) {
  .auth-wrap { padding: 1.75rem 1.25rem 1.5rem; }
  .nav-user  { display: none; } /* username hidden on mobile, logout still in menu */
}
