/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens ── */
:root {
  --bg:        #f7f1e3;
  --bg-2:      #efe3c9;
  --bg-3:      #e6d6b8;
  --text:      #2b2118;
  --text-2:    #6e5d49;
  --text-3:    #a3927a;
  --border:    rgba(43,33,24,0.16);
  --border-2:  rgba(43,33,24,0.32);
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-uneven:    5px 3px 6px 4px;
  --radius-uneven-lg: 7px 5px 9px 4px;
  --font-sans: Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Fira Mono", monospace;

  /* stamp inks */
  --stamp-red:   #b23a2e;
  --stamp-green: #3f6b2e;
  --stamp-amber: #a3691a;

  /* ambient unease — slow background pulse, intensity set by tier/stage */
  --unease-rgb:       178, 58, 46;
  --unease-duration:  32s;
  --unease-amplitude: 0.05;

  /* semantic */
  --info-bg:     #f1e1d2;
  --info-border: var(--stamp-red);
  --info-text:   var(--stamp-red);

  --green-bg:    #e6ecd6;
  --green-text:  var(--stamp-green);
  --amber-bg:    #f3e3c4;
  --amber-text:  var(--stamp-amber);
  --red-bg:      #f5ddd6;
  --red-text:    var(--stamp-red);
  --red-border:  var(--stamp-red);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #2a231b;
    --bg-2:     #332b20;
    --bg-3:     #3c3225;
    --text:     #ecdfc6;
    --text-2:   #bfac8d;
    --text-3:   #8a795f;
    --border:   rgba(236,223,198,0.12);
    --border-2: rgba(236,223,198,0.24);

    --stamp-red:   #e6685c;
    --stamp-green: #9ec97a;
    --stamp-amber: #e0ad5c;

    --unease-rgb: 230, 104, 92;

    --info-bg:     #3c2b24;
    --info-border: var(--stamp-red);
    --info-text:   var(--stamp-red);

    --green-bg:   #2f3722;
    --green-text: var(--stamp-green);
    --amber-bg:   #3f2f17;
    --amber-text: var(--stamp-amber);
    --red-bg:     #3f2420;
    --red-text:   var(--stamp-red);
    --red-border: var(--stamp-red);
  }
}

/* Unease ramps up with the chosen fury tier, and again once the
   translation has come back — the moment before the user decides
   whether to send it. */
html[data-tier="2"]      { --unease-duration: 20s; --unease-amplitude: 0.08; }
html[data-tier="3"]      { --unease-duration: 13s; --unease-amplitude: 0.12; }
html[data-stage="output"] { --unease-duration: 8s;  --unease-amplitude: 0.16; }

/* ── Base ── */
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-3);
  min-height: 100vh;
  padding: 2rem 1rem;
  animation: unease-bg var(--unease-duration) ease-in-out infinite;
}
@keyframes unease-bg {
  0%, 100% { background-color: var(--bg-3); }
  50% {
    background-color: color-mix(
      in srgb,
      var(--bg-3) calc(100% - var(--unease-amplitude) * 100%),
      rgb(var(--unease-rgb)) calc(var(--unease-amplitude) * 100%)
    );
  }
}
@media (prefers-reduced-motion: reduce) {
  body, .app { animation: none; }
}

/* ── App shell ── */
.app {
  max-width: 680px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-uneven-lg);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(43,33,24,0.06), 0 10px 30px rgba(43,33,24,0.08);
  transform: rotate(-0.3deg);
  animation: unease-glow var(--unease-duration) ease-in-out infinite;
}
@keyframes unease-glow {
  0%, 100% {
    box-shadow: 0 1px 2px rgba(43,33,24,0.06), 0 10px 30px rgba(43,33,24,0.08);
  }
  50% {
    box-shadow: 0 1px 2px rgba(43,33,24,0.06), 0 10px 30px rgba(43,33,24,0.08),
      0 0 70px 6px rgba(var(--unease-rgb), var(--unease-amplitude));
  }
}

/* ── Stamps ── */
.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 2px solid currentColor;
  border-radius: 4px;
  padding: 4px 10px;
  mix-blend-mode: multiply;
  opacity: 0.85;
}
@media (prefers-color-scheme: dark) {
  .stamp { mix-blend-mode: normal; }
}

/* ── Header ── */
.header {
  position: relative;
  padding: 2.25rem 2rem 1.75rem;
  border-bottom: 3px double var(--border-2);
  text-align: center;
}
.letterhead-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.header h1 { font-size: 24px; font-weight: 600; margin-bottom: 6px; }
.tagline { font-size: 14px; color: var(--text-2); font-style: italic; }
.case-stamp {
  position: absolute;
  top: 16px; right: 18px;
  color: var(--stamp-red);
  transform: rotate(-8deg);
}

/* ── Sections ── */
.section,
.demo-section,
.intake-section,
.output-section,
.delivery-section {
  padding: 1.5rem 2rem;
  position: relative;
}
.section::after,
.demo-section::after,
.intake-section::after,
.output-section::after,
.delivery-section::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background-image: radial-gradient(circle, var(--border-2) 1.2px, transparent 1.3px);
  background-size: 9px 3px;
  background-repeat: repeat-x;
}
.demo-section,
.intake-section,
.output-section,
.delivery-section { display: none; }

