/* pythondeck.com - modern stylesheet with dark mode */

:root {
  --bg:           #f8fafc;
  --bg-elev:      #ffffff;
  --bg-code:      #f1f5f9;
  --bg-header:    rgba(255, 255, 255, 0.85);
  --text:         #0f172a;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --primary:      #3776ab;
  --primary-hov:  #2c5d8a;
  --accent:       #ffd43b;
  --success:      #10b981;
  --danger:       #ef4444;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md:    0 4px 16px rgba(15, 23, 42, .08);
  --radius:       10px;
  --max-w:        1100px;
}

[data-theme="dark"] {
  --bg:           #0b1120;
  --bg-elev:      #131c2e;
  --bg-code:      #0f172a;
  --bg-header:    rgba(11, 17, 32, 0.85);
  --text:         #e2e8f0;
  --text-muted:   #94a3b8;
  --border:       #1e293b;
  --primary:      #60a5fa;
  --primary-hov:  #93c5fd;
  --accent:       #fbbf24;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md:    0 4px 16px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .2s, color .2s;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------------------------------------------------------------- */
/* Sticky glass header                                               */
/* ----------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; color: var(--primary); }
.logo::before {
  content: "{ }";
  color: var(--primary);
  margin-right: 6px;
  font-family: ui-monospace, monospace;
  font-weight: 800;
}
.tagline { display: none; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  flex-wrap: wrap;
}
.main-nav a {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.main-nav a:hover {
  background: var(--bg-code);
  color: var(--primary);
  text-decoration: none;
}
.cart-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}
.cart-badge:empty { display: none; }

.theme-toggle {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ----------------------------------------------------------------- */
/* Main container + typography                                       */
/* ----------------------------------------------------------------- */
.container {
  max-width: var(--max-w);
  margin: 32px auto;
  padding: 0 24px;
}

h1, h2, h3 { color: var(--text); }
h1.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}
h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 32px 0 12px;
}
h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 20px 0 8px;
}
p { margin: 0 0 12px; }

/* Tutorial course layout */
.theory-body {
  margin-bottom: 28px;
}
.examples {
  margin-top: 8px;
}
.examples > p {
  margin-top: 22px;
}
.examples > p:first-child {
  margin-top: 0;
}
.examples pre {
  margin-bottom: 20px;
}
.deep-links {
  margin-top: 28px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ----------------------------------------------------------------- */
/* Hero (homepage)                                                   */
/* ----------------------------------------------------------------- */
.hero {
  padding: 72px 32px 64px;
  text-align: center;
  background:
    radial-gradient(ellipse at top left,
                    color-mix(in srgb, var(--primary) 18%, transparent), transparent 60%),
    radial-gradient(ellipse at bottom right,
                    color-mix(in srgb, var(--accent)  16%, transparent), transparent 60%),
    var(--bg-elev);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 32px;
  box-shadow: var(--shadow-md);
}
.hero h1 {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hero p.lede {
  font-size: 19px;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 28px;
  line-height: 1.5;
}
.hero .cta-buttons {
  justify-content: center;
}

.stat-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 28px;
}
.stat {
  text-align: center;
}
.stat .num {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.stat .label {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ----------------------------------------------------------------- */
/* Card grid                                                          */
/* ----------------------------------------------------------------- */
.card-grid,
ul.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 16px 0;
}
.card,
ul.product-grid > li {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  list-style: none;
  transition: all .15s ease;
}
.card:hover,
ul.product-grid > li:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card a,
ul.product-grid > li a {
  font-weight: 600;
  font-size: 15px;
}
.card small,
ul.product-grid > li small {
  color: var(--text-muted);
  font-size: 13px;
  display: block;
  margin-top: 6px;
}

/* ----------------------------------------------------------------- */
/* Buttons                                                           */
/* ----------------------------------------------------------------- */
.btn,
.btn-primary,
.btn-outline,
.btn-ghost,
.cta-buttons a,
.cta-buttons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg-elev);
  color: var(--text);
  transition: all .15s;
}
.btn:hover,
.btn-ghost:hover,
.cta-buttons a:hover,
.cta-buttons button:not(.btn-primary):hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}
.btn-primary,
.cta-buttons .btn-primary,
button.add-to-cart.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover,
.cta-buttons .btn-primary:hover,
button.add-to-cart.btn-primary:hover {
  background: var(--primary-hov);
  border-color: var(--primary-hov);
  color: #fff;
  text-decoration: none;
}
.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  white-space: nowrap;
}
td.cart-actions {
  white-space: nowrap;
}
td.cart-actions a {
  font-weight: 600;
  font-size: 13px;
}
td.cart-actions .add-to-cart {
  margin-left: 8px;
  vertical-align: middle;
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}
.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
  padding: 6px 10px;
  font-size: 13px;
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  text-decoration: none;
}

.cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

