:root {
  /* Warm color palette with Swift orange */
  --color-bg: #faf6f1;
  --color-bg-alt: #f5ede4;
  --color-bg-dark: #282828;
  --color-text: #1a1a1a;
  --color-text-muted: #666;
  --color-border: rgba(0, 0, 0, 0.1);

  /* Swift orange accent colors */
  --color-accent: #F05138;
  --color-accent-hover: #d63d25;
  --color-accent-light: #ff6f4a;
  --color-success: #4a9c5d;
  --color-warning: #e59a2f;
  --color-danger: #c20a1a;

  /* Code block colors (gruvbox-inspired) */
  --color-code-bg: #282828;
  --color-code-text: #fbf1c7;
  --color-code-comment: #928374;
  --color-code-keyword: #fb4934;
  --color-code-string: #b8bb26;
  --color-code-function: #fabd2f;

  /* Typography */
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Layout */
  --max-width: 860px;
  --spacing: 1.5rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
}

/* Header */
.site-header {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--color-border);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo:hover {
  color: var(--color-accent);
}

nav {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

nav a:hover {
  color: var(--color-text);
}

/* Hero */
.hero {
  padding: 5rem 0 4rem;
  border-bottom: 1px solid var(--color-border);
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 400;
  line-height: 0.95;
  margin-bottom: 1.5rem;
  letter-spacing: -0.03em;
  font-style: italic;
}

.hero h1 .accent {
  display: block;
  font-style: normal;
  color: var(--color-accent);
}

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  max-width: 540px;
  line-height: 1.6;
}

.hero .credit {
  margin-top: 1.5rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  text-align: left;
}

.hero .credit a {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}

.hero .credit a:hover {
  color: var(--color-accent);
}

.hero .tribute {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: left;
}

.hero .tribute a {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
}

.hero .tribute a:hover {
  color: var(--color-accent);
  text-decoration-color: var(--color-accent);
}

/* Banner */
.banner {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding: 0.875rem 1.25rem;
  background: var(--color-accent);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.2s, transform 0.2s;
}

.banner:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  text-decoration: none;
}

.banner-text {
  opacity: 0.9;
}

.banner-cta {
  font-weight: 600;
}

/* Sections */
section {
  padding: 3.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

section:last-of-type {
  border-bottom: none;
}

h2 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 1.25rem;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h3 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 400;
  margin: 2.5rem 0 1rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

h4 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 400;
  margin: 1.5rem 0 0.5rem;
  color: var(--color-text);
}

p {
  margin-bottom: 1rem;
}

/* Mental Model Boxes */
.mental-model {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: 4px;
}

.mental-model h4 {
  color: var(--color-accent);
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.mental-model p:last-child {
  margin-bottom: 0;
}

.mental-model code {
  background: oklch(0.88 0.04 50);
  color: oklch(0.4 0.1 50);
}

/* Warning/Tip Boxes */
.warning {
  background: rgba(250, 189, 47, 0.12);
  border: 1px solid rgba(250, 189, 47, 0.3);
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: 4px;
}

.warning h4 {
  color: #b57614;
  margin-top: 0;
}

.warning code {
  background: oklch(0.88 0.06 85);
  color: oklch(0.4 0.12 85);
}

.tip {
  background: rgba(74, 156, 93, 0.1);
  border: 1px solid rgba(74, 156, 93, 0.3);
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: 4px;
}

.tip h4 {
  color: var(--color-success);
  margin-top: 0;
}

.tip code {
  background: oklch(0.88 0.06 145);
  color: oklch(0.35 0.12 145);
}

/* Analogy Boxes - Office Building Theme */
.analogy {
  background: rgba(69, 133, 163, 0.08);
  border: 1px solid rgba(69, 133, 163, 0.25);
  border-left: 4px solid #458588;
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: 4px;
}

.analogy h4 {
  font-family: var(--font-serif);
  color: #458588;
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.analogy h4::before {
  content: "🏢 ";
}

.analogy p:last-child,
.analogy ul:last-child {
  margin-bottom: 0;
}

.analogy code {
  background: oklch(0.85 0.04 220);
  color: oklch(0.35 0.08 220);
}

/* Code Tabs */
.code-tabs {
  margin: 1.5rem 0;
}

.code-tabs-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-code-bg);
}

