/* ── iOS/SwiftUI Tutorial — Apple-Inspired Design ── */
:root {
  --blue: #007AFF;
  --blue-dark: #0062CC;
  --blue-light: #E8F3FF;
  --green: #34C759;
  --orange: #FF9500;
  --red: #FF3B30;
  --purple: #AF52DE;
  --gray1: #8E8E93;
  --gray2: #AEAEB2;
  --gray3: #C7C7CC;
  --gray4: #D1D1D6;
  --gray5: #E5E5EA;
  --gray6: #F2F2F7;
  --label: #000000;
  --secondary-label: #3C3C43;
  --tertiary-label: #636366;
  --bg: #FFFFFF;
  --secondary-bg: #F2F2F7;
  --grouped-bg: #F2F2F7;
  --separator: rgba(60,60,67,0.12);
  --fill: rgba(120,120,128,0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  background: var(--grouped-bg);
  color: var(--label);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── TOP NAV ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(242,242,247,0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--separator);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-back {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 400;
}
.nav-back::before { content: '‹'; font-size: 1.3rem; line-height: 1; }
.nav-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--label);
  flex: 1;
}
.nav-badge {
  background: var(--blue);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

/* ── HERO ── */
.hero {
  background: linear-gradient(160deg, #1C1C1E 0%, #2C2C2E 40%, #1A1A2E 100%);
  color: #fff;
  padding: 80px 24px 70px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 40%, rgba(0,122,255,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 70%, rgba(175,82,222,0.12) 0%, transparent 60%);
}
.hero-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  position: relative;
  display: inline-block;
}
.hero-eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 10px;
  position: relative;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  position: relative;
  margin-bottom: 16px;
}
.hero-sub {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.65);
  max-width: 560px;
  margin: 0 auto 32px;
  position: relative;
  line-height: 1.7;
}
.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  position: relative;
}
.chip {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
  font-size: 0.78rem;
  padding: 5px 14px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

/* ── MAIN CONTAINER ── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── CARDS ── */
.card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 12px rgba(0,0,0,0.04);
}
.card-list {
  list-style: none;
}
.card-list li {
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--separator);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  border-radius: 0;
}
.card-list li:last-child { border-bottom: none; }
.card-list li:hover { background: var(--blue-light); }
.card-list a {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  text-decoration: none;
  color: inherit;
}
.list-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: var(--blue-light);
}
.list-content { flex: 1; }
.list-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--label);
  margin-bottom: 3px;
}
.list-desc { font-size: 0.82rem; color: var(--tertiary-label); }
.list-chevron {
  color: var(--gray3);
  font-size: 1rem;
  align-self: center;
  flex-shrink: 0;
}
.list-num {
  width: 28px;
  height: 28px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Section Header */
.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray1);
  margin: 32px 0 10px 4px;
}
.section-label:first-child { margin-top: 0; }

/* ── CHAPTER PAGE LAYOUT ── */
.chapter-hero {
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  color: #fff;
  padding: 60px 24px 50px;
  text-align: center;
}
.chapter-hero .ch-num {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 10px;
}
.chapter-hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.chapter-hero p { opacity: 0.8; font-size: 1rem; max-width: 540px; margin: 0 auto; }

/* Content styles */
.content { max-width: 780px; margin: 0 auto; padding: 40px 24px 80px; }

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--label);
  margin: 40px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--blue-light);
}
h2:first-child { margin-top: 0; }
h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--label);
  margin: 28px 0 10px;
}
h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--secondary-label);
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
}

p { margin-bottom: 14px; color: var(--secondary-label); font-size: 0.95rem; line-height: 1.75; }

