:root {
  color-scheme: light;
  --header-h: 52px;
  --bg: #e7e7e7;
  --bg-alt: #f0f0f0;
  --fg: #1a1a1a;
  --fg-muted: #4d4d4d;
  --border: #9b9b9b;
  --link: #0000ee;
  --link-hover: #000080;
  --figure-bg: #dcdcdc;
  --figure-border: #ababab;
  --fig-shadow: rgba(0, 0, 0, 0.28);
  --fig-highlight: rgba(255, 255, 255, 0.4);
  --btn-bg-top: #ffffff;
  --btn-bg-mid-hi: #e3e5e8;
  --btn-bg-mid-lo: #c8cacf;
  --btn-bg-bot: #eceef1;
  --btn-bd: rgba(0, 0, 0, 0.55);
  --btn-ic: #333333;
  --btn-gloss-hi: rgba(255, 255, 255, 0.95);
  --btn-gloss-lo: rgba(255, 255, 255, 0.2);
  --btn-active-top: #b9bcc2;
  --btn-active-mid-hi: #c6c9cf;
  --btn-active-mid-lo: #a9adb5;
  --btn-active-bot: #c3c6cc;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #202020;
  --bg-alt: #2a2a2a;
  --fg: #d6d6d6;
  --fg-muted: #9a9a9a;
  --border: #404040;
  --link: #7fa8ff;
  --link-hover: #b7ccff;
  --figure-bg: #2e2e2e;
  --figure-border: #4a4a4a;
  --fig-shadow: rgba(0, 0, 0, 0.6);
  --fig-highlight: rgba(255, 255, 255, 0.08);
  --btn-bg-top: #6a6a70;
  --btn-bg-mid-hi: #525258;
  --btn-bg-mid-lo: #3a3a40;
  --btn-bg-bot: #58585e;
  --btn-bd: rgba(0, 0, 0, 0.85);
  --btn-ic: #eeeeee;
  --btn-gloss-hi: rgba(255, 255, 255, 0.4);
  --btn-gloss-lo: rgba(255, 255, 255, 0.05);
  --btn-active-top: #2e2e33;
  --btn-active-mid-hi: #34343a;
  --btn-active-mid-lo: #26262b;
  --btn-active-bot: #303036;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header"
    "aside main"
    "footer footer";
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: Tahoma, Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

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

hr {
	margin-top: 30px;
	width: 80%;
}

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

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

menu {
  margin: 0;
  padding: 0;
  list-style: none;
}

header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  background: linear-gradient(180deg, #245edc 0%, #3166c9 45%, #3a6ea5 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid #163d8f;
}

header nav {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  gap: 12px;
}

header nav h1 {
  margin: 0;
  display: flex;
  align-items: center;
  line-height: 0;
  font-variant: small-caps;
  font-size: 1.3rem;
  letter-spacing: 1px;
  white-space: nowrap;
}

header nav h1 a {
  color: #ffffff;
  display: inline-block;
  line-height: 0;
}

header nav h1 img {
  height: 32px;
  width: auto;
  display: block;
  padding: 1px;
  border: 1px solid rgba(0, 0, 0, 0.6);
  box-shadow:
    inset 1px 1px 0 #ffffff,
    inset 2px 2px 0 rgba(255, 255, 255, 0.55),
    inset -1px -1px 0 rgba(0, 0, 0, 0.7),
    inset -2px -2px 0 rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

header nav a:hover {
  color: #ffffff;
}

header nav ul {
  display: flex;
	list-style: none;
  margin: 0;
  padding: 0;
  gap: 2px;
}

header nav ul li a {
  color: #ffffff;
  font-size: 0.95rem;
  display: inline-block;
  padding: 5px 10px;
}

header nav ul li a[aria-current="page"] {
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

header nav ul li a:hover {
  background: rgba(255, 255, 255, 0.15);
}

#theme-btn,
#to-top {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--btn-bd);
  border-radius: 8px;
  cursor: pointer;
  color: var(--btn-ic);
  font-family: inherit;
  background: linear-gradient(180deg, var(--btn-bg-top) 0%, var(--btn-bg-mid-hi) 48%, var(--btn-bg-mid-lo) 52%, var(--btn-bg-bot) 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    inset 1px 0 0 rgba(255, 255, 255, 0.55),
    inset -1px 0 0 rgba(255, 255, 255, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

#theme-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  padding: 0;
}

#to-top {
  position: fixed;
  right: 16px;
  bottom: 62px;
  z-index: 30;
  height: 32px;
  padding: 0 16px;
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

#theme-btn::after,
#to-top::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  height: 46%;
  border-radius: 7px 7px 40% 40%;
  background: linear-gradient(180deg, var(--btn-gloss-hi), var(--btn-gloss-lo));
  pointer-events: none;
}

#theme-btn:hover,
#to-top:hover {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.55),
    0 0 3px rgba(255, 255, 255, 0.4),
    inset 1px 0 0 rgba(255, 255, 255, 0.65),
    inset -1px 0 0 rgba(255, 255, 255, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

#theme-btn:active,
#to-top:active {
  transform: translateY(1px);
  background: linear-gradient(180deg, var(--btn-active-top) 0%, var(--btn-active-mid-hi) 48%, var(--btn-active-mid-lo) 52%, var(--btn-active-bot) 100%);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}

#theme-btn svg {
  width: 18px;
  height: 18px;
  position: relative;
  z-index: 1;
}

.icon-sun {
  display: none;
}

.icon-moon {
  display: block;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

aside {
  grid-area: aside;
  position: sticky;
  top: var(--header-h);
  align-self: start;
  width: 250px;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 10px 14px 14px;
}

aside menu li {
  margin-bottom: 6px;
}

aside menu a {
  font-size: 0.9rem;
}

main {
  grid-area: main;
  min-width: 0;
  padding: 1.5rem 2rem;
}

article {
  max-width: 46rem;
}

article h1 {
  font-size: 1.65rem;
  margin: 0 0 0.75em;
}

article h2 {
  font-size: 1.25rem;
  margin: 1.5em 0 0.6em;
}

article p {
  margin: 0 0 1em;
  line-height: 1.5;
}

article h2 a.secondary {
  color: var(--fg);
  text-decoration: underline;
}

article img {
  border-radius: 5px;
  max-width: 100%;
	max-height: 300px;
  height: auto;
}

article figure {
  border: 1px solid var(--figure-border);
  border-radius: 8px;
  background: var(--figure-bg);
  box-shadow:
    inset 0 2px 4px var(--fig-shadow),
    inset 0 -1px 1px var(--fig-highlight);
  padding: 8px;
  display: inline-block;
  margin: 1rem 0;
  max-width: 100%;
}

article figure img {
  display: block;
}

article figure figcaption {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-align: center;
  margin-top: 6px;
}

article img:not([src]) {
  display: none;
}

article figure:has(img:not([src])) {
  display: none;
}

article footer {
	text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  padding-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--border);
  font-style: italic;
  color: var(--fg-muted);
}

blockquote cite {
  display: block;
  margin-top: 0.5rem;
  font-style: normal;
}

body > footer {
  grid-area: footer;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 2rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}

#main-hero {
	text-align: center;
	font-size: clamp(2.25rem, 7vw, 4.2rem);
	color: var(--fg);

}
#main-hero h1 {
	text-align: left;
	font-size: 17px;
	font-weight: normal;
	color: var(--fg);
}
#main-hero a {
	font-size: clamp(1.9rem, 7vw, 2.5rem);
	font-variant: small-caps;
}

.hero {
  padding: 0.5rem 0 1rem;
}

.hero-tagline {
  font-style: italic;
  font-weight: normal;
  color: var(--fg-muted);
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

.blog-hero li,
.projects-list li {
  margin: 0.4rem 0;
	font-size: clamp(1.05rem, 2vw, 1.3rem);
}

main .blog-hero a::after {
  content: ", " attr(data-date);
  color: var(--fg-muted);
  text-decoration: none;
}

@media (max-width: 768px) {
  aside {
    display: none;
  }

  header {
    height: auto;
    min-height: var(--header-h);
  }

  header nav {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
  }

  header nav ul li a {
    font-size: clamp(0.72rem, 3.6vw, 0.9rem);
    padding: 4px 8px;
}

  main {
    padding: 1rem;
  }

  body > footer {
    padding: 0.5rem 1rem;
  }

	#main-hero {
		font-size: clamp(1.8rem, 9vw, 2.4rem);
	}
	#main-hero a {
		font-size: clamp(1.5rem, 9vw, 1.6rem);
	}
}
