/* AskKara styles
   big text, noise texture, dark/light theme */

/* dark theme (default) */
:root {
    --bg: #030303;
    --bg-surface: rgba(3, 3, 3, 0.95);
    --green: #00ffa3;
    --green-dark: #005a39;
    --green-glow: rgba(0, 255, 163, 0.03);
    --text-main: #f5f5f5;
    --text-dim: #777777;
    --text-dark: #222222;
    --text-answer: #cccccc;
    --text-strong: #ffffff;
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);
    --tooltip-bg: rgba(0, 0, 0, 0.8);
    --tooltip-border: rgba(255, 255, 255, 0.1);
    --tooltip-text: #ffffff;
    --noise-opacity: 0.04;
    --input-text: #ffffff;

    --font-head: 'Playfair Display', serif;
    --font-body: 'Space Grotesk', sans-serif;

    --ease: cubic-bezier(0.8, 0, 0.1, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* light theme - just swap the colors */
[data-theme="light"] {
    --bg: #f5f2ed;
    --bg-surface: rgba(245, 242, 237, 0.97);
    --green: #00b876;
    --green-dark: #008f5d;
    --green-glow: rgba(0, 184, 118, 0.06);
    --text-main: #1a1a1a;
    --text-dim: #888888;
    --text-dark: #cccccc;
    --text-answer: #3a3a3a;
    --text-strong: #111111;
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);
    --border-strong: rgba(0, 0, 0, 0.15);
    --tooltip-bg: rgba(255, 255, 255, 0.9);
    --tooltip-border: rgba(0, 0, 0, 0.1);
    --tooltip-text: #111111;
    --noise-opacity: 0.025;
    --input-text: #111111;
}

/* reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    background: var(--bg);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background 0.5s var(--ease-out), color 0.5s var(--ease-out);
}

body {
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

::selection {
    background: var(--green);
    color: var(--bg);
}

/* hide scrollbar but keep scroll working */
::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* noise texture on top of everything
   its basically a huge svg that moves around to look like film grain */
.noise {
    position: fixed;
    inset: -50%;
    width: 200%;
    height: 200vh;
    pointer-events: none;
    z-index: 9000;
    opacity: var(--noise-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    animation: grain 8s steps(10) infinite;
}

@keyframes grain {

    0%,
    100% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(-5%, -10%);
    }

    20% {
        transform: translate(-15%, 5%);
    }

    30% {
        transform: translate(7%, -25%);
    }

    40% {
        transform: translate(-5%, 25%);
    }

    50% {
        transform: translate(-15%, 10%);
    }

    60% {
        transform: translate(15%, 0%);
    }

    70% {
        transform: translate(0%, 15%);
    }

    80% {
        transform: translate(3%, 35%);
    }

    90% {
        transform: translate(-10%, 10%);
    }
}

/* that soft green glow in the background, follows the mouse a bit */
.ambient-glow {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 80vw;
    height: 80vh;
    background: radial-gradient(circle, var(--green-glow) 0%, transparent 60%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
    transition: transform 0.8s var(--ease-out);
}

/* header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    /* this makes text always readable on dark bg, but we turn it off for light mode
       because it makes stuff look weird (like green turns pink etc) */
    mix-blend-mode: difference;
}

[data-theme="light"] .header {
    mix-blend-mode: normal;
}

.brand {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-style: italic;
    font-weight: 700;
    letter-spacing: -0.02em;
    cursor: pointer;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    font-weight: 500;
    opacity: 0.6;
}

.menu-btn {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.3s;
    font-family: var(--font-body);
}

.menu-btn:hover {
    color: var(--text-main);
    border-color: var(--green);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* dark/light toggle button, sits at bottom right */
.theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    cursor: pointer;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s var(--ease-out);
    overflow: hidden;
}

.theme-toggle:hover {
    border-color: var(--green);
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--green-glow);
}

.theme-toggle .icon {
    line-height: 1;
    transition: transform 0.5s var(--ease-out), opacity 0.3s;
    color: var(--text-dim);
}

/* show moon by default (dark mode), show sun in light mode */
.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: none;
}

/* sidebar that slides in from right for past conversations */
.sidebar-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 350px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-subtle);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.5s var(--ease);
    display: flex;
    flex-direction: column;
}

.sidebar-panel.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.close-btn:hover {
    opacity: 1;
}

.sidebar-content {
    padding: 20px 40px;
    overflow-y: auto;
    flex: 1;
}

.sidebar-item {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: color 0.3s;
    opacity: 0.7;
}

.sidebar-item:hover {
    color: var(--green);
    opacity: 1;
}

/* main layout */
.container {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    z-index: 10;
    overflow: hidden;
}

/* both sections are stacked on top of each other,
   only the .active one is visible */
.section-landing,
.section-results {
    position: absolute;
    inset: 0;
    padding: 100px 40px 40px;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s var(--ease-out), visibility 0.8s;
}

.section-landing.active,
.section-results.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* landing page */
.section-landing {
    justify-content: center;
}

.hero-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.hero-prompt {
    font-family: var(--font-head);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text-dim);
    margin-bottom: 2rem;
    transform: translateY(40px);
    opacity: 0;
    animation: revealUp 1.2s var(--ease) 0.2s forwards;
}

.hero-prompt .italic {
    font-style: italic;
    color: var(--text-main);
}

.input-massive-wrapper {
    position: relative;
    width: 100%;
    transform: translateY(40px);
    opacity: 0;
    animation: revealUp 1.2s var(--ease) 0.4s forwards;
}

/* real input is hidden, we show a styled mirror div instead
   so we can do the big text + cursor effect */
.input-hidden {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 2;
    font-size: 16px; /* keeps ios from zooming in */
}

