/* ============================================================================
   VARIATION 4: REFINED CLASSIC
   ============================================================================
   Aesthetic: Timeless elegance with approachable warmth
   Typography: Lora (serif headings) + Nunito (sans body)
   Palette: Paper-like background, warm charcoal text, classic accents
   Mood: Traditional yet friendly, refined yet accessible
   ========================================================================== */

/* ============================================================================
   VARIABLES & THEME
   ========================================================================== */

:root {
  /* Colors - Refined Classic Palette */
  --color-primary: #2B2621;          /* Warm charcoal (near black) */
  --color-secondary: #3F3935;        /* Medium warm charcoal */
  --color-accent: #2B75A8;           /* Classic blue */
  --color-accent-hover: #1D5378;     /* Deep blue */
  --color-background: #F9F6F1;       /* Paper-like cream */
  --color-surface: #F0EBE5;          /* Warm gray surface */
  --color-border: #DED6CA;           /* Warm taupe border */
  --color-text: #2B2621;             /* Warm charcoal */
  --color-text-light: #6E6660;       /* Medium warm gray */
  --color-success: #3B8556;          /* Classic green */
  --color-warning: #D14738;          /* Classic red */

  /* Typography - Classic Serif + Friendly Sans Pairing */
  --font-family-headings: "Lora", Georgia, serif;
  --font-family-base: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-family-mono: "Monaco", "Menlo", "Consolas", monospace;

  --font-size-base: 17px;
  --font-size-sm: 14px;
  --font-size-lg: 19px;
  --font-size-xl: 22px;
  --font-size-2xl: 28px;
  --font-size-3xl: 38px;

  --line-height-base: 1.7;
  --line-height-tight: 1.3;
  --line-height-loose: 1.8;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Layout */
  --sidebar-width: 250px;
  --sidebar-width-mobile: 0;
  --main-max-width: 900px;
  --content-padding: var(--space-lg);

  /* Shadows - Refined, classic shadows */
  --shadow-sm: 0 1px 3px rgba(43, 38, 33, 0.08);
  --shadow-md: 0 4px 8px rgba(43, 38, 33, 0.12);
  --shadow-lg: 0 10px 20px rgba(43, 38, 33, 0.14);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;
}

/* ============================================================================
   RESET & BASE STYLES
   ========================================================================== */

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

.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-accent);
  color: white;
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  z-index: 9999;
  border-radius: 0 0 var(--radius-md) 0;
  font-weight: 600;
}

.skip-to-content:focus {
  top: 0;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-background);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================================
   TYPOGRAPHY
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-headings);
  font-weight: 600;
  line-height: var(--line-height-tight);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  color: var(--color-primary);
}

h1 {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  margin-top: 0;
}

h2 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: var(--space-md);
}

h3 {
  font-size: var(--font-size-xl);
  font-weight: 600;
}

h4 {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

h5, h6 {
  font-size: var(--font-size-base);
  font-weight: 600;
}

p {
  margin-bottom: var(--space-md);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

p + p {
  margin-top: -var(--space-sm);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
  font-weight: 600;
}

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

a:active {
  color: var(--color-accent-hover);
}

strong {
  font-weight: 700;
  color: var(--color-primary);
}

/* ============================================================================
   LISTS
   ========================================================================== */

ul, ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
}

li {
  margin-bottom: var(--space-sm);
}

ul ul, ol ol, ul ol, ol ul {
  margin-top: var(--space-sm);
  margin-bottom: 0;
}

/* ============================================================================
   CODE & BLOCKS
   ========================================================================== */

code {
  font-family: var(--font-family-mono);
  font-size: 0.9em;
  background-color: var(--color-surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

pre {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
  position: relative;
}

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

blockquote {
  border-left: 4px solid var(--color-accent);
  padding-left: var(--space-md);
  margin-bottom: var(--space-md);
  color: var(--color-text-light);
  font-style: italic;
  font-family: var(--font-family-headings);
}

/* ============================================================================
   LAYOUT: SIDEBAR + MAIN CONTENT
   ========================================================================== */

body {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: auto 1fr auto;
}

@media (max-width: 767px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }
}

/* ============================================================================
   SIDEBAR NAVIGATION
   ========================================================================== */

.sidebar {
  background-color: var(--color-primary);
  color: white;
  padding: var(--space-md) var(--space-lg);
  overflow-y: auto;
  max-height: 100vh;
  grid-row: 1 / -1;
  grid-column: 1;
}

@media (min-width: 768px) {
  .sidebar {
    position: sticky;
    top: 0;
  }
}

.sidebar h2 {
  color: white;
  border-bottom-color: rgba(255, 255, 255, 0.2);
  font-size: var(--font-size-base);
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
  font-family: var(--font-family-headings);
  font-weight: 700;
}

.sidebar h2:first-child {
  margin-top: 0;
}

.sidebar h3 {
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--font-size-sm);
  font-weight: 700;
  margin-top: var(--space-md);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--font-family-base);
}

