/*
 * Notation: the PolyEmbed design system. See DESIGN.md.
 * Warm ink on warm paper, Swiss grid, one rule: colour carries data, not decoration.
 * Shared by the landing page and the app shell.
 */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    --bg: #F5F3EE;
    --surface: #ECE9E2;
    --border: #DCD7CD;
    --rule: #1D1B18;
    --text: #1D1B18;
    --text-2: #57534C;
    --text-3: #6E695F;
    --accent: #1D1B18;
    --on-accent: #F5F3EE;
    /* The highlighter from the original landing page: selection and the one highlighted point. */
    --marker: #F1E38A;
    --on-marker: #1D1B18;

    /* Data: the only colour. Diverging around a neutral cell, for vectors. */
    --neg: #2B59C3;
    --pos: #D1495B;
    --neg-tint: #8FA9E6;
    --pos-tint: #EE97A1;
    --cell: #EAE6DE;

    /* Categorical series, for charts with several keys (validated, fixed order). */
    --series-1: #2A78D6;
    --series-2: #EB6834;
    --series-3: #1BAF7A;
    --series-4: #EDA100;
    --series-5: #E87BA4;
    --series-6: #008300;

    /* State. Errors keep red; success and information speak in ink. */
    --red: #B3321F;
    --red-bg: #F6E3DC;
    --green: var(--text);
    --green-bg: var(--surface);
    --blue: var(--text);
    --blue-bg: var(--surface);
    --amber: var(--text);
    --amber-bg: var(--surface);

    --display: "Funnel Display", "Helvetica Neue", Arial, sans-serif;
    --sans: "Funnel Sans", "Helvetica Neue", Arial, sans-serif;
    --mono: "Azeret Mono", ui-monospace, "SF Mono", Menlo, monospace;
    /* Older templates name the body face --serif. */
    --serif: var(--sans);

    --wrap: 1280px;
    --gutter: 40px;
    color-scheme: light;
}

.dark {
    --bg: #171513;
    --surface: #201D1A;
    --border: #36322C;
    --rule: #EDE8DF;
    --text: #EDE8DF;
    --text-2: #B3ACA1;
    --text-3: #958E83;
    --accent: #EDE8DF;
    --on-accent: #171513;
    --marker: #E3CF6B;
    --on-marker: #171513;

    --neg-tint: #34497F;
    --pos-tint: #84383F;
    --cell: #24211D;

    --series-1: #3987E5;
    --series-2: #D95926;
    --series-3: #199E70;
    --series-4: #C98500;
    --series-5: #D55181;
    --series-6: #008300;

    --red: #F0806A;
    --red-bg: #2E1A15;
    color-scheme: dark;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 400 16px/1.55 var(--sans);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
::selection { background: var(--marker); color: var(--on-marker); }
code { font: 400 0.84em var(--mono); padding: 1px 5px; background: var(--surface); border: 1px solid var(--border); }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--text-2); }
.nb { white-space: nowrap; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ── Logo ───────────────────────────────────────────────────────────────── */
.logo { display: block; height: 26px; width: auto; color: var(--text); }
.mark { display: block; width: 1em; height: 1em; }

/* ── Navigation ─────────────────────────────────────────────────────────── */
.site-nav .wrap { display: flex; align-items: center; gap: 28px; height: 68px; }
.site-nav .brand { margin-right: auto; display: flex; align-items: center; }
.site-nav .links { display: flex; align-items: center; gap: 26px; font-size: 15px; font-weight: 500; }
.site-nav .links a:not(.btn):hover, .site-nav .links a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 6px; }
.site-nav .user { font-family: var(--mono); font-size: 13px; font-weight: 400; color: var(--text-2); }
.theme-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.theme-btn:hover { color: var(--text); }
.theme-btn [data-theme-icon] { font-family: system-ui, sans-serif; }

/* ── Buttons and links ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px;
    font: 600 15px/1 var(--sans); white-space: nowrap; cursor: pointer;
    background: var(--accent); color: var(--on-accent); border: 0; box-shadow: inset 0 0 0 1.5px var(--accent);
}
.btn:hover { background: var(--bg); color: var(--text); }
.btn-quiet, .btn.ghost { background: transparent; color: var(--text); }
.btn-quiet:hover, .btn.ghost:hover { background: var(--accent); color: var(--on-accent); }
.btn-danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1.5px var(--red); }
.btn-danger:hover { background: var(--red); color: var(--bg); }
.btn:disabled, .btn:disabled:hover { opacity: 0.4; cursor: not-allowed; background: transparent; color: var(--text); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.text-action { font-size: 14px; font-weight: 500; color: var(--red); }
.text-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.link { text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text); }

/* ── App page structure ─────────────────────────────────────────────────── */
.app-main { padding-bottom: 112px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 48px 0 8px; }
.crumb { font-size: 14px; font-weight: 500; color: var(--text-2); }
.crumb a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.title { font: 700 clamp(36px, 4vw, 52px)/0.95 var(--display); letter-spacing: -0.04em; }
.title-row { display: flex; align-items: baseline; gap: 16px; margin-top: 6px; }
.lede { margin-top: 16px; max-width: 34em; font-size: 18px; line-height: 1.5; color: var(--text-2); }

