/* scire.dev — knowledge engineering, mid-century warm */

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

:root {
    --linen: #faf5ee;
    --walnut: #3e2723;
    --teak: #8d6e47;
    --canvas: #ffffff;
    --terracotta: #c75b39;
    --olive: #5d6e4b;
    --body: #4a4a4a;

    --teak-soft: rgba(141, 110, 71, 0.20);
    --teak-line: rgba(141, 110, 71, 0.35);
    --walnut-shadow-1: 0 2px 12px rgba(62, 39, 35, 0.08);
    --walnut-shadow-2: 0 4px 20px rgba(62, 39, 35, 0.12);
    --walnut-shadow-3: 0 10px 30px rgba(62, 39, 35, 0.14);

    --serif: "DM Serif Display", "Lora", Georgia, serif;
    --sans: "Nunito Sans", "Inter", system-ui, -apple-system, sans-serif;
    --mono: "Fira Code", "JetBrains Mono", Menlo, monospace;
}

html { scroll-behavior: smooth; }

body {
    background: var(--linen);
    color: var(--body);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

/* ---------------------- Top bar ---------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--linen);
    border-bottom: 1px solid var(--teak-soft);
    backdrop-filter: saturate(140%) blur(6px);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.5rem;
    align-items: center;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--walnut);
    text-decoration: none;
    font-family: var(--serif);
    font-size: 1.35rem;
    line-height: 1;
}

.brand-mark {
    position: relative;
    width: 24px;
    height: 24px;
    display: inline-block;
}

.brand-circle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--terracotta);
    top: 0;
    left: 0;
}

.brand-half {
    position: absolute;
    width: 16px;
    height: 8px;
    border-radius: 0 0 16px 16px;
    background: var(--olive);
    bottom: 2px;
    right: 0;
}

.brand-name { letter-spacing: 0.005em; }
.brand-dot { color: var(--terracotta); }

.tabs {
    display: flex;
    gap: 0.25rem;
    align-items: stretch;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    appearance: none;
    border: 0;
    background: transparent;
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--body);
    padding: 0.85rem 1rem 0.65rem;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 180ms ease, border-color 180ms ease;
}

.tab:hover { color: var(--walnut); }

.tab.active {
    color: var(--walnut);
    border-bottom: 3px solid var(--terracotta);
}

.search {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.search-input {
    appearance: none;
    border: 2px solid var(--teak);
    border-radius: 24px;
    padding: 0.5rem 3rem 0.5rem 2.25rem;
    background: var(--linen);
    color: var(--walnut);
    font-family: var(--sans);
    font-size: 0.9rem;
    width: 280px;
    box-shadow: inset 0 1px 2px rgba(62, 39, 35, 0.06);
    transition: border-color 180ms ease, box-shadow 180ms ease, width 220ms ease;
}

.search-input::placeholder { color: var(--teak); }

.search-input:focus {
    outline: 0;
    border-color: var(--terracotta);
    box-shadow: inset 0 1px 2px rgba(62, 39, 35, 0.06), 0 0 0 4px rgba(199, 91, 57, 0.12);
    width: 320px;
}

.search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--teak);
    display: inline-flex;
}

.search-key {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--teak);
    background: rgba(141, 110, 71, 0.10);
    border: 1px solid var(--teak-soft);
    border-radius: 6px;
    padding: 1px 6px;
}

/* ---------------------- Workspace + hero ---------------------- */

.workspace {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
}

.hero {
    position: relative;
    padding: 2.75rem 2rem 3rem;
    margin-bottom: 2rem;
    background: linear-gradient(180deg, #ffffff 0%, #fbf6ec 100%);
    border-radius: 18px;
    box-shadow: var(--walnut-shadow-1);
    overflow: hidden;
    border: 1px solid var(--teak-soft);
}

.hero-shape {
    position: absolute;
    pointer-events: none;
    opacity: 0.85;
}

.hero-shape-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--terracotta);
    top: -28px;
    right: 90px;
    opacity: 0.18;
}