.code-tabs-nav button {
  background: transparent;
  border: none;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.code-tabs-nav button:hover {
  color: var(--color-text);
}

.code-tabs-nav button.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.code-tab-content {
  display: none;
}

.code-tab-content.active {
  display: block;
}

.code-tab-content pre {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Code Blocks */
pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 1.25rem 1.5rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

p code, li code {
  background: oklch(0.92 0.02 60);
  color: oklch(0.35 0.05 60);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* Syntax Highlighting - Gruvbox-inspired */
pre[class*="language-"] {
  background: var(--color-code-bg);
}

code[class*="language-"] {
  color: var(--color-code-text);
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #928374;
}

.token.punctuation {
  color: #a89984;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: #fb4934;
}

.token.boolean,
.token.number {
  color: #d3869b;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #b8bb26;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
  color: #fe8019;
}

.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
  color: #fabd2f;
}

.token.keyword {
  color: #fb4934;
}

.token.regex,
.token.important {
  color: #fe8019;
}

.token.important,
.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

.token.entity {
  cursor: help;
}

/* Line numbers if used */
pre[class*="language-"].line-numbers {
  position: relative;
  padding-left: 3.8em;
  counter-reset: linenumber;
}

pre[class*="language-"].line-numbers > code {
  position: relative;
  white-space: inherit;
}

/* Lists */
ul, ol {
  margin: 1rem 0 1.5rem 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Tables */
.comparison {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

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

td:first-child {
  white-space: nowrap;
}

th {
  background: var(--color-bg-alt);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Summary Cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.summary-card {
  background: var(--color-bg-alt);
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.summary-card h4 {
  color: var(--color-text);
  margin-top: 0;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
}

.summary-card p {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.summary-card p:last-child {
  margin-bottom: 0;
}

/* Tribute section */
.tribute {
  text-align: center;
  padding: 2rem 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.tribute a {
  color: var(--color-text-muted);
  text-decoration: underline;
}

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

/* Footer */
.site-footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.site-footer .container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.site-footer a {
  color: var(--color-text-muted);
}

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

/* Resource Links */
.resources {
  margin: 1.5rem 0;
}

.resources h4 {
  margin-bottom: 0.75rem;
}

.resources ul {
  margin: 0;
  list-style: none;
  padding: 0;
}

.resources li {
  margin-bottom: 0.4rem;
  padding-left: 0;
}

.resources li::before {
  content: none;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .site-header .container {
    flex-direction: column;
    text-align: center;
  }

  nav {
    justify-content: center;
    gap: 1.25rem;
  }

  .hero {
    padding: 3.5rem 0 3rem;
  }

  .hero h1 {
    font-size: 2.5rem;
  }

  section {
    padding: 2.5rem 0;
  }
}

/* Strong text */
strong {
  font-weight: 600;
}

/* Blockquote */
blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  font-style: italic;
}

/* TL;DR Section */
.tldr {
  background: var(--color-accent);
  color: #fff;
  padding: 2.5rem 0;
  text-align: center;
}

.tldr h2 {
  color: #fff;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.tldr p {
  color: #fff;
  max-width: 600px;
  margin: 0 auto 1rem auto;
  font-size: 1.1rem;
  line-height: 1.6;
}

.tldr a:not(.read-more) {
  color: #fff;
  text-decoration: underline;
}

.tldr .read-more {
  display: inline-block;
  margin-top: 1rem;
  color: #fff;
  text-decoration: underline;
  font-size: 0.95rem;
}

.tldr .read-more:hover {
  opacity: 0.9;
}

/* Compiler Errors */
.compiler-error {
  background: #1a1a1a;
  color: #ff6b6b;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin: 0.75rem 0;
  border-left: 3px solid #ff6b6b;
}

.error-fix {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-success);
  border-left: 3px solid var(--color-success);
  padding: 1rem;
  margin: 0.75rem 0;
  border-radius: 4px;
}

.error-fix h5 {
  color: var(--color-success);
  font-size: 0.85rem;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Isolation Domain Highlighting */
.isolation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  font-family: var(--font-sans);
}

.isolation-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.isolation-legend-item::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.isolation-legend-item.main::before {
  background: rgba(240, 81, 56, 0.35);
}

.isolation-legend-item.detached::before {
  background: rgba(147, 112, 219, 0.35);
}

.isolation-legend-item.actor::before {
  background: rgba(66, 165, 245, 0.35);
}

.isolation-legend-item.nonisolated::before {
  background: rgba(156, 163, 175, 0.35);
}

/* Code block with isolation sidebar */
.code-isolation {
  position: relative;
  margin: 1.5rem 0;
}

.code-isolation pre {
  margin: 0;
  padding-left: 1.5rem;
}

/* Isolation sidebar - shows colored segments */
.isolation-sidebar {
  position: absolute;
  left: 0.5rem;
  top: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  width: 4px;
  border-radius: 2px;
  overflow: hidden;
  z-index: 2;
}

.isolation-sidebar .segment {
  flex-grow: 1;
}

.isolation-sidebar .segment.main {
  background: #F05138;
}

.isolation-sidebar .segment.actor {
  background: #42a5f5;
}

.isolation-sidebar .segment.detached {
  background: #9370db;
}

.isolation-sidebar .segment.nonisolated {
  background: #9ca3af;
}

/* Isolation overlay - highlights non-primary sections */
.isolation-overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  z-index: 1;
  pointer-events: none;
  border-radius: 0 4px 4px 0;
  overflow: hidden;
}

.isolation-overlay .segment {
  flex-grow: 1;
}

.isolation-overlay .segment.main-highlight {
  background: rgba(240, 81, 56, 0.15);
}

.isolation-overlay .segment.actor-highlight {
  background: rgba(66, 165, 245, 0.15);
}

.isolation-overlay .segment.detached-highlight {
  background: rgba(147, 112, 219, 0.15);
}

.isolation-overlay .segment.nonisolated-highlight {
  background: rgba(156, 163, 175, 0.15);
}
