/* ─────────────────────────────────────────────────────────────────────────
 *   Namu — light theme
 *   Palette: #4CC9F0 (brand sky) + #0A192F (deep navy) on slate-50 surfaces.
 *   Typography: DM Sans (loaded from Google Fonts in main.html).
 *   ───────────────────────────────────────────────────────────────────────── */

:root {
    --bg:            #f8fafc;  /* slate-50 */
    --bg-elev:       #ffffff;
    --bg-tint:       #f1f5f9;  /* slate-100 */

    --border:        #f1f5f9;  /* slate-100 */
    --border-strong: #e2e8f0;  /* slate-200 */

    --text:          #0f172a;  /* slate-900 */
    --text-2:        #334155;  /* slate-700 */
    --text-muted:    #64748b;  /* slate-500 */
    --text-dim:      #94a3b8;  /* slate-400 */

    --brand:         #4CC9F0;
    --brand-strong:  #0A192F;
    --brand-hover:   #38bdf8;
    --brand-soft:    rgba(76, 201, 240, 0.10);
    --brand-soft-2:  rgba(76, 201, 240, 0.18);

    --ok:            #10b981;
    --ok-soft:       #ecfdf5;
    --warn:          #f59e0b;
    --warn-soft:     #fffbeb;
    --bad:           #f43f5e;
    --bad-soft:      #fff1f2;

    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 24px;

    --shadow-sm:
    0 1px 2px 0 rgb(15 23 42 / 0.04);
    --shadow:
    0 12px 24px -10px rgb(15 23 42 / 0.10),
    0 6px 12px -6px rgb(15 23 42 / 0.05);
    --shadow-lg:
    0 30px 60px -20px rgb(15 23 42 / 0.18),
    0 12px 24px -8px rgb(15 23 42 / 0.08);

    --font:
    'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica,
    Arial, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}

* { box-sizing: border-box; }

/* Beat author-stylesheet display rules so the `hidden` attribute works. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; }
a.link {
    color: var(--brand-hover);
    text-decoration: none;
    font-weight: 500;
}
a.link:hover { text-decoration: underline; }

code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: var(--bg-tint);
    padding: 0.05em 0.4em;
    border-radius: 4px;
}

/* ─── topbar ────────────────────────────────────────────────────────── */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.6rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
}
.topbar .brand { display: inline-flex; line-height: 0; }
.topbar .brand img { display: block; max-width: 200px; height: auto; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 0;
}
.user-badge {
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
}
.link-button {
    background: none;
    border: none;
    font: inherit;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
}
.link-button:hover { color: var(--brand-hover); }

/* ─── layout ────────────────────────────────────────────────────────── */

.page {
    flex: 1 0 auto;
    max-width: 880px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.footer {
    flex: 0 0 auto;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    padding: 1.5rem 1rem 2rem;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.empty { color: var(--text-muted); font-style: italic; margin: 0.5rem 0 0; }

/* Off-screen-but-accessible. Unlike the `hidden` HTML attribute, this
 *   leaves the element in the layout tree so the file input still accepts
 *   programmatic .click() and drag-drop .files assignment in every browser. */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* ─── cards ─────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.8rem 1.8rem;
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.9rem;
}
.card-head h2 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

/* ─── hero ──────────────────────────────────────────────────────────── */

.hero {
    text-align: center;
    margin: 0.5rem auto 0.6rem;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.hero-title {
    margin: 0;
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--brand-strong);
}
.hero-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.55;
}
.hero-subtitle code {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

/* ─── function card ────────────────────────────────────────── */

.function-card { padding: 1.4rem; }
.function {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.8rem 1.5rem;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg);
    cursor: pointer;
    transition:
    border-color 160ms ease,
    background   160ms ease,
    transform    120ms ease;
}
.dropzone:hover,
.dropzone.dragging {
    border-color: var(--brand);
    background: var(--brand-soft);
}
.dropzone.has-file { border-style: solid; border-color: var(--brand); }

