/* ===========================
   storiographer.net - Styles
   Collaborative Story Platform
   =========================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --canvas-white: #FFFFFF;
    --parchment-warm: #F5F2ED;
    --platform-blue: #2563EB;
    --platform-blue-dark: #1D4ED8;
    --platform-blue-light: #DBEAFE;
    --ink-dark: #1E293B;
    --slate-medium: #64748B;
    --slate-light: #E2E8F0;
    --success-green: #16A34A;
    --engagement-amber: #F59E0B;
    --contributor-violet: #7C3AED;
    --connection-line: #CBD5E1;
    --heat-warm: #FEF3C7;
    --dot-grid-color: rgba(226, 232, 240, 0.3);
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    --card-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.08);
    --frosted-bg: rgba(245, 242, 237, 0.85);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--parchment-warm);
    color: var(--ink-dark);
    line-height: 1.6;
    overflow-x: hidden;
    background-image: radial-gradient(circle, var(--dot-grid-color) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.card-excerpt, .card-highlight p, .mosaic-card p:not(.mosaic-meta) {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    line-height: 1.72;
    font-size: clamp(1rem, 1.8vw, 1.125rem);
}

.card-timestamp, .card-author, .card-version, .card-action span,
.contributor-count, .margin-time, .margin-summary, .margin-label,
.mosaic-meta, .mosaic-badge, .card-trending {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 0.8125rem;
}

.card-version, .margin-time {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
}

/* ===========================
   HERO ZONE
   =========================== */
.hero-zone {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--parchment-warm);
    background-image: radial-gradient(circle, var(--dot-grid-color) 1px, transparent 1px);
    background-size: 24px 24px;
}

.hero-cursor-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

/* Ghost Cursors */
.ghost-cursor {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.gc-arrow {
    display: block;
    width: 12px;
    height: 18px;
    position: relative;
}

.gc-arrow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 6px solid currentColor;
    border-right: 6px solid transparent;
    border-bottom: 10px solid transparent;
    border-top: 10px solid currentColor;
}

.gc-arrow::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 2px;
    width: 3px;
    height: 8px;
    background: currentColor;
}

.gc-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    color: var(--canvas-white);
}

