/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for Theme Colors */
:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f6f3;
    --bg-tertiary: #f1f1ef;
    --text-primary: #37352f;
    --text-secondary: #6f6e69;
    --text-tertiary: #9b9a97;
    --border-color: #e9e9e7;
    --accent-color: #2383e2;
    --accent-hover: #1a73d1;
    --success-color: #0f7b0f;
    --shadow-light: rgba(15, 15, 15, 0.1);
    --shadow-medium: rgba(15, 15, 15, 0.2);
    
    /* Component specific colors */
    --blockquote-bg: #f7f6f3;
    --blockquote-border: #e9e9e7;
    --code-bg: #f7f6f3;
    --code-text: #eb5757;
    --table-header-bg: #f7f6f3;
    --table-border: #e9e9e7;
    --button-shadow: rgba(0, 0, 0, 0.1);
    --input-border: #d3d3d1;
    --input-focus: #2383e2;
}

/* Dark Theme Colors */
[data-theme="dark"] {
    --bg-primary: #191919;
    --bg-secondary: #2f2f2f;
    --bg-tertiary: #3f3f3f;
    --text-primary: #ffffff;
    --text-secondary: #c9c7c4;
    --text-tertiary: #9b9a97;
    --border-color: #3f3f3f;
    --accent-color: #5ba2f5;
    --accent-hover: #4a91e4;
    --success-color: #4ade80;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    
    /* Component specific colors */
    --blockquote-bg: #2f2f2f;
    --blockquote-border: #3f3f3f;
    --code-bg: #2f2f2f;
    --code-text: #ff6b6b;
    --table-header-bg: #2f2f2f;
    --table-border: #3f3f3f;
    --button-shadow: rgba(0, 0, 0, 0.3);
    --input-border: #3f3f3f;
    --input-focus: #5ba2f5;
}

/* Base Body Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
}

.theme-icon {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-icon {
    transform: rotate(20deg);
}

/* Main Container - 712px like Notion */
.container {
    max-width: 712px;
    margin: 0 auto;
    padding: 60px 20px 40px;
    min-height: 100vh;
}

.content {
    width: 100%;
}

.content:focus {
    outline: none;
}

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

/* Typography - Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin: 2em 0 0.5em 0;
    color: var(--text-primary);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-top: 0;
}

h2 {
    font-size: 2rem;
    margin-top: 1.5em;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.125rem;
}

h6 {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Subtitle */
.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-weight: 400;
}

/* Body Text */
p {
    margin: 1em 0;
    color: var(--text-primary);
    line-height: 1.7;
}

/* Text Formatting */
strong {
    font-weight: 600;
    color: var(--text-primary);
}

em {
    font-style: italic;
}

code {
    color: var(--code-text);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9em;
}

[data-theme="dark"] .language-css .token.string,
[data-theme="dark"] .style .token.string,
[data-theme="dark"] .token.entity,
[data-theme="dark"] .token.operator,
[data-theme="dark"] .token.url {
    background: hsla(0,0%,100%,.1);
}

[data-theme="dark"] code[class*=language-] ::-moz-selection,
[data-theme="dark"] code[class*=language-]::-moz-selection,
[data-theme="dark"] pre[class*=language-] ::-moz-selection,
[data-theme="dark"] pre[class*=language-]::-moz-selection {
  text-shadow:none;
  background:#5a5a5a
}
[data-theme="dark"] code[class*=language-] ::selection,
[data-theme="dark"] code[class*=language-]::selection,
[data-theme="dark"] pre[class*=language-] ::selection,
[data-theme="dark"] pre[class*=language-]::selection {
  text-shadow:none;
  background:#5a5a5a
}

/* Links */
.link, a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.link:hover, a:hover {
    border-bottom-color: var(--accent-color);
}

/* Blockquotes */
blockquote {
    background: var(--blockquote-bg);
    border-left: 4px solid var(--accent-color);
    margin: 2em 0;
    padding: 1.5em 2em;
    border-radius: 0 8px 8px 0;
    position: relative;
}

blockquote p {
    margin: 0 0 1em 0;
    font-style: italic;
    font-size: 1.1em;
    line-height: 1.6;
}

blockquote cite {
    display: block;
    margin-top: 1em;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-style: normal;
}

/* Code Blocks */
pre {
    /* background: var(--code-bg); */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5em;
    margin: 2em 0;
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

/* Copy Button */
.copy-button {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(-4px);
    z-index: 10;
}

pre:hover .copy-button {
    opacity: 1;
    transform: translateY(0);
}

.copy-button:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.copy-button:active {
    transform: translateY(1px);
}

.copy-button.copied {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.copy-button:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    opacity: 1;
    transform: translateY(0);
}

/* Image Lightbox */
.image-container {
    position: relative;
    overflow: hidden;
}

.image-expand-icon {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.3s ease;
    z-index: 10;
}

.image-container:hover .image-expand-icon {
    opacity: 1;
    transform: translateY(0);
}

.image-expand-icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.image-expand-icon:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-1px);
}

.responsive-image {
    cursor: pointer;
}

/* Lightbox Modal */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.lightbox-overlay.active .lightbox-content {
    transform: scale(1);
}

.lightbox-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: -40px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-close:focus {
    outline: none;
}

.lightbox-close svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.lightbox-caption {
    position: absolute;
    bottom: -60px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-size: 0.9em;
    opacity: 0.8;
}

