/*
 * saidify site-specific layer.
 * Brand tokens (--gleif-*, --color-*, --font-*) come from tokens.css, which
 * loads before this file. No hardcoded hexes here — reference tokens or use
 * color-mix for tints. FLAG: marks values the brand deck does not cover.
 */

:root {
    /* FLAG: component spec — brand deck does not define a radius scale */
    --radius: 4px;
    --radius-lg: 8px;

    /* FLAG: brand deck has no mono stack */
    --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;

    /* FLAG: surface layering — brand deck gives --color-bg/surface only;
       we derive deeper surfaces from cyprus mixed with white */
    --color-surface-2: color-mix(in srgb, var(--gleif-cyprus) 6%, var(--color-bg));
    --color-surface-3: color-mix(in srgb, var(--gleif-cyprus) 12%, var(--color-bg));
    --color-border: color-mix(in srgb, var(--gleif-cyprus) 18%, var(--color-bg));
    --color-hover: color-mix(in srgb, var(--gleif-jade) 10%, var(--color-bg));

    /* State colors — map to brand where possible, FLAG where not */
    --color-success: var(--gleif-jade);        /* FLAG: no success token; jade reads as affirmative */
    --color-warning: var(--gleif-honey);
    --color-error: var(--gleif-lava);
    --color-info: var(--gleif-azure);

    /* FLAG: no shadow scale in brand; use cyprus-tinted translucency */
    --shadow-sm: 0 2px 8px color-mix(in srgb, var(--gleif-cyprus) 12%, transparent);
    --shadow-md: 0 4px 16px color-mix(in srgb, var(--gleif-cyprus) 18%, transparent);
}

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

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: var(--line-height-body);
}

/* Header */
header {
    background: var(--color-surface);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

header .logo {
    width: 40px;
    height: 40px;
}

header h1 {
    font-size: var(--font-size-h3);
    color: var(--color-accent-deep);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.1em;
    line-height: var(--line-height-heading);
}

header .subtitle {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--color-border);
}

/* Main */
main {
    flex: 1;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* Footer */
footer {
    background: var(--color-surface);
    padding: 0.75rem 2rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

footer code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-accent-deep);
}

/* Form */
.saidify-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--color-surface);
    padding: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.form-label {
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    font-size: var(--font-size-sm);
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
    border-color: var(--color-accent-mid);
    background: var(--color-hover);
    outline: none;
}

.drop-text {
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.drop-text code {
    font-family: var(--font-mono);
    color: var(--color-accent-deep);
}

.drop-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.json-input {
    width: 100%;
    min-height: 220px;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    resize: vertical;
    tab-size: 2;
}

.json-input:focus {
    outline: none;
    border-color: var(--color-accent-mid);
}

.upload-error {
    color: var(--color-error);
    font-size: var(--font-size-sm);
}

.upload-error:empty {
    display: none;
}

.json-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

.form-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.label-select {
    padding: 0.4rem 0.6rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.label-select:focus {
    outline: none;
    border-color: var(--color-accent-mid);
}

.checkbox-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.checkbox-control input[type="checkbox"] {
    accent-color: var(--color-accent-mid);
    cursor: pointer;
}

.primary-btn {
    margin-left: auto;
    padding: 0.5rem 1.5rem;
    background: var(--color-accent-mid);
    color: var(--color-text-inverse);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-body);
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--color-accent-deep);
}

.primary-btn:disabled {
    background: var(--color-text-muted);
    cursor: not-allowed;
}

/* Result */
.result-section {
    min-height: 8rem;
}

.result-placeholder {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    background: var(--color-surface-2);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
}

.result-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    background: var(--color-bg);
}

.badge code {
    font-family: var(--font-mono);
    color: var(--color-accent-deep);
}

.said-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-accent-deep);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.copy-btn {
    padding: 0.35rem 0.75rem;
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-btn:hover {
    background: var(--color-accent-mid);
    border-color: var(--color-accent-mid);
    color: var(--color-text-inverse);
}

.copy-btn.copied {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-text-inverse);
}

.result-output {
    margin: 0;
    padding: 1rem;
    background: var(--color-bg);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    white-space: pre;
}

.result-output code {
    font-family: inherit;
    color: var(--color-text);
}

/* Error — saturated brand fill, white text (brand rule 5) */
.error-card {
    background: var(--gleif-lava);
    color: var(--color-text-inverse);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

/* HTMX loading indicator */
.htmx-request .primary-btn {
    opacity: 0.7;
    pointer-events: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-surface);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 700px) {
    main {
        padding: 1rem;
    }

    header {
        padding: 1rem;
    }

    .form-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .primary-btn {
        margin-left: 0;
    }

    .result-header {
        flex-wrap: wrap;
    }
}
