/* ===================================================================
   CRISPR-Cas Finder — Full Human Design System
   =================================================================== */

/* --- Design tokens ------------------------------------------------- */
:root {
    --bg-page: #ffffff;
    --bg-surface: #ffffff;
    --bg-subtle: #fafafa;

    --text-primary: #171717; /* neutral-900 */
    --text-secondary: #525252; /* neutral-600 */
    --text-tertiary: #737373; /* neutral-500 */
    --text-disabled: #a3a3a3; /* neutral-400 */

    --border-default: #e5e5e5; /* neutral-200 */
    --border-subtle: #f5f5f5; /* neutral-100 */

    --accent: #22c55e; /* green-500 */
    --accent-hover: #16a34a; /* green-600 */
    --accent-subtle: #f0fdf4; /* green-50 */

    --positive-bg: #ecfdf5;
    --positive-border: #a7f3d0;
    --positive-text: #047857;

    --negative-bg: #fef2f2;
    --negative-border: #fecaca;
    --negative-text: #b91c1c;

    --font-sans: "Geist", system-ui, -apple-system, sans-serif;
    --font-mono: "Geist Mono", ui-monospace, Menlo, Monaco, monospace;

    --radius-card: 12px;
    --radius-input: 0;
    --radius-btn: 0;

    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #000000;
        --bg-surface: #171717;
        --bg-subtle: #0a0a0a;

        --text-primary: #fafafa;
        --text-secondary: #a3a3a3;
        --text-tertiary: #737373;
        --text-disabled: #525252;

        --border-default: #262626;
        --border-subtle: #171717;

        --accent: #4ade80;
        --accent-hover: #22c55e;
        --accent-subtle: #052e16;

        --positive-bg: #022c22;
        --positive-border: #065f46;
        --positive-text: #6ee7b7;

        --negative-bg: #450a0a;
        --negative-border: #991b1b;
        --negative-text: #fca5a5;
    }
}

/* --- Reset & base -------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

body {
    margin: 0;
    color: var(--text-primary);
    background: var(--bg-page);
    font-family: var(--font-sans);
    font-weight: 300;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
    ::selection {
        background: rgba(255, 255, 255, 0.12);
    }
}

*:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: 3px;
}

/* --- Header -------------------------------------------------------- */
.browser-notice {
    background: #fef9c3;
    color: #713f12;
    border-bottom: 1px solid #fde68a;
    text-align: center;
    padding: 10px 24px;
    font-size: 0.875rem;
}

@media (prefers-color-scheme: dark) {
    .browser-notice {
        background: #422006;
        color: #fde68a;
        border-bottom-color: #713f12;
    }
}

/* --- Info notice --------------------------------------------------- */
.info-notice {
    background: #eff6ff;
    color: #1e3a8a;
    border-bottom: 1px solid #bfdbfe;
    padding: 12px 24px;
    font-size: 0.875rem;
}

@media (prefers-color-scheme: dark) {
    .info-notice {
        background: #0f172a;
        color: #93c5fd;
        border-bottom-color: #1d4ed8;
    }
}

.info-notice-inner {
    width: min(1280px, 100%);
    margin: 0 auto;
}

.info-notice p {
    margin: 0;
    line-height: 1.6;
}

.info-notice a {
    color: inherit;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

.info-notice a:hover {
    opacity: 0.75;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-subtle);
    height: 64px;
    display: flex;
    align-items: center;
}

@media (prefers-color-scheme: dark) {
    .site-header {
        background: rgba(0, 0, 0, 0.9);
    }
}

.header-inner {
    width: min(1280px, 100%);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wordmark {
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.header-tag {
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* --- Layout -------------------------------------------------------- */
.layout {
    width: min(860px, 100%);
    margin: 0 auto;
    padding: 48px 24px 96px;
    display: grid;
    gap: 24px;
}

@media (min-width: 1024px) {
    .layout {
        padding: 64px 48px 128px;
        gap: 32px;
    }
}

/* --- Hero ---------------------------------------------------------- */
.hero {
    padding: 32px 0 16px;
}

.hero h1 {
    margin: 0;
    font-size: clamp(1.875rem, 4vw, 3rem);
    font-weight: 200;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: var(--text-primary);
}

.hero-sub {
    margin: 12px 0 0;
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 576px;
}

/* --- Panels -------------------------------------------------------- */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    padding: 24px;
    min-width: 0;
    overflow: hidden;
    animation: fadeIn 500ms ease-out;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

/* Section heading — "detail" style from design system */
.detail {
    margin: 0;
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-disabled);
}

.section-heading {
    margin-top: 24px;
}

.block-label {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* --- FASTA textarea ------------------------------------------------ */
.fasta {
    width: 100%;
    min-height: 200px;
    resize: vertical;
    border: 1px solid var(--border-default);
    border-radius: 0;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-page);
    transition: border-color 300ms ease;
}

.fasta:focus {
    border-color: var(--text-primary);
    outline: none;
}

/* --- File upload row ----------------------------------------------- */
.file-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

#fasta-file {
    display: none;
}

.file-name {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* --- Options grid -------------------------------------------------- */
.grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 640px) {
    .grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    font-weight: 300;
    color: var(--text-secondary);
}

.grid input[type="number"] {
    border: 1px solid var(--border-default);
    border-radius: 0;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-page);
    transition: border-color 300ms ease;
}

