/* Jurnal — "written by lamplight": dusk indigo-plum ground, warm amber accent.
   Committed single look (no light theme): an evening ritual object. */

:root {
  --noapte: #191533;   /* page ground */
  --seara: #221d40;    /* cards */
  --ceata: #2c2650;    /* raised / inputs */
  --linie: #3a3364;    /* hairlines, idle waveform bars */
  --hartie: #efeaf7;   /* primary text */
  --estompat: #9a91b8; /* secondary text */
  --lampa: #f2b366;    /* amber accent */
  --lampa-int: #ffd9a0;
  --rosu: #e4738c;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Instrument Sans", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--noapte);
  color: var(--hartie);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

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

/* ---------- Login ---------- */

#login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(340px, 100%);
  text-align: center;
}

.wordmark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 52px;
  margin: 0;
  letter-spacing: -0.01em;
}

.wordmark::after {
  content: ".";
  color: var(--lampa);
}

.tagline {
  color: var(--estompat);
  margin: 6px 0 36px;
  font-size: 15px;
}

#login-form {
  display: grid;
  gap: 12px;
}

#password, #text-input, .text-field {
  background: var(--ceata);
  border: 1px solid var(--linie);
  border-radius: 12px;
  color: var(--hartie);
  font-family: inherit;
  font-size: 16px;
  padding: 13px 16px;
  width: 100%;
}

#password::placeholder, #text-input::placeholder, .text-field::placeholder { color: var(--estompat); }

#password:focus, #text-input:focus, .text-field:focus {
  outline: none;
  border-color: var(--lampa);
}

.btn-primary {
  background: var(--lampa);
  color: #241c10;
  font-weight: 600;
  font-size: 16px;
  border-radius: 12px;
  padding: 13px 22px;
  transition: filter 0.15s;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  color: var(--estompat);
  font-size: 15px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 10px;
}

.btn-ghost:hover { color: var(--hartie); }

.form-error { color: var(--rosu); font-size: 14px; margin: 4px 0 0; }

/* ---------- App shell ---------- */

#app-view {
  max-width: 620px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 0;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 14px 10px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--noapte) 78%, transparent);
  z-index: 5;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--estompat);
  font-size: 26px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover { color: var(--hartie); background: var(--seara); }

.date-title {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 4px 16px;
  border-radius: 12px;
}

.date-title:hover { background: var(--seara); }

.weekday {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lampa);
  font-weight: 500;
}

.date-big {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 27px;
  letter-spacing: -0.01em;
}

/* ---------- Timeline ---------- */

#timeline {
  flex: 1;
  padding: 8px 18px 140px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.entry {
  position: relative;
  background: var(--seara);
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 14px 18px 16px;
  animation: entry-in 0.35s ease both;
}

.entry.flash {
  border-color: var(--lampa);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lampa) 22%, transparent);
  transition: border-color 0.6s, box-shadow 0.6s;
}

@keyframes entry-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.entry-time {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--lampa);
  letter-spacing: 0.06em;
}

.entry-text {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.entry.pending .entry-text,
.entry.failed .entry-text { color: var(--estompat); font-style: italic; }

.entry.pending .entry-text {
  background: linear-gradient(90deg, var(--estompat) 40%, var(--hartie) 50%, var(--estompat) 60%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  from { background-position: 130% 0; }
  to { background-position: -130% 0; }
}

.entry.failed { border-color: color-mix(in srgb, var(--rosu) 45%, transparent); }

.entry-error {
  margin-top: 6px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  color: var(--estompat);
  overflow-wrap: anywhere;
}

.retry-btn {
  margin-top: 10px;
  color: var(--rosu);
  font-size: 14px;
  font-weight: 600;
}

/* Waveform = play control (the signature element) */

.wave {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
  padding: 6px 0;
}

.wave-icon { color: var(--lampa); flex: none; display: grid; place-items: center; }

.wave-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  flex: 1;
  overflow: hidden;
}

.wave-bars i {
  flex: 1;
  min-width: 2px;
  max-width: 5px;
  border-radius: 2px;
  background: var(--linie);
  transition: background 0.12s;
}

.wave-bars i.played { background: var(--lampa); }

.wave-duration {
  font-size: 13px;
  color: var(--estompat);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* Entry editing */

.entry-edit {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--linie);
  transition: color 0.15s, background 0.15s;
}

.entry-edit:hover { color: var(--hartie); background: var(--ceata); }

.entry-editor { margin-top: 8px; }

.entry-editor .text-field {
  resize: vertical;
  min-height: 72px;
  font-size: 16px;
  line-height: 1.5;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.editor-spacer { flex: 1; }

.btn-danger {
  color: var(--rosu);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 10px;
}

.btn-danger:hover { background: color-mix(in srgb, var(--rosu) 14%, transparent); }

.btn-danger[data-armed="1"] { background: color-mix(in srgb, var(--rosu) 20%, transparent); }

.btn-primary.btn-small { padding: 9px 16px; font-size: 14px; }

/* ---------- Empty state ---------- */

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--estompat);
  padding: 40px 20px;
}

.empty-state .big {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  color: var(--hartie);
  margin-bottom: 8px;
}

/* ---------- Composer ---------- */

.composer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  justify-items: center;
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--noapte) 42%);
  z-index: 6;
}

.composer > .icon-btn { grid-column: 1; }

.rec-button {
  grid-column: 2;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 32% 28%, var(--lampa-int), var(--lampa) 65%);
  color: #241c10;
  box-shadow: 0 6px 30px color-mix(in srgb, var(--lampa) 35%, transparent);
  transition: transform 0.15s ease;
}

.rec-button:active { transform: scale(0.94); }

.composer-hint {
  grid-column: 2;
  grid-row: 2;
  margin-top: 10px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--estompat);
}

/* Live recording bar */

.rec-live {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 100%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--noapte) 30%);
  z-index: 7;
}

#level-canvas {
  flex: 1;
  height: 56px;
  min-width: 0;
}

.rec-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--lampa);
  font-size: 16px;
  flex: none;
}

.rec-stop {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--rosu);
  color: #2b0f16;
  flex: none;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rosu) 45%, transparent); }
  50% { box-shadow: 0 0 0 12px transparent; }
}

/* ---------- Sheets ---------- */

.sheet {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--noapte) 55%, transparent);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.sheet-body {
  width: min(620px, 100%);
  max-height: 78dvh;
  overflow-y: auto;
  background: var(--seara);
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  animation: sheet-up 0.28s ease both;
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin: 0;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

#text-input { resize: vertical; min-height: 96px; }

/* Archive */

.archive-month {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lampa);
  font-weight: 500;
  margin: 18px 0 6px;
}

.archive-day {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  padding: 11px 10px;
  border-radius: 12px;
  font-size: 16px;
  text-align: left;
}

.archive-day:hover { background: var(--ceata); }

.archive-day .count { color: var(--estompat); font-size: 14px; }

.archive-empty { color: var(--estompat); padding: 12px 0 4px; }

#search-input { margin: 4px 0 6px; }

.search-hit {
  display: grid;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 11px 10px;
  border-radius: 12px;
}

.search-hit:hover { background: var(--ceata); }

.hit-date {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lampa);
  font-weight: 500;
}

.hit-text { font-size: 15px; color: var(--hartie); }

.export-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  text-decoration: none;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .entry, .sheet-body { animation: none; }
  .rec-stop { animation: none; }
  .entry.pending .entry-text {
    animation: none;
    -webkit-text-fill-color: currentColor;
    background: none;
  }
}
