/* Swift Server Tutorial — krew.inductor.dev に寄せた Apple-Tutorials feel
 *
 * 設計方針:
 *   1. mesh-gradient を fixed bg に。両モードで雰囲気を出す
 *   2. tutorial hero は full-bleed の大型 gradient テキスト
 *   3. section heading に accent eyebrow と大型 h2
 *   4. step card は glass-morphism + 余白 + hover lift
 *   5. code listing は glass card + 角丸 16px + 控えめ shadow
 *   6. SF Pro stack と引き締まった letter-spacing
 *
 * DocC が body[data-color-scheme] を切替えるので両モード対応。
 * ベースは krew の tailwind tokens を直輸入。
 */

/* ===== Tokens (shared) ===== */
:root {
  --font-sans:
    -apple-system, system-ui, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-display:
    -apple-system, system-ui, "SF Pro Display", "Helvetica Neue",
    "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-mono:
    "SF Mono", Menlo, Monaco, "Roboto Mono", "Courier New", monospace;

  --tracking-tight:   -0.022em;
  --tracking-tighter: -0.03em;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 980px;

  --ease-apple: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ===== LIGHT mode (default + auto:light) ===== */
body[data-color-scheme="light"],
body[data-color-scheme="auto"] {
  --bg-base:        #f5f5f7;
  --bg-elevated:    rgba(255, 255, 255, 0.6);
  --glass:          rgba(255, 255, 255, 0.72);
  --glass-border:   rgba(0, 0, 0, 0.08);
  --glass-hover:    rgba(0, 0, 0, 0.03);
  --label-1:        rgba(0, 0, 0, 0.85);
  --label-2:        rgba(0, 0, 0, 0.55);
  --label-3:        rgba(0, 0, 0, 0.35);
  --separator:      rgba(0, 0, 0, 0.08);
  --fill-quietly:   rgba(120, 120, 128, 0.12);
  --accent-blue:    #0071e3;
  --accent-purple:  #a550c7;
  --accent-cyan:    #0077cc;
  --accent-pink:    #ff2d55;
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:      0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg:      0 12px 40px rgba(0, 0, 0, 0.08);
  --hero-text:
    linear-gradient(135deg, #1d1d1f 0%, #0071e3 50%, #0077cc 100%);
  --hero-bg:
    radial-gradient(ellipse at 20% 30%, rgba(0, 113, 227, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 10%, rgba(165, 80, 199, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 60% 90%, rgba(0, 119, 204, 0.06) 0%, transparent 55%),
    #f5f5f7;
}

/* ===== DARK mode (explicit + auto:dark via @media below) ===== */
body[data-color-scheme="dark"] {
  --bg-base:        #000000;
  --bg-elevated:    rgba(28, 28, 30, 0.6);
  --glass:          rgba(255, 255, 255, 0.05);
  --glass-border:   rgba(255, 255, 255, 0.10);
  --glass-hover:    rgba(255, 255, 255, 0.08);
  --label-1:        rgba(255, 255, 255, 0.92);
  --label-2:        rgba(255, 255, 255, 0.55);
  --label-3:        rgba(255, 255, 255, 0.35);
  --separator:      rgba(255, 255, 255, 0.08);
  --fill-quietly:   rgba(120, 120, 128, 0.20);
  --accent-blue:    #0a84ff;
  --accent-purple:  #bf5af2;
  --accent-cyan:    #64d2ff;
  --accent-pink:    #ff6482;
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-md:      0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg:      0 20px 60px rgba(0, 0, 0, 0.6);
  --hero-text:
    linear-gradient(135deg, #ffffff 0%, #64d2ff 50%, #0a84ff 100%);
  --hero-bg:
    radial-gradient(ellipse at 20% 30%, rgba(10, 132, 255, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 10%, rgba(191, 90, 242, 0.16) 0%, transparent 55%),
    radial-gradient(ellipse at 60% 90%, rgba(100, 210, 255, 0.10) 0%, transparent 55%),
    #000000;
}
@media (prefers-color-scheme: dark) {
  body[data-color-scheme="auto"] {
    --bg-base:        #000000;
    --bg-elevated:    rgba(28, 28, 30, 0.6);
    --glass:          rgba(255, 255, 255, 0.05);
    --glass-border:   rgba(255, 255, 255, 0.10);
    --glass-hover:    rgba(255, 255, 255, 0.08);
    --label-1:        rgba(255, 255, 255, 0.92);
    --label-2:        rgba(255, 255, 255, 0.55);
    --label-3:        rgba(255, 255, 255, 0.35);
    --separator:      rgba(255, 255, 255, 0.08);
    --fill-quietly:   rgba(120, 120, 128, 0.20);
    --accent-blue:    #0a84ff;
    --accent-purple:  #bf5af2;
    --accent-cyan:    #64d2ff;
    --accent-pink:    #ff6482;
    --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.6);
    --shadow-md:      0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg:      0 20px 60px rgba(0, 0, 0, 0.6);
    --hero-text:
      linear-gradient(135deg, #ffffff 0%, #64d2ff 50%, #0a84ff 100%);
    --hero-bg:
      radial-gradient(ellipse at 20% 30%, rgba(10, 132, 255, 0.18) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 10%, rgba(191, 90, 242, 0.16) 0%, transparent 55%),
      radial-gradient(ellipse at 60% 90%, rgba(100, 210, 255, 0.10) 0%, transparent 55%),
      #000000;
  }
}

/* ===== Document base ===== */
html, body {
  background: var(--bg-base) !important;
  color: var(--label-1) !important;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* DocC's color tokens override (defense in depth — also set inline). */
body {
  --colors-fill: var(--bg-base) !important;
  --colors-fill-secondary: var(--bg-elevated) !important;
  --colors-fill-tertiary: var(--glass) !important;
  --colors-text: var(--label-1) !important;
  --colors-text-background: transparent !important;
  --colors-link: var(--accent-blue) !important;
  --colors-figure-blue: var(--accent-blue) !important;
  --colors-figure-gray: var(--label-1) !important;
  --colors-figure-gray-secondary: var(--label-2) !important;
  --colors-figure-gray-tertiary: var(--label-3) !important;
  --colors-header-text: var(--label-1) !important;
  --colors-nav-keyline: var(--separator) !important;
}

/* Mesh-gradient fixed background, behind everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--hero-bg);
  transition: background 0.4s var(--ease-apple);
}

/* ===== Headings ===== */
h1, .heading, .headline {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-tight);
  font-weight: 700;
  color: var(--label-1);
}
h2 {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-tight);
  font-weight: 600;
}
h3, h4 {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-tight);
  font-weight: 600;
}

/* ===== Tutorial Hero (.tutorial-hero) =====
 * The hero is full-bleed (1506px). We give it generous padding,
 * mesh background already comes from body, plus we pump up the
 * H1 size and apply hero-text gradient.
 */
/* DocC hardcodes dark backgrounds onto tutorials-overview elements
   (Apple's developer.apple.com convention). Strip them so our body
   mesh shows through and light mode is actually light. */
.tutorial-hero,
.tutorial-hero .hero,
.tutorial-hero > div,
.tutorials-overview,
.tutorials-overview.router-content,
.tutorials-overview .intro,
.tutorials-overview .intro > div,
.tutorials-overview .radial-gradient,
.tutorials-overview .learning-path,
.tutorials-overview .topic-icon,
.tutorials-overview .chapter,
.tutorials-overview section.chapter {
  background: transparent !important;
  background-image: none !important;
}

/* DocC pins the top nav to `theme-dark` on the TOC. Force it to follow
   our actual scheme so light mode gets a light nav. */
nav.nav.theme-dark {
  background: color-mix(in srgb, var(--bg-base) 72%, transparent) !important;
  color: var(--label-1) !important;
}
nav.nav.theme-dark .nav__background {
  background: transparent !important;
}
nav.nav.theme-dark a,
nav.nav.theme-dark .nav__title {
  color: var(--label-1) !important;
}

/* The "Tutorials" subhead next to the project name is hardcoded white. */
nav.nav .subhead,
nav.nav.theme-dark .subhead {
  color: var(--label-2) !important;
}

/* Re-skin chapter cards so they pop in either mode. */
.tutorials-overview .chapter,
.tutorials-overview section.chapter {
  background: var(--glass) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-lg) !important;
  padding: 32px !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-md);
}
.tutorials-overview .topic-icon {
  background: var(--fill-quietly) !important;
  color: var(--accent-blue) !important;
}

.tutorial-hero {
  padding: 120px 24px 80px !important;
  position: relative;
}
.tutorials-overview .intro {
  padding: 120px 24px 80px !important;
}

/* TOC hero H1 is `.tutorials-overview section.hero h1.title` and DocC
   hardcodes color: white on it (assuming dark hero). Re-bind to our
   per-mode hero gradient so it reads in both modes. */
.tutorials-overview h1.title,
.tutorials-overview .hero h1 {
  background: var(--hero-text) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  color: transparent !important;
  font-size: 64px !important;
  line-height: 1.08 !important;
  letter-spacing: var(--tracking-tighter) !important;
  font-weight: 700 !important;
}

/* Force every text descendant of the TOC into our label tokens so the
   DocC defaults (white-everywhere because it assumes a dark hero) stop
   hurting light mode readability. */
.tutorials-overview .hero,
.tutorials-overview .hero *,
.tutorials-overview .duration,
.tutorials-overview .duration *,
.tutorials-overview .content,
.tutorials-overview .content *,
.tutorials-overview .intro,
.tutorials-overview .intro * {
  color: var(--label-1);
}
.tutorials-overview .hero p,
.tutorials-overview .duration,
.tutorials-overview .intro p {
  color: var(--label-2) !important;
}

/* Sidebar nav (the "Part I: 基盤と本番品質" rail). */
.tutorials-overview .tutorials-navigation,
.tutorials-overview .tutorials-navigation a,
.tutorials-overview .tutorials-navigation-link {
  color: var(--label-1) !important;
}
.tutorials-overview .tutorials-navigation-link.active,
.tutorials-overview .tutorials-navigation-link:hover {
  color: var(--accent-blue) !important;
}

/* Topic icon (the little badge next to "開発環境のセットアップ" etc) */
.tutorials-overview .topic-icon {
  background: var(--fill-quietly) !important;
  color: var(--accent-blue) !important;
}
.tutorials-overview .topic-icon svg,
.tutorials-overview .topic-icon * {
  color: var(--accent-blue) !important;
  fill: var(--accent-blue) !important;
}

/* Topic title inside chapter card. */
.tutorials-overview .topic-title,
.tutorials-overview a.topic-title,
.tutorials-overview .chapter .topic-title {
  color: var(--label-1) !important;
}
.tutorials-overview .topic-title:hover {
  color: var(--accent-blue) !important;
}

/* Time labels (10min, 15min). */
.tutorials-overview .topic-time,
.tutorials-overview .time-estimate,
.tutorials-overview [class*="time"] {
  color: var(--label-2) !important;
}
.tutorial-hero .intro,
.tutorials-overview .intro > * {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}
.tutorial-hero .eyebrow,
.tutorials-overview .eyebrow,
.tutorial .eyebrow {
  color: var(--accent-blue) !important;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0;
  margin-bottom: 16px;
  text-transform: none;
}
.tutorial-hero h1,
.tutorials-overview .intro h1 {
  font-size: 80px !important;
  line-height: 1.05 !important;
  letter-spacing: var(--tracking-tighter) !important;
  font-weight: 700 !important;
  margin: 0 0 28px !important;
  background: var(--hero-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  word-break: keep-all !important;
  overflow-wrap: break-word !important;
}
.tutorial-hero .content,
.tutorial-hero p,
.tutorials-overview .intro p {
  font-size: 22px !important;
  line-height: 1.45 !important;
  color: var(--label-2);
  max-width: 720px;
}
.tutorial-hero .duration,
.tutorial .duration {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 8px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  font-size: 14px;
  color: var(--label-2);
}

/* ===== Sections ===== */
.section {
  padding-top: 96px !important;
}
.section .section-content {
  max-width: 1180px !important;
  margin: 0 auto !important;
  padding: 0 24px !important;
}
.section .headline {
  font-size: 48px !important;
  line-height: 1.1 !important;
  letter-spacing: var(--tracking-tight) !important;
  font-weight: 700 !important;
  margin: 0 0 24px !important;
  color: var(--label-1) !important;
  background: none !important;
  -webkit-text-fill-color: var(--label-1) !important;
}
.section .eyebrow {
  color: var(--accent-blue) !important;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 12px;
  display: block;
}
.section .content > p,
.section > .content-and-media p {
  font-size: 19px;
  line-height: 1.55;
  color: var(--label-2);
  max-width: 740px;
}

/* ===== Steps (left-text + right-code split) ===== */
.steps {
  margin-top: 48px !important;
}
.step {
  background: var(--glass) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-lg) !important;
  padding: 28px 32px !important;
  margin-bottom: 24px !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s var(--ease-apple);
}
.step:hover {
  border-color: var(--accent-blue) !important;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.step.focused {
  background: var(--glass-hover) !important;
  border-color: var(--accent-blue) !important;
  box-shadow: var(--shadow-md), 0 0 0 1px var(--accent-blue);
}
.step .step-label {
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.step p {
  color: var(--label-1);
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
}

/* ===== Code listing (right column on tutorials) ===== */
.code-listing,
pre.source {
  background: var(--glass) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-md) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.code-listing pre,
.code-listing code,
pre.source code {
  background: transparent !important;
  font-family: var(--font-mono) !important;
  font-feature-settings: "liga" 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--label-1);
}
.code-listing .file-name,
.code-listing .filename {
  background: var(--glass-hover) !important;
  color: var(--label-2) !important;
  padding: 10px 16px !important;
  border-bottom: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* Inline code chips. */
:not(pre):not(.code-listing) > code {
  background: var(--fill-quietly);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--label-1);
}

/* Syntax highlighting palette (Apple Xcode-ish). */
.token.keyword       { color: var(--accent-pink); }
.token.string        { color: #ff8170; }
.token.number        { color: #d9c97c; }
.token.comment       { color: #7f8c98; font-style: italic; }
.token.attribute,
.token.attr-name     { color: var(--accent-purple); }
.token.type-annotation,
.token.type          { color: var(--accent-cyan); }
.token.function      { color: var(--accent-cyan); }

/* ===== Links ===== */
a, .link {
  color: var(--accent-blue) !important;
  text-decoration: none;
  transition: color 0.2s var(--ease-apple);
}
a:hover, .link:hover {
  color: var(--accent-cyan) !important;
}

/* ===== Top nav (Apple-style sticky blur) ===== */
.nav, .navigation, header.nav {
  background: color-mix(in srgb, var(--bg-base) 72%, transparent) !important;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator) !important;
}
.nav .nav-title,
.nav__title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--label-1) !important;
}

/* ===== TOC / aside ===== */
aside, .aside {
  background: var(--glass) !important;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* ===== Buttons / CTAs (Apple pill) =====
 * NB: `.call-to-action` is BOTH the button AND its wrapping <section> in
 * DocC's "next chapter" callout. Restrict to actual button-ish elements,
 * never the wrapper.
 */
a.button-cta, button.button-cta, button.primary, .btn,
a.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill) !important;
  background: var(--accent-blue) !important;
  color: #fff !important;
  font-weight: 500;
  border: 0;
  padding: 12px 24px;
  transition: all 0.3s var(--ease-apple);
  text-decoration: none;
}
a.button-cta:hover, button.button-cta:hover, button.primary:hover, .btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent-blue) 30%, transparent);
}

/* The "next chapter" CTA section wrapper (DIV.call-to-action) needs to be
 * a card, not a giant pill. */
div.call-to-action,
section.call-to-action {
  background: var(--glass) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-lg) !important;
  padding: 32px !important;
  margin: 48px 24px !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-md);
  color: var(--label-1) !important;
}
div.call-to-action h2,
div.call-to-action h3,
div.call-to-action .eyebrow {
  color: var(--label-1) !important;
}
div.call-to-action p {
  color: var(--label-2) !important;
}

/* ===== Body text legibility ===== */
.content p, .description p,
.tutorials-overview .content p {
  line-height: 1.6;
  color: var(--label-1);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--label-3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--label-2); }

/* ===== Tutorials overview grid (TOC page) ===== */
.tutorials-overview .chapter-list,
.tutorials-overview .timeline {
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 24px;
}
.tutorials-overview .timeline .item,
.tutorials-overview .chapter {
  background: var(--glass) !important;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  margin-bottom: 24px;
  transition: all 0.3s var(--ease-apple);
}
.tutorials-overview .timeline .item:hover,
.tutorials-overview .chapter:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