.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 1rem;
}
.section-label::before { content: "§ "; }

/* ── Mood grid ── */
.mood-prompt {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1.25rem;
}
.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 1rem 0.75rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-uneven);
  background: var(--bg-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
  font-family: var(--font-sans);
}
.mood-btn:hover { background: var(--bg-3); }
.mood-btn.selected {
  border: 2px solid var(--stamp-red);
  background: var(--info-bg);
}
.mood-icon { font-size: 24px; }
.mood-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.mood-sub   { font-size: 11px; color: var(--text-2); line-height: 1.3; }
.mood-btn.selected .mood-title,
.mood-btn.selected .mood-sub { color: var(--stamp-red); }

/* ── Demo video ── */
.demo-intro {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}
.video-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-uneven);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}
.video-tier-label {
  position: absolute;
  top: 14px; left: 14px;
  transform: rotate(-6deg);
}
.video-placeholder.tier-1 .video-tier-label { color: var(--stamp-green); }
.video-placeholder.tier-2 .video-tier-label { color: var(--stamp-amber); }
.video-placeholder.tier-3 .video-tier-label { color: var(--stamp-red);   }
.video-play-icon { font-size: 40px; color: var(--text-3); }
.video-coming    { font-size: 13px; color: var(--text-3); }
.video-caption   { font-size: 12px; color: var(--text-3); font-style: italic; text-align: center; }

/* ── Shared buttons ── */
.continue-btn,
.action-btn,
.send-btn {
  width: 100%;
  padding: 13px;
  margin-top: 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-uneven);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.continue-btn:hover,
.action-btn:hover:not(:disabled),
.send-btn:hover:not(:disabled) {
  background: var(--bg-3);
  border-color: var(--stamp-red);
  color: var(--stamp-red);
}
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mic ── */
.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.mic-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-size: 28px;
  color: var(--text);
}
.mic-btn:hover { background: var(--bg-3); border-color: var(--stamp-red); }
.mic-btn.recording {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red-text);
  animation: pulse 1.2s ease-in-out infinite;
}
.mic-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
.mic-btn:disabled .ti-loader-2 {
  animation: spin 1s linear infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(178,58,46,0.2); }
  50%      { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(178,58,46,0); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.mic-label { font-size: 13px; color: var(--text-2); text-align: center; font-style: italic; }
.mic-label.recording { color: var(--stamp-red); font-style: normal; font-weight: 600; }

/* ── Transcript ── */
.transcript-box {
  width: 100%;
  min-height: 112px;
  background: var(--bg-2);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    var(--border) 28px
  );
  border: 1px solid var(--border);
  border-radius: var(--radius-uneven);
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 28px;
}
.transcript-placeholder { color: var(--text-3); font-style: italic; }

/* ── Output ── */
.output-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 1rem;
}
.output-label::before { content: "§ "; }
.translation-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-uneven);
  padding: 1.5rem;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  font-family: var(--font-mono);
}
.received-stamp {
  position: absolute;
  top: 3.25rem; right: 2.5rem;
  color: var(--stamp-red);
  transform: rotate(-10deg);
}

/* ── Loading dots ── */
.loading-dots { display: flex; gap: 6px; align-items: center; padding: 1rem 0; }
.loading-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.4; }
  40%          { transform: translateY(-6px); opacity: 1; }
}

/* ── Delivery ── */
.delivery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 1.5rem;
}
.delivery-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 1rem;
  border-radius: var(--radius-uneven);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  position: relative;
}
.delivery-card.active { cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.delivery-card.active:hover { background: var(--bg-3); border-color: var(--stamp-red); }
.delivery-card.active.selected {
  border: 2px solid var(--stamp-red);
  background: var(--info-bg);
}
.delivery-card.locked { opacity: 0.5; cursor: not-allowed; }
.delivery-icon { font-size: 22px; color: var(--text-2); }
.delivery-card.active.selected .delivery-icon { color: var(--stamp-red); }
.delivery-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.delivery-card.active.selected .delivery-title { color: var(--stamp-red); }
.delivery-desc { font-size: 11px; color: var(--text-2); line-height: 1.4; }
.delivery-card.active.selected .delivery-desc { color: var(--stamp-red); }
.coming-badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-3); color: var(--text-3);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}

/* ── Email form ── */
.email-form { display: flex; flex-direction: column; gap: 12px; }
.form-row   { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 12px; color: var(--text-2); }
.form-input {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-uneven);
  font-size: 14px;
  color: var(--text);
  font-family: var(--font-mono);
  width: 100%;
}
.form-input:focus { outline: none; border-color: var(--stamp-red); }
.anon-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.anon-row input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.anon-row label { font-size: 13px; color: var(--text-2); cursor: pointer; flex: 1; }
.anon-hint { font-size: 11px; color: var(--text-3); line-height: 1.5; }

.send-status { font-size: 13px; color: var(--text-2); text-align: center; padding: 8px 0; }
.send-status.success { color: var(--green-text); }
.send-status.error   { color: var(--red-text); }

/* ── No speech support ── */
.no-support { text-align: center; padding: 2rem; color: var(--text-2); font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  body { padding: 0; }
  .app { border-radius: 0; border-left: none; border-right: none; transform: none; }
  .mood-grid,
  .delivery-grid { grid-template-columns: 1fr; }
}