.input-mirror {
    font-size: clamp(1.5rem, 3.5vw, 2.5rem);
    font-weight: 500;
    color: var(--green);
    border-bottom: 2px solid var(--border-medium);
    padding-bottom: 10px;
    min-height: calc(clamp(1.5rem, 3.5vw, 2.5rem) + 20px);
    word-break: break-word;
    display: inline-block;
    max-width: 100%;
    position: relative;
    transition: border-color 0.4s;
}

.input-hidden:focus~.input-mirror {
    border-color: var(--green);
}

.mirror-text {
    letter-spacing: -0.02em;
}

.cursor-blink {
    display: inline-block;
    width: clamp(1.5rem, 3.5vw, 2.5rem);
    height: 4px;
    background: var(--green);
    vertical-align: baseline;
    margin-left: 8px;
    animation: blinkCursor 1s steps(2, start) infinite;
    opacity: 0;
}

/* only show cursor when input is focused */
.input-hidden:focus~.input-mirror .cursor-blink {
    opacity: 1;
}

@keyframes blinkCursor {
    to {
        visibility: hidden;
    }
}

.hint-text {
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: var(--text-dim);
    margin-top: 30px;
    opacity: 0;
    transition: opacity 0.5s;
    transform: translateY(40px);
    animation: revealUp 1.2s var(--ease) 0.6s forwards;
}

.hint-text.visible {
    opacity: 1;
}

@keyframes revealUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* results / feed view */
.section-results {
    overflow-y: auto;
    padding-top: 15vh;
    padding-bottom: 0;
    scroll-behavior: smooth;
}

.feed-container {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 200px; /* room for the sticky input at bottom */
}

/* each question+answer block */
.feed-block {
    margin-bottom: 100px;
    padding-top: 20px;
    opacity: 0;
    transform: translateY(30px);
    transition: transform 1s var(--ease), opacity 1s;
}

.feed-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.query-huge {
    font-family: var(--font-head);
    font-size: clamp(1.2rem, 2.5vw, 2.2rem);
    font-weight: 400;
    font-style: italic;
    line-height: 1.2;
    margin-bottom: 40px;
    color: var(--green);
    word-break: break-word;
}

.sources-strip {
    display: flex;
    align-items: center;
    gap: 20px;
    border-top: 1px solid var(--border-medium);
    border-bottom: 1px solid var(--border-medium);
    padding: 15px 0;
    margin-bottom: 40px;
}

.strip-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--text-dim);
    font-weight: 700;
}

.strip-items {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.source-item {
    font-size: 0.8rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
}

/* underline that grows on hover */
.source-item::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--green);
    transition: width 0.3s var(--ease-out);
}

.source-item:hover::after {
    width: 100%;
}

.answer-block {
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    line-height: 1.6;
    font-weight: 300;
    color: var(--text-answer);
}

.answer-block p {
    margin-bottom: 1.5em;
}

.answer-block strong {
    color: var(--text-strong);
    font-weight: 500;
}

.answer-block .cite-num {
    display: inline-block;
    font-size: 0.6em;
    vertical-align: super;
    color: var(--green);
    margin-left: 2px;
}

.answer-typing-cursor {
    display: inline-block;
    width: 0.6em;
    height: 0.6em;
    background: var(--green);
    border-radius: 50%;
    margin-left: 10px;
    animation: blink 0.8s infinite;
}

/* followup input sticks to bottom with a fade gradient so it looks nice */
.followup-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, var(--bg) 80%, transparent);
    padding: 40px 0;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s, visibility 0.8s;
}

.section-results.active .followup-wrapper {
    opacity: 1;
    visibility: visible;
}

.followup-line {
    max-width: 900px;
    margin: 0 auto;
    border-bottom: 1px solid var(--border-strong);
    position: relative;
    pointer-events: auto;
    transition: border-color 0.4s;
    transform: translateY(30px);
    transition: transform 1s var(--ease) 0.6s, border-color 0.4s;
}

.section-results.active .followup-line {
    transform: translateY(0);
}

.followup-line:focus-within {
    border-color: var(--green);
}

.followup-line::before {
    content: '+';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--green);
    font-size: 1.5rem;
    pointer-events: none;
}

.input-followup {
    width: 100%;
    padding: 20px 20px 20px 40px;
    font-size: 1.2rem;
    color: var(--input-text);
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-body);
}

.input-followup::placeholder {
    color: var(--text-dim);
}

/* dots on the left side that show which block you're looking at
   you can click them to jump to a specific question */
.history-track {
    position: fixed;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 15px;
    opacity: 1;
    transition: opacity 0.5s;
}

.history-track.hidden {
    opacity: 0;
    pointer-events: none;
}

.hist-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

/* makes it easier to click on such a tiny dot */
.hist-dot::before {
    content: '';
    position: absolute;
    inset: -10px;
}

.hist-dot:hover {
    background: var(--text-main);
    transform: scale(1.5);
}

.hist-dot.active {
    background: var(--green);
}

/* little label that pops up when you hover a dot */
.hist-dot::after {
    content: attr(data-title);
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--tooltip-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--tooltip-border);
    color: var(--tooltip-text);
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    transform-origin: left;
    font-family: var(--font-body);
}

.hist-dot:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(10px);
}

/* mobile */
@media (max-width: 768px) {
    .header {
        padding: 20px;
    }

    .section-landing,
    .section-results {
        padding: 80px 20px 20px;
    }

    .history-track {
        display: none;
    }

    .input-mirror {
        border-bottom-width: 1px;
    }

    .theme-toggle {
        bottom: 20px;
        right: 20px;
        width: 38px;
        height: 38px;
    }
}