/* Orithms — the site's one style sheet, for the home page and the lesson pages.
   The look is swiftbyheart.com's, so that the two courses are a matching set: its near-black graphite ground and
   warm white text, one accent kept for what matters, Spectral SC for headings and labels and Spectral for text,
   its measures, its ruled lines. Only the accent differs, so that the two are told apart at once: it is blue here
   (--accent, and the softer --accentsoft), where swiftbyheart.com has the Swift logo's colour. One shape language
   through the whole site: square and ruled. Nothing is rounded. There is one scheme, the graphite one, as there. */
@font-face{font-family:"Spectral"; font-weight:300; font-style:normal; font-display:swap;
  src:url(/assets/fonts/Spectral-Light.woff) format("woff");}
@font-face{font-family:"Spectral"; font-weight:300; font-style:italic; font-display:swap;
  src:url(/assets/fonts/Spectral-LightItalic.woff) format("woff");}
@font-face{font-family:"Spectral"; font-weight:600; font-style:normal; font-display:swap;
  src:url(/assets/fonts/Spectral-SemiBold.woff) format("woff");}
@font-face{font-family:"Spectral SC"; font-weight:500; font-style:normal; font-display:swap;
  src:url(/assets/fonts/SpectralSC-Medium.woff) format("woff");}

:root{
  --paper:#1b1c20;
  --panel:#24252b;
  --ink:#e9e6df;
  --ink2:#a6a49c;
  --rule:rgba(233,230,223,.16);
  --accent:#3d8bff;
  --accentsoft:#5b9dff;
  --codebg:#1f1f24;
  --sc:"Spectral SC","Spectral",Georgia,serif;
  --mono:ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
  color-scheme:dark;
}
*{box-sizing:border-box;}
html{scroll-behavior:smooth; -webkit-text-size-adjust:100%; text-size-adjust:100%;}
body{
  margin:0; background:var(--paper); color:var(--ink);
  font-family:"Spectral",Georgia,serif; font-weight:300; font-size:17px; line-height:1.62;
}
::selection{background:rgba(61,139,255,.35);}
a{color:var(--accentsoft); text-decoration:none; border-bottom:1px solid rgba(91,157,255,.35); overflow-wrap:anywhere;}
a:hover{border-bottom-color:var(--accentsoft);}
a:focus-visible, summary:focus-visible, button:focus-visible{outline:2px solid var(--accent); outline-offset:3px;}
.sheet{max-width:920px; margin:0 auto; padding:56px 34px 100px;}
.sheet.reading{max-width:820px;}
p{margin:0 0 14px;}
p, li, td{overflow-wrap:break-word;}
b, strong{font-weight:600;}
em, i{font-style:italic;}
code{
  font-family:var(--mono); font-size:.86em; font-weight:400; font-style:normal; background:rgba(233,230,223,.08);
  padding:1px 5px; overflow-wrap:anywhere;
}
ul, ol{margin:0 0 14px; padding-left:22px;}
li{margin-bottom:6px;}
li > ul, li > ol{margin:6px 0 0;}

/* ---------- headings ---------- */
.kicker{
  font-family:var(--sc); font-weight:500; font-size:12.5px; letter-spacing:.3em; text-indent:.3em;
  font-variant-numeric:lining-nums; color:var(--accent); text-align:center; margin:0 0 16px;
}
h1{
  font-family:var(--sc); font-weight:500; font-size:52px; letter-spacing:.04em;
  text-align:center; margin:0 0 12px; line-height:1.1;
}
/* the mark between two rules: a four-pointed star, cut from a square */
.star{
  display:inline-block; flex:none; width:13px; height:13px; background:var(--accent);
  clip-path:polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}
.mastrule{display:flex; align-items:center; gap:14px; max-width:380px; margin:0 auto 16px;}
.mastrule .ln{flex:1; height:1px; background:var(--rule);}
.mastrule .star{width:15px; height:15px;}
.sub{font-style:italic; color:var(--ink2); text-align:center; max-width:600px; margin:0 auto;}
h2{
  font-family:var(--sc); font-weight:500; font-size:25px; letter-spacing:.04em;
  margin:52px 0 12px; line-height:1.25;
}
h3{font-family:var(--sc); font-weight:500; font-size:20px; letter-spacing:.03em; margin:0 0 8px; line-height:1.3;}
h4{font-family:var(--sc); font-weight:500; font-size:16.5px; letter-spacing:.06em; margin:22px 0 6px; line-height:1.3;}
h1 code, h2 code, h3 code, h4 code{font-size:.74em; letter-spacing:0;}
.label{font-family:var(--sc); font-weight:500; font-size:11.5px; letter-spacing:.24em; color:var(--accentsoft);}