/* Responsive lightbox */
@media (max-width: 768px) {
    .lightbox-content {
        max-width: 95%;
        max-height: 85%;
    }
    
    .lightbox-close {
        top: -45px;
        width: 36px;
        height: 36px;
    }
    
    .lightbox-close svg {
        width: 20px;
        height: 20px;
    }
    
    .lightbox-caption {
        bottom: -50px;
        font-size: 0.8em;
        padding: 0 10px;
    }
}

code[class*="language-"], pre[class*="language-"] {
    text-shadow: none;
}
pre code {
    /* background: none; */
    color: var(--text-primary);
    padding: 0;
    border-radius: 0;
}

/* Prism.js Theme Integration */
pre[class*="language-"] {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
}

code[class*="language-"],
pre[class*="language-"] {
    color: var(--text-primary);
    background: none;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 14px;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    word-wrap: normal;
    line-height: 1.5;
    tab-size: 4;
    hyphens: none;
}

/* Syntax highlighting colors for light theme */
:root {
    --syntax-comment: #6a737d;
    --syntax-keyword: #d73a49;
    --syntax-string: #032f62;
    --syntax-function: #6f42c1;
    --syntax-number: #005cc5;
    --syntax-operator: #d73a49;
    --syntax-punctuation: #24292e;
    --syntax-tag: #22863a;
    --syntax-attr-name: #6f42c1;
    --syntax-attr-value: #032f62;
}

/* Syntax highlighting colors for dark theme */
[data-theme="dark"] {
    --syntax-comment: #8b949e;
    --syntax-keyword: #ff7b72;
    --syntax-string: #a5d6ff;
    --syntax-function: #d2a8ff;
    --syntax-number: #79c0ff;
    --syntax-operator: #ff7b72;
    --syntax-punctuation: #e6edf3;
    --syntax-tag: #7ee787;
    --syntax-attr-name: #d2a8ff;
    --syntax-attr-value: #a5d6ff;
}

/* Apply syntax colors */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: var(--syntax-comment);
    font-style: italic;
}

.token.punctuation {
    color: var(--syntax-punctuation);
}

.token.property,
.token.tag,
.token.boolean,
.token.constant,
.token.symbol,
.token.deleted {
    color: var(--syntax-tag);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: var(--syntax-string);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: var(--syntax-operator);
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: var(--syntax-keyword);
}

.token.function,
.token.class-name {
    color: var(--syntax-function);
}

.token.regex,
.token.important,
.token.variable {
    color: var(--syntax-keyword);
}

.token.number {
    color: var(--syntax-number);
}

/* Images */
.image-container {
    margin: 2em 0;
    text-align: center;
}

.responsive-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.responsive-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow-medium);
}

figcaption {
    margin-top: 0.75em;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-style: italic;
}

/* Tables */
.table-container {
    margin: 2em 0;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
}

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

th {
    background: var(--table-header-bg);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

tr:hover {
    background: var(--bg-secondary);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    margin: 2em 0;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    box-shadow: 0 2px 4px var(--button-shadow);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--button-shadow);
}

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

.btn-secondary:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
}

.btn-outline:hover {
    background: var(--accent-color);
    color: white;
    transform: translateY(-1px);
}

/* Form Elements */
.form-section {
    margin: 2em 0;
}

.checkbox-group {
    margin: 1.5em 0;
}

.checkbox-item {
    display: flex;
    align-items: center;
    margin: 0.75em 0;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.5;
}

.checkbox-item input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: var(--bg-primary);
}

.checkbox-item input[type="checkbox"]:checked + .checkmark {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-item input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.checkbox-item:hover .checkmark {
    border-color: var(--accent-color);
}

/* Input Fields */
.input-group {
    margin: 1.5em 0;
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.text-input, .textarea-input {
    padding: 12px 16px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input:focus, .textarea-input:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.1);
}

.textarea-input {
    min-height: 120px;
    resize: vertical;
}

/* Lists */
ul, ol {
    margin: 1em 0;
    padding-left: 2em;
}

li {
    margin: 0.5em 0;
    line-height: 1.6;
}

ul ul, ol ol {
    margin: 0.5em 0;
}

/* Divider */
.divider {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 3em 0;
}

/* Footer */
.footer-text {
    color: var(--text-secondary);
    font-size: 0.9em;
    text-align: center;
    margin-top: 3em;
    padding-top: 2em;
    border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 80px 16px 40px;
    }
    
    .theme-toggle {
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }
    
    .theme-icon {
        font-size: 18px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.375rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    blockquote {
        padding: 1em 1.5em;
        margin: 1.5em 0;
    }
    
    pre {
        padding: 1em;
        font-size: 13px;
    }
    
    .table-container {
        font-size: 0.9em;
    }
    
    th, td {
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 70px 12px 30px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    blockquote {
        padding: 0.75em 1em;
    }
    
    pre {
        padding: 0.75em;
        font-size: 12px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.85em;
    }
    
    th, td {
        padding: 6px 8px;
        font-size: 0.85em;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
*:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.btn:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Remove outline from container and theme toggle */
.container:focus,
.theme-toggle:focus {
    outline: none;
}

/* Hide skip link by default */
.skip-link {
    position: absolute !important;
    top: -40px !important;
    left: 6px;
    background: var(--accent-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s;
    opacity: 0;
    pointer-events: none;
}

.skip-link:focus {
    top: 6px !important;
    opacity: 1;
    pointer-events: auto;
}

/* Print styles */
@media print {
    .theme-toggle {
        display: none;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
}
