/* ============================================================
   The Doby Family Archive
   Aesthetic: editorial archival / museum exhibit
   ============================================================ */

:root {
  /* Palette: aged ivory, oxblood, walnut, brass, forest */
  --paper:        #f4ebd6;
  --paper-deep:   #ebe0c7;
  --paper-shadow: #d8c9a8;
  --ink:          #2a1a10;
  --ink-soft:     #4d3525;
  --ink-faded:    #7a614c;
  --oxblood:      #6b1f1f;
  --oxblood-deep: #4a1414;
  --forest:       #2d3a2e;
  --brass:        #a8763a;
  --brass-bright: #c9924a;
  --rule:         rgba(42, 26, 16, 0.18);

  /* Typography */
  --display: 'Fraunces', Georgia, serif;
  --body:    'Newsreader', Georgia, serif;

  /* Layout */
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --max-w:  44rem;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.65;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  /* Subtle radial warmth */
  background-image:
    radial-gradient(ellipse at top, rgba(168, 118, 58, 0.08), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(107, 31, 31, 0.04), transparent 60%);
  background-attachment: fixed;
}

/* ============================================================
   Paper grain overlay — subtle SVG noise
   ============================================================ */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  z-index: 1;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
}

/* ============================================================
   Layout container
   ============================================================ */
.archive {
  position: relative;
  z-index: 2;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) 4rem;
}

/* ============================================================
   Hero header
   ============================================================ */
.hero {
  text-align: center;
  margin-bottom: 3rem;
  animation: fade-up 1.2s ease-out;
}

.hero__eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  color: var(--brass);
}

.rule {
  flex: 0 0 3rem;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
}

.eyebrow-text {
  font-family: var(--body);
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
}

.hero__title {
  font-family: var(--display);
  font-weight: 400;
  /* Fraunces variable axes for character */
  font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
  font-size: clamp(2.75rem, 8vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.hero__title .ornament {
  font-style: italic;
  font-weight: 300;
  color: var(--oxblood);
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
}

.hero__subtitle {
  font-family: var(--body);
  font-size: 1.1rem;
  font-style: italic;
  font-weight: 300;
  color: var(--ink-soft);
  max-width: 32rem;
  margin: 0 auto 2rem;
  line-height: 1.5;
}

.hero__flourish {
  color: var(--brass);
  display: flex;
  justify-content: center;
}

/* ============================================================
   Placard / about card — feels like an exhibit panel
   ============================================================ */
.placard {
  position: relative;
  background: var(--paper-deep);
  padding: 2rem 2.25rem;
  margin-bottom: 3rem;
  border: 1px solid var(--paper-shadow);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 4px 20px rgba(42, 26, 16, 0.06),
    0 1px 3px rgba(42, 26, 16, 0.08);
  animation: fade-up 1.2s ease-out 0.2s backwards;
}

.placard__corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--brass);
}
.placard__corner--tl { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.placard__corner--tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.placard__corner--bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }
.placard__corner--br { bottom: 8px; right: 8px; border-left: none; border-top: none; }

.placard__lead {
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  margin-bottom: 1rem;
}

.placard__hint {
  font-size: 0.9rem;
  color: var(--ink-faded);
  line-height: 1.55;
}

.placard__hint em {
  font-style: italic;
  color: var(--oxblood);
}

/* ============================================================
   The conversation
   ============================================================ */
.archive-room {
  animation: fade-up 1.2s ease-out 0.4s backwards;
}

.conversation {
  background: var(--paper-deep);
  border: 1px solid var(--paper-shadow);
  border-radius: 2px;
  padding: 1.5rem;
  min-height: 360px;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 1.25rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 8px 32px rgba(42, 26, 16, 0.08);
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.conversation::-webkit-scrollbar { width: 8px; }
.conversation::-webkit-scrollbar-track { background: transparent; }
.conversation::-webkit-scrollbar-thumb {
  background: var(--paper-shadow);
  border-radius: 4px;
}
.conversation::-webkit-scrollbar-thumb:hover { background: var(--ink-faded); }

/* Individual entries */
.entry {
  margin-bottom: 1.5rem;
  animation: entry-in 0.5s ease-out;
}

.entry:last-child { margin-bottom: 0; }

.entry__label {
  font-family: var(--body);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border: 1px solid currentColor;
}

.entry__body {
  font-size: 1.05rem;
  line-height: 1.65;
}

/* The user's questions — bold, oxblood */
.entry--user .entry__label {
  color: var(--oxblood);
}
.entry--user .entry__body {
  font-family: var(--display);
  font-variation-settings: "opsz" 32, "SOFT" 50;
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.4;
  border-left: 3px solid var(--oxblood);
  padding-left: 1rem;
}

/* The archivist's responses — body serif, indented */
.entry--archivist .entry__label {
  color: var(--forest);
  background: rgba(45, 58, 46, 0.06);
  border-color: rgba(45, 58, 46, 0.3);
}
.entry--archivist .entry__body {
  font-family: var(--body);
  color: var(--ink);
  white-space: pre-wrap;
}
.entry--archivist .entry__body p {
  margin-bottom: 0.85rem;
}
.entry--archivist .entry__body p:last-child { margin-bottom: 0; }

.entry--welcome .entry__body {
  font-style: italic;
  color: var(--ink-soft);
}

/* Limit reached entry — distinct styling */
.entry--limit .entry__body {
  background: rgba(168, 118, 58, 0.1);
  border: 1px solid var(--brass);
  border-left: 3px solid var(--brass);
  padding: 1rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* Thinking state */
.entry--thinking .entry__body::after {
  content: "";
  display: inline-block;
  animation: dots 1.4s infinite;
}

@keyframes dots {
  0%, 20% { content: ""; }
  40% { content: "."; }
  60% { content: ".."; }
  80%, 100% { content: "..."; }
}

/* ============================================================
   Composer / input
   ============================================================ */
.composer {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
}

.composer input[type=text] {
  flex: 1;
  background: var(--paper);
  border: 1px solid var(--paper-shadow);
  border-bottom: 1.5px solid var(--ink-soft);
  padding: 0.95rem 1.1rem;
  font-family: var(--body);
  font-size: 1.05rem;
  color: var(--ink);
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

.composer input[type=text]::placeholder {
  color: var(--ink-faded);
  font-style: italic;
}

.composer input[type=text]:focus {
  background: #fdf7e8;
  border-bottom-color: var(--oxblood);
}

.composer button {
  background: var(--oxblood);
  color: var(--paper);
  border: none;
  padding: 0 1.5rem;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: 0 2px 0 var(--oxblood-deep);
}

.composer button:hover:not(:disabled) {
  background: var(--oxblood-deep);
}

.composer button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--oxblood-deep);
}

.composer button:disabled {
  background: var(--ink-faded);
  cursor: not-allowed;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

.send-icon { transition: transform 0.2s; }
.composer button:hover:not(:disabled) .send-icon {
  transform: translateX(2px);
}

/* ============================================================
   Footer / meta
   ============================================================ */
.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--ink-faded);
  letter-spacing: 0.05em;
}

.meta__counter {
  font-variant-numeric: tabular-nums;
}

.meta__attribution {
  font-style: italic;
}

/* ============================================================
   Utility
   ============================================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes entry-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 540px) {
  .placard { padding: 1.5rem 1.25rem; }
  .conversation { padding: 1.1rem; }
  .composer button .send-text { display: none; }
  .composer button { padding: 0 1rem; }
  .hero__title { letter-spacing: -0.03em; }
  .meta { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
