/* =========================================================
   Operating Systems — A Short Lecture
   Stylesheet for the deck + the About page.
   ========================================================= */

:root {
  color-scheme: light dark;

  /* Light palette — paper, ink, a little blue chalk */
  --bg:           #fbfaf6;          /* warm paper */
  --bg-soft:      #f1efe7;
  --ink:          #1b1d23;
  --ink-soft:     #4b4f5a;
  --muted:        #7a7e8a;
  --rule:         #d9d6cb;
  --accent:       #1d4ed8;          /* chalk blue */
  --accent-soft:  #dbeafe;
  --warm:         #b45309;          /* highlighter amber */
  --warm-soft:    #fef3c7;
  --shadow:       0 1px 2px rgba(0,0,0,.06), 0 12px 32px -16px rgba(0,0,0,.18);

  /* Diagram colours */
  --d-hw:         #94a3b8;
  --d-os:         #1d4ed8;
  --d-app:        #b45309;
  --d-user:       #0f766e;

  /* Typography */
  --serif:  "Iowan Old Style", "Source Serif Pro", Georgia, Cambria, "Times New Roman", Times, serif;
  --sans:   -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:   ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Shared dark palette — applied via prefers-color-scheme or [data-theme="dark"] */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0e1116;
    --bg-soft:      #161a22;
    --ink:          #e7e6e0;
    --ink-soft:     #c5c6cc;
    --muted:        #8a8e99;
    --rule:         #262b36;
    --accent:       #93c5fd;
    --accent-soft:  #1e3a8a44;
    --warm:         #fbbf24;
    --warm-soft:    #78350f44;
    --shadow:       0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.6);

    --d-hw:         #64748b;
    --d-os:         #93c5fd;
    --d-app:        #fbbf24;
    --d-user:       #5eead4;
  }
}

/* Manual override: force light, even on a dark-mode OS */
html[data-theme="light"] {
  color-scheme: light;
  --bg:           #fbfaf6;
  --bg-soft:      #f1efe7;
  --ink:          #1b1d23;
  --ink-soft:     #4b4f5a;
  --muted:        #7a7e8a;
  --rule:         #d9d6cb;
  --accent:       #1d4ed8;
  --accent-soft:  #dbeafe;
  --warm:         #b45309;
  --warm-soft:    #fef3c7;
  --shadow:       0 1px 2px rgba(0,0,0,.06), 0 12px 32px -16px rgba(0,0,0,.18);
  --d-hw:         #94a3b8;
  --d-os:         #1d4ed8;
  --d-app:        #b45309;
  --d-user:       #0f766e;
}

/* Manual override: force dark, even on a light-mode OS */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #0e1116;
  --bg-soft:      #161a22;
  --ink:          #e7e6e0;
  --ink-soft:     #c5c6cc;
  --muted:        #8a8e99;
  --rule:         #262b36;
  --accent:       #93c5fd;
  --accent-soft:  #1e3a8a44;
  --warm:         #fbbf24;
  --warm-soft:    #78350f44;
  --shadow:       0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.6);
  --d-hw:         #64748b;
  --d-os:         #93c5fd;
  --d-app:        #fbbf24;
  --d-user:       #5eead4;
}

/* -------------------- base -------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(17px, 1.05vw + 14px, 21px);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

kbd {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink-soft);
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 100;
}
.skip-link:focus { top: 8px; }

/* -------------------- topbar -------------------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 14px;
}

.topbar__title {
  display: flex; align-items: baseline; gap: 8px;
  color: var(--ink-soft);
  letter-spacing: .01em;
}
.topbar__course {
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 12px;
}
.topbar__sep   { color: var(--muted); }
.topbar__lecture { color: var(--ink); }

.topbar__nav { display: flex; align-items: center; gap: 14px; }
.topbar__nav a {
  color: var(--ink-soft);
  text-decoration: none;
}
.topbar__nav a:hover { color: var(--accent); }

.iconbtn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.iconbtn:hover  { color: var(--accent); border-color: var(--accent); }
.iconbtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -------------------- deck (lecture only) -------------------- */

.lecture .deck {
  position: relative;
  width: 100%;
  min-height: 100vh;
  padding-top: 56px;      /* under topbar */
  padding-bottom: 88px;   /* above controls */
}

.lecture .deck:focus { outline: none; }

.slide {
  display: none;
  min-height: calc(100vh - 56px - 88px);
  padding: clamp(20px, 4vw, 56px);
  animation: slideIn 320ms ease both;
}
.slide.is-active { display: flex; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .slide { animation: none; }
}

