/* Ancora Imparo — a page from an old master's sketchbook */

:root {
  --graphite: #2B2723;
  --graphite-deep: #211E1B;
  --chalk: #EDE6DA;
  --sanguine: #A8462E;        /* ink: fills, rules — never small text */
  --sanguine-lift: #C4623F;   /* the mark glyph: 3.65:1, passes non-text AA */
  --faded: #9A9284;           /* metadata: 4.81:1, passes AA normal text */
  --slate: #5B6B73;           /* thread-line indicator */

  --serif: "Source Serif 4", "Source Serif Pro", Charter, Georgia, serif;
  --display: "Cormorant Garamond", Garamond, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(1.5rem, 7vw, 3.25rem);
  --fade: 520ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--graphite);
  color: var(--chalk);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overscroll-behavior: none;   /* no bounce — wrong texture */
  overflow: hidden;
}

:focus-visible {
  outline: 2px solid var(--sanguine-lift);
  outline-offset: 3px;
  border-radius: 1px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ── Running header ─────────────────────────────────────────── */

.running-head {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding: max(0.9rem, env(safe-area-inset-top)) var(--gutter) 0.9rem;
  background: linear-gradient(to bottom, var(--graphite) 55%, transparent);
  pointer-events: none;
}
.running-head > * { pointer-events: auto; }

.tag {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faded);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  min-width: 0;
  transition: opacity var(--fade);
}
.tag .sep {
  display: inline-block;
  width: 1.6em;
  height: 1px;
  background: var(--slate);
  flex: none;
}
.tag .thread { color: var(--faded); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── The feed ───────────────────────────────────────────────── */

.feed {
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior-y: contain;
}
.feed::-webkit-scrollbar { display: none; }

.card {
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  display: grid;
  align-content: center;
  padding: 5.5rem var(--gutter) 5rem;
  max-width: 42rem;
  margin: 0 auto;
}

/* soft crossfade in, nothing springy */
.card .lesson {
  opacity: 0;
  transform: translateY(0.6rem);
  transition: opacity var(--fade), transform var(--fade);
}
.card.is-active .lesson { opacity: 1; transform: none; }

.card .title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.05rem, 8.5vw, 3rem);
  line-height: 1.08;
  letter-spacing: 0.005em;
  margin: 0 0 1.5rem;
  text-wrap: balance;
}

.card .body {
  font-size: clamp(1.02rem, 4.3vw, 1.14rem);
  line-height: 1.72;
  margin: 0;
  color: var(--chalk);
  hanging-punctuation: first;
}

.card .source {
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: var(--faded);
  margin: 1.9rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(154, 146, 132, 0.22);
  max-width: 34rem;
}

/* ── "Tell me more" ─────────────────────────────────────────── */

.tell {
  position: absolute;
  right: var(--gutter);
  bottom: max(1.4rem, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  background: none;
  border: 0;
  padding: 0.8rem 0.15rem;      /* keeps the tap target near 44px tall */
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--fade), color var(--fade);
}
.card.is-active .tell { opacity: 1; }

.tell-label {
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faded);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color var(--fade), border-color var(--fade);
  white-space: nowrap;
}
.tell-label::after {
  content: " \2192";            /* → : this lesson goes out to an AI */
  color: var(--sanguine-lift);
}

.tell:hover .tell-label,
.tell:focus-visible .tell-label { color: var(--chalk); border-bottom-color: rgba(196, 98, 63, 0.55); }

.tell.is-copied .tell-label { color: var(--sanguine-lift); border-bottom-color: transparent; }
.tell.is-copied .tell-label::after { content: ""; }   /* the ✓ is in the text now */

/* ── Toast ──────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.3rem, env(safe-area-inset-bottom));
  transform: translate(-50%, 0.75rem);
  z-index: 30;
  max-width: min(28rem, calc(100vw - 2 * var(--gutter)));
  background: var(--graphite-deep);
  border: 1px solid rgba(154, 146, 132, 0.28);
  border-radius: 2px;
  color: var(--chalk);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  line-height: 1.45;
  text-align: center;
  padding: 0.7rem 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--fade), transform var(--fade), visibility var(--fade);
}
.toast.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* ── Loading / failure ──────────────────────────────────────── */

.notice {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: var(--gutter);
  color: var(--faded);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.notice[hidden] { display: none; }
.notice .msg { text-transform: none; letter-spacing: 0; font-family: var(--serif); font-size: 1rem; margin-top: 0.9rem; color: var(--chalk); }

/* ── Preferences ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .card .lesson { opacity: 1; transform: none; }
  .feed { scroll-behavior: auto; }
}

@media (min-width: 48rem) {
  .card { padding-top: 6.5rem; }
  .card .body { font-size: 1.16rem; }
}
