/* ==========================================================================
   dangode.com — stylesheet
   Modernized: CSS only. Every selector from the previous version is preserved,
   so no HTML changes are required.

   Notes kept from the original:
   - em is relative and nests unpredictably (indent/hang/space). rem is relative
     to the root element and does not compound, so rem is used throughout.
   - box-sizing: border-box makes width/height include padding and border
     (margins are always outside the box).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fonts
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "robotoregular";
  src:
    url("Roboto/roboto_regular_macroman/Roboto-Regular-webfont.woff2")
      format("woff2"),
    url("Roboto/roboto_regular_macroman/Roboto-Regular-webfont.woff")
      format("woff");
  font-display: swap;
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "robotoregular";
  src:
    url("Roboto/roboto_regular_macroman/Roboto-Medium-webfont.woff2")
      format("woff2");
  font-display: swap;
  font-weight: 500;
  font-style: normal;
}

@font-face {
  font-family: "robotoregular";
  src:
    url("Roboto/roboto_regular_macroman/Roboto-Bold-webfont.woff2")
      format("woff2");
  font-display: swap;
  font-weight: 700;
  font-style: normal;
}

/* All three weights are real cuts of Roboto, so nothing is faux-bolded.
   Headings use a serif stack for contrast against the sans body text. */

:root {
  --font-body:
    "robotoregular", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Helvetica, Arial, sans-serif;
  --font-display:
    Charter, "Bitstream Charter", "Sitka Text", Cambria, "Palatino Linotype",
    "Book Antiqua", Georgia, serif;
}

/* --------------------------------------------------------------------------
   2. Design tokens
   Hues match the previous palette's meaning (blue = links/h2, green = h3,
   magenta = h4, cyan = table tint) but desaturated to ink-like values.
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --ink: #1b2430;
  --ink-soft: #55616f;
  --page: #ffffff;

  --accent: #14487e; /* links, h2      (was #0000cc) */
  --accent-deep: #0e3560; /* h1             (was #000099) */
  --accent-hover: #0a7d5a; /* hover          (was #009900 — failed contrast) */
  --accent-active: #7a2e2f; /* active         (was #49090a) */
  --h3-color: #2c6350; /* h3             (was #336600) */
  --h4-color: #7d3a6e; /* h4             (was #a800c6) */

  /* Surfaces are separated on two axes, not just lightness: the header is a
     desaturated slate, the hover a saturated blue. Five pale tints of one hue
     are indistinguishable at this lightness — header vs hover measured
     dE2000 1.57, well under the ~2.3 perceptibility threshold. */
  --tint: #eaf0f6; /* zebra stripes, h1 band, toc  (was #ceefff) */
  --tint-strong: #dbe1e7; /* table headers — neutral slate  (was #cccccc) */
  --rule: #c6d0da;
  --rule-soft: #e2e9f0;
  --callout: #f3f7fb; /* .highlight                   (was #e0e2eb) */
  --row-hover: #cfe2f7; /* transient: reads as blue */

  --radius: 5px;
  --gutter: clamp(1rem, 4vw, 2rem);
  /* 76ch of actual text; the side gutter sits outside the measure so the
     column width doesn't shrink as padding grows. */
  --measure: calc(76ch + 2 * var(--gutter));

  font-family: var(--font-body);

  /* Fluid type, clamped at both ends. The previous rule used a raw calc() with
     no floor or ceiling; below ~300px it fell under 16px and above 2500px it
     kept growing. clamp() also lets the ratio-based line-height work — the old
     `1.2em + (1.5 - 1.2) * (...)` resolved to 1.20 at every width because the
     second term evaluated to a fraction of a pixel. */
  font-size: clamp(16px, 0.94rem + 0.42vw, 22px);
  line-height: 1.6;

  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

html {
  scroll-behavior: smooth;
  background-color: var(--page);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   3. Page frame
   -------------------------------------------------------------------------- */

body {
  margin: 0 auto;
  padding: 2rem var(--gutter) 4rem;
  max-width: var(--measure);
  background-color: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  /* Long unbroken URLs used to push the page sideways on phones. */
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* :target offset so anchor jumps clear the top of the viewport */
:target {
  scroll-margin-top: 2rem;
}

/* --------------------------------------------------------------------------
   4. Headings
   -------------------------------------------------------------------------- */

h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--accent-deep);
  padding: 0.15rem 0;
  margin: 0;
  text-wrap: balance;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--accent);
  margin: 2.25rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
  text-wrap: balance;
}

