/* otto.css — the Otto page: a sheet pinned to the drafting board.
   Tokens, .app__bar, .wordmark, .btn, .eyebrow come from audit.css. */

.ot-board {
  height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); background-image: var(--grid-paper);
}
.ot-board > .app__bar { flex: none; }
.ot-bar__alt {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
}
.ot-bar__alt:hover { color: var(--accent-deep); }
.ot-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- the sheet ---------- */
.ot-sheet {
  flex: 1; min-height: 0; width: min(100%, 880px); margin: 0 auto;
  background: var(--paper-raised);
  border-left: 1px solid var(--ink); border-right: 1px solid var(--ink);
  display: flex; flex-direction: column;
}

/* title block, as on a drawing */
.ot-title {
  display: grid; grid-template-columns: 1fr 1fr 1.2fr auto;
  border-bottom: 1px solid var(--ink);
}
.ot-title__cell {
  display: flex; flex-direction: column; gap: 3px; padding: 12px 18px 12px;
  border-right: 1px solid var(--line); min-width: 0;
}
.ot-title__cell:last-child { border-right: 0; }
.ot-title__k {
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
}
.ot-title__v {
  font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; letter-spacing: -0.005em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px;
}
.ot-title__mark { width: 10px; height: 10px; background: var(--accent); flex: none; box-shadow: 2px 2px 0 var(--ink); }
.ot-title__cell--progress { text-align: right; align-items: flex-end; }
.ot-title__cell--progress .ot-title__v { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.08em; color: var(--accent-deep); }

/* ---------- the conversation ---------- */
.ot-stream { flex: 1; min-height: 0; overflow-y: auto; padding: clamp(22px, 4vw, 34px) clamp(18px, 4vw, 36px) 16px; scroll-behavior: smooth; }

.turn { margin: 0 0 26px; animation: turn-in 220ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.turn--otto { max-width: 62ch; }
.turn__text { font-size: 1.05rem; line-height: 1.6; white-space: pre-wrap; margin: 0; }
.turn__text:empty { display: none; }
.turn__text + .turn__text { margin-top: 12px; }
.turn__q {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.22rem, 2.4vw, 1.42rem);
  line-height: 1.22; letter-spacing: -0.012em; margin: 12px 0 0; color: var(--ink);
}
.turn__q::before { content: ""; display: inline-block; width: 9px; height: 9px; background: var(--accent); margin: 0 10px 0 0; vertical-align: 0.12em; }

.turn--you { display: flex; justify-content: flex-end; }
.turn--you span {
  font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.5; white-space: pre-wrap;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: var(--press-sm);
  padding: 10px 14px; max-width: min(80%, 52ch);
}
.turn--file span { display: inline-flex; align-items: center; gap: 8px; }
.turn--file svg { flex: none; }

.turn--thinking { font-family: var(--font-mono); color: var(--ink-soft); letter-spacing: 0.2em; animation: think 1s steps(4, end) infinite; }
.turn--streaming .turn__text::after {
  content: ""; display: inline-block; width: 0.5em; height: 1em; margin-left: 2px;
  background: var(--accent); vertical-align: -0.15em; animation: ot-blink 0.9s steps(1) infinite;
}
@keyframes ot-blink { 50% { opacity: 0; } }
@keyframes turn-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ot-err {
  border: 1px solid var(--accent-deep); background: rgba(224, 78, 27, 0.06);
  padding: 12px 14px; margin: 0 0 26px; font-size: 0.92rem; max-width: 62ch;
}
.ot-err p { margin: 0 0 10px; }
.ot-err__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ot-err .btn { padding: 9px 13px; font-size: 0.74rem; }

/* ---------- the write-up ---------- */
.ot-wrap { margin: 4px 0 16px; }
.ot-summary { padding: 18px 20px; border: 1px solid var(--ink); background: var(--paper); box-shadow: var(--press-sm); }
.ot-summary .eyebrow { margin-bottom: 10px; }
.ot-summary__text { font-size: 1.02rem; line-height: 1.58; white-space: pre-wrap; }
.ot-cta { margin-top: 26px; padding-top: 22px; border-top: 1px dashed var(--line); }
.ot-cta__headline {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 3.4vw, 2rem);
  line-height: 1.08; letter-spacing: -0.015em; margin: 0 0 10px;
}
.ot-cta__body { color: var(--ink-soft); font-size: 1rem; max-width: 50ch; margin: 0 0 20px; }