/* ---------- the home page: what the course is ---------- */
.idea{max-width:680px; margin:46px auto 0;}
.idea h2{text-align:center; margin:0 0 18px;}
/* the four things: each with its number in a ruled square */
ol.how{margin:22px 0 22px; padding:0; counter-reset:how; list-style:none;}
ol.how > li{counter-increment:how; position:relative; padding:0 0 2px 40px; margin:0 0 12px;}
ol.how > li::before{
  content:counter(how); position:absolute; left:0; top:2px; width:25px; height:25px; border:1px solid var(--accent);
  color:var(--accent); text-align:center; font-family:var(--sc); font-size:13.5px; line-height:23px;
  font-variant-numeric:lining-nums;
}

/* ---------- the home page: the course ---------- */
.course-head{margin-top:74px; text-align:center;}
.course-head h2{margin:0 0 6px;}
.course-count{
  font-family:var(--sc); font-weight:500; font-size:12.5px; letter-spacing:.24em; text-indent:.24em;
  font-variant-numeric:lining-nums; color:var(--ink2); margin:0 0 6px;
}
.part{margin-top:64px;}
.part-no{
  font-family:var(--sc); font-weight:500; font-size:11.5px; letter-spacing:.3em; text-indent:.3em;
  font-variant-numeric:lining-nums; color:var(--ink2); text-align:center; margin:0 0 4px;
}
.part-head{display:flex; align-items:center; gap:14px;}
.part-head .ln{flex:1; height:1px; background:var(--rule);}
.part-head h2{margin:0; text-align:center; font-size:23px;}
.part-intro{max-width:640px; margin:10px auto 0; text-align:center; font-style:italic; color:var(--ink2);}
.part-intro code{font-size:.82em;}
ol.lessons{list-style:none; margin:22px 0 0; padding:0; border-top:1px solid var(--rule);}
ol.lessons > li{
  display:grid; grid-template-columns:76px 1fr; gap:18px; margin:0; padding:11px 0;
  border-bottom:1px solid var(--rule); align-items:baseline;
}
/* the lesson's row, come back to from its page (/#lesson-best) */
ol.lessons > li:target{margin:0 -14px; padding:11px 14px; background:rgba(61,139,255,.07); box-shadow:inset 2px 0 0 var(--accent);}
ol.lessons .no{
  font-family:var(--sc); font-weight:500; font-size:12.5px; letter-spacing:.14em; font-variant-numeric:lining-nums;
  color:var(--ink2);
}
ol.lessons h3{font-size:18px; margin:0; color:var(--ink2);}
/* a lesson that is written: its name is a link, and its sentence is under it */
ol.lessons > li.written{padding:15px 0 14px;}
ol.lessons > li.written:target{padding:15px 14px 14px;}
ol.lessons .written .no{color:var(--accentsoft);}
ol.lessons .written h3{margin:0 0 3px;}
ol.lessons h3 a{color:var(--ink); border-bottom-color:rgba(233,230,223,.3);}
ol.lessons h3 a:hover{border-bottom-color:var(--accentsoft); color:var(--accentsoft);}
ol.lessons p{margin:0; font-size:15.5px; color:var(--ink2);}

/* ---------- a lesson page: its head ---------- */
.crumbs{
  font-family:var(--sc); font-weight:500; font-size:12px; letter-spacing:.18em; font-variant-numeric:lining-nums;
  display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; color:var(--ink2);
}
.crumbs a{border-bottom:none; color:var(--ink2);}
.crumbs a:hover{color:var(--accentsoft);}
.lessonhead{margin:38px 0 0; text-align:center;}
.lessonhead .kicker{margin-bottom:10px;}
.lessonhead h1{font-size:40px;}
.lessonhead .sub{max-width:640px;}
/* when to reach for it, the move, the cost */
dl.intro{
  border:1px solid var(--rule); background:var(--panel); padding:20px 24px; margin:34px 0 0;
  display:grid; grid-template-columns:max-content 1fr; gap:9px 20px; align-items:baseline;
}
dl.intro dt{font-family:var(--sc); font-weight:500; font-size:11.5px; letter-spacing:.24em; color:var(--accentsoft);}
dl.intro dd{margin:0;}
/* the lesson's parts, as a line of links */
nav.parts{
  display:flex; flex-wrap:wrap; gap:4px 18px; margin:20px 0 0; padding:11px 0; border-top:1px solid var(--rule);
  border-bottom:1px solid var(--rule); font-family:var(--sc); font-weight:500; font-size:11.5px; letter-spacing:.13em;
}
nav.parts a{border-bottom:none; color:var(--ink2);}
nav.parts a:hover{color:var(--accentsoft);}