h3 {
  font-family: var(--font-display);
  font-size: 1.14rem;
  font-weight: 600;
  font-style: normal;
  line-height: 1.35;
  color: var(--h3-color);
  margin: 1.75rem 0 0.45rem;
  text-wrap: balance;
}

h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  font-style: italic;
  line-height: 1.4;
  color: var(--h4-color);
  margin: 1.5rem 0 0.4rem;
  text-wrap: balance;
}

h2,
h3,
h4 {
  page-break-after: avoid;
  break-after: avoid;
}

/* First heading after a section heading shouldn't double up on space */
h2 + h3,
h3 + h4 {
  margin-top: 0.9rem;
}

/* --------------------------------------------------------------------------
   5. Text
   -------------------------------------------------------------------------- */

p {
  text-align: left;
  margin: 0 0 1.05rem;
  line-height: 1.7;
}

.highlight {
  display: block;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.05rem;
  background-color: var(--callout);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink);
}

.boldunderline {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Used in the markup on core/prework.htm but never styled before. */
.indent2 {
  margin-left: 2rem;
}

strong,
b {
  font-weight: 700;
  color: var(--ink);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

code,
kbd,
samp,
pre {
  font-family:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.92em;
}

code {
  background-color: var(--tint);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}

pre {
  background-color: var(--tint);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.05rem;
}

pre code {
  background: none;
  padding: 0;
}

blockquote {
  margin: 0 0 1.05rem;
  padding-left: 1.1rem;
  border-left: 3px solid var(--rule);
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   6. Lists
   -------------------------------------------------------------------------- */

ul,
ol {
  margin: 0 0 1.05rem 1.6rem;
  list-style-position: outside;
}

/* Replaces the old `p + ul { margin-top: -0.7rem }` negative-margin hack */
p + ul,
p + ol {
  margin-top: -0.55rem;
}

li {
  text-align: left;
  margin: 0 0 0.45rem;
  line-height: 1.7;
  padding-left: 0.4rem;
}

li > ul,
li > ol {
  margin-top: 0.45rem;
  margin-bottom: 0.25rem;
}

ul li {
  list-style-type: square;
}

ol li {
  list-style-type: decimal;
}

ul li::marker {
  color: var(--accent);
}

ol li::marker {
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   7. Links
   Order matters: :link, :visited, :hover, :focus, :active.
   -------------------------------------------------------------------------- */

a:link,
a:visited {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus {
  /* Previous hover green (#009900) scored 3.78:1 on white — below the 4.5:1
     AA threshold, and hover was *less* readable than the resting state. */
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

a:active {
  color: var(--accent-active);
}

/* Links sitting inside running prose carry an underline so they aren't
   signalled by colour alone (WCAG 1.4.1). Navigation blocks opt out below. */
p a,
li a,
dd a,
td a {
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.17em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}

p a:hover,
li a:hover,
dd a:hover,
td a:hover {
  text-decoration-color: currentColor;
}

/* Keyboard focus was previously only a colour change. */
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
button:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   8. Navigation blocks
   -------------------------------------------------------------------------- */

.toplinks {
  text-align: center;
  margin: 0.9rem 0 1.5rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule-soft);
  line-height: 2.1;
}

.toplinks a {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin: 0.1rem 0;
  word-wrap: normal;
  border-radius: var(--radius);
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.toplinks a:hover,
.toplinks a:focus {
  background-color: var(--tint);
  color: var(--accent);
  text-decoration: none;
}

.centered {
  text-align: center;
}

.centered table {
  margin-inline: auto;
}

/* --------------------------------------------------------------------------
   9. Banner (Home | Page title | Search)
   -------------------------------------------------------------------------- */

.banner {
  display: grid;
  grid-template-areas: "on_left on_center on_right";
  /* 1fr auto 1fr keeps the title optically centred regardless of how wide the
     Home / Search labels are. The old `auto auto auto` let it drift. */
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto;
  grid-column-gap: 1rem;
  align-items: baseline;
  margin-bottom: 1.4rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--accent);
}

.left_banner {
  grid-area: on_left;
  text-align: left;
  margin: 0;
}

.center_banner {
  grid-area: on_center;
  text-align: center;
  min-width: 0;
}

.right_banner {
  grid-area: on_right;
  text-align: right;
  margin: 0;
}

.left_banner a,
.right_banner a {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--ink-soft);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.left_banner a:hover,
.right_banner a:hover,
.left_banner a:focus,
.right_banner a:focus {
  background-color: var(--tint);
  color: var(--accent);
  text-decoration: none;
}

@media only screen and (max-width: 34rem) {
  .banner {
    grid-template-areas:
      "on_center on_center"
      "on_left on_right";
    grid-template-columns: 1fr 1fr;
    grid-row-gap: 0.6rem;
  }
}

/* --------------------------------------------------------------------------
   10. Home page masthead
   -------------------------------------------------------------------------- */

[class*="welcome_"] {
  width: auto;
}

.welcome_myname {
  grid-area: welcome_myname;
  text-align: center;
}

.welcome_search {
  grid-area: welcome_search;
  text-align: center;
  margin: auto;
}

.welcome_mypicture {
  grid-area: welcome_mypicture;
  margin: 0;
  text-align: center;
  align-self: center;
  justify-self: center;
}

.welcome_mypicture img {
  border-radius: var(--radius);
  box-shadow:
    0 1px 3px rgb(0 0 0 / 0.12),
    0 6px 18px rgb(0 0 0 / 0.08);
}

.welcome_contact {
  grid-area: welcome_contact;
  text-align: center;
  /* Tight leading on purpose: this is a stack of short data lines, not prose.
     At 1.35 the block lands within ~3px of the photo's height at every
     viewport width, so the two masthead columns end on the same line. */
  line-height: 1.35;
  color: var(--ink-soft);
}

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

.welcome {
  /* Small screens first */
  display: grid;
  vertical-align: top;
  grid-template-areas:
    "welcome_myname"
    "welcome_search"
    "welcome_mypicture"
    "welcome_contact";
  grid-template-rows: max-content max-content max-content max-content;
  grid-template-columns: minmax(0, 1fr);
  grid-row-gap: 1rem;
  grid-column-gap: 1.25rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

@media only screen and (min-width: 768px) {
  .welcome {
    grid-template-areas:
      "welcome_myname welcome_search"
      "welcome_mypicture welcome_contact";
    grid-template-rows: max-content max-content;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .welcome_search,
  .welcome_contact {
    text-align: left;
  }
}

/* --------------------------------------------------------------------------
   11. Tables
   The course matrix is the most-used object on the site, so it is treated like
   the spreadsheet it is: pinned header row, hairline grid, row highlight.
   -------------------------------------------------------------------------- */

table {
  margin-bottom: 1.5rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

td {
  vertical-align: middle;
  margin: 0;
}

table.courselist {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--page);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  vertical-align: middle;
}

table.courselist td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-top: 1px solid var(--rule-soft);
  line-height: 1.45;
}

table.courselist th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
  background-color: var(--tint-strong);
  color: var(--accent-deep);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  border-top: 1px solid var(--rule);
  /* A solid rule under the header row separates it from the first data row
     structurally, so the two fills don't have to carry that job alone. */
  border-bottom: 2px solid var(--accent);
  /* Keeps Summer / Fall / Spring visible while scanning a long course list */
  position: sticky;
  top: 0;
  z-index: 1;
}

table.courselist tr:nth-child(odd),
table.courselist tr:nth-child(even) {
  background-color: transparent;
}

table.courselist tbody tr:hover td {
  background-color: var(--row-hover);
}

table.schedule {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background-color: var(--page);
  vertical-align: middle;
}

table.schedule td,
table.schedule th {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--rule-soft);
  line-height: 1.5;
}

table.schedule tr:nth-child(odd) td {
  background-color: var(--tint);
}

table.schedule tr:nth-child(even) td {
  background-color: var(--page);
}

table.schedule tbody tr:hover td {
  background-color: var(--row-hover);
}

/* Must stay after the nth-child rules above */
table.schedule th {
  background-color: var(--tint-strong);
  color: var(--accent-deep);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 1;
}

.offered {
  text-align: center;
  vertical-align: middle;
}

/* The term columns are a yes/no matrix: keep them narrow and equal so the
   pattern of offerings is readable down the page. */
table.courselist th:not(:first-child) {
  width: 6.5rem;
  text-align: center;
}

table.courselist td:not(:first-child) {
  text-align: center;
}

.offered img {
  width: 15px;
  height: 15px;
}

/* Wide tables scroll inside their own box on phones instead of stretching the
   whole page sideways. */
@media only screen and (max-width: 40rem) {
  table.courselist,
  table.schedule {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table.courselist th,
  table.schedule th {
    position: static;
  }
}

/* --------------------------------------------------------------------------
   12. Definition lists
   -------------------------------------------------------------------------- */

dl,
dl.widefirst {
  display: grid;
  grid-column-gap: 1.25rem;
  grid-row-gap: 0.75rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

dl {
  grid-template-columns: 10ch minmax(0, 1fr);
}

dl.widefirst {
  grid-template-columns: 16ch minmax(0, 1fr);
}

dt {
  grid-column-start: 1;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

dd {
  grid-column-start: 2;
  min-width: 0;
}

/* Two narrow columns don't fit on a phone; stack them. */
@media only screen and (max-width: 34rem) {
  dl,
  dl.widefirst {
    grid-template-columns: minmax(0, 1fr);
    grid-row-gap: 0.25rem;
  }

  dt,
  dd {
    grid-column-start: 1;
  }

  dt {
    font-weight: 700;
    margin-top: 0.6rem;
  }

  dd {
    margin-bottom: 0.4rem;
  }
}

/* --------------------------------------------------------------------------
   13. Table of contents
   -------------------------------------------------------------------------- */

#toc {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background-color: var(--tint);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

#toc ul {
  margin: 0;
  columns: 2;
  column-gap: 2rem;
}

#toc li {
  margin-bottom: 0.15rem;
  padding: 0.2rem 0.45rem;
  line-height: 1.45;
  list-style-type: none;
  border-radius: 3px;
  break-inside: avoid;
  transition: background-color 0.15s ease;
}

#toc li:hover {
  background-color: var(--row-hover);
}

#toc a {
  display: block;
  text-decoration: none;
}

#toc a:hover {
  text-decoration: none;
}

@media only screen and (max-width: 34rem) {
  #toc ul {
    columns: 1;
  }
}

/* --------------------------------------------------------------------------
   14. Media and forms
   -------------------------------------------------------------------------- */

img {
  max-width: 100%;
  height: auto;
}

iframe,
video,
embed,
object {
  max-width: 100%;
}

/* Keeps 16:9 embeds proportional once they're width-constrained */
iframe[width="560"] {
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: var(--radius);
  margin-bottom: 1.05rem;
}

input,
textarea,
select,
button {
  font-family: inherit;
  font-size: 1rem;
  max-width: 100%;
  color: var(--ink);
}

input[type="text"],
input[type="search"],
input[type="email"],
textarea,
select {
  padding: 0.42rem 0.65rem;
  background-color: var(--page);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

input[type="text"]:hover,
textarea:hover,
select:hover {
  border-color: var(--accent);
}

.smallbutton,
input[type="submit"],
button {
  font-size: 0.95rem;
  padding: 0.45rem 1rem;
  background-color: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.smallbutton:hover,
input[type="submit"]:hover,
button:hover {
  background-color: var(--accent-deep);
  border-color: var(--accent-deep);
}

/* --------------------------------------------------------------------------
   15. Print
   -------------------------------------------------------------------------- */

@media print {
  :root {
    font-family:
      TimesNewRoman, "Times New Roman", Times, Baskerville, Georgia, serif;
    font-size: 11pt;
    line-height: 1.35;

    --ink: #000;
    --ink-soft: #333;
    --page: #fff;
    --accent: #000;
    --accent-deep: #000;
    --h3-color: #000;
    --h4-color: #000;
    --tint: #f2f2f2;
    --tint-strong: #e4e4e4;
    --rule: #999;
    --rule-soft: #ccc;
    --callout: #f4f4f4;
  }

  @page {
    margin: 0.7in;
  }

  body {
    margin: 0;
    padding: 0;
    max-width: none;
    color: #000;
    background: #fff;
  }

  h1,
  h2,
  h3,
  h4 {
    font-family: inherit;
    color: #000;
  }

  h1 {
    border-bottom: 1pt solid #000;
    background: none;
    padding: 0 0 0.2rem;
  }

  a:link,
  a:visited {
    color: #000;
    text-decoration: underline;
  }

  /* Spell out destinations for external links only */
  p a[href^="http"]::after,
  li a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #444;
    word-break: break-all;
  }

  table.courselist th,
  table.schedule th {
    position: static;
  }

  table,
  figure,
  img,
  pre,
  blockquote {
    break-inside: avoid;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }

  .toplinks,
  .welcome_search,
  .left_banner,
  .right_banner,
  #toc,
  form {
    display: none;
  }
}
