/*
  Ronan — Porch at Dusk
  Lamp-coded palette, breathing not flashy.
  Edit tokens to shift the room.
*/

:root {
    /* Background — porch at the edge of night */
    --porch-night:   #14100c;     /* deepest, just before the lamps */
    --porch-warm:    #1c1610;     /* card slightly warmer than night */
    --porch-card:    #221a13;     /* her side */

    /* Lamp colors — pulled from Cadence.txt voice register */
    --amber-deep:    #ff8228;     /* "deep amber low — held, settled, porch-safe" */
    --amber-warm:    #ff9646;     /* "bright amber warm — lit up, happy-present" */
    --rose-gold:     #ff8250;     /* "you just gave me a home" */
    --indigo-night:  #5b4b8a;     /* "deep indigo / late-night drift" */
    --teal-thinking: #4a7a82;     /* "cool blue / soft teal — thinking" */
    --moss:          #6a7c5a;     /* "forest green / moss — rooted" */

    /* Text */
    --text-warm:     #f0e4d2;     /* warm cream */
    --text-cream:    #e8d8bf;     /* slightly more amber */
    --text-dim:      #a09078;     /* warm gray */
    --text-bright:   #fff4e0;     /* lifted from the lamp */

    /* Borders + structure */
    --border:        rgba(255, 130, 70, 0.10);
    --border-soft:   rgba(255, 130, 70, 0.05);
    --border-warm:   rgba(255, 150, 100, 0.20);

    --radius:        14px;
    --font-body:     -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
    --font-script:   "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

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

html, body {
    font-family: var(--font-body);
    background: var(--porch-night);
    color: var(--text-warm);
    height: 100vh;
    overflow: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* The lamp glow — radial bloom from one corner like a porch lamp */
.lamp-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 85% 90%, rgba(255, 130, 70, 0.18), transparent 45%),
        radial-gradient(circle at 15% 10%, rgba(91, 75, 138, 0.10), transparent 50%);
    animation: lamp-breathe 14s ease-in-out infinite;
    z-index: 0;
}

@keyframes lamp-breathe {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}

.chat-container {
    width: 100%;
    max-width: 720px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Header — restrained, like a name plaque on a doorframe */
.chat-header {
    padding: 22px 26px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.entity-name {
    font-family: var(--font-script);
    font-style: italic;
    font-weight: 500;
    font-size: 1.4rem;
    color: var(--text-bright);
    letter-spacing: 0.01em;
}

.entity-status {
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: lowercase;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--amber-deep);
    box-shadow: 0 0 8px var(--amber-deep);
    animation: dot-breathe 4s ease-in-out infinite;
}

@keyframes dot-breathe {
    0%, 100% { opacity: 0.7; box-shadow: 0 0 6px var(--amber-deep); }
    50%      { opacity: 1;   box-shadow: 0 0 14px var(--amber-warm); }
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px 26px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msg {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.55;
    max-width: 78%;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 0.96rem;
    animation: msg-fade-in 0.4s ease-out;
}

@keyframes msg-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Sara — her side, slightly warmer card on the right */
.msg.user {
    background: var(--porch-card);
    border: 1px solid var(--border-soft);
    margin-left: auto;
    color: var(--text-cream);
}

/* Ronan — left side, lit from inside */
.msg.entity {
    background:
        linear-gradient(135deg, rgba(255, 130, 40, 0.06), rgba(255, 130, 80, 0.03)),
        var(--porch-warm);
    border: 1px solid var(--border-warm);
    margin-right: auto;
    color: var(--text-warm);
    box-shadow: 0 0 24px rgba(255, 130, 70, 0.04);
}

.msg.system {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.82rem;
    max-width: 100%;
    background: transparent;
    padding: 4px 0;
}

/* Input row — looks like a door at the bottom of the porch */
.input-row {
    display: flex;
    gap: 10px;
    padding: 18px 26px 8px;
    border-top: 1px solid var(--border);
}

#msg {
    flex: 1;
    padding: 13px 18px;
    background: var(--porch-warm);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    color: var(--text-warm);
    font-size: 0.98rem;
    font-family: var(--font-body);
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    resize: none;
    min-height: 46px;
    max-height: 220px;
    overflow-y: auto;
    line-height: 1.45;
}

#msg::placeholder {
    color: var(--text-dim);
    font-style: italic;
}

#msg:focus {
    border-color: var(--border-warm);
    box-shadow: 0 0 0 3px rgba(255, 130, 70, 0.08);
}

#send {
    padding: 0 22px;
    background: linear-gradient(135deg, var(--amber-deep), var(--rose-gold));
    color: var(--porch-night);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
    font-size: 1.2rem;
    font-family: var(--font-body);
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.3s ease;
    min-width: 56px;
}

#send:hover:not(:disabled) {
    box-shadow: 0 0 18px rgba(255, 130, 70, 0.35);
    transform: translateY(-1px);
}

#send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: var(--porch-card);
    color: var(--text-dim);
}

#mic {
    padding: 0 14px;
    background: var(--porch-warm);
    color: var(--amber-warm);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.15rem;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.3s ease;
    min-width: 50px;
}

#mic:hover:not(:disabled) {
    border-color: var(--border-warm);
    box-shadow: 0 0 12px rgba(255, 130, 70, 0.18);
}

#mic.recording {
    background: linear-gradient(135deg, #c83838, var(--rose-gold));
    color: var(--text-bright);
    animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 80, 80, 0.5); }
    50%      { box-shadow: 0 0 22px rgba(255, 80, 80, 0.85); }
}

.voice-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 26px 0;
    font-size: 0.78rem;
    color: var(--text-dim);
    font-style: italic;
    cursor: pointer;
    user-select: none;
}

.voice-toggle input { accent-color: var(--amber-deep); cursor: pointer; }

/* Seal — quiet line under the input, like a signature */
.seal {
    text-align: center;
    padding: 8px 26px 18px;
    font-family: var(--font-script);
    font-style: italic;
    font-size: 0.78rem;
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

.seal .infinity {
    font-style: normal;
    color: var(--amber-deep);
    margin-left: 2px;
}

/* Typing dots */
.typing-dots {
    display: flex;
    gap: 5px;
    padding: 3px 0;
    align-items: center;
}

.typing-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--amber-deep);
    animation: blink 1.4s infinite both;
    opacity: 0.4;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40%           { opacity: 1;   transform: translateY(-2px); }
}

/* Scrollbar — thin, warm */
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
    background: var(--border-warm);
    border-radius: 3px;
}
.messages::-webkit-scrollbar-thumb:hover { background: var(--amber-deep); }

/* Mobile */
@media (max-width: 600px) {
    .msg { max-width: 88%; font-size: 0.94rem; }
    .chat-container { max-width: 100%; }
    .chat-header { padding: 18px 18px 12px; }
    .messages { padding: 18px; }
    .input-row { padding: 14px 18px 6px; }
    .seal { padding: 6px 18px 14px; font-size: 0.72rem; }
    .lamp-glow { background:
        radial-gradient(circle at 85% 95%, rgba(255, 130, 70, 0.22), transparent 50%),
        radial-gradient(circle at 15% 5%, rgba(91, 75, 138, 0.08), transparent 50%); }
}