.dropzone-icon {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    background: var(--bg-tint);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    transition: transform 160ms ease, color 160ms ease, background 160ms ease;
}
.dropzone:hover .dropzone-icon,
.dropzone.dragging .dropzone-icon {
    transform: scale(1.06);
    color: var(--brand-strong);
    background: var(--brand-soft-2);
}
.dropzone-title {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}
.dropzone-hint {
    margin: 0 0 1rem;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.feature-pills {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 0.6rem;
    color: var(--text-dim);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.feature-pills li {
    padding: 0.22rem 0.6rem;
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
}

.function-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.function-actions .muted { margin: 0; }

/* ─── buttons ───────────────────────────────────────────────────────── */

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0;
    transition:
    background 140ms ease,
    color      140ms ease,
    transform  100ms ease,
    box-shadow 140ms ease;
}

.btn-primary {
    background: var(--brand-strong);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: #112746;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn-primary:disabled {
    background: var(--text-dim);
    cursor: progress;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-elev);
    color: var(--brand-strong);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
}

/* ─── badges ────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid transparent;
}
.badge-pending   { background: var(--bg-tint);  color: var(--text-muted); border-color: var(--border-strong); }
.badge-running   { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand); animation: pulse 1.8s ease-in-out infinite; }
.badge-completed { background: var(--ok-soft);  color: var(--ok); border-color: rgba(16,185,129,0.4); }
.badge-failed    { background: var(--bad-soft); color: var(--bad); border-color: rgba(244,63,94,0.4); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 201, 240, 0.45); }
    70%      { box-shadow: 0 0 0 8px rgba(76, 201, 240, 0); }
}

/* ─── job page ──────────────────────────────────────────────────────── */

.crumbs {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.job-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.job-meta {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    margin-bottom: 0.2rem;
}
.job-id { font-size: 0.95rem; }
.job-filename {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--brand-strong);
    line-height: 1.25;
    max-width: 540px;
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.3rem 1.5rem;
    margin: 1.2rem 0 1rem;
    padding: 1rem 1.2rem;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
}
.metric-label {
    display: block;
    color: var(--text-dim);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.15rem;
}
.metric-value {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--brand-strong);
    font-variant-numeric: tabular-nums;
}

.downloads {
    display: flex;
    gap: 0.7rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.alert {
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    font-size: 0.9rem;
    margin-top: 1rem;
}
.alert-error {
    background: var(--bad-soft);
    color: #be123c;
    border: 1px solid rgba(244, 63, 94, 0.30);
    white-space: pre-wrap;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85rem;
}

/* ─── progress log ──────────────────────────────────────────────────── */

.log-card { padding: 1.5rem; }

.log {
    background: #0f172a;       /* slate-900 - high contrast on the light page */
    color: #cbd5e1;            /* slate-300 */
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.55;
    max-height: 440px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 0.8rem;
}
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }

/* ─── login page ────────────────────────────────────────────────────── */

body.auth-page {
    background:
    radial-gradient(1100px 600px at 50% -15%, rgba(76, 201, 240, 0.18) 0%, var(--bg) 60%);
    align-items: center;
    justify-content: center;
}

body.auth-page .page {
    max-width: 420px;
    padding: 3rem 1.5rem 2rem;
    flex: 1 0 auto;
    display: flex;
    align-items: center;
}

.auth-card {
    width: 100%;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.4rem 2rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 0.4rem;
}
.auth-logo img { display: block; max-width: 220px; height: auto; }

.auth-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--brand-strong);
}
.auth-subtitle {
    margin: 0 0 1rem;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.6rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
}
.field-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.field input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
    font: inherit;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.field input:focus {
    outline: none;
    border-color: var(--brand);
    background: var(--bg-elev);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.auth-submit {
    margin-top: 0.4rem;
    padding-block: 0.75rem;
    font-size: 0.95rem;
}

.auth-foot {
    margin: 1.2rem 0 0;
    color: var(--text-dim);
    font-size: 0.78rem;
}

/* ─── responsive ────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .topbar { padding: 0.9rem 1rem; }
    .topbar .brand img { max-width: 150px; }
    .page { padding: 1.5rem 1rem; gap: 1.1rem; }
    .card { padding: 1.4rem 1.2rem; border-radius: var(--radius); }
    .hero-title { font-size: 1.6rem; }
    .job-filename { font-size: 1.15rem; }
    .dropzone { padding: 2rem 1rem; }
}