.gc-1 { color: #7C3AED; }
.gc-1 .gc-label { background: #7C3AED; }
.gc-2 { color: #2563EB; }
.gc-2 .gc-label { background: #2563EB; }
.gc-3 { color: #16A34A; }
.gc-3 .gc-label { background: #16A34A; }
.gc-4 { color: #F59E0B; }
.gc-4 .gc-label { background: #F59E0B; color: var(--ink-dark); }
.gc-5 { color: #1D4ED8; }
.gc-5 .gc-label { background: #1D4ED8; }

/* Hero Typing Area */
.hero-typing-area {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 640px;
    padding: 0 24px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-typed-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.5rem;
    color: var(--ink-dark);
    line-height: 1.6;
    transition: opacity 1s ease;
}

.typing-cursor {
    display: inline-block;
    width: 1px;
    height: 1.5rem;
    background-color: var(--platform-blue);
    animation: cursorBlink 1.06s steps(1) infinite;
    vertical-align: text-bottom;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

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

.hero-title {
    position: relative;
    z-index: 2;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink-dark);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    margin-top: 32px;
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-subtitle {
    position: relative;
    z-index: 2;
    font-family: 'DM Sans', sans-serif;
    font-size: 1.125rem;
    font-weight: 400;
    color: var(--slate-medium);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease 0.3s, transform 0.6s ease 0.3s;
    margin-top: 12px;
}

.hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===========================
   MARGIN ANNOTATIONS
   =========================== */
.margin-annotations {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    padding: 80px 16px 80px 20px;
    overflow: hidden;
    z-index: 10;
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.margin-annotations.visible {
    opacity: 1;
}

@media (min-width: 1200px) {
    .margin-annotations {
        display: block;
    }
}

.margin-header {
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--slate-light);
}

.margin-label {
    font-weight: 500;
    color: var(--slate-medium);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
}

.margin-timeline {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.margin-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.margin-item:hover {
    opacity: 1;
}

.margin-avatar {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--slate-light);
    border: 2px solid currentColor;
    margin-top: 2px;
}

.margin-time {
    color: var(--slate-medium);
    white-space: nowrap;
    flex-shrink: 0;
}

.margin-summary {
    color: var(--ink-dark);
    font-size: 0.75rem;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===========================
   FEED RIVER
   =========================== */
.feed-river {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px 120px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.feed-river.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (min-width: 1200px) {
    .feed-river {
        margin-left: calc(240px + (100% - 240px - 800px) / 2);
    }
}

/* ===========================
   STORY CARDS
   =========================== */
.story-card {
    position: relative;
    background: var(--canvas-white);
    border-radius: 12px;
    border: 1px solid var(--slate-light);
    box-shadow: var(--card-shadow);
    padding: 24px;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    cursor: default;
    overflow: hidden;
}

.story-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.story-card.expanded {
    position: fixed;
    top: 5vh;
    left: 5vw;
    width: 90vw;
    height: 90vh;
    z-index: 100;
    border-radius: 16px;
    overflow-y: auto;
    padding: 40px;
    transform: none;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.card-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--slate-light);
    border: 2px solid;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.card-author {
    font-weight: 500;
    color: var(--ink-dark);
    font-size: 0.875rem;
}

.card-timestamp {
    color: var(--slate-medium);
}

.card-version {
    color: var(--slate-medium);
    background: rgba(226, 232, 240, 0.5);
    padding: 2px 8px;
    border-radius: 4px;
}

.card-trending {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--engagement-amber);
    font-weight: 500;
    margin-left: 8px;
}

.card-title {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    margin-bottom: 12px;
    color: var(--ink-dark);
    line-height: 1.3;
}

.card-excerpt {
    color: var(--ink-dark);
    margin-bottom: 16px;
}

.card-highlight {
    border-left: 4px solid var(--platform-blue);
    background: rgba(219, 234, 254, 0.4);
    padding: 16px 20px;
    margin-bottom: 16px;
    border-radius: 0 8px 8px 0;
}

.card-highlight p {
    font-style: italic;
    color: var(--ink-dark);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    border-top: 1px solid var(--slate-light);
}

.card-actions {
    display: flex;
    gap: 16px;
}

.card-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--slate-medium);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8125rem;
}

.card-action:hover {
    color: var(--platform-blue);
    background: rgba(37, 99, 235, 0.06);
}

.card-action svg {
    flex-shrink: 0;
}

.card-contributors {
    display: flex;
    align-items: center;
    gap: 4px;
}

.contributor-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.contributor-count {
    color: var(--slate-medium);
    margin-left: 2px;
}

/* Engagement Pulse */
.engagement-pulse {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--platform-blue);
    opacity: 0;
    pointer-events: none;
    transform: scale(1);
}

.engagement-pulse.active {
    animation: engagementPulse 0.8s ease-out forwards;
}

@keyframes engagementPulse {
    0% {
        opacity: 0.2;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(3);
    }
}

/* ===========================
   DISCOVERY MOSAIC
   =========================== */
.discovery-mosaic {
    padding: 8px 0;
}

.mosaic-heading {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--slate-medium);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
}

.mosaic-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 12px;
    min-height: 280px;
}

.mosaic-card {
    background: var(--canvas-white);
    border-radius: 12px;
    border: 1px solid var(--slate-light);
    box-shadow: var(--card-shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    cursor: default;
    opacity: 0;
    transform: translateY(16px);
}

.mosaic-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.mosaic-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.mosaic-large {
    grid-column: 1 / 3;
    grid-row: 1 / 3;
}

.mosaic-large h4 {
    font-size: 1.25rem;
    line-height: 1.3;
}

.mosaic-large p {
    font-size: 0.9375rem;
    color: var(--slate-medium);
    line-height: 1.5;
}

.mosaic-small h4 {
    font-size: 0.9375rem;
    line-height: 1.3;
}

.mosaic-meta {
    font-size: 0.75rem;
    color: var(--slate-medium);
}

.mosaic-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 500;
    width: fit-content;
}

.badge-trending {
    background: rgba(245, 158, 11, 0.12);
    color: var(--engagement-amber);
}

.badge-new {
    background: rgba(37, 99, 235, 0.1);
    color: var(--platform-blue);
}

.badge-active {
    background: rgba(124, 58, 237, 0.1);
    color: var(--contributor-violet);
}

.badge-complete {
    background: rgba(22, 163, 74, 0.1);
    color: var(--success-green);
}

.mosaic-contributors {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: auto;
}

/* Typing Dots */
.typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--contributor-violet);
    animation: typingDotBounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.4s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.8s;
}

@keyframes typingDotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Mobile mosaic fallback */
@media (max-width: 640px) {
    .mosaic-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .mosaic-large {
        grid-column: 1;
        grid-row: auto;
    }
}

/* ===========================
   COMPOSE BAR
   =========================== */
.compose-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--frosted-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--slate-light);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.compose-bar.scrolling {
    opacity: 0.6;
}

.compose-inner {
    max-width: 800px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
}

@media (min-width: 1200px) {
    .compose-inner {
        margin-left: calc(240px / 2);
    }
}

.compose-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--slate-light);
    border: 2px solid;
}

.compose-input-wrapper {
    flex: 1;
}

.compose-input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--slate-light);
    border-radius: 20px;
    background: var(--canvas-white);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 0.9375rem;
    color: var(--ink-dark);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.compose-input::placeholder {
    color: var(--slate-medium);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
}

.compose-input:focus {
    border-color: var(--platform-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.compose-submit {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--platform-blue);
    color: var(--canvas-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.compose-submit:hover {
    background: var(--platform-blue-dark);
}

.compose-submit:active {
    transform: scale(0.95);
}

/* ===========================
   CARD EXPAND OVERLAY
   =========================== */
.card-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.card-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ===========================
   CONTRIBUTION HEAT MAP (Margin)
   =========================== */
.margin-annotations::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to bottom, #DBEAFE, #FEF3C7);
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
}

.margin-annotations::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to top, var(--parchment-warm), transparent);
    pointer-events: none;
}

/* Connection Lines between cards on hover */
.story-card::after {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 50%;
    width: 1px;
    height: 16px;
    background: #CBD5E1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.story-card:hover::after {
    opacity: 0.5;
}

/* ===========================
   SCROLLBAR
   =========================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--slate-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--slate-medium);
}

/* ===========================
   SELECTION
   =========================== */
::selection {
    background: var(--platform-blue-light);
    color: var(--ink-dark);
}
