/* -----------------------------------------------------------------------------
 * Custom Stylesheet: Core Site Styling & Theme Variables
 * Author: Donovan Middleton + Copilot
 * Date: 2026-01-19
 *
 * Purpose:
 *   Provides the core styling for the website including typography, colors,
 *   layout, navigation, and responsive design.
 *
 *   This stylesheet imports Google Fonts (Inter for body text, JetBrains Mono
 *   for code blocks) and defines custom CSS variables for light/dark themes.
 *
 * Notes:
 *   - Uses CSS custom properties for theme switching
 *   - Responsive design with mobile-first approach
 *   - Includes Prism.js code block styling
 *   - Theme toggle handled by ThemeToggle.js
 * -----------------------------------------------------------------------------
 */

/* --- Import Fonts --- 
 * Reference: https://fonts.google.com/specimen/Inter (used for body)
 *   and https://fonts.google.com/specimen/JetBrains+Mono (used for ClodeBlocks)'
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* --- Root font setup --- */
* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Keep monospace for code - be specific for Prism */
pre, 
code, 
kbd, 
samp,
.code,
pre[class*="language-"],
code[class*="language-"],
.token {
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace !important;
}

/* --- Smooth fade between themes --- */
html,
body {
    transition: background-color 0.35s ease, color 0.35s ease;
    margin: 0;
    padding: 0;
}

body {
    padding: 80px 1.5rem 1.5rem 1.5rem;
}

body.menu-open {
    overflow: hidden;
}

/* Prism code block fade */
pre[class*="language-"] {
    transition: background-color 0.35s ease, color 0.35s ease;
}

/* --- Line numbers support --- */
pre[class*="language-"].line-numbers {
    position: relative;
    padding-left: 3.8em;
    counter-reset: linenumber;
}

pre[class*="language-"].line-numbers > code {
    position: relative;
    white-space: inherit;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid #999;
    user-select: none;
}

.line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: #999;
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* --- Prism toolbar (copy button) --- */
.code-toolbar {
    position: relative;
}

.code-toolbar>.toolbar {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 9999;
    opacity: 1;
}

.code-toolbar .toolbar-item {
    display: inline-block;
}

.code-toolbar .toolbar-item > button,
.code-toolbar .toolbar-item > span {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 16px;
    border-radius: 6px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.code-toolbar .toolbar-item > button:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* Dark mode copy button */
body:has(#theme-toggle-input:checked) .code-toolbar .toolbar-item > button,
body:has(#theme-toggle-input:checked) .code-toolbar .toolbar-item > span {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #eee;
}

body:has(#theme-toggle-input:checked) .code-toolbar .toolbar-item > button:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --- Theme Switcher --- */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.theme-switch {
    display: inline-block;
    height: 18px;
    position: relative;
    width: 34px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

/* Light mode (sun/right = checked) */
input:checked+.slider {
    background-color: #ccc;
}

input:checked+.slider:before {
    transform: translateX(16px);
}

/* Dark mode (moon/left = unchecked) */
input:not(:checked)+.slider {
    background-color: #444;
}

input:not(:checked)+.slider:before {
    transform: translateX(0);
}

/* --- Navigation Bar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: #fff;
    border-bottom: 2px solid #ddd;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
}

/* Dark mode navbar background */
body:has(#theme-toggle-input:checked) .navbar {
    background: #2a2a2a;
    border-bottom: 2px solid #444;
}

/* Navbar header with menu button and site title */
.navbar-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 1rem;
    justify-content: space-between;
}

.site-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin: 0;
    flex-grow: 1;
}

body:has(#theme-toggle-input:checked) .site-title {
    color: #eee;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
    flex-shrink: 0;
}

.nav-btn span {
    width: 24px;
    height: 2.5px;
    background: #333;
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

.nav-btn.active span:nth-child(1) {
    transform: rotate(45deg);
}

.nav-btn.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(20px);
}

.nav-btn.active span:nth-child(3) {
    transform: rotate(-45deg);
}

/* Dark mode nav button color */
body:has(#theme-toggle-input:checked) .nav-btn span {
    background: #eee;
}

/* Navigation menu */
.nav-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
}

.nav-menu.active {
    max-height: 600px;
}

.nav-menu ul {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.nav-menu ul li {
    padding: 0;
}

/* Category titles (non-clickable) */
.nav-category {
    position: relative;
}

.category-title {
    display: block;
    padding: 0.75rem 1.5rem;
    color: #555;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.category-title:hover {
    background: #f0f0f0;
    color: #333;
}

/* Submenu styling */
.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #f5f5f5;
}

.nav-submenu li a {
    display: block;
    padding: 0.6rem 1.5rem 0.6rem 2.5rem;
    color: #555;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-submenu li a:hover {
    background: #e8e8e8;
    border-left-color: #007acc;
    padding-left: 2.75rem;
    color: #333;
}

/* Regular nav links (not in submenu) */
.nav-menu > ul > li > a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: #333;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-menu > ul > li > a:hover {
    background: #e8e8e8;
    border-left-color: #007acc;
    padding-left: 1.75rem;
}

/* Dark mode menu */
body:has(#theme-toggle-input:checked) .nav-menu {
    background: #333;
    border-top: 1px solid #444;
}

body:has(#theme-toggle-input:checked) .nav-submenu {
    background: #2a2a2a;
}

body:has(#theme-toggle-input:checked) .category-title {
    color: #ccc;
}

body:has(#theme-toggle-input:checked) .category-title:hover {
    background: #3a3a3a;
    color: #eee;
}

body:has(#theme-toggle-input:checked) .nav-menu > ul > li > a {
    color: #eee;
}

body:has(#theme-toggle-input:checked) .nav-menu > ul > li > a:hover {
    background: #3a3a3a;
    border-left-color: #4a9eff;
}

body:has(#theme-toggle-input:checked) .nav-submenu li a {
    color: #bbb;
}

body:has(#theme-toggle-input:checked) .nav-submenu li a:hover {
    background: #3a3a3a;
    border-left-color: #4a9eff;
    color: #eee;
}

/* Breadcrumbs in navbar */
.breadcrumbs {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #666;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
}

.breadcrumbs a {
    color: #007acc;
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

body:has(#theme-toggle-input:checked) .breadcrumbs {
    background: #2a2a2a;
    border-top: 1px solid #444;
    color: #aaa;
}

body:has(#theme-toggle-input:checked) .breadcrumbs a {
    color: #4a9eff;
}

/* --- 404 Page SVG --- */
a svg {
    cursor: pointer;
    max-height: 80vh;
    width: auto;
    display: block;
    margin: 0 auto;
}

/* --- Storyset Attribution Link --- */
a[href*="storyset.com"] {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0066cc;
    text-decoration: none;
}

a[href*="storyset.com"]:hover {
    text-decoration: underline;
}

body:has(#theme-toggle-input:checked) a[href*="storyset.com"] {
    color: #4a9eff;
}