.slide__inner {
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  align-self: center;
}

/* Without JS, show slides stacked so the page is still readable. */
.no-js .slide {
  display: block;
  border-bottom: 1px solid var(--rule);
  min-height: 0;
}
.no-js .controls,
.no-js .progress { display: none; }

/* -------------------- typography on slides -------------------- */

.eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 .5rem 0;
}

.slide h1.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(40px, 6.5vw, 88px);
  line-height: 1.05;
  letter-spacing: -.02em;
  margin: .2rem 0 1rem;
}
.slide h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.15;
  letter-spacing: -.01em;
  margin: 0 0 1rem 0;
}
.slide h2 em {
  font-style: italic;
  color: var(--accent);
}
.slide h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15em;
  margin: 0 0 .35rem 0;
}

.subtitle {
  font-size: clamp(18px, 1.6vw, 24px);
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 2rem 0;
}

.byline {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 14px;
}

.lead {
  font-size: 1.05em;
  margin: 0 0 1rem 0;
  color: var(--ink);
  max-width: 64ch;
}

.pull {
  margin: 1.4rem 0 0;
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-style: italic;
  color: var(--ink);
  max-width: 64ch;
  border-radius: 0 6px 6px 0;
}

.aside {
  margin-top: 1.4rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 14px;
}
.aside a { color: var(--muted); text-decoration: underline; }
.aside a:hover { color: var(--accent); }

.bullets,
.agenda { padding-left: 1.25rem; margin: 1rem 0; max-width: 60ch; }
.bullets { list-style: disc; }
.agenda  { list-style: decimal; }
.bullets li, .agenda li { margin: .35rem 0; }

/* Title slide flourish */
.slide--title { background:
  radial-gradient(80% 80% at 20% 20%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%),
  radial-gradient(60% 60% at 80% 90%, color-mix(in srgb, var(--warm) 6%, transparent), transparent 60%);
}

.slide--closing .lead { max-width: 56ch; }

/* -------------------- figure / illustrations -------------------- */

.figure {
  margin: 1.2rem 0 0;
}
.figure--wide svg { max-width: 100%; }
.figure svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 760px;
  margin: 0 auto;
}
.figure figcaption {
  margin: .65rem auto 0;
  text-align: center;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  max-width: 60ch;
}

/* --- layered diagram --- */
.illus--layers text {
  font-family: var(--sans);
  font-size: 15px;
  fill: var(--ink);
}
.illus--layers .layer--user > circle,
.illus--layers .layer--user > path { stroke: var(--d-user); fill: none; stroke-width: 2.5; }
.illus--layers .layer--user circle { fill: var(--d-user); }
.illus--layers .layer--apps rect { fill: color-mix(in srgb, var(--d-app) 14%, transparent); stroke: var(--d-app); stroke-width: 1.5; }
.illus--layers .layer--os   rect { fill: color-mix(in srgb, var(--d-os)  18%, transparent); stroke: var(--d-os);  stroke-width: 1.5; }
.illus--layers .layer--hw   rect { fill: color-mix(in srgb, var(--d-hw)  18%, transparent); stroke: var(--d-hw);  stroke-width: 1.5; }
.illus--layers .arrows path { stroke: var(--ink-soft); stroke-width: 1.8; fill: none; }

/* --- switchboard diagram --- */
.illus--switchboard text {
  font-family: var(--sans);
  fill: var(--ink);
}
.illus--switchboard .hub__title { font-size: 18px; font-weight: 600; }
.illus--switchboard .node__title { font-size: 15px; font-weight: 600; }
.illus--switchboard .node__sub   { font-size: 12px; fill: var(--muted); }
.illus--switchboard .hub rect    { fill: color-mix(in srgb, var(--d-os) 22%, transparent); stroke: var(--d-os); stroke-width: 2; }
.illus--switchboard .node rect   { fill: var(--bg-soft); stroke: var(--rule); stroke-width: 1.5; }
.illus--switchboard .spokes line { stroke: var(--ink-soft); stroke-width: 1.2; stroke-dasharray: 4 4; }

/* --- time-slicing --- */
.illus--timeslice text { font-family: var(--sans); fill: var(--ink); font-size: 14px; }
.illus--timeslice .track__bg { fill: var(--bg-soft); stroke: var(--rule); stroke-width: 1; }
.illus--timeslice .track__on { fill: var(--d-os); opacity: .85; }
.illus--timeslice .track:nth-of-type(2) .track__on { fill: var(--d-app); }
.illus--timeslice .track:nth-of-type(3) .track__on { fill: var(--d-user); }
.illus--timeslice .axis { stroke: var(--ink-soft); stroke-width: 1.2; }
.illus--timeslice .axis__label { fill: var(--muted); font-size: 12px; }