.sidebar h3:first-of-type {
  margin-top: var(--space-sm);
}

.sidebar a {
  color: rgba(255, 255, 255, 0.85);
  display: block;
  padding: 0.4rem var(--space-md);
  margin-left: -var(--space-md);
  margin-right: -var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: var(--font-size-sm);
  line-height: 1.4;
  font-weight: 400;
}

.sidebar a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
}

.sidebar a.active {
  background-color: var(--color-accent);
  color: white;
  font-weight: 700;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-sm) 0;
}

.sidebar li {
  margin-bottom: 0;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--font-size-xl);
  cursor: pointer;
  padding: var(--space-sm);
  margin: 0;
  line-height: 1;
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: -250px;
    top: 0;
    width: 250px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease-in-out;
    grid-column: unset;
    grid-row: unset;
  }

  .sidebar.active {
    left: 0;
  }

  .sidebar-toggle {
    display: block;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }
}

/* ============================================================================
   MAIN CONTENT AREA
   ========================================================================== */

main {
  grid-column: 2;
  grid-row: 1 / -1;
  padding: var(--content-padding);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: break-word;
}

@media (max-width: 767px) {
  main {
    grid-column: 1;
    grid-row: 3;
  }
}

.container {
  max-width: var(--main-max-width);
  margin: 0 auto;
  width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================================================
   HEADER
   ========================================================================== */

header {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

@media (max-width: 767px) {
  header {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

header .site-title {
  margin: 0;
  font-family: var(--font-family-headings);
  font-size: var(--font-size-xl);
  font-weight: 700;
  line-height: var(--line-height-tight);
  color: var(--color-primary);
  flex: 1;
}

@media (min-width: 768px) {
  header .site-title {
    display: none;
  }
}

/* ============================================================================
   FOOTER
   ========================================================================== */

footer {
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  grid-column: 2;
  grid-row: -1;
  margin-top: auto;
}

@media (max-width: 767px) {
  footer {
    grid-column: 1 / -1;
  }
}

footer p {
  margin: 0;
}

footer a {
  color: var(--color-accent);
}

footer a:hover {
  color: var(--color-accent-hover);
}

/* ============================================================================
   BUTTONS & INTERACTIVE ELEMENTS
   ========================================================================== */

button, .button {
  background-color: var(--color-accent);
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 600;
}

button:hover, .button:hover {
  background-color: var(--color-accent-hover);
  box-shadow: var(--shadow-md);
}

button:active, .button:active {
  transform: scale(0.98);
}

button.secondary {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

button.secondary:hover {
  background-color: var(--color-border);
}

.download-button {
  display: inline-block;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-base);
  font-weight: 700;
  background-color: var(--color-success);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: var(--space-md);
}

.download-button:hover {
  background-color: #2C6744;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.download-button:active {
  transform: translateY(0);
}

.copy-button {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  opacity: 0;
  transition: opacity var(--transition-fast);
  background-color: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}

pre:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background-color: var(--color-accent-hover);
}

/* ============================================================================
   PAGE BANNERS
   ========================================================================== */

.page-banner {
  height: 120px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg,
    #667eea 0%,
    #764ba2 25%,
    #a855f7 50%,
    #667eea 75%,
    #4facfe 100%);
  background-size: 200% 200%;
  animation: gradientShift 120s ease infinite;
  box-shadow: var(--shadow-lg);
}

.page-banner h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: white;
  text-align: center;
  font-family: var(--font-family-headings);
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
               0 1px 3px rgba(0, 0, 0, 0.4);
}

.page-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  animation: flowingShapes 90s ease-in-out infinite;
}

@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes flowingShapes {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  33% {
    transform: translate(10%, 5%) rotate(5deg);
  }
  66% {
    transform: translate(-5%, 10%) rotate(-3deg);
  }
}

/* ============================================================================
   CARDS & CALLOUTS
   ========================================================================== */

.card, .callout {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.callout.highlight {
  border-left: 4px solid var(--color-accent);
  background-color: rgba(43, 117, 168, 0.06);
}

.callout.warning {
  border-left: 4px solid var(--color-warning);
  background-color: rgba(209, 71, 56, 0.06);
}

.download-section {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
}

.download-section h3 {
  margin-top: 0;
}

.download-section ol {
  margin-left: var(--space-lg);
}

.blog-callout {
  margin: var(--space-xl) 0;
}

.blog-callout h3 {
  margin-top: 0;
}

.author-callout {
  background: linear-gradient(135deg, rgba(43, 117, 168, 0.08) 0%, rgba(43, 117, 168, 0.03) 100%);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin: var(--space-xl) 0;
  box-shadow: var(--shadow-md);
}

.author-callout h2 {
  margin-top: 0;
  color: var(--color-accent);
  font-family: var(--font-family-headings);
  font-weight: 700;
}

.author-signature {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.author-photo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.author-signature p {
  margin: 0;
  font-style: italic;
  font-family: var(--font-family-headings);
  color: var(--color-text-light);
}

/* ============================================================================
   TABLES
   ========================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  background-color: var(--color-background);
}

thead {
  background-color: var(--color-surface);
}

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

th {
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-family-headings);
}

tbody tr:hover {
  background-color: var(--color-surface);
}

/* ============================================================================
   NAVIGATION: NEXT/PREVIOUS
   ========================================================================== */

.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.nav-buttons a {
  flex: 1;
  padding: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  transition: all var(--transition-fast);
}

.nav-buttons a:hover {
  background-color: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
  text-decoration: none;
}

.nav-buttons a:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   FORMS & INPUTS
   ========================================================================== */

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-background);
  color: var(--color-text);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(43, 117, 168, 0.1);
}

/* ============================================================================
   UTILITY CLASSES
   ========================================================================== */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-text-light);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