/* Toast feedback */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ----------------------------------------------------------------- */
/* Notice / callout                                                  */
/* ----------------------------------------------------------------- */
.notice {
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  margin: 12px 0;
}

/* ----------------------------------------------------------------- */
/* Code                                                              */
/* ----------------------------------------------------------------- */
pre, code {
  font-family:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}
:not(pre) > code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  border: 1px solid var(--border);
  color: var(--text);
}
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
  margin: 12px 0;
  color: var(--text);
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ----------------------------------------------------------------- */
/* Tables                                                            */
/* ----------------------------------------------------------------- */
table,
table.editions {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0;
  font-size: 14px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
table th, table td,
table.editions th, table.editions td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
table th,
table.editions th {
  background: var(--bg-code);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
table tr:last-child td { border-bottom: none; }
table tbody tr:hover td {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

/* ----------------------------------------------------------------- */
/* Related links box                                                 */
/* Default (mobile / medium screens): inline at original flow        */
/* Wide screens (>=1200px): sticks to upper-right corner via grid    */
/* ----------------------------------------------------------------- */
.related-links {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 28px 0;
}
.related-links h3 {
  margin-top: 0;
  font-size: 16px;
  color: var(--text);
}
.related-links ul {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.related-links li {
  padding: 9px 12px;
  background: var(--bg-code);
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  transition: all .15s;
}
.related-links li:hover {
  border-color: var(--primary);
}
.related-links a {
  font-weight: 500;
}

/* Upper-right corner sidebar on wide screens.
   Uses a dedicated wrapper so row heights are not inflated by grid spanning. */
@media (min-width: 1200px) {
  .container:has(.layout-with-sidebar) {
    max-width: calc(var(--max-w) + 300px);
  }
  .layout-with-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    column-gap: 32px;
    align-items: start;
  }
  .layout-main {
    min-width: 0;
  }
  .layout-with-sidebar > .related-links {
    position: sticky;
    top: 76px;
    align-self: start;
    margin: 0;
    padding: 16px 18px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
  }
  .layout-with-sidebar > .related-links h3 {
    font-size: 14px;
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
  }
  .layout-with-sidebar > .related-links p {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
  }
  .layout-with-sidebar > .related-links ul {
    display: block;
    margin: 0;
  }
  .layout-with-sidebar > .related-links li {
    padding: 7px 11px;
    margin-bottom: 4px;
    font-size: 13px;
    background: var(--bg-code);
  }
}

/* ----------------------------------------------------------------- */
/* TOC lists                                                          */
/* ----------------------------------------------------------------- */
ul.toc {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
ul.toc > li {
  padding: 9px 14px;
  border-radius: 6px;
  margin: 2px 0;
  transition: background .12s;
}
ul.toc > li:hover {
  background: var(--bg-code);
}
ul.toc > li ul.toc {
  margin-left: 16px;
  margin-top: 4px;
}
ul.toc > li ul.toc > li {
  font-size: 14px;
  padding: 5px 12px;
  color: var(--text-muted);
}
ul.toc > li ul.toc > li a {
  color: var(--text-muted);
}
ul.toc > li ul.toc > li a:hover {
  color: var(--primary);
}

/* ----------------------------------------------------------------- */
/* Breadcrumb                                                        */
/* ----------------------------------------------------------------- */
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ----------------------------------------------------------------- */
/* Cart widgets                                                      */
/* ----------------------------------------------------------------- */
#cart-empty {
  text-align: center;
  padding: 64px 16px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
}
#cart-empty p {
  color: var(--text-muted);
  margin: 10px 0;
}
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 18px;
  font-weight: 700;
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cart-total .label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cart-total .amount {
  color: var(--primary);
  font-size: 24px;
}
.qty-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.qty-controls button {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.qty-controls button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.qty-controls .qty {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
}

/* ----------------------------------------------------------------- */
/* Article (blog post)                                               */
/* ----------------------------------------------------------------- */
article {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  margin: 16px 0;
}
article > p:first-of-type {
  font-size: 17px;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------- */
/* Footer                                                            */
/* ----------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 28px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-elev);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--primary); }

/* ----------------------------------------------------------------- */
/* Responsive                                                        */
/* ----------------------------------------------------------------- */
@media (max-width: 720px) {
  .header-inner {
    padding: 10px 14px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .logo { font-size: 16px; }
  .theme-toggle { padding: 5px 8px; font-size: 12px; }
  .main-nav {
    order: 3;
    width: 100%;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .main-nav a { padding: 4px 8px; font-size: 13px; }
  .container { padding: 0 14px; margin: 16px auto; }
  .hero { padding: 48px 16px; }
  .hero h1 { font-size: 34px; }
  .hero p.lede { font-size: 16px; }
  article { padding: 20px 18px; }
  .card-grid, ul.product-grid { grid-template-columns: 1fr; }
  table { font-size: 13px; }
  table th, table td { padding: 8px 10px; }
}
