/* Molisana — the hills of Molise, porcelain paper, ink, one bottle-green accent.
   Speakers are distinguished by typography: user notes in Karla,
   Molisana's replies in Newsreader, like correspondence. */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 600;
  src: url("/fonts/newsreader-normal-400-600.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400 600;
  src: url("/fonts/newsreader-italic-400-600.woff2") format("woff2");
}
@font-face {
  font-family: "Karla";
  font-style: normal;
  font-weight: 400 700;
  src: url("/fonts/karla-normal-400-700.woff2") format("woff2");
}
@font-face {
  font-family: "Karla";
  font-style: italic;
  font-weight: 400;
  src: url("/fonts/karla-italic-400.woff2") format("woff2");
}

:root {
  --carta: #fbfbf7;        /* porcelain paper */
  --carta-scura: #f2f3ec;  /* sidebar, cards */
  --inchiostro: #1c1f1c;   /* ink */
  --pietra: #6f766f;       /* stone grey */
  --linea: #e2e3da;        /* hairline */
  --verde: #2a5240;        /* bottle green */
  --verde-fondo: #1f4032;  /* green, pressed */
  --verde-velo: #ecf1ea;   /* green veil */
  --rosso: #a4453c;        /* error, muted brick */
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Karla", "Segoe UI", system-ui, sans-serif;
  --shadow-pill: 0 1px 2px rgba(28, 31, 28, 0.06), 0 8px 28px rgba(28, 31, 28, 0.09);
}

* { box-sizing: border-box; }

/* Screens toggle via the hidden attribute; keep it authoritative. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--carta);
  color: var(--inchiostro);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--verde-velo); color: var(--inchiostro); }

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

button { font-family: var(--sans); cursor: pointer; }

/* ---------- Shared controls ---------- */

.button {
  background: var(--verde);
  color: var(--carta);
  border: none;
  padding: 0.72rem 1.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.button:hover { background: var(--verde-fondo); }
.button:disabled { opacity: 0.45; cursor: default; }

.quiet-button {
  background: none;
  border: 1px solid var(--linea);
  color: var(--inchiostro);
  padding: 0.3rem 0.85rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 999px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.quiet-button:hover { border-color: var(--verde); color: var(--verde); }

.link-button {
  background: none;
  border: none;
  color: var(--pietra);
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.35rem;
}
.link-button:hover { color: var(--inchiostro); }

.error { color: var(--rosso); font-size: 0.88rem; margin: 0.9rem auto 0; max-width: 34rem; }

/* ---------- The pill (shared by lock form and composer) ---------- */

.pill {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  background: #fff;
  border: 1px solid var(--linea);
  border-radius: 28px;
  padding: 0.45rem 0.45rem 0.45rem 1.35rem;
  box-shadow: var(--shadow-pill);
  transition: border-color 0.15s ease;
}
.pill:focus-within { border-color: var(--verde); }

.pill input,
.pill textarea {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--inchiostro);
  padding: 0.55rem 0;
  min-width: 0;
}
.pill input:focus-visible,
.pill textarea:focus-visible { outline: none; }
.pill ::placeholder { color: var(--pietra); }

.pill-button {
  background: var(--verde);
  color: var(--carta);
  border: none;
  border-radius: 999px;
  padding: 0.68rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.pill-button:hover { background: var(--verde-fondo); }
.pill-button:disabled { opacity: 0.45; cursor: default; }

/* ---------- Entrance loader ---------- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--carta);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

body.ready #loader {
  opacity: 0;
  visibility: hidden;
}

.loader-mark {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 2.8rem;
  color: var(--inchiostro);
  animation: settle 0.9s ease both;
}

/* A hairline that breathes: a green glint sweeping a quiet line */
.loader-line {
  width: 8.5rem;
  height: 1px;
  background: var(--linea);
  position: relative;
  overflow: hidden;
}
.loader-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--verde), transparent);
  transform: translateX(-100%);
  animation: glint 1.8s ease-in-out infinite;
}
@keyframes glint {
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  #loader { display: none; }
}

/* ---------- Lock screen: hero ---------- */

#lock-screen { min-height: 100vh; }

.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* The scene: video with its own first frame as poster, so the hero always
   shows the lake — still until the film plays, seamless when it does. */
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  background: url("/media/hero-poster.jpg") center / cover no-repeat;
}

/* Porcelain veil over the footage so ink text stays legible and the
   scene sits inside the brand palette. */
.hero-veil {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(50% 54% at 50% 47%,
      rgba(251, 251, 247, 0.78),
      rgba(251, 251, 247, 0.42) 58%,
      rgba(251, 251, 247, 0) 80%),
    linear-gradient(180deg,
      rgba(251, 251, 247, 0.78) 0%,
      rgba(251, 251, 247, 0.35) 28%,
      rgba(251, 251, 247, 0.05) 55%,
      rgba(31, 64, 50, 0.3) 100%);
}

.hero-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.6rem 2.2rem;
}

.wordmark-small {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.7rem;
}

.hero-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--verde);
}

.hero-center {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 1.5rem 6vh;
  animation: settle 0.8s ease both;
}

.ornament { color: var(--verde); font-size: 0.5rem; margin-bottom: 1.1rem; }

