/* ==========================================================================
   WishbookWeb Catalogs - Site 1 (1937-1975)
   Vintage department-store catalog theme: newsprint cream, holly green,
   vintage red, brass accents. No external fonts or image assets.
   ========================================================================== */

:root {
  /* Palette */
  --green-deep: #0b2a1f;
  --green: #14503a;
  --green-mid: #103f2d;
  --red: #8f1626;
  --red-bright: #b8202f;
  --gold: #d6b065;
  --gold-soft: #ecd8a6;
  --paper: #fbf6ea;
  --paper-dim: #efe6d2;
  --ink: #241c14;
  --ink-soft: #5d5345;

  /* Type */
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
             "Times New Roman", serif;
  --ui: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;

  /* Shape and depth */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.18);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.26);
  --shadow-lg: 0 16px 38px rgba(0, 0, 0, 0.42);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--ui);
  color: var(--paper);
  background-color: var(--green-deep);
  min-height: 100vh;
  padding: 28px 20px 64px;
  position: relative;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Layered backdrop: warm vignettes over deep green, plus a faint snowfall
   pattern. Replaces the old tiled-emoji wallpaper. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(214, 176, 101, 0.20), transparent 70%),
    radial-gradient(ellipse 70% 60% at 8% 12%, rgba(143, 22, 38, 0.42), transparent 72%),
    radial-gradient(ellipse 75% 65% at 92% 88%, rgba(143, 22, 38, 0.34), transparent 70%),
    linear-gradient(170deg, var(--green) 0%, var(--green-mid) 45%, var(--green-deep) 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='%23ffffff' fill-opacity='0.14'%3E%3Ccircle cx='18' cy='26' r='1.6'/%3E%3Ccircle cx='74' cy='12' r='1'/%3E%3Ccircle cx='132' cy='38' r='1.8'/%3E%3Ccircle cx='46' cy='62' r='1.1'/%3E%3Ccircle cx='104' cy='78' r='1.5'/%3E%3Ccircle cx='12' cy='104' r='1.3'/%3E%3Ccircle cx='66' cy='124' r='1.7'/%3E%3Ccircle cx='146' cy='112' r='1'/%3E%3Ccircle cx='96' cy='148' r='1.2'/%3E%3Ccircle cx='28' cy='146' r='1'/%3E%3C/g%3E%3Cg stroke='%23ecd8a6' stroke-opacity='0.16' stroke-width='1' stroke-linecap='round'%3E%3Cpath d='M120 20v8M116 24h8'/%3E%3Cpath d='M38 92v7M34.5 95.5h7'/%3E%3Cpath d='M86 44v6M83 47h6'/%3E%3C/g%3E%3C/svg%3E");
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* --------------------------------------------------------------- Masthead */

header {
  text-align: center;
  color: var(--paper);
  margin: 10px 0 34px;
  padding-bottom: 26px;
  position: relative;
}

header::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 90%);
  height: 4px;
  border-top: 1px solid rgba(214, 176, 101, 0.75);
  border-bottom: 1px solid rgba(214, 176, 101, 0.38);
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin-bottom: 14px;
}

header h1 {
  font-family: var(--display);
  font-size: clamp(2rem, 5.2vw, 3.5rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22), 0 10px 26px rgba(0, 0, 0, 0.3);
}

.masthead-sub {
  display: block;
  margin-top: 12px;
  font-family: var(--ui);
  font-size: clamp(0.78rem, 1.6vw, 0.98rem);
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-soft);
  text-shadow: none;
}

header p {
  margin-top: 20px;
}

.site-link {
  display: inline-block;
  padding: 10px 22px;
  border: 1px solid rgba(214, 176, 101, 0.6);
  border-radius: 999px;
  background: rgba(251, 246, 234, 0.07);
  color: var(--gold-soft);
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease,
              transform 0.25s ease;
}

.site-link:hover,
.site-link:focus-visible {
  background: var(--gold);
  border-color: var(--gold);
  color: #2b1d08;
  transform: translateY(-2px);
}

/* --------------------------------------------------------- Shared panels */

.selector-container,
.stats,
.catalog-title,
.error {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid rgba(36, 28, 20, 0.12);
  box-shadow: var(--shadow);
}

/* -------------------------------------------------------- Catalog chooser */

.selector-container {
  position: sticky;
  top: 10px;
  z-index: 20;
  padding: 20px 22px;
  border-radius: var(--radius);
  border-top: 3px solid var(--red);
  margin-bottom: 30px;
}

.selector-container label {
  display: block;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin-bottom: 12px;
}

.selector-container select {
  width: 100%;
  padding: 13px 44px 13px 15px;
  font-family: var(--ui);
  font-size: 1.02rem;
  color: var(--ink);
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%238f1626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  border: 1px solid rgba(36, 28, 20, 0.28);
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.selector-container select:hover {
  border-color: var(--green);
}

.selector-container select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 80, 58, 0.22);
}

/* ------------------------------------------------------------------ Stats */

.stats {
  padding: 18px 22px;
  border-radius: var(--radius);
  margin-bottom: 30px;
}

.stats p {
  margin: 6px 0;
  font-size: 1rem;
  color: var(--ink-soft);
}

.stats p strong {
  color: var(--ink);
}

/* ----------------------------------------------------------- Catalog head */