/* ---------- composer, pinned to the bottom of the view ---------- */
.ot-foot {
  flex: none;
  background: var(--paper-raised); border-top: 1px solid var(--ink);
  padding: 14px clamp(14px, 3vw, 22px) calc(12px + env(safe-area-inset-bottom));
}
.ot-compose { display: flex; gap: 10px; align-items: flex-end; }
.ot-compose textarea {
  flex: 1; min-width: 0; resize: none;
  font-family: var(--font-body); font-size: 1.05rem; line-height: 1.45; color: var(--ink);
  background: var(--paper); border: 1px solid var(--ink); border-radius: 0;
  box-shadow: var(--press-sm);
  padding: 13px 15px; min-height: 50px; max-height: 160px;
}
.ot-compose textarea:focus { outline: none; border-color: var(--accent); box-shadow: 3px 3px 0 var(--accent); }
.ot-compose textarea::placeholder { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em; color: var(--ink-soft); }
.ot-attach {
  flex: none; width: 50px; height: 50px; display: grid; place-items: center;
  color: var(--ink-soft); background: var(--paper-raised); border: 1px solid var(--ink); box-shadow: var(--press-sm); cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, color 120ms ease;
}
.ot-attach:hover { color: var(--accent-deep); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.ot-attach:active { transform: translate(3px, 3px); box-shadow: none; }
.ot-attach:focus-visible, .ot-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ot-send {
  flex: none; width: 50px; height: 50px;
  font-family: var(--font-mono); font-size: 1.15rem; color: #fff;
  background: var(--accent-strong); border: 1.5px solid var(--ink); box-shadow: var(--press-sm); cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.ot-send:hover { background: var(--accent-deep); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.ot-send:active { transform: translate(3px, 3px); box-shadow: none; }
#otto-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.ot-foot__hint {
  display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 2px 0;
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.03em; color: var(--ink-soft);
}

[data-state="streaming"] .ot-compose textarea,
[data-state="loading"] .ot-compose textarea { color: var(--ink-soft); box-shadow: none; border-color: var(--line); }
[data-state="streaming"] .ot-send,
[data-state="loading"] .ot-send { pointer-events: none; opacity: 0.5; }
[data-state="done"] .ot-foot,
[data-state="capped"] .ot-foot { display: none; }

/* ---------- opt-in under the write-up ---------- */
.ot-optin { margin-top: 28px; padding-top: 22px; border-top: 1px dashed var(--line); }
.ot-optin .optin__label { font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 10px; display: block; }
.ot-optin .optin__row { display: flex; gap: 10px; }
.ot-optin .optin__row input { flex: 1; min-width: 0; font-family: var(--font-body); font-size: 1rem; padding: 11px 13px; background: var(--paper); border: 1px solid var(--line); }
.ot-optin .optin__row input:focus { outline: none; border-color: var(--accent); }
.ot-optin .btn { padding: 11px 16px; font-size: 0.78rem; }
.ot-optin .optin__status { font-family: var(--font-mono); font-size: 0.76rem; color: var(--ink-soft); margin: 8px 0 0; }

/* ---------- whole-page drop scrim ---------- */
.ot-scrim {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: rgba(22, 19, 14, 0.32); pointer-events: none;
}
.ot-scrim span {
  font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; color: var(--paper);
  border: 2px dashed var(--paper); padding: 22px 32px;
}

@media (prefers-reduced-motion: reduce) {
  .turn { animation: none; }
  .turn--streaming .turn__text::after { animation: none; }
}

@media (max-width: 880px) {
  .ot-board { background-image: none; }
  .ot-sheet { border-left: 0; border-right: 0; }
  .ot-title { grid-template-columns: 1fr 1fr auto; }
  .ot-title__cell--length { display: none; }
  .ot-title__cell { padding: 10px 14px; }
  .ot-stream { padding: 20px 16px 8px; }
  .turn--you span { max-width: 88%; }
  .ot-foot__hint span:not(:last-child) { display: none; }
}