/* ---------- a lesson page: its parts ---------- */
section.lpart{margin-top:58px; padding-top:26px; border-top:1px solid var(--rule);}
section.lpart > h2{margin:0 0 16px;}
nav.parts + section.lpart{margin-top:40px; padding-top:0; border-top:none;}   /* the line of links is rule enough */
.step{margin-top:42px;}
.step > .sno{
  font-family:var(--sc); font-weight:500; font-size:11.5px; letter-spacing:.28em; font-variant-numeric:lining-nums;
  color:var(--accent); margin:0 0 2px;
}
.step > .sno a{color:inherit; border-bottom-color:rgba(61,139,255,.4);}
.step > h3{margin:0 0 12px;}
blockquote{margin:0 0 16px; padding:2px 0 2px 16px; border-left:2px solid var(--ink2); color:var(--ink2);}
blockquote > :last-child{margin-bottom:0;}
.notice{border-left:2px solid var(--accent); padding:6px 0 6px 16px; margin:18px 0 0; color:var(--ink2); font-style:italic;}

/* the idea: a conversation. Harper asks, flush left with the accent's rule; Arthur answers, set in and on the panel. */
.talk{margin:20px 0 24px;}
.turn{
  display:grid; grid-template-columns:74px 1fr; gap:0 14px; align-items:baseline;
  padding:10px 16px 10px 14px; border-left:2px solid var(--accent); margin:0 0 6px;
}
.turn .who{font-family:var(--sc); font-weight:500; font-size:11.5px; letter-spacing:.24em; color:var(--accent);}
.turn.arthur{margin-left:34px; border-left-color:var(--ink2); background:var(--panel);}
.turn.arthur .who{color:var(--ink2);}
.turn .says{min-width:0;}
.turn .says > :last-child{margin-bottom:0;}
.turn .says > figure.code{margin-top:10px;}

