:root {
    --bg: #ffffff;
    --text: #000000;
    --muted: #666666;
    --accent: #000000;
    --border: #e5e5e5;
    --max-width: 900px;
    --rhythm: 16px;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --text: #ffffff;
        --muted: #999999;
        --accent: #ffffff;
        --border: #222222;
    }
}

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    * {
        animation: none !important;
        transition: none !important;
    }
}

body {
    font-family: var(--font-mono);
    font-weight: 400;
    line-height: 1.8;
    color: var(--text);
    background-color: var(--bg);
    min-height: 100vh;
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-mono);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 calc(var(--rhythm) * 2);
}

@media (max-width: 768px) {
    .container {
        padding: 0 var(--rhythm);
    }
}

/* Navigation */
.nav {
    padding: calc(var(--rhythm) * 3) 0;
    border-bottom: 1px solid var(--border);
}

.nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 400;
    display: inline-flex;
    align-items: center;
}

.logo-image {
    height: 32px;
    width: auto;
    display: block;
}

.nav-links {
    display: flex;
    gap: calc(var(--rhythm) * 3);
    list-style: none;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.nav-link:hover,
.nav-link--active {
    color: var(--text);
}

.nav-link--active {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.nav-link:focus-visible {
    outline: 1px solid var(--text);
    outline-offset: 4px;
}

/* Hero */
.hero {
    padding: calc(var(--rhythm) * 8) 0 calc(var(--rhythm) * 6);
}

.hero-title {
    font-size: 2.5rem;
    margin-bottom: var(--rhythm);
    font-weight: 400;
}

.hero-role {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: calc(var(--rhythm) * 2);
}

.hero-sub {
    font-size: 1rem;
    max-width: 600px;
    margin: 0 0 calc(var(--rhythm) * 2);
    color: var(--text);
    line-height: 1.8;
}

.hero-cta {
    display: inline-block;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    padding: calc(var(--rhythm) * 1) calc(var(--rhythm) * 2);
    border: 1px solid var(--text);
    margin-bottom: calc(var(--rhythm) * 4);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.hero-cta:hover {
    background-color: var(--text);
    color: var(--bg);
}

/* KPI Badges */
.kpi-badges {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: calc(var(--rhythm) * 3);
    padding-top: calc(var(--rhythm) * 2);
}

.kpi-badge {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Sections */
.section-title {
    font-size: 1.5rem;
    margin-bottom: calc(var(--rhythm) * 4);
    font-weight: 400;
}

.pip {
    display: none;
}

.values,
.work-preview,
.logos,
.timeline,
.capabilities,
.cases {
    padding: calc(var(--rhythm) * 6) 0;
}

.work-preview {
    background: transparent;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

/* Value Cards */
.values-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: calc(var(--rhythm) * 4);
}

.value-card {
    padding: 0;
}

.value-title {
    font-size: 1.125rem;
    margin-bottom: var(--rhythm);
    font-weight: 400;
}

.value-text {
    color: var(--muted);
    line-height: 1.8;
    font-size: 0.875rem;
}

/* Work Grid */
.work-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: calc(var(--rhythm) * 2);
}

.work-tile {
    display: block;
    padding: calc(var(--rhythm) * 2) 0;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: opacity 0.2s;
}

.work-tile:last-child {
    border-bottom: none;
}

.work-tile:hover {
    opacity: 0.7;
}

.work-tile-content {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.work-tile-title {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.work-tile-meta {
    color: var(--muted);
    font-size: 0.75rem;
}

.work-tile-cta {
    color: var(--muted);
    font-size: 0.875rem;
}

/* Logos */
.logos-row {
    display: flex;
    gap: calc(var(--rhythm) * 4);
    flex-wrap: wrap;
}

.logo-item {
    font-size: 0.875rem;
    color: var(--muted);
}

/* Page Headers */
.page-title {
    font-size: 2rem;
    margin-bottom: calc(var(--rhythm) * 2);
}

.page-sub {
    font-size: 0.875rem;
    color: var(--muted);
    max-width: 600px;
    line-height: 1.8;
}

.work-hero,
.about-hero {
    padding: calc(var(--rhythm) * 6) 0 calc(var(--rhythm) * 4);
}

/* Cases */
.case-block {
    margin-bottom: calc(var(--rhythm) * 2);
}

.case-details {
    border: 1px solid var(--border);
    margin-bottom: var(--rhythm);
}

.case-summary {
    padding: calc(var(--rhythm) * 2);
    cursor: pointer;
    display: block;
    width: 100%;
    text-align: left;
    list-style: none;
}

.case-summary::-webkit-details-marker {
    display: none;
}

.case-summary::before {
    content: '[+] ';
    color: var(--muted);
}

.case-details[open] .case-summary::before {
    content: '[-] ';
}

.case-summary:hover {
    background: rgba(0, 0, 0, 0.02);
}

@media (prefers-color-scheme: dark) {
    .case-summary:hover {
        background: rgba(255, 255, 255, 0.02);
    }
}

.case-summary:focus-visible {
    outline: 1px solid var(--text);
    outline-offset: -1px;
}

.case-header {
    display: inline;
}

.case-title {
    font-size: 1rem;
    display: inline;
    margin-right: var(--rhythm);
}

.case-meta {
    color: var(--muted);
    font-size: 0.75rem;
    display: inline;
}

.case-metrics {
    margin-top: var(--rhythm);
    display: flex;
    gap: calc(var(--rhythm) * 2);
}

.case-metric {
    font-size: 0.75rem;
    color: var(--muted);
}

.case-content {
    padding: 0 calc(var(--rhythm) * 2) calc(var(--rhythm) * 2);
}

.case-section-title {
    font-size: 0.875rem;
    margin: calc(var(--rhythm) * 2) 0 var(--rhythm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.case-text {
    color: var(--muted);
    margin-bottom: var(--rhythm);
    font-size: 0.875rem;
    line-height: 1.8;
}

.case-list {
    color: var(--muted);
    margin: var(--rhythm) 0;
    padding-left: calc(var(--rhythm) * 2);
    font-size: 0.875rem;
    list-style-type: '- ';
}

.case-link {
    color: var(--text);
    font-size: 0.875rem;
    margin-top: var(--rhythm);
    display: inline-block;
}

.case-link:hover {
    text-decoration: underline;
}

/* Bio */
.bio-content {
    max-width: 600px;
}

.bio-text {
    font-size: 0.875rem;
    line-height: 1.8;
    margin-bottom: calc(var(--rhythm) * 2);
}

/* Companies */
.companies-hero,
.companies-list,
.companies-cta {
    padding: calc(var(--rhythm) * 6) 0;
}

.company-block {
    padding: calc(var(--rhythm) * 4) 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: calc(var(--rhythm) * 2);
}

.company-block:last-child {
    border-bottom: none;
}

.company-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: calc(var(--rhythm) * 2);
}

.company-name {
    font-size: 1.5rem;
    margin-bottom: 0;
}

.company-status {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.company-description {
    font-size: 0.875rem;
    line-height: 1.8;
    margin-bottom: calc(var(--rhythm) * 3);
    max-width: 700px;
}

.company-metrics {
    display: flex;
    gap: calc(var(--rhythm) * 3);
    flex-wrap: wrap;
    margin-bottom: calc(var(--rhythm) * 3);
}

.company-metric {
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.company-details {
    margin-bottom: calc(var(--rhythm) * 3);
    max-width: 700px;
}

.detail-title {
    font-size: 0.875rem;
    margin: calc(var(--rhythm) * 2) 0 var(--rhythm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.detail-text {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.8;
    margin-bottom: calc(var(--rhythm) * 2);
}

.detail-list {
    list-style: none;
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.8;
    margin-bottom: calc(var(--rhythm) * 2);
}

.detail-list li {
    padding-left: calc(var(--rhythm) * 2);
    position: relative;
}

.detail-list li::before {
    content: '- ';
    position: absolute;
    left: 0;
}

.company-links {
    display: flex;
    gap: calc(var(--rhythm) * 2);
    flex-wrap: wrap;
}

.company-link {
    color: var(--text);
    font-size: 0.875rem;
    text-decoration: none;
}

.company-link:hover {
    text-decoration: underline;
}

/* Work Sections */
.work-section {
    padding: calc(var(--rhythm) * 6) 0;
}

.work-section:not(:first-child) {
    border-top: 1px solid var(--border);
}

.section-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: calc(var(--rhythm) * 4);
    margin-top: calc(var(--rhythm) * -2);
}

@media (max-width: 768px) {
    .company-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .company-metrics {
        flex-direction: column;
        gap: var(--rhythm);
    }
    
    .company-links {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Timeline */
.timeline {
    background: transparent;
    border-top: 1px solid var(--border);
}

.timeline-items {
    max-width: 600px;
}

.timeline-item {
    display: flex;
    gap: calc(var(--rhythm) * 3);
    padding: calc(var(--rhythm) * 2) 0;
    border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-item::before {
    display: none;
}

.timeline-year {
    font-size: 0.75rem;
    color: var(--muted);
    min-width: 80px;
    padding-top: 2px;
}

.timeline-content {
    flex: 1;
}

.timeline-role {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.timeline-text {
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.6;
}

.timeline-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.timeline-list li {
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    position: relative;
}

.timeline-list li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--text);
}

/* Capabilities */
.capabilities-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: calc(var(--rhythm) * 4);
    max-width: 600px;
}

@media (max-width: 600px) {
    .capabilities-grid {
        grid-template-columns: 1fr;
    }
}

.capability-group {
    padding: 0;
    background: transparent;
    border: none;
    clip-path: none;
}

.capability-title {
    font-size: 0.875rem;
    margin-bottom: var(--rhythm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.capability-list {
    list-style: none;
    font-size: 0.75rem;
    line-height: 2;
}

.capability-list li {
    color: var(--muted);
    padding-left: 0;
}

.capability-list li::before {
    display: none;
}

/* Contact CTA */
.contact-cta,
.cta-section {
    padding: calc(var(--rhythm) * 6) 0;
    border-top: 1px solid var(--border);
}

.cta-card {
    padding: 0;
    background: transparent;
    border: none;
    text-align: left;
    clip-path: none;
}

.cta-title {
    font-size: 1.5rem;
    margin-bottom: var(--rhythm);
    background: none;
    -webkit-text-fill-color: var(--text);
}

.cta-text {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: calc(var(--rhythm) * 2);
    max-width: none;
}

.cta-actions {
    display: flex;
    gap: calc(var(--rhythm) * 2);
    margin-bottom: calc(var(--rhythm) * 2);
}

/* Buttons */
.btn {
    padding: calc(var(--rhythm) * 0.75) calc(var(--rhythm) * 2);
    font-size: 0.75rem;
    text-decoration: none;
    border: 1px solid var(--text);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: opacity 0.2s;
}

.btn--primary {
    background: var(--text);
    color: var(--bg);
}

.btn--primary:hover {
    opacity: 0.8;
    transform: none;
    box-shadow: none;
}

.btn--secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--text);
}

.btn--secondary:hover {
    opacity: 0.6;
    background: transparent;
    color: var(--text);
}

.btn:focus-visible {
    outline: 1px solid var(--text);
    outline-offset: 2px;
}

/* Contact Links */
.contact-links {
    display: flex;
    gap: calc(var(--rhythm) * 2);
}

.contact-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.75rem;
}

.contact-link:hover {
    color: var(--text);
    text-decoration: underline;
}

.contact-link::after {
    display: none;
}

/* Footer */
.footer {
    background: transparent;
    padding: calc(var(--rhythm) * 4) 0;
    border-top: 1px solid var(--border);
    margin-top: calc(var(--rhythm) * 6);
}

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

.footer-left {
    color: var(--muted);
    font-size: 0.75rem;
}

.footer-right {
    display: flex;
    gap: calc(var(--rhythm) * 2);
}

.footer-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.75rem;
}

.footer-link:hover {
    color: var(--text);
    text-decoration: underline;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }
    
    .hero {
        padding: calc(var(--rhythm) * 4) 0;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .kpi-badges {
        grid-template-columns: 1fr;
        gap: var(--rhythm);
    }
    
    .nav-links {
        gap: calc(var(--rhythm) * 1.5);
    }
    
    .logos-row {
        flex-direction: column;
        gap: var(--rhythm);
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-right {
        justify-content: center;
    }
    
    .timeline-item {
        flex-direction: column;
        gap: var(--rhythm);
    }
    
    .case-metrics {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .cta-actions {
        flex-direction: column;
        width: fit-content;
    }
    
    .contact-links {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Typing Animations */
.typing-cursor {
    animation: blink 1.2s step-end infinite;
}

.typing-complete {
    animation: fadeOut 0.5s ease-out forwards;
}

.cursor-blink::after {
    content: '█';
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes fadeOut {
    to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .typing-cursor,
    .cursor-blink::after {
        animation: none !important;
    }
    
    .typing-complete {
        opacity: 0 !important;
    }
}

/* Terminal loading states */
.kpi-value {
    min-height: 1.5rem;
    transition: opacity 0.3s;
}

/* Utility */
*:focus-visible {
    outline: 1px solid var(--text);
    outline-offset: 2px;
}

::selection {
    background: var(--text);
    color: var(--bg);
}

@media print {
    body {
        background: white;
        color: black;
    }

    .nav,
    .footer,
    .cta-section,
    .contact-cta {
        display: none;
    }
}

/* AI Chat Widget */
#ai-chat-widget {
    position: fixed;
    bottom: calc(var(--rhythm) * 2);
    right: calc(var(--rhythm) * 2);
    z-index: 9999;
}

.ai-chat-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    padding: calc(var(--rhythm) * 0.75) calc(var(--rhythm) * 1.5);
    border-radius: 24px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    animation: pulse-glow 3s ease-in-out infinite;
}

.ai-chat-toggle-icon {
    display: inline-block;
    animation: sparkle 2s ease-in-out infinite;
}

.ai-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.ai-chat-toggle:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.6);
    }
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.1) rotate(10deg);
    }
}

.ai-chat-panel {
    position: fixed;
    right: calc(var(--rhythm) * 2);
    bottom: calc(var(--rhythm) * 6);
    width: min(400px, calc(100vw - var(--rhythm) * 4));
    max-height: 560px;
    background: var(--bg);
    border: 1px solid var(--border);
    flex-direction: column;
    font-family: var(--font-mono);
}

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--rhythm) * 1.5);
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.ai-chat-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
}

.ai-chat-close:hover {
    opacity: 0.6;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: calc(var(--rhythm) * 1.5);
    display: flex;
    flex-direction: column;
    gap: calc(var(--rhythm) * 1);
    min-height: 320px;
    max-height: 400px;
}

.ai-chat-message {
    padding: calc(var(--rhythm) * 0.75) calc(var(--rhythm) * 1);
    border-radius: 4px;
    max-width: 85%;
    font-size: 0.75rem;
    line-height: 1.8;
    word-wrap: break-word;
    white-space: normal;
}

.ai-chat-message strong {
    font-weight: 600;
    color: inherit;
}

.ai-chat-message em {
    font-style: italic;
}

.ai-chat-message code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.ai-chat-message br {
    display: block;
    content: "";
    margin: 0.25rem 0;
}

@media (prefers-color-scheme: dark) {
    .ai-chat-message code {
        background: rgba(255, 255, 255, 0.1);
    }
}

.ai-chat-message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

.ai-chat-message-user code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.ai-chat-message-assistant {
    align-self: flex-start;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.ai-chat-input-wrapper {
    display: flex;
    gap: calc(var(--rhythm) * 0.75);
    padding: calc(var(--rhythm) * 1.5);
    border-top: 1px solid var(--border);
}

.ai-chat-input {
    flex: 1;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: calc(var(--rhythm) * 0.75) calc(var(--rhythm) * 1);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.ai-chat-input::placeholder {
    color: var(--muted);
}

.ai-chat-input:focus {
    outline: 1px solid var(--text);
}

.ai-chat-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    padding: calc(var(--rhythm) * 0.75) calc(var(--rhythm) * 1.5);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-chat-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.ai-chat-send:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

@media (max-width: 768px) {
    #ai-chat-widget {
        bottom: var(--rhythm);
        right: var(--rhythm);
    }

    .ai-chat-panel {
        right: var(--rhythm);
        bottom: calc(var(--rhythm) * 4);
        width: calc(100vw - var(--rhythm) * 2);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat-toggle,
    .ai-chat-send {
        transition: none;
        animation: none;
    }

    .ai-chat-toggle-icon {
        animation: none;
    }

    .ai-chat-toggle:hover,
    .ai-chat-send:hover {
        transform: none;
    }
}

@media print {
    #ai-chat-widget {
        display: none;
    }
}