.catalog-section {
  margin-bottom: 56px;
  scroll-margin-top: 120px;
}

.catalog-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  padding: 18px 22px;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  font-family: var(--display);
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.catalog-title::before {
  content: "";
  align-self: stretch;
  width: 4px;
  min-height: 1.4em;
  border-radius: 2px;
  background: linear-gradient(var(--red), var(--gold));
}

.catalog-title .count {
  font-family: var(--ui);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6d3b1f;
  background: rgba(214, 176, 101, 0.3);
  border: 1px solid rgba(143, 22, 38, 0.2);
  border-radius: 999px;
  padding: 5px 12px;
  margin-left: auto;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- Gallery */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 18px;
  padding: 22px;
  background: rgba(11, 42, 31, 0.55);
  border: 1px solid rgba(214, 176, 101, 0.28);
  border-top: 1px solid rgba(36, 28, 20, 0.12);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}

.thumbnail-container {
  display: block;
  position: relative;
  background: var(--paper);
  padding: 6px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(214, 176, 101, 0.25);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.thumbnail-container:hover,
.thumbnail-container:focus-visible {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg), 0 0 0 2px var(--gold);
  outline: none;
}

.thumbnail-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  background: var(--paper-dim);
}

/* Page-number tab */
.page-no {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(11, 42, 31, 0.82);
  border: 1px solid rgba(214, 176, 101, 0.5);
  color: var(--gold-soft);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  opacity: 0.72;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.thumbnail-container:hover .page-no,
.thumbnail-container:focus-visible .page-no {
  opacity: 1;
}

/* Skeleton laid OVER the image until it decodes. It must not hide the image
   itself: a display:none image never intersects the viewport, so one marked
   loading="lazy" would never start loading at all. */
.placeholder {
  position: absolute;
  inset: 6px;
  z-index: 1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background-color: var(--paper-dim);
  background-image: linear-gradient(100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.75) 40%,
    rgba(255, 255, 255, 0) 60%);
  background-size: 300% 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.6s linear infinite;
}

/* Opaque, so a broken-image icon cannot show through from the img beneath */
.placeholder.is-error {
  animation: none;
  background-image: none;
  background-color: #ecd9d3;
  color: var(--red);
}

@keyframes shimmer {
  0%   { background-position: 150% 0; }
  100% { background-position: -150% 0; }
}

/* ---------------------------------------------------------------- Loading */

.loading-indicator {
  text-align: center;
  padding: 48px 20px;
  color: var(--gold-soft);
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.spinner {
  display: inline-block;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(236, 216, 166, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-right: 14px;
  vertical-align: middle;
}

/* Dark-on-light variant, for use on the cream modal stage */
.spinner--ink {
  margin-right: 0;
  border-color: rgba(36, 28, 20, 0.18);
  border-top-color: var(--red);
}

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ Error */

.error {
  padding: 20px 24px;
  border-radius: var(--radius);
  border-left: 5px solid var(--red-bright);
  margin: 20px 0;
  text-align: center;
  color: var(--red);
  font-weight: 600;
}

/* ------------------------------------------------------------------ Modal */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(11, 42, 31, 0.9);
  padding: 24px;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  background: var(--paper);
  padding: 8px;
  border: 1px solid rgba(214, 176, 101, 0.5);
  border-radius: var(--radius);
  max-width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: var(--paper-dim);
}

/* Hold the dialog open at a sensible size before the page has arrived, so it
   does not snap from a sliver to full height when the image lands. */
.modal-stage.is-loading,
.modal-stage.is-error {
  width: min(58vh, 70vw);
  height: min(78vh, 95vw);
}

.modal img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 92px);
  width: auto;
  height: auto;
  border-radius: 3px;
}

.modal-stage.is-loading #modalImage,
.modal-stage.is-error #modalImage {
  display: none;
}

.modal-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.6;
}

.modal-status[hidden] {
  display: none;
}

.modal-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  padding: 11px 6px 3px;
}

.modal-caption {
  font-family: var(--display);
  font-size: 1rem;
  color: var(--ink);
}

.modal-original {
  font-size: 0.82rem;
  color: var(--red);
  text-decoration: none;
  border-bottom: 1px solid rgba(143, 22, 38, 0.4);
  white-space: nowrap;
}

.modal-original:hover,
.modal-original:focus-visible {
  border-bottom-color: var(--red);
}

/* Stop the page behind the dialog from scrolling */
body.modal-open {
  overflow: hidden;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  color: var(--gold-soft);
  background: rgba(11, 42, 31, 0.85);
  border: 1px solid rgba(214, 176, 101, 0.5);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease, color 0.25s ease;
}

.close-btn:hover,
.close-btn:focus-visible {
  background: var(--gold);
  color: #2b1d08;
  outline: none;
}

/* ----------------------------------------------------------- Breakpoints */

@media (max-width: 768px) {
  body {
    padding: 18px 14px 48px;
  }

  .eyebrow {
    letter-spacing: 0.2em;
  }

  .selector-container {
    position: static;
    padding: 16px;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .thumbnail-container {
    padding: 4px;
  }

  .placeholder {
    inset: 4px;
  }

  .page-no {
    right: 6px;
    bottom: 6px;
    padding: 2px 7px;
    font-size: 0.6rem;
  }

  .catalog-title .count {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