/* code: Swift in the colours of Xcode's Default (Dark) theme, as on swiftbyheart.com, under a bar with its Copy button */
figure.code{margin:16px 0 18px; min-width:0;}
.codebar{display:flex; align-items:flex-end; justify-content:space-between; gap:12px;}
.codebar .where{
  font-family:var(--sc); font-weight:500; font-size:11px; letter-spacing:.2em; color:var(--ink2);
  padding:5px 12px; background:var(--panel); border:1px solid var(--rule); border-bottom:none;
}
button.copy{
  font-family:var(--sc); font-weight:500; font-size:11px; letter-spacing:.16em; color:var(--ink2);
  background:var(--panel); border:1px solid var(--rule); border-radius:0; padding:4px 10px; margin:0 0 5px;
  cursor:pointer; line-height:1.4; -webkit-appearance:none; appearance:none;
}
button.copy:hover{color:var(--ink); border-color:var(--ink2);}
button.copy.is-done{color:var(--accentsoft); border-color:var(--accentsoft);}
pre{
  font-family:var(--mono); font-size:13px; line-height:1.6; font-weight:500; margin:0;
  background:var(--codebg); color:rgba(255,255,255,.85); border:1px solid var(--rule); padding:14px 16px;
  overflow-x:auto; tab-size:4; max-width:100%;
}
pre code{font-family:inherit; font-size:inherit; font-weight:inherit; background:none; padding:0; overflow-wrap:normal;}
pre.text{margin:16px 0 18px; background:#101114; color:#f0ede6;}
pre .k{color:#FC5FA3; font-weight:700;}   /* keyword */
pre .s{color:#FC6A5D;}                    /* string */
pre .n{color:#D0BF69;}                    /* number */
pre .c{color:#6C7986;}                    /* comment */
pre .at{color:#BF8555;}                   /* attribute */
pre .p{color:#FD8F3F;}                    /* #if and its kind */
pre .dt{color:#5DD8FF;}                   /* the name a type declaration introduces */
pre .dd{color:#41A1C0;}                   /* the name a function or variable declaration introduces */
pre .t{color:#9EF1DD;}                    /* a type the lesson makes */
pre .ts{color:#D0A8FF;}                   /* a type of the standard library */

/* a table stays readable on a phone: it scrolls sideways inside its own box, never the page */
.tablebox{overflow-x:auto; margin:16px 0 18px; max-width:100%;}
table{border-collapse:collapse; width:100%; font-variant-numeric:lining-nums tabular-nums;}
th, td{padding:7px 18px 7px 0; border-bottom:1px solid var(--rule); text-align:left; vertical-align:top;}
th:last-child, td:last-child{padding-right:0;}
/* a heading may go onto two lines, a word at a time, before the table has to scroll: on a phone that keeps every
   column of a trace in sight */
th{font-family:var(--sc); font-weight:500; font-size:12px; letter-spacing:.2em; color:var(--ink2);
  vertical-align:bottom; border-bottom-color:rgba(233,230,223,.34);}
th code{white-space:nowrap; letter-spacing:0;}   /* a piece of code in a heading stays in one piece */
td.c, th.c{text-align:center;}
td.r, th.r{text-align:right;}

/* say it back: the question, and its answer when it is asked for */
.ask{border-top:1px solid var(--rule); padding:20px 0 12px; display:grid; grid-template-columns:34px 1fr; gap:0 6px;}
.ask:first-of-type{margin-top:6px;}
.ask .qno{
  font-family:var(--sc); font-weight:500; font-size:19px; font-variant-numeric:lining-nums; color:var(--accent);
  line-height:1.45;
}
.ask .q{font-size:18.5px; line-height:1.5; margin:0 0 10px; grid-column:2;}
.ask details{grid-column:2; min-width:0;}
.ask summary{
  cursor:pointer; list-style:none; display:inline-block; font-family:var(--sc); font-weight:500; font-size:12.5px;
  letter-spacing:.22em; color:var(--accent); padding:4px 0;
}
.ask summary::-webkit-details-marker{display:none;}
.ask summary::before{content:"\25B8\00a0\00a0";}
.ask details[open] summary::before{content:"\25BE\00a0\00a0";}
.ask details .hide, .ask details[open] .show{display:none;}
.ask details[open] .hide{display:inline;}
.ask .answer{border-left:2px solid var(--accent); padding:2px 0 2px 16px; margin:10px 0 6px;}
.ask .answer > :last-child{margin-bottom:0;}

/* ---------- the foot of a page ---------- */
.lessonnav{display:flex; justify-content:space-between; gap:14px; margin-top:70px; padding-top:20px; border-top:1px solid var(--rule); flex-wrap:wrap;}
.lessonnav > *{max-width:46%;}
.lessonnav a{border-bottom:none;}
.lessonnav .plain{color:var(--ink2);}
.lessonnav .dir{
  display:block; font-family:var(--sc); font-weight:500; font-size:11px; letter-spacing:.24em;
  font-variant-numeric:lining-nums; color:var(--ink2);
}
.lessonnav .next{text-align:right; margin-left:auto;}
.colophon{margin-top:80px; text-align:center; font-style:italic; color:var(--ink2); font-size:14.5px;}
.lessonnav + .colophon{margin-top:44px;}
.notfound{margin-top:90px; text-align:center;}
.notfound p{margin-top:26px;}

/* ---------- a phone ---------- */
@media(max-width:700px){
  body{font-size:16px;}
  .sheet{padding:40px 18px 70px;}
  h1{font-size:36px;}
  .lessonhead h1{font-size:29px;}
  h2{font-size:21px;}
  h3{font-size:18.5px;}
  /* a name that does not fit between the two rules goes onto two lines, and the rules keep some length */
  .part-head h2{font-size:18px; max-width:calc(100% - 136px); text-wrap:balance;}
  .part{margin-top:54px;}
  ol.lessons > li{grid-template-columns:44px 1fr; gap:10px;}
  ol.lessons h3{font-size:17px;}
  dl.intro{grid-template-columns:1fr; gap:2px; padding:16px;}
  dl.intro dd{margin:0 0 9px;}
  dl.intro dd:last-child{margin-bottom:0;}
  section.lpart{margin-top:46px; padding-top:22px;}
  nav.parts + section.lpart{margin-top:34px;}
  .turn{grid-template-columns:1fr; padding:9px 12px 10px 12px;}
  .turn .who{margin:0 0 1px;}
  .turn.arthur{margin-left:22px;}
  pre{font-size:12px; padding:12px;}
  th{font-size:11.5px; letter-spacing:.12em;}
  th, td{padding-right:12px;}
  .ask{grid-template-columns:26px 1fr;}
  .ask .qno{font-size:17.5px;}
  .ask .q{font-size:17px;}
  .lessonnav > *{max-width:100%;}
}
