/* Design: Design-neu.md, Neumorphic Tech Schematic */

@font-face {
    font-family: "Roboto";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/roboto-400.woff2") format("woff2");
}

@font-face {
    font-family: "Roboto";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/roboto-500.woff2") format("woff2");
}

@font-face {
    font-family: "Roboto";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/roboto-700.woff2") format("woff2");
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/jetbrains-mono-400.woff2") format("woff2");
}

:root {
    color-scheme: light;

    --bg: #f4f6f8;
    --surface: #f4f6f8;
    --surface-soft: #fafbfc;
    --text: #2c2c2c;
    --text-muted: #5f6670;
    --line: #c5ccd6;
    --border: rgba(44, 44, 44, 0.08);

    --accent: #eb5757;
    --accent-hover: #d84f4f;
    /* #EB5757 is too light for text on the light background, this keeps the hue at 4.8:1 contrast. */
    --accent-text: #c53a3a;
    --on-accent: #ffffff;

    --shadow-light: #ffffff;
    --shadow-dark: #d1d9e6;

    --danger: #b42318;
    --success: #1e7f4f;
    --warning: #9a6200;

    --raise: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    --raise-sm: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
    --raise-xs: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
    --inset: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    --inset-sm: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);

    --radius-sm: 20px;
    --radius-md: 40px;
    --radius-lg: 60px;
    --radius-control: 14px;
    --space: 0.5rem;

    --font: "Roboto", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

    --z-sticky: 100;
    --z-overlay: 200;
    --z-toast: 500;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(44, 44, 44, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(44, 44, 44, 0.035) 1px, transparent 1px);
    background-size: 32px 32px;
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.6;
    animation: page-in 200ms ease-out;
}

@keyframes page-in {
    from {
        opacity: 0;
    }
}

a {
    color: var(--accent-text);
    text-decoration: none;
    transition: color 200ms var(--ease);
}

a:hover {
    color: var(--danger);
    text-decoration: underline;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

h1 {
    font-size: 2.25rem;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

h3 {
    font-size: 1.125rem;
    font-weight: 500;
}

p {
    margin: 0;
    max-width: 72ch;
}

code,
.mono {
    font-family: var(--font-mono);
    font-size: 0.85em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: calc(var(--space) * 5) 1.5rem calc(var(--space) * 10);
}

.stack {
    display: grid;
    align-content: start;
    gap: calc(var(--space) * 3);
}

.stack-sm {
    display: grid;
    align-content: start;
    gap: calc(var(--space) * 1.5);
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: calc(var(--space) * 1.5);
}

.row-between {
    justify-content: space-between;
}

.grid-main {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: calc(var(--space) * 4);
    align-items: start;
}

.grid-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(var(--space) * 3);
}

.muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--danger);
}

.small {
    font-size: 0.875rem;
}

.label {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

/* Top bar */

.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--surface);
    box-shadow: 0 6px 16px rgba(209, 217, 230, 0.7), 0 -1px 0 var(--shadow-light) inset;
}

.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: calc(var(--space) * 1.5) 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: calc(var(--space) * 2);
}

.brand {
    display: flex;
    align-items: center;
    gap: calc(var(--space) * 1.25);
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}

.brand:hover {
    color: var(--text);
    text-decoration: none;
}

.brand-orb {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--raise-xs);
}

.brand-orb::after {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: var(--accent);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--space) * 0.5);
    flex: 1;
}

.nav a {
    position: relative;
    padding: calc(var(--space) * 0.75) calc(var(--space) * 1.5);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: color 200ms var(--ease), box-shadow 200ms var(--ease);
}

.nav a:hover {
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--raise-xs);
}

.nav a.is-active {
    color: var(--text);
    font-weight: 500;
    box-shadow: var(--inset-sm);
}

.nav a.is-active::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 3px;
    width: 18px;
    height: 3px;
    margin-left: -9px;
    border-radius: 3px;
    background: var(--accent);
}

.nav-badge {
    display: inline-block;
    min-width: 1.4em;
    margin-left: 0.35em;
    padding: 0 0.4em;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: calc(var(--space) * 1.5);
    font-size: 0.875rem;
}