/* --- windows --- */
.illus--windows .desktop-bg { fill: var(--bg-soft); }
.illus--windows .win rect:first-child { fill: var(--bg); stroke: var(--rule); stroke-width: 1.5; }
.illus--windows .win__bar { fill: var(--bg-soft); }
.illus--windows .win circle { fill: var(--muted); }
.illus--windows .win--back  { opacity: .55; }
.illus--windows .win--mid   { opacity: .80; }
.illus--windows .win--front rect:first-child { stroke: var(--accent); stroke-width: 2; filter: drop-shadow(0 6px 18px rgba(0,0,0,.18)); }
.illus--windows .win__bar--focused { fill: var(--accent-soft); }
.illus--windows .win__title { font-family: var(--sans); font-size: 13px; fill: var(--ink); }

/* --- memory diagram --- */
.illus--memory text { font-family: var(--sans); fill: var(--ink); }
.illus--memory .vmem__label { font-size: 13px; fill: var(--ink-soft); }
.illus--memory .ram__label  { font-size: 13px; fill: var(--ink-soft); font-weight: 600; }
.illus--memory .vmem--a rect { fill: color-mix(in srgb, var(--d-os) 22%, transparent); stroke: var(--d-os); stroke-width: 1.5; }
.illus--memory .vmem--b rect { fill: color-mix(in srgb, var(--d-app) 22%, transparent); stroke: var(--d-app); stroke-width: 1.5; }
.illus--memory .vmem line { stroke: var(--bg); stroke-width: 1.2; }
.illus--memory .ram rect { fill: var(--bg-soft); stroke: var(--rule); stroke-width: 1.5; }
.illus--memory .ram line { stroke: var(--rule); stroke-width: 1; }
.illus--memory .mem-map path { fill: none; stroke-width: 1.2; }
.illus--memory .mem-map--a path { stroke: var(--d-os);  opacity: .65; }
.illus--memory .mem-map--b path { stroke: var(--d-app); opacity: .65; }

/* -------------------- timeline -------------------- */
.timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: .35rem;
}
.timeline li {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
  padding: .55rem .25rem;
  border-bottom: 1px dashed var(--rule);
}
.timeline__era {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  align-self: baseline;
}
.timeline__what { color: var(--ink); }

@media (max-width: 640px) {
  .timeline li { grid-template-columns: 1fr; gap: .15rem; padding: .45rem .25rem; }
}

/* -------------------- grids / cards -------------------- */

.grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
.grid--oses {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.card {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.card p { margin: 0; color: var(--ink-soft); font-size: .95em; }

/* -------------------- devices -------------------- */

.devices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.device {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: .9rem;
  text-align: center;
}
.device svg {
  width: 44px; height: 44px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  margin-bottom: .25rem;
}
.device h3 { margin: .1rem 0 .2rem; font-size: 1em; }
.device p  { margin: 0; color: var(--ink-soft); font-family: var(--sans); font-size: 13px; }

/* -------------------- controls + progress -------------------- */

.controls {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 14px 24px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-top: 1px solid var(--rule);
}
.counter {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-size: 14px;
  min-width: 64px;
  text-align: center;
}

.progress {
  position: fixed;
  inset: auto 0 56px 0;       /* sits just above controls */
  height: 3px;
  background: var(--rule);
  z-index: 19;
}
.progress__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .25s ease;
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .controls { gap: 12px; padding: 10px 14px 14px; }
  .lecture .deck { padding-top: 50px; padding-bottom: 78px; }
  .slide { min-height: calc(100vh - 50px - 78px); padding: 18px; }
  .progress { bottom: 52px; }
}

/* -------------------- About page (.page) -------------------- */

.page {
  padding-top: 64px;
}
.prose {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.prose h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.1;
  margin: 0 0 1rem;
  letter-spacing: -.01em;
}
.prose h2 {
  font-family: var(--serif);
  font-size: 1.4em;
  margin: 2rem 0 .5rem;
}
.prose p {
  margin: 0 0 1rem;
  color: var(--ink);
}
.prose .back {
  margin-top: 2.5rem;
  font-family: var(--sans);
  font-size: 14px;
}

/* -------------------- print -------------------- */

@media print {
  .topbar, .controls, .progress, .skip-link { display: none; }
  .slide { display: block !important; page-break-after: always; min-height: auto; }
  body { background: #fff; color: #000; }
  .figure svg { max-width: 100%; }
}