.hero-shape-half {
    width: 140px;
    height: 70px;
    border-radius: 0 0 140px 140px;
    background: var(--olive);
    top: 0;
    right: -30px;
    opacity: 0.20;
}

.hero-shape-tri {
    width: 0;
    height: 0;
    border-left: 36px solid transparent;
    border-right: 36px solid transparent;
    border-bottom: 60px solid var(--teak);
    bottom: -10px;
    right: 200px;
    opacity: 0.18;
    transform: rotate(18deg);
}

.kicker {
    font-family: var(--mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--olive);
    margin-bottom: 0.85rem;
}

.display {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 3.6rem);
    line-height: 1.08;
    color: var(--walnut);
    max-width: 820px;
    margin-bottom: 1.25rem;
    letter-spacing: -0.005em;
}

.display em {
    font-style: italic;
    color: var(--terracotta);
}

.lede {
    max-width: 720px;
    color: var(--body);
    font-size: 1.05rem;
    margin-bottom: 1.75rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.25rem;
    border-radius: 24px;
    font-family: var(--sans);
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 200ms ease, background 200ms ease, color 200ms ease;
}

.cta.primary {
    background: var(--terracotta);
    color: var(--linen);
    box-shadow: 0 4px 14px rgba(199, 91, 57, 0.28);
}

.cta.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(199, 91, 57, 0.36);
}

.cta.ghost {
    background: transparent;
    color: var(--walnut);
    border: 2px solid var(--teak);
}

.cta.ghost:hover {
    background: rgba(141, 110, 71, 0.10);
}

/* ---------------------- Panels and bento grid ---------------------- */

.panel {
    display: none;
    animation: panel-in 320ms ease both;
}

.panel.active { display: block; }

@keyframes panel-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bento {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background: var(--canvas);
    border-radius: 12px;
    box-shadow: var(--walnut-shadow-1);
    padding: 1.5rem;
    position: relative;
    transition: box-shadow 220ms ease, transform 220ms ease;
}

.card:hover {
    box-shadow: var(--walnut-shadow-2);
}

.card-wide { grid-column: span 2; }

@media (max-width: 720px) {
    .card-wide { grid-column: span 1; }
}

.card-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.card-title {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    color: var(--walnut);
    line-height: 1.2;
}

.card-title code {
    font-family: var(--mono);
    font-size: 0.9em;
    color: var(--teak);
    background: rgba(141, 110, 71, 0.10);
    padding: 0.05em 0.35em;
    border-radius: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-terracotta { background: var(--terracotta); }
.dot-olive { background: var(--olive); }
.dot-teak { background: var(--teak); }

.tag {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.72rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--teak-line);
    color: var(--teak);
    background: rgba(141, 110, 71, 0.06);
}

.card p { color: var(--body); }
.card p + p { margin-top: 0.6rem; }

.card-link {
    display: inline-block;
    margin-top: 0.85rem;
    font-weight: 700;
    color: var(--terracotta);
    text-decoration: none;
    border-bottom: 1px dotted rgba(199, 91, 57, 0.4);
    padding-bottom: 1px;
    transition: color 160ms ease, border-color 160ms ease;
}

.card-link:hover {
    color: var(--walnut);
    border-bottom-color: var(--walnut);
}

/* Term tooltips */
.term {
    border-bottom: 1px dotted var(--teak);
    cursor: help;
    color: var(--walnut);
    font-weight: 600;
}

.tooltip {
    position: fixed;
    background: var(--walnut);
    color: var(--linen);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    line-height: 1.45;
    max-width: 280px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 8px 22px rgba(62, 39, 35, 0.22);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 14px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--walnut);
}

