/* ==========================================================================
   Modern Classless CSS
   Applies directly to standard HTML tags.
   ========================================================================== */

/* Modern CSS Reset & Design Tokens */
:root {
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border-color: #e2e8f0;
  --code-bg: #1e293b;
  --code-text: #f8fafc;
  
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Dark Mode support out of the box */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --border-color: #334155;
    --code-bg: #020617;
    --code-text: #f8fafc;
  }
}

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

html {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--bg-color);
  accent-color: var(--primary);
  scroll-behavior: smooth;
}

/* Page Layout Container */
body {
  max-width: 70ch;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header & Navigation */
header {
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}

nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-top: 1rem;
}

/* Main Content Area */
main {
  flex: 1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h1 { font-size: 2.25rem; margin-top: 0; }
h2 { font-size: 1.75rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }

p {
  margin-bottom: 1.25rem;
  color: var(--text-main);
}

small {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Links */
a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

/* Lists */
ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

/* Blockquotes & Callouts */
blockquote {
  border-left: 4px solid var(--primary);
  background-color: var(--surface-color);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Code & Preformatted Text */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--border-color);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.9em;
}

pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
}

/* Media Elements */
img, video, svg {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
  margin: 1.5rem 0;
}

figure {
  margin: 1.5rem 0;
}

figcaption {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background-color: var(--surface-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: var(--border-color);
  font-weight: 600;
}

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

/* Form Controls */
form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 1.5rem 0;
  background: var(--surface-color);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

fieldset {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

legend {
  padding: 0 0.5rem;
  font-weight: 600;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea,
select {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-color);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

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

/* Buttons */
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  color: #ffffff;
  background-color: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease;
  align-self: flex-start;
}

button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover {
  background-color: var(--primary-hover);
}

/* Horizontal Rule */
hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2.5rem 0;
}

/* Footer */
footer {
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}
