/* ------------------------------------------------------------------ */
/*  Poor Richard's Engineering Almanack — Colonial Almanac Stylesheet  */
/* ------------------------------------------------------------------ */

:root {
  --parchment:   #f5e6c8;
  --parchment-dk:#ead9b0;
  --ink:         #2c1a0e;
  --ink-faded:   #5a3e28;
  --red:         #8b1a1a;
  --rule-color:  #5a3e28;
  --font-main:   'IM Fell English', Georgia, serif;
  --font-sc:     'IM Fell English SC', 'Small Caps', Georgia, serif;
}

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

body {
  background: #c8b090;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='4' height='4' fill='%23c8b090'/%3E%3Crect x='0' y='0' width='2' height='2' fill='%23c2aa88' opacity='.4'/%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  font-family: var(--font-main);
  color: var(--ink);
}

.page {
  background: var(--parchment);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='0.06'/%3E%3C/svg%3E");
  max-width: 720px;
  width: 100%;
  padding: 2.5rem 3rem;
  box-shadow: 0 4px 40px rgba(0,0,0,0.45), inset 0 0 60px rgba(0,0,0,0.04);
  border: 1px solid var(--parchment-dk);
}

/* ---- Rules ---- */
.masthead-rule {
  border: none;
  border-top: 2px solid var(--rule-color);
  border-bottom: 2px solid var(--rule-color);
  height: 6px;
  margin: 1rem 0;
}
.masthead-rule.thin {
  border-bottom: none;
  height: 2px;
  margin: 1.5rem 0;
}

/* ---- Masthead ---- */
.masthead { text-align: center; padding: 0.5rem 0; }

.year-line {
  font-family: var(--font-sc);
  letter-spacing: 0.25em;
  font-size: 0.85rem;
  color: var(--ink-faded);
  margin-bottom: 0.3rem;
}

.title {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-family: var(--font-sc);
  color: var(--red);
  line-height: 1.2;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.subtitle {
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-faded);
  margin-bottom: 0.4rem;
}

.byline {
  font-size: 0.9rem;
  color: var(--ink-faded);
}

/* ---- Saying of the day ---- */
.saying-of-day { margin: 1.5rem 0; text-align: center; }

.section-head {
  font-family: var(--font-sc);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--ink-faded);
  text-align: center;
  margin-bottom: 0.8rem;
}

.daily-saying {
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.65;
  max-width: 560px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  border-left: 3px solid var(--red);
  border-right: 3px solid var(--red);
  color: var(--ink);
}

/* ---- Ask section ---- */
.ask-section { margin: 1rem 0 1.5rem; }

.instruction {
  font-style: italic;
  text-align: center;
  font-size: 0.92rem;
  color: var(--ink-faded);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.input-wrap { margin-bottom: 0.75rem; }

textarea {
  width: 100%;
  font-family: var(--font-main);
  font-size: 1rem;
  color: var(--ink);
  background: #fdf6e3;
  border: 1px solid var(--rule-color);
  border-radius: 2px;
  padding: 0.65rem 0.9rem;
  resize: vertical;
  line-height: 1.5;
  transition: box-shadow 0.15s;
}
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(139,26,26,0.25);
}

button {
  display: block;
  margin: 0 auto;
  font-family: var(--font-sc);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  color: var(--parchment);
  background: var(--red);
  border: none;
  padding: 0.55rem 2rem;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s, opacity 0.15s;
}
button:hover:not(:disabled)  { background: #6e1414; }
button:disabled { opacity: 0.5; cursor: default; }

.rate-note {
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-faded);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ---- Answer section ---- */
.answer-section { margin: 1rem 0; }

.answer-text {
  font-size: 1rem;
  line-height: 1.75;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
}

.proverbs-head {
  font-family: var(--font-sc);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--ink-faded);
  margin-bottom: 0.6rem;
}

.proverbs-list {
  list-style: none;
  padding: 0;
}

.proverbs-list li {
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px dotted var(--rule-color);
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
}
.proverbs-list li:last-child { border-bottom: none; }

.saying-text { font-style: italic; flex: 1; }
.saying-meta { font-size: 0.76rem; color: var(--ink-faded); white-space: nowrap; }

/* ---- Error ---- */
.error-msg {
  color: var(--red);
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
  padding: 0.5rem;
}

/* ---- Loading dots ---- */
.loading-dots { color: var(--ink-faded); }

/* ---- Colophon ---- */
.colophon {
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-faded);
  line-height: 1.6;
  font-style: italic;
}
.colophon code {
  font-family: monospace;
  font-size: 0.85em;
  font-style: normal;
  background: var(--parchment-dk);
  padding: 1px 4px;
  border-radius: 2px;
}

/* ---- Responsive ---- */
@media (max-width: 540px) {
  .page { padding: 1.5rem 1.25rem; }
  .title { font-size: 1.7rem; }
  .daily-saying { font-size: 1rem; }
}
