/* Journal — warm paper, warm ink, one serif, no containers. */

:root {
  --paper: #f8f6f3;
  --ink: #262019;
  --muted: #6d6154;
  --accent: #9c5a2e;
  --serif: 'Charter', 'Iowan Old Style', 'Georgia', 'Times New Roman', serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #211d18;
    --ink: #ece5da;
    --muted: #b0a494;
    --accent: #d08a55;
  }
}

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

html {
  background: var(--paper);
}

body {
  font-family: var(--serif);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding: calc(env(safe-area-inset-top) + 2.5rem) 1.375rem calc(env(safe-area-inset-bottom) + 4rem);
}

::selection {
  background: color-mix(in srgb, var(--accent) 25%, var(--paper));
}

main {
  max-width: 34rem;
  margin: 0 auto;
}

/* ---------- Date header ---------- */

#date, #setup-title {
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.3;
  margin-bottom: 2rem;
}

/* ---------- Writing area ---------- */

.write {
  margin-bottom: 3.5rem;
}

#input {
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  line-height: 1.65;
  caret-color: var(--accent);
  min-height: 5.2rem;
}

#input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.write-row {
  display: flex;
  align-items: baseline;
  column-gap: 1.75rem;
  flex-wrap: wrap;
}

#send, #when, #photo-btn {
  font: inherit;
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0.75rem 0;
  margin-top: 0;
  min-height: 44px;
  cursor: pointer;
  transition: color 160ms ease-out;
}

#send:hover, #when:hover, #photo-btn:hover,
#send:focus-visible, #when:focus-visible, #photo-btn:focus-visible {
  color: var(--accent);
}

#send:focus-visible, #when:focus-visible, #photo-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

#photo-preview {
  display: block;
  max-width: 38%;
  margin-bottom: 1rem;
  cursor: pointer;
}

#photo-preview[hidden] {
  display: none;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Entries ---------- */

.day {
  font-size: 0.9375rem;
  font-weight: 400;
  margin: 3.5rem 0 1.5rem;
}

.day-toggle {
  font: inherit;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0.6rem 1rem 0.6rem 0;
  margin: -0.6rem 0; /* hit area grows without moving the day rhythm */
  min-height: 44px;
  cursor: pointer;
  transition: color 160ms ease-out;
}

.day-toggle:hover, .day-toggle:focus-visible {
  color: var(--accent);
}

.day-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

.entry {
  margin-bottom: 2.75rem;
}

.entry-photo {
  display: block;
  max-width: 100%;
  margin: 0 0 1rem;
}

.entry-text {
  white-space: pre-wrap;
  text-wrap: pretty;
}

.entry-response {
  font-style: italic;
  font-size: 0.9792rem;
  color: var(--muted);
  margin-top: 1.1rem;
  padding-left: 1.375rem;
  white-space: pre-wrap;
}

.entry-response:empty {
  display: none;
}

.entry-response.arrived {
  animation: settle 700ms ease-out;
}

@keyframes settle {
  from { opacity: 0; transform: translateY(0.2rem); }
  to   { opacity: 1; transform: none; }
}

.entry-response.pending {
  animation: breathe 2.4s ease-in-out infinite;
}

.entry-response.pending .think {
  display: inline-block;
  vertical-align: -0.12em;
  animation: think-turn 3.6s linear infinite;
}

@keyframes think-turn {
  to { transform: rotate(360deg); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 0.8; }
}

.entry-response.retry {
  cursor: pointer;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  margin-top: 0.6rem;
}

.entry-response.retry:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

.notice {
  font-style: italic;
  color: var(--muted);
}

/* ---------- Threads ---------- */

.thread-me {
  font-size: 0.9792rem;
  margin-top: 1.1rem;
  white-space: pre-wrap;
}

.thread-mirror {
  padding-left: 0;
}

.reply-action {
  display: block;
  font: inherit;
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0.6rem 1rem 0.6rem 0;
  cursor: pointer;
  transition: color 160ms ease-out;
}

.reply-action:hover, .reply-action:focus-visible {
  color: var(--accent);
}

.reply-action:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

.reply-box {
  margin-top: 0.4rem;
}

.reply-box textarea {
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  line-height: 1.65;
  caret-color: var(--accent);
  min-height: 3.4rem;
}

.reply-box textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.reply-send {
  font: inherit;
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0.6rem 1rem 0.6rem 0;
  min-height: 44px;
  cursor: pointer;
  transition: color 160ms ease-out;
}

.reply-send:hover, .reply-send:focus-visible {
  color: var(--accent);
}

.reply-send:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

.photo-retry {
  font-style: italic;
  font-size: 0.9375rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}

.photo-retry:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .entry-response.arrived { animation: none; }
  .entry-response.pending { animation: none; opacity: 0.55; }
  .entry-response.pending .think { animation: none; }
}

/* ---------- Token setup ---------- */

.setup-note {
  color: var(--muted);
  margin-bottom: 2rem;
}

#token-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
  padding: 0.4rem 0;
  caret-color: var(--accent);
}

#token-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

#token-save {
  font: inherit;
  font-style: italic;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0.75rem 1rem 0.75rem 0;
  margin-top: 0.75rem;
  min-height: 44px;
  cursor: pointer;
}

#token-save:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

#token-save:hover, #token-save:focus-visible {
  color: var(--accent);
}
