/* ============================================
   Atmospheric Theme - Ghost Blog
   Aligned with Portfolio Design DNA
   ============================================ */

/* Google Fonts - Loaded via default.hbs */

/* ============================================
   CSS Custom Properties (Design Tokens)
   Matched with portfolio site
   ============================================ */

:root {
    /* Ghost Custom Font Variables - Required for theme validation */
    --gh-font-heading: var(--font-sans);
    --gh-font-body: var(--font-serif);

    /* Typography - Portfolio aligned */
    --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Georgia', 'Noto Serif SC', serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;

    /* Font Sizes (Fluid Scale) */
    --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
    --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
    --text-3xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);

    /* Colors - Child Personality: Warmer for Reading */
    --color-bg: #0a0a0a;
    /* Warmer than pure black */
    --color-surface: #141414;
    --color-surface-elevated: #1a1a1a;
    --color-border: #2a2a2a;
    --color-text-primary: #f5f5f5;
    /* Softer for reading comfort */
    --color-text-secondary: #b0b0b0;
    --color-text-muted: #707070;

    /* Accent Colors - Portfolio Matched */
    --color-accent: #4da6ff;
    --color-accent-hover: #6bb3ff;
    --color-accent-light: #1a2a3a;
    --color-accent-coral: #E57373;
    --color-accent-ice: #A8D4E6;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Layout */
    --max-width-content: 680px;
    --max-width-wide: 1200px;

    /* Motion - Portfolio Matched */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;
    --ease-magnetic: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-snappy: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text-primary);
    background-color: var(--color-bg);
    min-height: 100vh;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* ============================================
   Vignette Overlay - Softened for Reading
   ============================================ */

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse 90% 70% at 50% 50%,
            transparent 0%,
            rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
    z-index: 9999;
    opacity: 0.25;
    /* Softer vignette for focus */
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   Site Header - Frosted Glass (Child Nuance)
   ============================================ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-md) var(--space-xl);
    background: rgba(10, 10, 10, 0.85);
    /* Solid with slight transparency */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    transition: background-color var(--transition-base), border-color var(--transition-base);
    overflow: hidden;
    /* Contain bokeh within header */
}

/* Header Bokeh Background Canvas */
.header-bokeh {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}

.site-header__inner {
    max-width: var(--max-width-wide);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.site-logo {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text-primary);
    transition: color var(--transition-fast);
}

.site-logo:hover {
    color: var(--color-text-primary);
}

.site-nav {
    display: flex;
    gap: var(--space-lg);
}

.site-nav a {
    position: relative;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.site-nav a:hover {
    color: var(--color-text-primary);
    background: var(--color-accent-light);
}

/* Active nav indicator - underline glow */
.site-nav a.nav-current::after,
.site-nav a[aria-current="page"]::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--color-accent);
    border-radius: var(--radius-full);
    box-shadow: 0 0 8px rgba(77, 166, 255, 0.5);
}

/* ============================================
   Site Main
   ============================================ */

.site-main {
    max-width: var(--max-width-content);
    margin: 0 auto;
    padding: var(--space-3xl) var(--space-xl);
}

/* ============================================
   Post Feed (Homepage) - Glassmorphism Cards
   ============================================ */

.post-feed {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}

.post-card {
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: transform 0.4s var(--ease-bounce),
        border-color var(--transition-base),
        box-shadow var(--transition-base);
}

.post-card:hover {
    transform: translateY(-2px);
    border-color: rgba(77, 166, 255, 0.1);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(77, 166, 255, 0.05);
}

.post-card__image {
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.post-card__title {
    font-size: var(--text-2xl);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    line-height: 1.3;
}

.post-card__title a {
    color: var(--color-text-primary);
    transition: color var(--transition-fast);
}

.post-card__title a:hover {
    color: var(--color-accent);
}

.post-card__excerpt {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
    max-width: 65ch;
}

.post-card__meta {
    display: flex;
    gap: var(--space-md);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* ============================================
   Single Post
   ============================================ */

.post__header {
    margin-bottom: var(--space-2xl);
}

.post__title {
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-md);
}

.post__meta {
    display: flex;
    gap: var(--space-md);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-xl);
}

.post__feature-image {
    margin-bottom: var(--space-2xl);
}

.post__feature-image img {
    border-radius: var(--radius-md);
    width: 100%;
}

.post__content {
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    line-height: 1.8;
}

