/**
 * Arc Browser Receiver — Dark theme matching desktop app.
 *
 * Colour palette from docs/Arc_Design.md Section A3.
 * All text/background combinations WCAG AA compliant (4.5:1 minimum).
 * No emoji, no frosted glass, no ambient canvas.
 *
 * Typography: system font stack (Phase 1).
 * Max-width: 480px centred (matching desktop app window).
 * Responsive: works on mobile browsers.
 */

/* =========================================================================
   CSS Custom Properties
   ========================================================================= */

:root {
    /* Background & Surface */
    --bg: #0C1117;
    --surface: #141C24;
    --surface-elevated: #1C2630;
    --divider: rgba(255, 255, 255, 0.06);

    /* Text */
    --text-primary: #E8ECF0;
    --text-body: #B8C4D0;
    --text-secondary: #8A9AAA;
    --text-disabled: #4A5668;

    /* Accent */
    --primary: #1B4D3E;
    --interactive: #2A6B54;
    --success: #52A880;
    --active: #4A9ECC;
    --warning: #D4943A;
    --destructive-text: #D86E5F;
    --destructive-btn: #943F35;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.1, 1);
    --transition-fast: 0.2s var(--ease);
    --transition-normal: 0.3s var(--ease);
}

/* =========================================================================
   Reset & Base
   ========================================================================= */

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text-body);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================================================
   Layout
   ========================================================================= */

.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =========================================================================
   Screens — visibility
   ========================================================================= */

.screen {
    display: none;
    flex-direction: column;
    flex: 1;
    opacity: 0;
    transition: opacity 0.25s var(--ease);
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* =========================================================================
   Branding
   ========================================================================= */

.brand {
    text-align: center;
    padding: 40px 0 32px;
}

.brand-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 2px;
}

.brand-tagline {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* =========================================================================
   Headings
   ========================================================================= */

.heading {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.heading-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.heading-success {
    color: var(--success);
}

/* Section labels: 11px uppercase */
.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* =========================================================================
   Code Input (B1)
   ========================================================================= */

.code-input-group {
    margin-bottom: 20px;
}

.code-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-elevated);
    border: 1px solid var(--divider);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 400;
    text-align: center;
    letter-spacing: 2px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.code-input::placeholder {
    color: var(--text-disabled);
    letter-spacing: 1px;
    font-size: 14px;
}

.code-input:focus {
    border-color: var(--interactive);
    outline: 2px solid var(--interactive);
    outline-offset: 2px;
}

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), opacity var(--transition-fast);
    min-height: 44px;
    min-width: 44px;
}

.btn:focus-visible {
    outline: 2px solid var(--interactive);
    outline-offset: 2px;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-primary);
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--interactive);
}

.btn-primary.connecting {
    opacity: 0.7;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.5; }
}

.btn-secondary {
    background: var(--surface-elevated);
    color: var(--text-body);
    border: 1px solid var(--divider);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface);
    border-color: var(--interactive);
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

/* =========================================================================
   Error Display
   ========================================================================= */

.error-message {
    display: none;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: rgba(212, 148, 58, 0.08);
    border-radius: 4px;
}

/* =========================================================================
   Upgrade Prompt
   ========================================================================= */

.upgrade-prompt {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 24px;
}

.upgrade-prompt a {
    color: var(--success);
    text-decoration: none;
}

.upgrade-prompt a:hover {
    text-decoration: underline;
}

.upgrade-prompt a:focus-visible {
    outline: 2px solid var(--interactive);
    outline-offset: 2px;
}

/* =========================================================================
   Footer
   ========================================================================= */

.footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 24px 0 16px;
    margin-top: auto;
    border-top: 1px solid var(--divider);
}

/* =========================================================================
   Progress Bar (B2)
   ========================================================================= */

.progress-container {
    margin: 20px 0;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--surface-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* =========================================================================
   Transfer Metadata (B2)
   ========================================================================= */

.transfer-meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.meta-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.meta-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-body);
}

.meta-value-mono {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-primary);
}

/* =========================================================================
   File List (B3)
   ========================================================================= */

.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--surface);
    border-radius: 6px;
    gap: 12px;
}

.file-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.file-notice {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* =========================================================================
   Honest Limitation Note (B3) — always visible, not dismissible
   ========================================================================= */

.limitation-note {
    padding: 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--interactive);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 16px;
}

/* =========================================================================
   View-Only Notice (B3) — shown when ViewOnly policy active
   ========================================================================= */

.view-only-notice {
    display: none;
    padding: 10px 12px;
    color: var(--text-body);
    font-size: 13px;
    margin-bottom: 12px;
}

/* =========================================================================
   Receiver Timer (B3)
   ========================================================================= */

.receiver-timer {
    display: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: right;
    transition: color 0.5s var(--ease);
}

/* =========================================================================
   Preview Overlay
   ========================================================================= */

.preview-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(12, 17, 23, 0.95);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.preview-header {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    max-width: 800px;
    margin-bottom: 12px;
}

.preview-close {
    background: var(--surface-elevated);
    border: 1px solid var(--divider);
    color: var(--text-body);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    min-height: 36px;
}

.preview-close:hover {
    background: var(--surface);
    border-color: var(--interactive);
}

.preview-close:focus-visible {
    outline: 2px solid var(--interactive);
    outline-offset: 2px;
}

.preview-container {
    width: 100%;
    max-width: 800px;
    max-height: calc(100vh - 120px);
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-image {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border-radius: 4px;
}

.preview-pdf {
    width: 100%;
    height: calc(100vh - 120px);
    border: none;
    border-radius: 4px;
}

.preview-text {
    width: 100%;
    max-height: calc(100vh - 120px);
    overflow: auto;
    padding: 16px;
    background: var(--surface);
    border-radius: 6px;
    color: var(--text-body);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
}

/* =========================================================================
   Expired State
   ========================================================================= */

.expired-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    gap: 8px;
}

.expired-heading {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.expired-subtext {
    font-size: 13px;
    color: var(--text-secondary);
}

/* =========================================================================
   Browser Unsupported State
   ========================================================================= */

.unsupported-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    gap: 12px;
    padding: 40px 20px;
}

.unsupported-heading {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.unsupported-body {
    font-size: 14px;
    color: var(--text-body);
    max-width: 360px;
}

.unsupported-features {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 4px;
}

/* =========================================================================
   Success Indicator (B3 heading)
   ========================================================================= */

.success-check {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--success);
    position: relative;
}

.success-check::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid var(--bg);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 520px) {
    .app-container {
        padding: 16px;
    }

    .brand {
        padding: 24px 0 20px;
    }

    .code-input {
        font-size: 18px;
        padding: 12px 14px;
    }

    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .file-item .btn {
        width: 100%;
    }
}

/* =========================================================================
   Noscript Styling
   ========================================================================= */

.noscript-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
    color: var(--text-body);
    font-family: var(--font-sans);
    font-size: 16px;
    text-align: center;
    padding: 20px;
}
