@font-face {
  font-family: "Inter";
  src: url("assets/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fafafa;
  --ink: #232326;
  --muted: #646469;
  --accent: #a31f34;
  --line: #dcdcdf;
  --hover: #eeeeef;
  --logo-filter: none;
  --mit-logo-filter: none;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #18191b;
  --ink: #f0f0f2;
  --muted: #b0b0b7;
  --accent: #ed8295;
  --line: #3b3c41;
  --hover: #292a2f;
  --logo-filter: grayscale(1) invert(1);
  --mit-logo-filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #18191b;
    --ink: #f0f0f2;
    --muted: #b0b0b7;
    --accent: #ed8295;
    --line: #3b3c41;
    --hover: #292a2f;
    --logo-filter: grayscale(1) invert(1);
    --mit-logo-filter: invert(1);
  }
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  justify-content: flex-end;
  padding: 1.5rem 3rem 0;
}

/* Preserve the supplied image's internal margins and add clear space greater
   than the M's width (about 25px at this size). The visible mark is 45px tall. */
.mit-home {
  display: block;
  padding: 1rem;
  margin-right: -1rem;
}

.mit-home img {
  display: block;
  width: 6.5rem;
  height: auto;
  filter: var(--mit-logo-filter);
}

.identity {
  flex: 1;
  display: grid;
  place-items: center;
  padding: clamp(4rem, 12vh, 9rem) 2rem;
}

.identity-content { width: min(100%, 44rem); }

.wordmark-art { position: relative; }

.wordmark {
  display: block;
  width: 100%;
  height: auto;
  filter: var(--logo-filter);
}

/* Retain the original red seal while adapting the dark brushwork for dark mode.
   Both layers use the same uncropped image, so scaling stays pixel-aligned. */
.wordmark-seal {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: auto;
  clip-path: inset(32% 68.4% 3% 24.7%);
}

.identity-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: clamp(2rem, 5vw, 3rem);
  text-align: center;
}

.identity-details::before {
  content: "";
  width: 2rem;
  height: 1px;
  margin-bottom: 1.125rem;
  background: var(--accent);
}

h1 {
  margin: 0;
  font-family: inherit;
  font-size: clamp(1.5rem, 1.2rem + 0.8vw, 1.875rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: normal;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}

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

:where(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
  border-radius: 3px;
}

.contact {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
  text-decoration-color: var(--muted);
}

.contact:hover { text-decoration-color: currentColor; }

.footer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  width: calc(100% - 6rem);
  margin-inline: auto;
  padding-block: 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.footer-identity { min-width: 0; }
.organization-name {
  margin: 0;
  color: var(--ink);
  font-size: inherit;
  font-weight: 500;
  line-height: 1.5;
}

.footer small { font-size: 0.8125rem; }
.institute-name { max-width: 22rem; text-decoration: none; }
.institute-name:hover { text-decoration: underline; }
.footer-info { display: flex; align-items: center; gap: 0 0.75rem; }
.footer-separator { opacity: 0.55; }
.footer a { display: inline-flex; align-items: center; min-height: 44px; }

.theme-control { position: relative; flex-shrink: 0; }

.theme-menu {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: calc(100% + 0.75rem);
  display: flex;
  gap: 0.25rem;
  width: max-content;
  padding: 0.375rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 12%);
}

.theme-menu[hidden] { display: none; }

.theme-menu button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.theme-menu button svg { width: 18px; height: 18px; }
.theme-menu button:hover,
.theme-menu button:focus-visible { background: var(--hover); }
.theme-menu button:focus-visible { outline-offset: -3px; }
.theme-menu button[aria-checked="true"] {
  color: var(--accent);
  border-color: currentColor;
  background: var(--hover);
}
.theme-menu button[aria-checked="true"]::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 0.25rem;
  height: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.theme-toggle {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--paper);
  cursor: pointer;
}

.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--ink); background: var(--hover); }
.theme-toggle svg { display: none; width: 18px; height: 18px; }
.theme-toggle[data-mode="system"] [data-theme-icon="system"],
.theme-toggle[data-mode="light"] [data-theme-icon="light"],
.theme-toggle[data-mode="dark"] [data-theme-icon="dark"] { display: block; }

@media (max-width: 40rem) {
  .site-header { padding: 1rem 1.5rem 0; }
  .identity { padding-inline: 1.5rem; }
  .footer { width: calc(100% - 3rem); grid-template-columns: 1fr auto; gap: 0.5rem 1rem; }
  .footer-identity { grid-column: 1 / -1; }
  .institute-name { max-width: 100%; }
  .footer-info { flex-direction: column; align-items: flex-start; gap: 0; }
  .footer-separator { display: none; }
}

@media (forced-colors: active) {
  .mit-home img { filter: none; background: white; }
  .wordmark { filter: none; background: white; }
  .wordmark-seal { display: none; }
  .identity-details::before { background: CanvasText; }
  :where(a, button):focus-visible { outline-color: LinkText; }
}