/* Bullets (warm geometric markers) */
.bullets {
    list-style: none;
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.bullets li {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    color: var(--body);
}

.bullet {
    width: 10px;
    height: 10px;
    margin-top: 0.5rem;
    flex-shrink: 0;
    background: var(--teak);
    border-radius: 50%;
}

.bullet-terracotta { background: var(--terracotta); }
.bullet-olive { background: var(--olive); border-radius: 0 0 10px 10px; height: 5px; margin-top: 0.7rem; }
.bullet-teak { background: var(--teak); transform: rotate(45deg); border-radius: 2px; }

/* Stat cards */
.card-stat {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #fbf6ec 100%);
    border: 1px solid var(--teak-soft);
}

.card-stat.alt {
    background: linear-gradient(180deg, #ffffff 0%, #f3ede1 100%);
}

.stat-label {
    font-family: var(--mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--olive);
    margin-bottom: 0.4rem;
}

.stat-value {
    font-family: var(--serif);
    font-size: clamp(2.4rem, 5vw, 3.2rem);
    line-height: 1;
    color: var(--walnut);
    margin-bottom: 0.4rem;
}

.stat-suffix {
    font-size: 0.55em;
    color: var(--teak);
    margin-left: 0.15em;
}

.stat-foot {
    color: var(--body);
    font-size: 0.9rem;
}

.trend {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--teak);
}

.trend.up { color: var(--olive); }

.card-shape {
    position: absolute;
    pointer-events: none;
}

.shape-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--terracotta);
    opacity: 0.12;
    bottom: -28px;
    right: -20px;
}

.shape-half {
    width: 110px;
    height: 55px;
    border-radius: 110px 110px 0 0;
    background: var(--olive);
    opacity: 0.16;
    bottom: 0;
    right: -20px;
}

.shape-tri {
    width: 0;
    height: 0;
    border-left: 36px solid transparent;
    border-right: 36px solid transparent;
    border-bottom: 60px solid var(--teak);
    opacity: 0.16;
    bottom: -10px;
    right: -10px;
    transform: rotate(18deg);
}

/* Concept card */
.concept-name {
    font-family: var(--serif);
    font-size: 1.5rem;
    color: var(--walnut);
    margin-top: 0.25rem;
    margin-bottom: 0.15rem;
}

.concept-class {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--teak);
    margin-bottom: 0.85rem;
}

.concept-class code {
    background: rgba(141, 110, 71, 0.10);
    padding: 0.1em 0.4em;
    border-radius: 6px;
}

/* Code blocks */
.card-code .code {
    background: #fbf6ec;
    border: 1px solid var(--teak-soft);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    margin-top: 0.6rem;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--walnut);
}

.code .kw { color: var(--terracotta); font-weight: 500; }
.code .var { color: var(--olive); }
.code .cls { color: var(--teak); }
.code .str { color: var(--olive); }
.code .num { color: var(--terracotta); }
.code .cmt { color: var(--teak); font-style: italic; opacity: 0.9; }

pre.code { white-space: pre; }
pre.code code { font-family: inherit; }

/* People list */
.people {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.4rem;
}

.people li {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--av, var(--teak));
    color: var(--linen);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--sans);
    font-weight: 700;
    font-size: 0.78rem;
    position: relative;
}

.avatar::before {
    content: attr(data-initial);
}

.who { display: flex; flex-direction: column; line-height: 1.35; }
.who strong { color: var(--walnut); font-weight: 700; }
.who span { font-size: 0.88rem; color: var(--body); }
.who em { color: var(--teak); font-style: normal; font-family: var(--mono); font-size: 0.85em; }

.when {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--teak);
}

/* Schema rows */
.schema {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.schema-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    background: #fbf6ec;
    border: 1px solid var(--teak-soft);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 0.85rem;
}

.schema-row .cls { color: var(--walnut); }
.schema-row .prop { color: var(--terracotta); }
.schema-row .arrow { color: var(--teak); }

/* Tree */
.tree {
    list-style: none;
    margin-top: 0.4rem;
    font-family: var(--mono);
    font-size: 0.88rem;
    line-height: 1.9;
    color: var(--walnut);
}

.tree ul {
    list-style: none;
    padding-left: 1.1rem;
    border-left: 1px dashed var(--teak-line);
    margin-left: 0.3rem;
}