.mode-banner {
    display: block;
    padding: 6px 1.5rem;
    background: #fff4e0;
    border-top: 1px solid #f0d9a8;
    color: var(--warning);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

.mode-banner:hover {
    color: var(--warning);
    text-decoration: none;
    background: #ffefd2;
}

/* Panels */

.panel {
    position: relative;
    padding: calc(var(--space) * 3);
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--raise);
}

.panel-highlight {
    border-top: 3px solid var(--accent);
}

.panel > h2 {
    margin-bottom: calc(var(--space) * 2);
}

.panel > h2 + p {
    margin-top: calc(var(--space) * -1);
    margin-bottom: calc(var(--space) * 2);
}

a.panel {
    display: block;
    color: inherit;
    transition: box-shadow 200ms var(--ease);
}

a.panel:hover {
    color: inherit;
    text-decoration: none;
    box-shadow: var(--raise-sm);
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: calc(var(--space) * 1.5);
    margin-bottom: calc(var(--space) * 2);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: calc(var(--space) * 2);
    margin-bottom: calc(var(--space) * 4);
}

.page-header p {
    margin-top: var(--space);
}

/* Stats */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: calc(var(--space) * 3);
}

.stat {
    padding: calc(var(--space) * 2.5);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 400;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-value small {
    font-family: var(--font);
    font-size: 1rem;
    color: var(--text-muted);
}

.meter {
    height: 8px;
    margin-top: calc(var(--space) * 1.5);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--inset-sm);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(235, 87, 87, 0.45), var(--accent));
}

/* Flow: comments to replies, the hub and spoke element of the design */

.flow {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: calc(var(--space) * 2);
    margin: 0;
    padding: calc(var(--space) * 2) 0 0;
    list-style: none;
}

.flow-step {
    position: relative;
    display: grid;
    justify-items: center;
    gap: var(--space);
    text-align: center;
}

.flow-step + .flow-step::before {
    content: "";
    position: absolute;
    top: 44px;
    right: calc(50% + 52px);
    width: calc(100% - 104px + var(--space) * 2);
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(235, 87, 87, 0.15), var(--accent));
}

.flow-node {
    display: grid;
    place-items: center;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--raise);
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-variant-numeric: tabular-nums;
}

.flow-step.is-hot .flow-node {
    color: var(--accent-text);
}

.flow-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: transform 200ms var(--ease), background-color 200ms var(--ease), box-shadow 200ms var(--ease), border-color 200ms var(--ease);
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--raise-sm);
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--on-accent);
    transform: translateY(-1px);
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
}

.btn-primary:active {
    box-shadow: var(--inset-sm);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--surface-soft);
    box-shadow: var(--raise-xs);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: rgba(180, 35, 24, 0.35);
}

.btn-danger:hover {
    color: var(--danger);
    background: #fdf0ef;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 12px;
}

.inline-form {
    display: inline;
}

/* Forms */

.field {
    display: grid;
    gap: calc(var(--space) * 0.75);
}

.field-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.input,
.textarea,
.select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-control);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--inset-sm);
    color: var(--text);
    font: inherit;
    transition: border-color 200ms var(--ease);
}

.textarea {
    min-height: 96px;
    resize: vertical;
}

.input:hover,
.textarea:hover,
.select:hover {
    border-color: var(--line);
}

.input::placeholder,
.textarea::placeholder {
    color: #8b929c;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--space);
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(var(--space) * 2);
}

.form-grid .field-wide {
    grid-column: 1 / -1;
}

.counter {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

.counter.is-over {
    color: var(--danger);
}

/* Tables */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-control);
    background: var(--surface-soft);
    box-shadow: var(--inset-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    padding: 12px 14px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background-color 200ms var(--ease);
}

.table tbody tr:hover {
    background: rgba(235, 87, 87, 0.04);
}

.cell-text {
    max-width: 38ch;
    overflow-wrap: anywhere;
}

.nowrap {
    white-space: nowrap;
}

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--raise-xs);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

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

.badge-danger {
    color: var(--danger);
}

.badge-warning {
    color: var(--warning);
}

.badge-accent {
    color: var(--accent-text);
}

/* Alerts */

.alert {
    padding: calc(var(--space) * 2) calc(var(--space) * 2.5);
    border-radius: var(--radius-control);
    border-left: 4px solid;
    background: var(--surface-soft);
    box-shadow: var(--raise-xs);
    font-size: 0.95rem;
}

