/* ===== CUSTOM PROPERTIES ===== */
:root {
  --cream:      #f5f0e8;
  --cream-dark: #ede8dc;
  --ink:        #2c2416;
  --ink-mid:    #6b5f4a;
  --ink-light:  #a09070;
  --accent:     #c0392b;
  --rule:       #d4c9b0;

  --font-hand: 'Caveat', cursive;
  --font-body: 'Lora', Georgia, serif;

  --max-width: 860px;
  --pad-h: clamp(1.25rem, 5vw, 2.5rem);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;

}

/* ===== HEADER ===== */
.site-header {
  border-bottom: 2px solid var(--rule);
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem var(--pad-h);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-family: var(--font-hand);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
  line-height: 1;
}

.logo:hover {
  color: var(--accent);
}

.day-counter {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-light);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== MAIN LAYOUT ===== */
main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--pad-h);
}

/* ===== PROMPT SECTION ===== */
.prompt-section {
  padding: clamp(2.5rem, 8vw, 5rem) 0 clamp(2rem, 6vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}

.prompt-lead {
  font-family: var(--font-body);
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  font-style: italic;
  color: var(--ink-mid);
  margin-bottom: 0.6rem;
  letter-spacing: 0.01em;
}

.prompt-text {
  font-family: var(--font-hand);
  font-size: clamp(2rem, 6.5vw, 3.8rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.01em;
  min-height: 1.2em; /* prevent layout jump before JS runs */
}

/* ===== CURSOR ===== */
.cursor {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  margin-left: 1px;
  animation: blink 0.7s step-end infinite;
  /* Use user-select:none so cursor char isn't copy-pasted */
  user-select: none;
  -webkit-user-select: none;
}

.cursor--idle {
  animation: blink 1.2s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ===== HISTORY SECTION ===== */
.history-section {
  padding-bottom: 0.5rem;
}

.prompts-stack {
  position: relative;
}

/* Gradient that makes the last items dissolve into the page,
   giving the sense the products section is encroaching */
.prompts-stack.is-clipped::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 7rem;
  background: linear-gradient(to bottom, transparent, var(--cream));
  pointer-events: none;
}

.history-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  line-height: 1.25;
  transition: opacity 0.2s ease;
  cursor: default;
  /* opacity set per-item via --op; see rules below */
}

.history-item:last-child {
  border-bottom: none;
}

/* Opacity is driven by the --op custom property set inline per item.
   hover/focus overrides it to 1 regardless. */
.history-item {
  opacity: var(--op, 1);
}

.history-item:hover,
.history-item:focus {
  opacity: 1 !important;
  outline: none;
}

/* On touch-only devices, raise the floor to 0.38 so faded items are readable
   without needing to tap. Yesterday (0.58) and day-before (0.36) stay as-is
   because max() picks the larger value. */
@media (hover: none) {
  .history-item {
    opacity: max(var(--op, 1), 0.38);
  }
  .history-item:focus {
    opacity: 1 !important;
  }
}

.history-day {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 3.8rem;
}

.history-prompt {
  font-family: var(--font-hand);
  font-weight: 700;
  color: var(--ink);
}

.history-actions {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin: 1.25rem 0 0;
}

.load-more-btn,
.collapse-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  font-style: italic;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.12s ease;
}

.load-more-btn {
  color: var(--ink-light);
}

.load-more-btn:hover {
  color: var(--accent);
}

.collapse-btn {
  color: var(--rule);
}

.collapse-btn:hover {
  color: var(--ink-light);
}

/* ===== PRODUCTS SECTION ===== */
.products-section {
  padding: clamp(2rem, 6vw, 3.5rem) 0 clamp(1.5rem, 4vw, 2.5rem);
  border-top: 2px solid var(--rule);
  margin-top: 1.5rem;
}

.products-heading {
  font-family: var(--font-body);
  font-size: clamp(0.85rem, 2vw, 1rem);
  font-weight: 600;
  font-style: italic;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1.5rem;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

/* ===== PRODUCT CARD ===== */
.product-card {
  background: var(--cream-dark);
  border: 1px solid var(--rule);
  box-shadow: 2px 3px 0px var(--rule);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.product-card:hover {
  box-shadow: 3px 4px 0px var(--rule);
  transform: translate(-1px, -1px);
}

.product-image {
  width: 100%;
  height: 150px;
  object-fit: contain;
  display: block;
  border-bottom: 1px solid var(--rule);
  background: #fff;
}

.product-card-body {
  padding: 0.9rem 1.1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.product-category {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
}

.product-name {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

.product-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.product-link {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-mid);
  border: 1.5px solid var(--rule);
  padding: 0.3rem 0.65rem;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.product-link:hover,
.product-link:focus-visible {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  outline: none;
}

.product-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.5rem var(--pad-h) 2rem;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

.footer-tagline {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink-mid);
  margin-bottom: 0.5rem;
}

.affiliate-disclosure {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--ink-light);
  line-height: 1.6;
  max-width: 52ch;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: 1fr 1fr;
  }

  .product-card {
    box-shadow: 1px 2px 0px var(--rule);
  }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .cursor,
  .cursor--idle {
    animation: none;
    opacity: 1;
  }
}