.post__content p {
    margin-bottom: var(--space-lg);
    max-width: 65ch;
}

.post__content h2 {
    font-family: var(--font-sans);
    font-size: var(--text-xl);
    font-weight: 600;
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    color: var(--color-text-primary);
}

.post__content h3 {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 600;
    margin-top: var(--space-xl);
    margin-bottom: var(--space-sm);
    color: var(--color-text-primary);
}

.post__content blockquote {
    border-left: 3px solid var(--color-accent);
    padding-left: var(--space-lg);
    margin: var(--space-xl) 0;
    font-style: italic;
    color: var(--color-text-secondary);
}

.post__content pre {
    background: var(--color-surface-elevated);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-lg) 0;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    border: 1px solid var(--color-border);
}

.post__content code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-surface-elevated);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-sm);
}

.post__content pre code {
    background: none;
    padding: 0;
}

.post__content a {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.post__content a:hover {
    color: var(--color-accent-hover);
}

.post__footer {
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border);
}

.post__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.post__tag {
    font-size: var(--text-xs);
    padding: var(--space-xs) var(--space-md);
    background: rgba(229, 115, 115, 0.08);
    color: var(--color-accent-coral);
    border: 1px solid rgba(229, 115, 115, 0.15);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.post__tag:hover {
    background: rgba(229, 115, 115, 0.15);
    color: var(--color-accent-coral);
    transform: scale(1.05);
}

/* ============================================
   Page
   ============================================ */

.page__header {
    margin-bottom: var(--space-2xl);
}

.page__title {
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-lg);
}

.page__content {
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    line-height: 1.8;
}

.page__content p {
    margin-bottom: var(--space-lg);
    max-width: 65ch;
}

/* ============================================
   Navigation
   ============================================ */

.post-nav {
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border);
}

.post-nav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface-elevated);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.post-nav__link:hover {
    color: var(--color-text-primary);
    background: var(--color-accent-light);
    transform: translateX(4px);
}

/* ============================================
   Site Footer
   ============================================ */