.alert-success {
    border-color: var(--success);
}

.alert-danger {
    border-color: var(--danger);
}

.alert-warning {
    border-color: #e0a336;
}

.alert-info {
    border-color: var(--accent);
}

.flashes {
    position: fixed;
    top: 84px;
    right: 1.5rem;
    z-index: var(--z-toast);
    display: grid;
    gap: var(--space);
    width: min(420px, calc(100vw - 3rem));
}

.flashes .alert {
    background: var(--surface-soft);
    box-shadow: var(--raise);
    transition: opacity 300ms var(--ease), transform 300ms var(--ease);
}

.flashes .alert.is-leaving {
    opacity: 0;
    transform: translateY(-8px);
}

/* Tabs */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space);
}

.tab {
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--raise-xs);
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: box-shadow 200ms var(--ease), color 200ms var(--ease);
}

.tab:hover {
    color: var(--text);
    text-decoration: none;
}

.tab.is-active {
    color: var(--text);
    font-weight: 500;
    box-shadow: var(--inset-sm);
}

.tab.is-active::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 0.45em;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: middle;
}

/* Campaign editor */

.keyword-card {
    scroll-margin-top: 110px;
}

.keyword-title {
    display: flex;
    align-items: center;
    gap: var(--space);
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--accent-text);
}

.template {
    display: grid;
    gap: var(--space);
    padding: calc(var(--space) * 2);
    border-radius: var(--radius-control);
    background: var(--surface);
    box-shadow: var(--raise-sm);
}

.template.is-inactive {
    opacity: 0.6;
}

.template-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space);
}

.message-bubble {
    padding: calc(var(--space) * 1.5) calc(var(--space) * 2);
    border-radius: 18px 18px 18px 4px;
    background: var(--surface-soft);
    border-left: 3px solid var(--accent);
    box-shadow: var(--raise-xs);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Misc */

.empty-state {
    display: grid;
    justify-items: center;
    gap: calc(var(--space) * 1.5);
    padding: calc(var(--space) * 6) calc(var(--space) * 2);
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    padding: 14px;
    border-radius: 50%;
    box-shadow: var(--raise-sm);
    color: var(--accent);
}

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.definition {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space) calc(var(--space) * 3);
    margin: 0;
    font-size: 0.95rem;
}

.definition dt {
    color: var(--text-muted);
}

.definition dd {
    margin: 0;
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
}

.copy-field {
    display: flex;
    gap: var(--space);
}

.copy-field .input {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

details summary {
    cursor: pointer;
    color: var(--accent-text);
    font-size: 0.9rem;
    font-weight: 500;
}

details[open] summary {
    margin-bottom: calc(var(--space) * 1.5);
}

pre.context {
    margin: var(--space) 0 0;
    padding: calc(var(--space) * 1.5);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--inset-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.steps {
    margin: 0;
    padding-left: 1.25rem;
    display: grid;
    gap: var(--space);
}

.steps li::marker {
    color: var(--accent);
    font-family: var(--font-mono);
}

/* Auth and public pages */

.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.auth-panel {
    width: min(420px, 100%);
}

.auth-shell > .panel:not(.auth-panel) {
    width: min(760px, 100%);
}

.auth-panel h1 {
    font-size: 1.75rem;
}

/* Motion */

.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 420ms ease-out, transform 420ms ease-out;
    transition-delay: calc(var(--i, 0) * 80ms);
}

.reveal.is-visible {
    opacity: 1;
    transform: none;
}

.no-js .reveal {
    opacity: 1;
    transform: none;
}

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

    .reveal {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 767px) {
    h1 {
        font-size: 1.75rem;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .grid-main,
    .grid-split,
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .topbar-inner {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .nav {
        order: 3;
        flex-basis: 100%;
    }

    .user-menu .muted {
        display: none;
    }

    .definition {
        grid-template-columns: minmax(0, 1fr);
    }

    .flashes {
        right: 1rem;
        width: calc(100vw - 2rem);
    }

    .flow {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        row-gap: calc(var(--space) * 3);
    }

    .flow-step + .flow-step::before {
        display: none;
    }
}
