@charset "utf-8";

:root {
  color-scheme: light dark;
  --page-bg: #fff;
  --text: #222;
  --link: #0066cc;
  --link-hover: #003d80;
  --tile-grey: #8a8a8a;
  --home-link: #222;
  --grey-logo-filter: none;
  --logo-filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #000;
    --text: #fff;
    --link: #0066cc;
    --link-hover: #3399ff;
    --tile-grey: #999;
    --home-link: #fff;
    --grey-logo-filter: invert(1);
    --logo-filter: none;
  }
}

html {
  color: var(--text);
  height: 100%;
}

body {
  background: var(--page-bg);
}

@media (prefers-color-scheme: dark) {
  body {
    background: #000 url(images/background.png) bottom right no-repeat fixed;
  }
}

body,
div,
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  padding: 0;
}

html, body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-align: center;
  margin: 0;
  padding: 0;
}

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

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

.nohover,
.nohover:hover {
  color: var(--text);
}

img {
  border-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  background-color: currentColor;
  -webkit-mask: var(--icon) no-repeat center / contain;
  mask: var(--icon) no-repeat center / contain;
}

.icon-circle-left {
  --icon: url(icons/circle-left.svg);
  width: 48px;
  height: 40px;
  margin-right: 6px;
  vertical-align: middle;
  /* the mask is taller than the box and bottom-aligned, so only the top of the circle is cropped.
     Firefox ignores the three-value form "center bottom 1px", so spell it out */
  -webkit-mask-size: 46px 46px;
  mask-size: 46px 46px;
  -webkit-mask-position: 50% calc(100% - 1px);
  mask-position: 50% calc(100% - 1px);
}

/* The logo is light-coloured artwork, so darken it on the light theme */
.misclogo {
  max-width: 100%;
  filter: var(--logo-filter);
}

#misc {
  padding-top: 10px;
}

#misc #miscmain {
  margin: 0 25px 10px 25px;
}

#homelink {
  padding: 0;
  margin: 0 2px 0 0;
  border-width: 0;
  position: fixed;
  top: 0;
  right: 0;
  opacity: 0.75;
  -moz-transition: opacity 750ms ease;
  -webkit-transition: opacity 750ms ease;
  -o-transition: opacity 750ms ease;
  transition: opacity 750ms ease;
}

#homelink a {
  display: flex;
  align-items: center;
  padding: 0 10px 0 0;
  color: var(--home-link) !important;
}

#homelink:hover,
#homelink:focus-within {
  opacity: 1.0;
}

/* Portrait: four rows filling the window. Hover effects apply instantly and fade out */
/* Percentage heights follow the visible area, unlike 100vh which includes mobile browser chrome */
body.home,
body.home main {
  height: 100%;
}

#links {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.tile {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 28px;
  min-height: 0;
  padding: 8px 32px;
  color: var(--text);
  text-align: left;
  -moz-transition: background-color 750ms ease;
  -webkit-transition: background-color 750ms ease;
  -o-transition: background-color 750ms ease;
  transition: background-color 750ms ease;
}

.tile:hover,
.tile:focus-visible {
  color: var(--text);
  background-color: rgba(128, 128, 128, 0.12);
  -moz-transition: none;
  -webkit-transition: none;
  -o-transition: none;
  transition: none;
}

.tile:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: -3px;
}

.tile .label {
  font-size: 1.8em;
  line-height: 1.2;
}

.logo {
  position: relative;
  display: block;
  flex: none;
  width: 72px;
  height: 72px;
}

.logo img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.logo .colour {
  opacity: 0;
  -moz-transition: opacity 750ms ease;
  -webkit-transition: opacity 750ms ease;
  -o-transition: opacity 750ms ease;
  transition: opacity 750ms ease;
}

.tile:hover .colour,
.tile:focus-visible .colour {
  opacity: 1;
  -moz-transition: none;
  -webkit-transition: none;
  -o-transition: none;
  transition: none;
}

.logo .grey.invert-dark {
  filter: var(--grey-logo-filter);
}

/* Single colour logo: brightens on hover instead of fading to a coloured image */
.logo-cap {
  background-color: var(--tile-grey);
  -webkit-mask: url(icons/graduation-cap.svg) no-repeat center / contain;
  mask: url(icons/graduation-cap.svg) no-repeat center / contain;
  -moz-transition: background-color 750ms ease;
  -webkit-transition: background-color 750ms ease;
  -o-transition: background-color 750ms ease;
  transition: background-color 750ms ease;
}

.tile:hover .logo-cap,
.tile:focus-visible .logo-cap {
  background-color: var(--text);
  -moz-transition: none;
  -webkit-transition: none;
  -o-transition: none;
  transition: none;
}

/* No hover on touch devices, so always show the colour version */
@media (hover: none) {
  .logo .colour {
    opacity: 1;
  }

  .logo-cap {
    background-color: var(--text);
  }
}

/* Landscape: four quadrants filling the window */
@media (orientation: landscape) {
  #links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .tile {
    flex: none;
    flex-direction: column;
    justify-content: center;
    gap: 2vmin;
    padding: 12px;
    text-align: center;
  }

  .tile .label {
    font-size: clamp(1.1em, 3.4vmin, 2.2em);
  }

  .logo {
    width: clamp(48px, 16vmin, 140px);
    height: clamp(48px, 16vmin, 140px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  .logo .colour,
  .logo-cap,
  #homelink {
    -moz-transition: none;
    -webkit-transition: none;
    -o-transition: none;
    transition: none;
  }
}