.grid input[type="number"]:focus {
    border-color: var(--text-primary);
    outline: none;
}

.checkbox {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    cursor: pointer;
}

.checkbox input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* --- Actions ------------------------------------------------------- */
.actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* --- Buttons ------------------------------------------------------- */
.btn-primary {
    display: inline-block;
    padding: 12px 32px;
    background: var(--text-primary);
    color: var(--bg-page);
    border: none;
    border-radius: var(--radius-btn);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 300ms ease;
}

.btn-primary:not(:disabled):hover {
    opacity: 0.8;
}

.btn-secondary,
.file-label {
    display: inline-block;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-btn);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition:
        border-color 300ms ease,
        color 300ms ease;
}

.btn-secondary:hover,
.file-label:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-outline {
    display: inline-block;
    padding: 12px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-btn);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 300ms ease;
}

.btn-outline:not(:disabled):hover {
    border-color: var(--text-primary);
    background: var(--text-primary);
    color: var(--bg-page);
}

button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* --- Status panel -------------------------------------------------- */
.status-panel {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 400;
}

.status-panel.ok {
    background: var(--positive-bg);
    border-color: var(--positive-border);
    color: var(--positive-text);
}

.status-panel.error {
    background: var(--negative-bg);
    border-color: var(--negative-border);
    color: var(--negative-text);
}

.hidden {
    display: none;
}

/* --- Results ------------------------------------------------------- */
.summary {
    margin: 0;
    font-size: 14px;
    font-weight: 300;
    color: var(--text-tertiary);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    overflow: hidden;
    min-width: 0;
    background: var(--border-default);
}

/* --- Result row (summary) ------------------------------------------ */
.result-row {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--bg-surface);
    cursor: pointer;
    user-select: none;
    transition: background 200ms ease;
}

.result-row:hover {
    background: var(--bg-subtle);
}

.result-row[aria-expanded="true"] {
    background: var(--bg-subtle);
}

.result-badge {
    display: inline-block;
    padding: 3px 0;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
    border-radius: 2px;
}

.result-badge.crispr {
    color: var(--accent);
    background: var(--accent-subtle);
}

.result-badge.cas {
    color: var(--positive-text);
    background: var(--positive-bg);
}

.result-title {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
}

.result-subtitle {
    font-size: 13px;
    font-weight: 300;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.result-chevron {
    font-size: 14px;
    color: var(--text-disabled);
    transition: transform 250ms ease;
}

.result-row[aria-expanded="true"] .result-chevron {
    transform: rotate(90deg);
}

/* --- Result detail (expandable) ------------------------------------ */
.result-detail {
    display: none;
    background: var(--bg-subtle);
    padding: 0 20px;
}

.result-detail[aria-hidden="false"] {
    display: block;
    padding: 16px 20px 20px;
}

.result-detail,
.result-row {
    min-width: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px 24px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-disabled);
}

.detail-value {
    font-size: 14px;
    font-weight: 300;
    color: var(--text-primary);
}

.detail-value.mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

.detail-value.seq {
    font-family: var(--font-mono);
    font-size: 12px;
    word-break: break-all;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* --- Gene sub-table ------------------------------------------------ */
.gene-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 12px;
    table-layout: fixed;
}

.gene-table th,
.gene-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.gene-table th {
    background: transparent;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-disabled);
}

.gene-table td {
    font-weight: 300;
    color: var(--text-secondary);
}

.gene-table td:nth-child(2),
.gene-table td:nth-child(3) {
    font-family: var(--font-mono);
    font-size: 12px;
}

.gene-table td:nth-child(4) {
    font-family: var(--font-mono);
    font-size: 12px;
}

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

/* --- References panel ---------------------------------------------- */
.references-panel .detail {
    margin-bottom: 12px;
}

.references-intro {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 300;
    color: var(--text-secondary);
}

.references-list {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.references-list li {
    font-size: 13px;
    font-weight: 300;
    line-height: 1.65;
    color: var(--text-secondary);
}

.references-list li em {
    font-style: italic;
    color: var(--text-primary);
}

.references-list a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
    white-space: nowrap;
}

.references-list a:hover {
    color: var(--text-primary);
}

/* --- Footer -------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 32px 24px;
    text-align: center;
}

.site-footer p {
    margin: 0;
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 0.05em;
    color: var(--text-disabled);
}

/* --- Animation ----------------------------------------------------- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* --- Responsive ---------------------------------------------------- */
@media (max-width: 639px) {
    .layout {
        padding: 32px 16px 64px;
        gap: 16px;
    }

    .panel {
        padding: 16px;
    }

    .hero h1 {
        font-size: 1.5rem;
    }
}
