/*
  mystyle.css - accessibility-focused replacement
  Target: Davar Khoshnevisan math.utah.edu pages
  Goal: improve ADA/WCAG-oriented visual accessibility without requiring HTML changes.

  Notes:
  - CSS alone cannot guarantee ADA/WCAG compliance. HTML semantics, alt text,
    document titles, headings, forms, and keyboard behavior must also be checked.
  - This stylesheet avoids fixed text sizes, keeps links visually identifiable,
    adds strong keyboard focus styles, and uses high-contrast color pairs.
*/

:root {
  color-scheme: light;

  --page-bg: #f8fafc;
  --page-bg-image: none;
  --photo-bg-image: url("Moab_Arches_2018.jpg");
  --photo-opacity: 0.26;
  --body-bg: rgba(255, 255, 255, 0.975);
  --content-bg: #ffffff;
  --body-border: rgba(203, 213, 225, 0.9);
  --body-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.36);
  --text: #111827;
  --muted-text: #334155;
  --heading: #0f172a;
  --border: #cbd5e1;

  --link: #111827;
  --link-hover: #000000;
  --link-visited: #111827;
  --focus: #92400e;
  --focus-bg: rgba(146, 64, 14, 0.12);

  --notice-bg: #fff7ed;
  --notice-text: #7c2d12;

  --measure: 80ch;
  --body-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --body-font-size: 1rem; /* Browser default: 16px unless the user has changed their default font size. */
  --space: 1rem;
}

* {
  box-sizing: border-box;
}

html {
  position: relative;
  min-height: 100%;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--page-bg);
  background-image: var(--page-bg-image);
}

/* Faint grayscale photo layer behind the page. */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(248, 250, 252, 0.30), rgba(248, 250, 252, 0.30)),
    var(--photo-bg-image);
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  opacity: var(--photo-opacity);
  filter: grayscale(100%) contrast(0.95) brightness(0.88);
}

body {
  position: relative;
  z-index: 1;
  margin: clamp(1rem, 3vw, 2rem) auto;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  max-width: var(--measure);
  min-height: calc(100vh - clamp(2rem, 6vw, 4rem));
  border: 1px solid var(--body-border);
  border-radius: 0.6rem;
  box-shadow: var(--body-shadow);
  background: var(--body-bg);
  color: var(--text);
  font-family: var(--body-font);
  font-size: var(--body-font-size);
  line-height: 1.65;
}

/* Keep common older-page containers readable if present. */
main,
article,
section,
.content,
.container,
#content,
#main,
table {
  max-width: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--heading);
  line-height: 1.25;
  margin-block: 1.25em 0.5em;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2rem);
}

h3 {
  font-size: 1.35rem;
}

p,
ul,
ol,
dl,
pre,
blockquote,
figure,
table {
  margin-block: 0 1rem;
}

ul,
ol {
  padding-inline-start: 1.5rem;
}

li + li {
  margin-top: 0.35rem;
}

/* Links are underlined by default so color is not the only cue. */
a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.16em;
  overflow-wrap: anywhere;
}

a:visited {
  color: var(--link-visited);
}

a:hover,
a:active {
  color: var(--link-hover);
  text-decoration-thickness: 0.14em;
}

a:focus-visible {
  border-radius: 0.15em;
  background-color: var(--focus-bg);
}

/* Strong visible keyboard focus. */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
summary:focus,
[tabindex]:focus {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Use :focus-visible when supported, without removing focus for older browsers. */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Make navigation/link clusters easier to target on touch screens. */
nav a,
.nav a,
.navigation a,
.footer a,
footer a,
p > a,
li > a {
  padding-block: 0.08rem;
}

/* Generic button/form support in case subpages use forms. */
button,
input,
select,
textarea {
  font: inherit;
  color: var(--text);
}

button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.55rem 0.85rem;
  border: 2px solid var(--heading);
  border-radius: 0.25rem;
  background: var(--content-bg);
  cursor: pointer;
}

input,
select,
textarea {
  min-height: 2.75rem;
  max-width: 100%;
  border: 2px solid var(--border);
  border-radius: 0.25rem;
  background: var(--content-bg);
  padding: 0.45rem 0.6rem;
}

textarea {
  min-height: 8rem;
}

label {
  display: inline-block;
  margin-block: 0.5rem 0.25rem;
  font-weight: 700;
}

/* Images scale instead of forcing horizontal scrolling. */
img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

img {
  border: 0;
}

figure {
  margin-inline: 0;
}

figcaption,
small,
.footer,
footer,
address {
  color: var(--muted-text);
  font-size: 0.95em;
}

address {
  font-style: normal;
}

/* Tables remain readable on small screens and at 200% zoom. */
table {
  border-collapse: collapse;
  width: 100%;
  overflow-x: auto;
}

th,
td {
  padding: 0.5rem;
  border: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

th {
  background: #e5e7eb;
  color: var(--heading);
}

/* Code and preformatted text should wrap instead of breaking zoomed layouts. */
code,
kbd,
samp,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--content-bg);
}

blockquote {
  margin-inline: 0;
  padding-inline: 1rem;
  border-left: 0.25rem solid var(--border);
  color: var(--muted-text);
}

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

/* Optional skip link support if the HTML adds <a class="skip-link" href="#main">Skip to content</a>. */
.skip-link {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 999;
  transform: translateY(-150%);
  padding: 0.75rem 1rem;
  border: 2px solid var(--heading);
  background: var(--content-bg);
  color: var(--link);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* Utility classes for notes or warnings, if used on subpages. */
.notice,
.warning,
.important {
  padding: 1rem;
  border: 2px solid var(--focus);
  border-radius: 0.25rem;
  background: var(--notice-bg);
  color: var(--notice-text);
}

/* Respect users who request less motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Preserve visibility in Windows High Contrast / forced-colors modes. */
@media (forced-colors: active) {
  html,
  body {
    background: Canvas;
    background-image: none;
    border-color: CanvasText;
    box-shadow: none;
  }

  html::before {
    display: none;
  }

  a {
    color: LinkText;
  }

  a:visited {
    color: VisitedText;
  }

  a:focus,
  button:focus,
  input:focus,
  select:focus,
  textarea:focus,
  summary:focus,
  [tabindex]:focus,
  :focus-visible {
    outline: 3px solid Highlight;
  }
}

/* Small-screen adjustments. */
@media (max-width: 40rem) {
  body {
    margin: 0 auto;
    min-height: 100vh;
    padding: 1rem;
    border-width: 0;
    border-radius: 0;
  }

  nav,
  .nav,
  .navigation,
  footer,
  .footer {
    line-height: 1.8;
  }
}

/* Print remains clean and legible. */
@media print {
  html,
  body {
    background: #ffffff;
    background-image: none;
    box-shadow: none;
  }

  html::before {
    display: none;
  }

  body {
    max-width: none;
    min-height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    color: #000000;
    font-size: 12pt;
  }

  a {
    color: #000000;
    text-decoration: underline;
  }
}


/* Page-specific helpers for the funding table page. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.page-header {
  text-align: center;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin-block: 1rem 1.5rem;
}

.table-wrapper:focus {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

caption {
  caption-side: top;
  color: var(--heading);
  font-weight: 700;
  text-align: left;
  margin-block-end: 0.35rem;
}

tfoot th,
tfoot td,
.total-cost {
  font-weight: 700;
}

dl.notes {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 0.75rem;
  row-gap: 0.5rem;
}

dl.notes dt {
  font-weight: 700;
}

dl.notes dd {
  margin: 0;
}
