/* === CSS Variables === */
:root {
    /* Light Mode */
    --color-bg-gradient-start-light: #f0f2f5;
    --color-bg-gradient-end-light: #e6e9ee;
    --glass-bg-light: rgba(255, 255, 255, 0.6);
    --glass-border-light: rgba(255, 255, 255, 0.8);
    --text-primary-light: #1f2937;
    --text-secondary-light: #6b7280;
    --shadow-md-light: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.07);
    --shadow-lg-light: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.07);
    --shadow-dark-light: rgba(0, 0, 0, 0.1);
    --input-bg-light: rgba(255, 255, 255, 0.7);
    --input-bg-focus-light: rgba(255, 255, 255, 1);
    --focus-ring-color-light: #3b82f6;

    /* Dark Mode */
    --color-bg-gradient-start-dark: #1f2937;
    --color-bg-gradient-end-dark: #111827;
    --glass-bg-dark: rgba(31, 41, 55, 0.6);
    --glass-border-dark: rgba(55, 65, 81, 0.8);
    --text-primary-dark: #f9fafb;
    --text-secondary-dark: #9ca3af;
    --shadow-md-dark: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg-dark: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-dark-dark: rgba(0, 0, 0, 0.3);
    --input-bg-dark: rgba(55, 65, 81, 0.7);
    --input-bg-focus-dark: rgba(55, 65, 81, 1);
    --focus-ring-color-dark: #60a5fa;

    /* Set default vars */
    --color-bg-gradient-start: var(--color-bg-gradient-start-light);
    --color-bg-gradient-end: var(--color-bg-gradient-end-light);
    --glass-bg: var(--glass-bg-light);
    --glass-border: var(--glass-border-light);
    --text-primary: var(--text-primary-light);
    --text-secondary: var(--text-secondary-light);
    --shadow-md: var(--shadow-md-light);
    --shadow-lg: var(--shadow-lg-light);
    --shadow-dark: var(--shadow-dark-light);
    --input-bg: var(--input-bg-light);
    --input-bg-focus: var(--input-bg-focus-light);
    --focus-ring-color: var(--focus-ring-color-light);

    /* Sizing */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
}

/* Apply Dark Mode */
.dark-mode {
    --color-bg-gradient-start: var(--color-bg-gradient-start-dark);
    --color-bg-gradient-end: var(--color-bg-gradient-end-dark);
    --glass-bg: var(--glass-bg-dark);
    --glass-border: var(--glass-border-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --shadow-md: var(--shadow-md-dark);
    --shadow-lg: var(--shadow-lg-dark);
    --shadow-dark: var(--shadow-dark-dark);
    --input-bg: var(--input-bg-dark);
    --input-bg-focus: var(--input-bg-focus-dark);
    --focus-ring-color: var(--focus-ring-color-dark);
}

/* === Base Styles === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: linear-gradient(135deg, var(--color-bg-gradient-start), var(--color-bg-gradient-end));
    transition: background-color 0.3s ease;
    overflow: hidden; /* Hide scrollbars */
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

/* === Layout === */
.page-wrapper {
    width: 90vw;
    height: 90vh;
    margin: 5vh auto;
    /* This is the 3D "camera" */
    perspective: 1000px;
}

.app-shell {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 240px 1fr; /* Sidebar width and main content */
    grid-template-rows: 64px 20px 1fr 64px; /* Header, Gap, Main, Footer */
    grid-template-areas:
        "header header"
        "gap    gap"
        "sidebar main"
        "footer footer";
    gap: 10px;
    padding: 10px;
    
    /* FIXED: This is the critical line that enables 3D nesting.
      It tells this element to be a 3D stage for its children.
    */
    transform-style: preserve-3d;

    /* We apply the 3D rotation vars here, but they are set by JS */
    /* The main header is the primary moving part */
    --header-rotate-x: var(--rotate-x, 0deg);
    --header-rotate-y: var(--rotate-y, 0deg);
    
    /* Other elements follow at a different "depth" */
    --sidebar-rotate-x: calc(var(--rotate-x, 0deg) * 0.8);
    --sidebar-rotate-y: calc(var(--rotate-y, 0deg) * 0.8);
    --main-rotate-x: calc(var(--rotate-x, 0deg) * 0.6);
    --main-rotate-y: calc(var(--rotate-y, 0deg) * 0.6);
    --footer-rotate-x: calc(var(--rotate-x, 0deg) * 0.9);
    --footer-rotate-y: calc(var(--rotate-y, 0deg) * 0.9);
    
    transition: transform 0.1s ease-out;
}

/* === Main Content Area === */
.main-content {
    grid-area: main;
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    overflow-y: auto;
    
    /* 3D Tilt */
    transform: translateZ(100px) var(--main-rotate-x) var(--main-rotate-y);
    transition: transform 0.1s ease-out, background-color 0.3s ease, border-color 0.3s ease, opacity 0.15s ease-out;
    opacity: 1;
}

.main-content.fade-out {
    opacity: 0;
}

.page-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.page-content p {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.page-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1.25rem;
}

.page-content li {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* === Focus Visible (Accessibility) === */
/* Style for keyboard/remote/joypad navigation */
:is(a, button, input):focus-visible {
    outline: 3px solid var(--focus-ring-color);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