.section { margin-top: 64px; }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { font: 700 26px/1.1 var(--display); letter-spacing: -0.03em; }
.section-note { margin-top: 6px; max-width: 46em; font-size: 15px; color: var(--text-2); }

.panel { background: var(--bg); border: 1px solid var(--border); }
.panel-pad { padding: 20px 24px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.input {
    display: block; width: 100%; height: 44px; padding: 0 12px;
    font: 16px var(--sans); color: var(--text); background: var(--bg);
    border: 0; border-radius: 0; box-shadow: inset 0 0 0 1px var(--border);
}
.input.mono { font-family: var(--mono); font-size: 14px; }
.input:hover { box-shadow: inset 0 0 0 1px var(--text-3); }
.input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--text); }
select.input { appearance: none; padding-right: 36px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23707070' stroke-width='1.5'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center; }
.hint { margin-top: 6px; font-size: 14px; color: var(--text-2); }
.hint ul { padding-left: 1.1em; }
.error { margin-top: 6px; font-size: 14px; color: var(--red); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row .field { flex: 1 1 160px; }
input[type="range"] { accent-color: var(--text); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; padding: 12px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: baseline; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface); }
.table .end, .table .num { text-align: right; }
.scroll-x { overflow-x: auto; }

/* ── Roles: told apart by shape, not colour ─────────────────────────────── */
.role { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text-2); }
.role::before { content: ""; width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text); }
.role-owner::before { background: var(--text); }
.role-admin::before { background: linear-gradient(90deg, var(--text) 50%, transparent 50%); }

/* ── Segmented control ──────────────────────────────────────────────────── */
.seg { display: inline-flex; box-shadow: inset 0 0 0 1px var(--border); }
.seg > * { font-size: 13.5px; font-weight: 500; line-height: 1.2; color: var(--text-2); padding: 7px 12px; }
.seg > *:hover { color: var(--text); }
.seg > [aria-pressed="true"], .seg > [aria-current="true"] { background: var(--accent); color: var(--on-accent); }

/* ── Figures ────────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 16px 24px; }
.stat-val { font: 400 22px/1.1 var(--mono); letter-spacing: -0.03em; }
.stat-key { margin-top: 6px; font-size: 13.5px; color: var(--text-2); }

/* ── Notices ────────────────────────────────────────────────────────────── */
.notice { padding: 14px 16px; font-size: 15px; box-shadow: inset 3px 0 0 var(--text); background: var(--surface); }
.notice-error { color: var(--red); background: var(--red-bg); box-shadow: inset 3px 0 0 var(--red); }
.messages { display: grid; gap: 8px; padding-top: 20px; }

/* Narrow single-form pages (log in, sign up, new team) */
.narrow { max-width: 420px; margin: 72px auto 0; }
.narrow .field + .field { margin-top: 20px; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-foot { font-size: 14px; color: var(--text-2); }
.site-foot .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-top: 22px; padding-bottom: 28px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 22px; }
.site-foot a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.site-foot .by { display: flex; align-items: center; gap: 10px; }
.site-foot .by .mark { font-size: 18px; color: var(--text); }

/* ── Vector field: 768 values tinted by sign and size ───────────────────── */
.vfield { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 1px; font: 400 10.5px/1 var(--mono); }
.vfield span {
    padding: 6px 0 5px; text-align: center; cursor: crosshair;
    --pole: var(--pos-tint);
    background: color-mix(in oklab, var(--pole) calc(var(--t, 0) * 100%), var(--cell));
    transition: background-color 0.35s;
}
.vfield span.n { --pole: var(--neg-tint); }
.vfield span:hover { outline: 1.5px solid var(--text); outline-offset: -1.5px; }
.vlegend { display: inline-flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--text-2); }
.vlegend i { width: 120px; height: 10px; background: linear-gradient(90deg, var(--neg-tint), var(--cell), var(--pos-tint)); }

/* ── Switch ─────────────────────────────────────────────────────────────── */
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.switch i { width: 38px; height: 22px; border-radius: 11px; box-shadow: inset 0 0 0 1.5px var(--text); position: relative; flex: none; }
.switch i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform 0.18s; }
.switch[aria-checked="true"] i { background: var(--text); }
.switch[aria-checked="true"] i::after { background: var(--bg); transform: translateX(16px); }

@media (max-width: 1000px) {
    .vfield { grid-template-columns: repeat(12, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    :root { --gutter: 20px; }
    .site-nav .wrap { gap: 16px; }
    .site-nav .links { gap: 16px; }
    .site-nav .hide-sm, .theme-btn [data-theme-label] { display: none; }
    .page-head { flex-direction: column; align-items: flex-start; padding-top: 32px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .vfield { grid-template-columns: repeat(8, minmax(0, 1fr)); }
    .logo { height: 22px; }
}