/* Info boxes */
.callout {
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 20px 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.88rem;
  line-height: 1.65;
}
.callout-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.callout p { margin: 0; color: inherit; font-size: inherit; }
.callout strong { display: block; margin-bottom: 4px; font-weight: 700; }
.callout.info { background: var(--blue-light); color: #003F8A; border-left: 3px solid var(--blue); }
.callout.tip { background: #F0FFF4; color: #1B5E20; border-left: 3px solid var(--green); }
.callout.warning { background: #FFF8E1; color: #6D4C1A; border-left: 3px solid var(--orange); }
.callout.danger { background: #FFF0F0; color: #7A1A1A; border-left: 3px solid var(--red); }

/* Code blocks */
pre {
  background: #1C1C1E;
  color: #E5E5EA;
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.65;
  margin: 16px 0;
  position: relative;
}
pre .lang-label {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
}
code {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
}
p code, li code, td code {
  background: var(--gray5);
  color: #C0392B;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Keyword coloring */
.kw { color: #FC5FA3; }     /* keywords */
.ty { color: #5DD8FF; }     /* types */
.st { color: #FC6A5D; }     /* strings */
.cm { color: #6C7986; }     /* comments */
.fn { color: #A167E6; }     /* functions */
.nu { color: #D0BF69; }     /* numbers */
.at { color: #BF8555; }     /* attributes */
.pr { color: #67B7A4; }     /* properties */

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.88rem;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
th {
  background: var(--gray6);
  color: var(--secondary-label);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
td { padding: 11px 16px; border-top: 0.5px solid var(--separator); color: var(--secondary-label); }
tr:last-child td { border-bottom: none; }

/* Definition list */
.def-list { list-style: none; }
.def-list li {
  padding: 14px 0;
  border-bottom: 0.5px solid var(--separator);
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  font-size: 0.9rem;
}
.def-list li:last-child { border-bottom: none; }
.def-term {
  font-weight: 600;
  color: var(--blue);
  font-family: 'SF Mono', monospace;
  font-size: 0.85rem;
}
.def-desc { color: var(--secondary-label); }

/* Step list */
.step-list { list-style: none; counter-reset: steps; }
.step-list li {
  counter-increment: steps;
  padding: 14px 0 14px 52px;
  border-bottom: 0.5px solid var(--separator);
  position: relative;
  font-size: 0.92rem;
  color: var(--secondary-label);
  line-height: 1.7;
}
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 14px;
  width: 30px;
  height: 30px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.step-list li strong { color: var(--label); }

/* ul / ol general */
.content ul, .content ol {
  padding-left: 22px;
  margin: 10px 0 16px;
  color: var(--secondary-label);
  font-size: 0.92rem;
  line-height: 1.8;
}

/* Chapter nav */
.chapter-nav {
  display: flex;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 0.5px solid var(--separator);
}
.chapter-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--label);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
  font-size: 0.82rem;
}
.chapter-nav a:hover { box-shadow: 0 4px 16px rgba(0,122,255,0.14); }
.chapter-nav .nav-dir { font-size: 0.72rem; color: var(--gray1); text-transform: uppercase; letter-spacing: 0.1em; }
.chapter-nav .nav-title-text { font-weight: 600; color: var(--blue); font-size: 0.9rem; }
.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }

/* Tag badges */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-right: 6px;
  margin-bottom: 4px;
}
.tag-blue { background: var(--blue-light); color: var(--blue); }
.tag-green { background: #F0FFF4; color: #1B5E20; }
.tag-orange { background: #FFF8E1; color: #E65100; }
.tag-purple { background: #F5F0FF; color: #6200EA; }
.tag-red { background: #FFF0F0; color: #B71C1C; }

/* Grid layout */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
@media (max-width: 600px) {
  .two-col { grid-template-columns: 1fr; }
  .def-list li { grid-template-columns: 1fr; gap: 4px; }
  .chapter-nav { flex-direction: column; }
}

/* Progress bar */
.progress {
  height: 3px;
  background: var(--gray5);
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Footer */
.site-footer {
  background: var(--secondary-bg);
  border-top: 0.5px solid var(--separator);
  padding: 32px 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray1);
}
.site-footer a { color: var(--blue); text-decoration: none; }