.tree code {
    color: var(--walnut);
    background: rgba(141, 110, 71, 0.08);
    padding: 0.05em 0.4em;
    border-radius: 6px;
}

/* Validation checks */
.checks {
    list-style: none;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checks li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--body);
}

.check {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--olive);
    flex-shrink: 0;
    position: relative;
}

.check::after {
    content: "";
    position: absolute;
    inset: 3px;
    background: var(--linen);
    border-radius: 50%;
}

.checks .warn .check { background: var(--terracotta); }

/* Saved queries list */
.qlist {
    list-style: none;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.qlist li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: background 160ms ease, border-color 160ms ease;
}

.qlist li:hover {
    background: #fbf6ec;
    border-color: var(--teak-soft);
}

.qlist code {
    font-family: var(--mono);
    font-size: 0.88rem;
    color: var(--walnut);
}

.qmeta {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--teak);
}

/* Result table */
.result {
    margin-top: 0.4rem;
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-size: 0.85rem;
}

.result th {
    text-align: left;
    color: var(--teak);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--teak-soft);
}

.result td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--teak-soft);
    color: var(--walnut);
}

.result tr:last-child td { border-bottom: 0; }

.result code {
    background: rgba(141, 110, 71, 0.08);
    padding: 0.05em 0.4em;
    border-radius: 6px;
}

/* Notebook */
.nb-cell {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 0.6rem;
    margin-top: 0.85rem;
}

.nb-prompt {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--terracotta);
    padding-top: 0.85rem;
    text-align: right;
}

.nb-prompt.out { color: var(--olive); }

.nb-cell.out .nb-text {
    background: rgba(93, 110, 75, 0.08);
    border: 1px solid rgba(93, 110, 75, 0.25);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    color: var(--walnut);
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.7;
}

/* Notes */
.notes {
    list-style: decimal;
    padding-left: 1.2rem;
    margin-top: 0.4rem;
    color: var(--body);
}

.notes li { margin-bottom: 0.55rem; }
.notes li::marker { color: var(--terracotta); font-weight: 700; }

/* Exports */
.exports {
    list-style: none;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.exports li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: #fbf6ec;
    border: 1px solid var(--teak-soft);
}

.ex-format { font-family: var(--mono); font-size: 0.88rem; color: var(--walnut); font-weight: 500; }
.ex-size { font-family: var(--mono); font-size: 0.78rem; color: var(--teak); }

/* Timeline */
.timeline {
    list-style: none;
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline li {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 1rem;
    align-items: start;
}

.ver {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--linen);
    background: var(--walnut);
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    text-align: center;
    line-height: 1.3;
    font-weight: 500;
}

.ver-title {
    font-family: var(--serif);
    font-size: 1.1rem;
    color: var(--walnut);
    margin-bottom: 0.15rem;
}

.timeline li > div p:not(.ver-title) { color: var(--body); font-size: 0.95rem; }

/* Footer */
.foot {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--teak-soft);
}

.foot-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.85rem;
    color: var(--body);
    font-size: 0.88rem;
}

.foot-brand {
    font-family: var(--serif);
    font-size: 1.1rem;
    color: var(--walnut);
}

.foot-meaning em {
    font-family: var(--serif);
    font-style: italic;
    color: var(--teak);
}

.foot-meta {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--teak);
}

/* ---------------------- Responsive tweaks ---------------------- */

@media (max-width: 900px) {
    .topbar-inner {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .search { width: 100%; }
    .search-input { width: 100%; }
    .search-input:focus { width: 100%; }
    .tabs { padding-bottom: 0.25rem; }
}

@media (max-width: 560px) {
    .workspace { padding: 1.25rem 1rem 3rem; }
    .hero { padding: 2rem 1.25rem 2.25rem; }
    .timeline li { grid-template-columns: 1fr; }
    .ver { width: max-content; }
    .nb-cell { grid-template-columns: 1fr; }
    .nb-prompt { text-align: left; padding-top: 0; }
}

/* ---------------------- Reduced motion ---------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .card:hover { box-shadow: var(--walnut-shadow-1); }
}