/* ============================================================================
   RESPONSIVE TYPOGRAPHY
   ========================================================================== */

@media (max-width: 767px) {
  h1 {
    font-size: var(--font-size-2xl);
  }

  h2 {
    font-size: var(--font-size-xl);
  }

  h3 {
    font-size: var(--font-size-lg);
  }

  main {
    padding: var(--space-md);
  }
}

/* ============================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  body {
    display: block;
  }

  .sidebar,
  .sidebar-toggle,
  .nav-buttons,
  footer,
  .copy-button {
    display: none !important;
  }

  main {
    max-width: 100%;
    padding: 0;
  }

  a {
    color: var(--color-text);
    text-decoration: none;
  }

  h2 {
    page-break-after: avoid;
  }

  pre {
    page-break-inside: avoid;
  }

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

/* ============================================================================
   TABLE OF CONTENTS (Collapsible)
   ========================================================================== */

.table-of-contents {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-lg) 0 var(--space-xl) 0;
}

.table-of-contents summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-family-headings);
  user-select: none;
  list-style: none;
}

.table-of-contents summary::-webkit-details-marker {
  display: none;
}

.table-of-contents[open] summary {
  margin-bottom: var(--space-md);
}

.table-of-contents nav {
  margin-top: var(--space-sm);
}

.table-of-contents ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.table-of-contents li {
  margin: var(--space-sm) 0;
  padding-left: var(--space-md);
}

.table-of-contents a {
  color: var(--color-accent);
  text-decoration: none;
  display: block;
  padding: var(--space-xs) 0;
  transition: color 0.2s ease;
}

.table-of-contents a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* ============================================================================
   BACK TO TOP BUTTON
   ========================================================================== */

.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: var(--color-accent);
  color: white;
  border: none;
  border-radius: 50px;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 900;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: var(--color-accent-hover);
  box-shadow: var(--shadow-lg);
}

.back-to-top:active {
  transform: translateY(1px);
}

@media (max-width: 768px) {
  .back-to-top {
    bottom: 20px;
    right: 20px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
  }
}
