/* --- Web Lessons Shared Stylesheet --- */

/* --- Variables & General Setup --- */
:root {
    --bg-color: #1a1a1a;
    --surface-color: #2b2b2b;
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --text-color: #f0f0f0;
    --subtle-text-color: #a0a0a0;
    --border-color: #444;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "Fira Code", "Courier New", monospace;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem; /* Offset for sticky nav */
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    color: var(--secondary-color);
    line-height: 1.3;
    margin-bottom: 1rem;
}
h1 { font-size: 2.8rem; }
h2 { font-size: 2.2rem; border-bottom: 2px solid var(--border-color); padding-bottom: 0.5rem; margin-top: 3rem; }
h3 { font-size: 1.6rem; color: var(--primary-color); margin-top: 2rem; }
h4 { font-size: 1.2rem; color: var(--subtle-text-color); margin-top: 1.5rem; }

p {
    margin-bottom: 1rem;
    max-width: 75ch; /* Improves readability */
}
a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: bold;
}
a:hover {
    text-decoration: underline;
}

/* --- Code Blocks --- */
pre {
    background-color: #111;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}
code {
    font-family: var(--font-mono);
    color: #c5c8c6;
}
p > code, li > code {
    background-color: var(--surface-color);
    padding: 2px 5px;
    border-radius: 4px;
}

/* --- Main Structure & Navigation --- */
.page-header {
    text-align: center;
    padding: 4rem 1rem;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(80, 227, 194, 0.1));
    border-bottom: 1px solid var(--border-color);
}
.page-header p {
    max-width: 60ch;
    margin: 1rem auto 0;
    color: var(--subtle-text-color);
}

nav {
    position: sticky;
    top: 0;
    background-color: rgba(43, 43, 43, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    padding: 0.5rem 0;
}
nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 1rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}
nav a {
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}
nav a:hover, nav a.active {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 2rem 4rem;
}

section {
    margin-bottom: 4rem;
}

.explanation {
    background-color: rgba(74, 144, 226, 0.1);
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    border-radius: 0 8px 8px 0;
    margin: 1rem 0;
}

.button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: transform 0.2s, background-color 0.2s;
    background-color: var(--primary-color);
    color: white;
    border: none;
}
.button:hover {
    transform: translateY(-2px);
    background-color: #5a9eee;
    text-decoration: none;
}

/* --- Index Page: Lesson Cards --- */
.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}
.lesson-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}
.lesson-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.lesson-card h3 {
    margin-top: 0;
}
.lesson-card p {
    flex-grow: 1; /* Pushes button to the bottom */
    color: var(--subtle-text-color);
}

/* --- Layout Page: Interactive Demo --- */
.layout-demo {
    border: 2px dashed var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}
.demo-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    background-color: var(--surface-color);
    padding: 1rem;
    border-radius: 8px;
}
.demo-controls label {
    font-weight: bold;
    margin-right: 0.5rem;
}
.demo-controls select {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0.25rem;
}
.flex-container {
    display: flex;
    min-height: 150px;
    gap: 1rem;
    background-color: var(--surface-color);
    padding: 1rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}
.flex-item {
    background-color: var(--primary-color);
    padding: 1rem;
    border-radius: 5px;
    color: white;
    text-align: center;
    flex-basis: 100px;
}
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    background-color: var(--surface-color);
    padding: 1rem;
    border-radius: 5px;
}
.grid-item {
    background-color: var(--secondary-color);
    padding: 2rem 1rem;
    border-radius: 5px;
    color: var(--bg-color);
    text-align: center;
    font-weight: bold;
}
.grid-item-span {
    grid-column: span 2;
    background-color: #e27d4a;
}

/* --- HTML Elements Page --- */
.element-group {
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-top: 2rem;
    border-radius: 8px;
}
blockquote {
    border-left: 4px solid var(--secondary-color);
    padding-left: 1rem;
    margin-left: 1rem;
    font-style: italic;
    color: var(--subtle-text-color);
}
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
th, td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}
th {
    background-color: var(--surface-color);
    color: var(--secondary-color);
}
img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* --- Forms Page --- */
form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}
fieldset {
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 8px;
}
legend {
    padding: 0 0.5rem;
    color: var(--primary-color);
    font-weight: bold;
}
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}
input[type="text"], input[type="email"], textarea, select {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 1rem;
}
button[type="submit"] {
    align-self: flex-start;
}
#form-output {
    margin-top: 2rem;
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-height: 100px;
}
#form-output h3 {
    margin-top: 0;
}