.site-footer {
    padding: var(--space-2xl) var(--space-xl);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

.site-footer__inner {
    max-width: var(--max-width-content);
    margin: 0 auto;
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.footer-copyright {
    margin-bottom: var(--space-sm);
}

.footer-disclaimer {
    font-size: var(--text-xs);
    line-height: 1.6;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}

.footer-disclaimer a {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.footer-disclaimer a:hover {
    color: var(--color-accent-hover);
}

.footer-icp {
    font-size: var(--text-xs);
    margin-top: var(--space-sm);
}

.footer-icp a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-icp a:hover {
    color: var(--color-text-secondary);
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
}

.pagination a {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.pagination a:hover {
    background: var(--color-accent-light);
    border-color: rgba(77, 166, 255, 0.2);
    color: var(--color-text-primary);
    transform: translateY(-1px);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .site-header {
        padding: var(--space-md);
    }

    .site-main {
        padding: var(--space-xl) var(--space-md);
    }

    .post-card {
        padding: var(--space-lg);
    }

    .site-nav {
        gap: var(--space-md);
    }
}

@media (max-width: 480px) {
    .site-header__inner {
        flex-direction: column;
        gap: var(--space-md);
    }

    .site-nav {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   Ghost Koenig Editor - Content Width Classes
   Required for editor image/embed expansions
   ============================================ */

.kg-width-wide {
    position: relative;
    width: 85vw;
    max-width: 1040px;
    margin-left: calc(50% - 42.5vw);
    margin-right: calc(50% - 42.5vw);
}

.kg-width-full {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

@media (max-width: 1040px) {
    .kg-width-wide {
        width: calc(100vw - var(--space-xl) * 2);
        margin-left: calc(50% - 50vw + var(--space-xl));
        margin-right: calc(50% - 50vw + var(--space-xl));
    }
}

/* Koenig Image Cards */
.kg-image-card,
.kg-gallery-card {
    margin: var(--space-xl) 0;
}

.kg-image-card img,
.kg-gallery-card img {
    border-radius: var(--radius-md);
}

.kg-image-card figcaption,
.kg-gallery-card figcaption {
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-top: var(--space-sm);
}

/* Koenig Embed Cards */
.kg-embed-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: var(--space-xl) 0;
}

.kg-embed-card iframe {
    border-radius: var(--radius-md);
}

/* Koenig Bookmark Cards */
.kg-bookmark-card {
    margin: var(--space-xl) 0;
}

.kg-bookmark-container {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    overflow: hidden;
    text-decoration: none;
    transition: border-color var(--transition-fast);
}

.kg-bookmark-container:hover {
    border-color: rgba(77, 166, 255, 0.3);
}

.kg-bookmark-content {
    flex: 1;
    padding: var(--space-lg);
}

.kg-bookmark-title {
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
}

.kg-bookmark-description {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: 1.5;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kg-bookmark-metadata {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.kg-bookmark-icon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

.kg-bookmark-thumbnail {
    width: 180px;
    min-height: 120px;
    object-fit: cover;
}

/* Koenig Gallery */
.kg-gallery-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.kg-gallery-row {
    display: flex;
    gap: var(--space-md);
}

.kg-gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   Light Mode Theme
   ============================================ */

[data-theme="light"] {
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-surface-elevated: #f0f0f0;
    --color-border: #e0e0e0;
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #4a4a4a;
    --color-text-muted: #6b6b6b;
    --color-accent: #0066cc;
    --color-accent-hover: #0055aa;
    --color-accent-light: #e6f0ff;
}

[data-theme="light"] body::before {
    background: radial-gradient(ellipse 90% 70% at 50% 50%,
            transparent 0%,
            rgba(0, 0, 0, 0.05) 100%);
}

[data-theme="light"] .site-header {
    background: rgba(250, 250, 250, 0.85);
}

[data-theme="light"] .post-card {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--color-border);
}

/* ============================================
   Header Controls
   ============================================ */

.header-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Prevent transitions on initial load */
.no-transitions,
.no-transitions * {
    transition: none !important;
}

/* ============================================
   Theme Toggle Button - Portfolio Matched
   ============================================ */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--color-surface-elevated);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: background-color var(--transition-fast),
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
    position: relative;
}

.theme-toggle:hover {
    transform: scale(1.05);
    background: var(--color-accent-light);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.4s var(--ease-bounce);
}

/* Sun icon - shown in dark mode */
.theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

/* Moon icon - shown in light mode */
.theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

/* Sun animation on hover */
.theme-toggle:hover .icon-sun {
    animation: sunRise 0.5s var(--ease-bounce);
}

@keyframes sunRise {
    0% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(180deg) scale(1.2);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* Moon animation on hover */
.theme-toggle:hover .icon-moon {
    animation: moonWobble 0.5s var(--ease-bounce);
}

@keyframes moonWobble {
    0% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-15deg);
    }

    75% {
        transform: rotate(15deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

/* Preview effects on hover */
.theme-toggle.preview-light {
    background: #f0f0f0 !important;
    color: #1a1a1a !important;
    box-shadow:
        0 0 20px 5px rgba(255, 255, 255, 0.4),
        0 0 50px 15px rgba(255, 255, 255, 0.25),
        0 0 80px 30px rgba(255, 255, 255, 0.15) !important;
}

.theme-toggle.preview-dark {
    background: #1a1a1a !important;
    color: #f0f0f0 !important;
    box-shadow:
        0 0 20px 5px rgba(0, 0, 0, 0.3),
        0 0 50px 15px rgba(0, 0, 0, 0.2),
        0 0 80px 30px rgba(0, 0, 0, 0.1) !important;
}

/* ============================================
   Admin Link Button - Animated Gear Icon
   ============================================ */

.admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--color-surface-elevated);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: background-color var(--transition-fast),
        transform var(--transition-fast),
        color var(--transition-fast),
        box-shadow var(--transition-fast);
    position: relative;
}

.admin-link:hover {
    transform: scale(1.05);
    background: var(--color-accent-light);
    color: var(--color-accent);
    box-shadow: 0 0 15px rgba(77, 166, 255, 0.2);
}

.admin-link svg {
    width: 20px;
    height: 20px;
    transition: transform 0.6s var(--ease-magnetic);
}

/* Gear rotation animation on hover */
.admin-link:hover svg {
    transform: rotate(90deg);
}

/* Active state - faster spin */
.admin-link:active svg {
    transform: rotate(180deg);
    transition-duration: 0.15s;
}

/* Pulse animation for hint */
@keyframes gearPulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

.admin-link .gear-outer {
    fill: currentColor;
    opacity: 0.7;
}

.admin-link:hover .gear-outer {
    opacity: 1;
    animation: gearPulse 1s ease-in-out infinite;
}

/* Light mode adjustments */
[data-theme="light"] .admin-link:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}