/* ============================================
   anjaneya — Styles
   Warm identity, open writing space.
   ============================================ */

:root {
    /* Header — South Asian warmth */
    --turmeric: #d4952e;
    --turmeric-light: #e8b44e;
    --turmeric-glow: #f5d690;
    --mustard: #c4880f;
    --header-from: #c47e1c;
    --header-mid: #d4952e;
    --header-to: #e2b54e;

    /* Page */
    --bg: #f7f5f2;
    --bg-writing: #fdfcfa;
    --text: #2d2a26;
    --text-soft: #73695e;
    --text-faint: #a89e93;
    --text-ghost: #c9c1b8;

    /* Accents */
    --sea: #5a9e92;
    --sea-bg: #e6f0ee;
    --coral: #c95a4a;

    /* Fonts */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Nunito', -apple-system, sans-serif;

    /* Radius */
    --radius: 16px;
    --radius-sm: 12px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Page layout
   ============================================ */

.page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
}

/* ============================================
   Header — turmeric gradient
   ============================================ */

.header {
    background: linear-gradient(135deg, var(--header-from) 0%, var(--header-mid) 45%, var(--header-to) 100%);
    padding: 28px 24px 20px;
    position: relative;
    overflow: hidden;
}

/* Subtle light texture */
.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 30%, rgba(255,255,255,0.05) 0%, transparent 40%);
    pointer-events: none;
}

/* Soft bleed into page */
.header::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, var(--header-to), var(--bg));
    opacity: 0.6;
}

.name-header {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: 1.6rem;
    color: white;
    text-align: center;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 8px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
    margin-bottom: 18px;
}

/* ============================================
   Mode toggle
   ============================================ */

.mode-toggle {
    display: flex;
    position: relative;
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 24px;
    padding: 3px;
    z-index: 1;
}

.mode-option {
    flex: 1;
    text-align: center;
    padding: 9px 16px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 21px;
    position: relative;
    z-index: 1;
    transition: color 0.35s ease;
    -webkit-tap-highlight-color: transparent;
}

.mode-option.active {
    color: var(--mustard);
}

.mode-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: white;
    border-radius: 21px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mode-slider.letter {
    transform: translateX(100%);
}

/* ============================================
   Content area
   ============================================ */

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 20px 16px;
}

/* ============================================
   Media actions
   ============================================ */

.media-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.media-action {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    border: 1.5px dashed var(--text-ghost);
    border-radius: 24px;
    background: transparent;
    color: var(--text-soft);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.media-action:active {
    background: rgba(212, 149, 46, 0.08);
    border-color: var(--turmeric-light);
    color: var(--turmeric);
}

.media-action svg {
    flex-shrink: 0;
    opacity: 0.65;
}

/* ============================================
   Photo preview
   ============================================ */

.photo-preview {
    position: relative;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    animation: fadeUp 0.3s ease;
}

.photo-preview img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
}

.remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.4);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ============================================
   Audio preview
   ============================================ */

.audio-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--sea-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    animation: fadeUp 0.3s ease;
}

.audio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sea);
    animation: pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

.audio-preview span {
    font-size: 0.84rem;
    color: var(--text-soft);
    flex: 1;
}

.audio-preview .remove-btn {
    position: static;
    background: transparent;
    color: var(--text-faint);
    width: 26px;
    height: 26px;
    font-size: 1rem;
}

/* ============================================
   Recording state
   ============================================ */

.recording-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 13px;
    background: #fdf0ee;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    animation: fadeUp 0.2s ease;
}

.rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--coral);
    animation: pulse-rec 1s ease-in-out infinite;
}

.rec-time {
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
}

.rec-stop {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 16px;
    border: 1.5px solid var(--coral);
    border-radius: 20px;
    background: transparent;
    color: var(--coral);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   Writing area
   ============================================ */

.writing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.writing-area textarea {
    width: 100%;
    min-height: 100px;
    max-height: 50vh;
    padding: 18px 20px;
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg-writing);
    border: none;
    border-radius: var(--radius);
    resize: none;
    outline: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    transition: box-shadow 0.3s ease;
    overflow-y: auto;
}

.writing-area textarea::placeholder {
    color: var(--text-ghost);
    font-weight: 400;
    font-style: italic;
}

.writing-area textarea:focus {
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* Letter mode — warmer writing area */
.page.letter-mode .writing-area textarea {
    background: #fffaf2;
    box-shadow: 0 1px 6px rgba(196, 136, 15, 0.06);
}

/* ============================================
   Send button — below textarea, right-aligned
   ============================================ */

.send-row {
    display: flex;
    justify-content: flex-end;
    padding-top: 14px;
}

.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--turmeric);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 14px rgba(212, 149, 46, 0.35);
}

.send-btn:disabled {
    opacity: 0.25;
    box-shadow: none;
    cursor: default;
}

.send-btn:not(:disabled):active {
    transform: scale(0.9);
}

.send-btn svg {
    margin-left: 2px;
    margin-top: -1px;
}

.send-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ============================================
   Toast
   ============================================ */

.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-16px);
    background: var(--text);
    color: white;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
    z-index: 200;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-sparkle {
    color: var(--turmeric-glow);
}

/* ============================================
   Login page
   ============================================ */

.login-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.login-hint {
    font-size: 0.9rem;
    color: var(--text-soft);
    margin-bottom: 20px;
    line-height: 1.5;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text);
    background: var(--bg-writing);
    border: none;
    border-radius: var(--radius-sm);
    outline: none;
    text-align: center;
    margin-bottom: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.login-input:focus {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.login-input::placeholder {
    color: var(--text-ghost);
}

.login-btn {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 32px;
    border: none;
    border-radius: 24px;
    background: var(--turmeric);
    color: white;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(212, 149, 46, 0.3);
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.login-btn:active {
    transform: scale(0.96);
}

.login-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.login-msg {
    font-size: 0.84rem;
    color: var(--text-soft);
    margin-top: 16px;
    min-height: 1.4em;
    line-height: 1.5;
}

.login-msg--ok {
    color: var(--sea);
}

.login-msg--debug a {
    color: var(--turmeric);
    text-decoration: underline;
}

/* ============================================
   Animations
   ============================================ */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@keyframes pulse-rec {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Safe area for notched phones
   ============================================ */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .content {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}