.hero-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.6rem, 6vw, 3.8rem);
  line-height: 1.1;
  margin: 0 0 1rem;
}

.hero-lede {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--inchiostro);
  max-width: 30rem;
  margin: 0 0 2rem;
}

#lock-form { width: min(34rem, 100%); }

.hint {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--inchiostro);
  max-width: 30rem;
  margin: 1.2rem 0 0;
}

/* Links and errors on the hero sit over footage — keep them ink-dark */
.hero .link-button { color: var(--inchiostro); }
.hero .error {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
}

.hero-more {
  position: relative;
  z-index: 1;
  align-self: center;
  margin-bottom: 1.6rem;
  color: var(--carta);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0.85;
}
.hero-more:hover { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Security pillars ---------- */

.pillars-band {
  background: var(--carta);
  padding: 4.2rem 2.2rem 2.6rem;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.6rem;
  max-width: 56rem;
  margin: 0 auto;
}

.pillar h2 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--verde);
  margin: 0 0 0.55rem;
}

.pillar p {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.65;
  margin: 0;
}

.colophon {
  margin-top: 3.4rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--linea);
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pietra);
}

/* ---------- Chat ---------- */

#chat-screen { display: flex; height: 100vh; }

#sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--carta-scura);
  border-right: 1px solid var(--linea);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.4rem 1.3rem 1.1rem;
}

.brand {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.45rem;
}

#conversation-list { flex: 1; overflow-y: auto; padding: 0.4rem 0.8rem; }

.conv-item {
  position: relative;
  padding: 0.55rem 0.7rem 0.55rem 1.1rem;
  font-size: 0.88rem;
  color: var(--pietra);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 3px;
  transition: color 0.15s ease;
}
.conv-item:hover { color: var(--inchiostro); }
.conv-item.active { color: var(--inchiostro); }
.conv-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65rem;
  bottom: 0.65rem;
  width: 2px;
  background: var(--verde);
}

.sidebar-footer {
  padding: 1.1rem 1.3rem 1.2rem;
  border-top: 1px solid var(--linea);
}
.privacy-note {
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--pietra);
  margin: 0 0 0.4rem;
}
.sidebar-footer .link-button { padding-left: 0; }

#chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 2.4rem 1.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  width: min(46rem, 100%);
  margin: 0 auto;
}

/* Empty conversation: a quiet invitation */
.empty-state {
  margin: auto;
  text-align: center;
  animation: settle 0.5s ease both;
}
.empty-state .ornament { margin-bottom: 0.9rem; }
.empty-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 2rem;
  margin: 0 0 1.6rem;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.chip {
  background: #fff;
  border: 1px solid var(--linea);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
  color: var(--inchiostro);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--verde); color: var(--verde); }

.msg { animation: rise 0.35s ease both; }

.msg.user {
  align-self: flex-end;
  max-width: 78%;
  background: var(--verde-velo);
  padding: 0.8rem 1.05rem;
  border-radius: 14px 14px 4px 14px;
  font-size: 0.94rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant {
  align-self: stretch;
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant.streaming::after {
  content: "▍";
  color: var(--verde);
  animation: blink 1.1s steps(1) infinite;
}

.msg.error-msg { color: var(--rosso); font-size: 0.88rem; }

/* ---------- Composer & quota ---------- */

.desk {
  width: min(46rem, 100%);
  margin: 0 auto;
  padding: 0.6rem 1.8rem 1rem;
}

#prompt { max-height: 200px; }

.quota {
  margin: 0.65rem 0.2rem 0;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pietra);
  text-align: center;
}

/* ---------- Paywall ---------- */

#paywall {
  border: 1px solid var(--linea);
  border-top: 2px solid var(--verde);
  background: #fff;
  border-radius: 6px;
  padding: 2rem 2.2rem 2.2rem;
  margin-bottom: 1rem;
  text-align: center;
  box-shadow: var(--shadow-pill);
  animation: rise 0.4s ease both;
}

.paywall-eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--verde);
  margin: 0 0 0.8rem;
}

.paywall-lede {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.55rem;
  margin: 0 0 0.7rem;
}

.paywall-body {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--pietra);
  max-width: 26rem;
  margin: 0 auto 1.4rem;
}

.paywall-note { font-size: 0.8rem; color: var(--pietra); margin: 1rem 0 0; }

/* ---------- Motion ---------- */

@keyframes settle {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .hero-header { padding: 1.2rem 1.2rem; }
  .pillars { grid-template-columns: 1fr; gap: 1.8rem; }
  .pillars-band { padding: 3rem 1.4rem 2rem; }

  #chat-screen { flex-direction: column; }
  #sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--linea);
  }
  .sidebar-header { padding: 0.8rem 1rem; }
  #conversation-list { display: flex; padding: 0.6rem 0.4rem; }
  .conv-item { flex-shrink: 0; max-width: 11rem; }
  .conv-item.active::before { top: auto; left: 1.1rem; right: 0.7rem; bottom: 0.2rem; width: auto; height: 2px; }
  .sidebar-footer { border-top: none; padding: 0.6rem 1rem; }
  .privacy-note { display: none; }
  #messages, .desk { padding-left: 1.1rem; padding-right: 1.1rem; }
}
