:root {
  --gray-100: #f5f5f5;
  --gray-200: #e0e0e0;
  --gray-500: #767676;
  --color-faint: #bbb;
  --color-link: #0055bb;
  --body-background: #fff;
  --body-font-color: #222;
  --sidebar: 16rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 20rem;
  color: var(--body-font-color);
  background: var(--body-background);
  font-family: "IBM Plex Sans", "IBM Plex Sans Arabic", Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
}

h1, h2, h3, h4, h5 {
  font-weight: 600;
  line-height: 1.25;
}

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

a:hover {
  color: #003d88;
}

.hidden { display: none !important; }

.flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

@media (min-width: 320px) {
  .container { width: 85%; padding: 0; }
}

@media (min-width: 550px) {
  body { padding-top: 50px; padding-bottom: 50px; }
  .container { width: 80%; }
}

@media (min-width: 1220px) {
  body { padding-top: 100px; padding-bottom: 100px; }
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.5em;
  row-gap: 0.35em;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 40;
}

.site-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.site-name a {
  color: var(--body-font-color);
  text-decoration: none;
}

.site-name a:hover,
.site-name a:focus,
.site-name a:focus-visible {
  color: var(--color-link);
}

.site-page-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  color: var(--color-faint);
  flex: 0 1 auto;
  min-width: 0;
}

.site-header nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
  color: var(--gray-500);
}

.site-header nav li {
  margin: 0;
}

.site-header nav li + li::before {
  content: "·";
  margin: 0 0.4em;
  color: var(--gray-500);
}

.site-header nav a {
  color: var(--gray-500);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--body-font-color);
  text-decoration: underline;
}

.site-header nav a.active {
  color: var(--body-font-color);
  text-decoration: none;
}

footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-faint);
  padding: 1.25rem 0 0.5rem;
}

footer a {
  color: inherit;
  text-decoration: none;
}

footer a:hover,
footer a:focus,
footer a:focus-visible {
  text-decoration: underline;
}

.menu-open,
.menu-close {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--gray-500);
  text-transform: lowercase;
}

.menu-open {
  margin-left: auto;
  flex: 0 0 auto;
}

.menu-open svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.menu-open:hover,
.menu-close:hover {
  color: var(--body-font-color);
  text-decoration: underline;
}

.menu-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.book-menu {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: var(--sidebar);
  visibility: hidden;
  transform: translateX(-100%);
  transition: transform 0.2s ease, visibility 0.2s ease;
}

.book-menu-content {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem;
  background: var(--body-background);
  border-right: 1px solid var(--gray-200);
  box-shadow: 0 0 0.5rem rgba(0, 0, 0, 0.08);
}

.book-brand {
  margin: 0.75rem 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.book-brand a {
  color: inherit;
  text-decoration: none;
}

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

.book-menu nav ul {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.book-menu nav li {
  margin: 0.35em 0;
}

.book-menu nav a.active {
  font-weight: 600;
  color: var(--body-font-color);
  text-decoration: none;
}

.book-menu nav .book-tags {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

.book-menu nav .book-tags li { margin: 0.2em 0; }

.book-menu nav .book-tags a { text-decoration: none; }

.book-menu nav .book-tags a:hover { text-decoration: underline; }

.book-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
}

#menu-control:checked ~ .book-menu {
  visibility: visible;
  transform: translateX(0);
}

#menu-control:checked ~ .book-menu-overlay {
  display: block;
}

#menu-control:checked ~ .container {
  opacity: 0.35;
}

.list-holder {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px;
}

.list-holder .thumbnail {
  flex: 0 0 100%;
  width: auto;
  height: auto;
  margin: 0;
  transition: opacity 0.5s;
}

.list-holder .thumbnail a.noline,
.list-holder .thumbnail a.noline:hover {
  display: block;
  color: inherit;
  text-decoration: none;
}

.list-holder .thumbnail img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 8 / 5;
  object-fit: cover;
  object-position: center;
  margin: 0;
  transition: opacity 0.5s;
}

.list-holder .thumbnail a:hover img {
  opacity: 0.4;
}

.list-holder .cover-fallback {
  display: block;
  width: 100%;
  aspect-ratio: 8 / 5;
  background: var(--gray-100);
}

@media (min-width: 700px) {
  .list-holder .thumbnail {
    flex: 0 0 calc((100% - 20px) / 3);
  }
}

.markdown {
  line-height: 1.6;
  max-width: 100%;
}

.markdown > :first-child { margin-top: 0; }

.markdown h1 a {
  color: inherit;
  text-decoration: none;
}

.markdown h1 a:hover {
  color: var(--color-link);
  text-decoration: underline;
}

.markdown h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.5rem;
}

.markdown h3 {
  font-size: 1.0625rem;
  margin: 1.25rem 0 0.35rem;
  font-weight: 600;
}

.markdown h5 {
  margin: 0.25rem 0 0.35rem;
  font-weight: 400;
  font-size: 1rem;
  color: var(--body-font-color);
}

.entry-year {
  color: var(--gray-500);
}

.entry-tags {
  margin: 0 0 0.75rem;
}

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

.entry-tags a:hover {
  color: #003d88;
  text-decoration: underline;
}

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

.markdown hr {
  border: 0;
  border-top: 1px solid var(--gray-200);
  margin: 1.5rem 0;
}

article code,
article pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.project-banner {
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: center;
  display: block;
  margin: 0 0 1.5rem;
}

.markdown p { text-align: justify; line-height: 1.55; }
.markdown aside { text-align: center; font-size: 1.125rem; }

.markdown blockquote {
  font-size: 1.0625rem;
  line-height: 1.55;
  border-left: 3px solid black;
  padding-left: 2em;
  margin-left: 0;
  margin-right: 0;
  font-style: italic;
}
.markdown blockquote cite::before { content: "— "; }
.markdown blockquote cite { padding-top: 1em; display: block; }

.markdown video,
.markdown iframe {
  border: 0;
  display: block;
  width: 100%;
  margin: 0 auto;
}

.page-project article video,
.page-project .video-poster {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.page-project .video-poster {
  overflow: hidden;
}

.page-project .video-poster img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}

.page-project figure.media.video-poster > img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  margin: 0;
}

.markdown pre {
  background: #f8f9fa;
  padding: 1em;
  overflow: auto;
  width: calc(100% - 2em);
}
.markdown pre code {
  white-space: wrap;
  color: #343a40;
  background: none;
  font-size: 0.9em;
  line-height: 1.5em;
}

.markdown code {
  font-size: 0.9em;
  white-space: pre;
  background: #fafafa;
  color: #333;
  padding: 2px;
}

.markdown a.noline,
.markdown a.noline:hover { text-decoration: none; }

.markdown figure.media {
  width: 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.markdown figure.media > img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.carousel {
  position: relative;
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  gap: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.35) transparent;
  padding-bottom: 12px;
}

.carousel figure { margin: 0; }
.markdown .carousel {
  width: 100%;
  max-width: 100%;
  overscroll-behavior-x: contain;
}

.carousel > * {
  flex: 0 0 100%;
  max-width: 100%;
  scroll-snap-align: start;
  display: flex;
  justify-content: center;
  align-items: center;
}

.carousel > img,
.carousel > * img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(70vh, 540px);
  object-fit: contain;
}

.carousel::-webkit-scrollbar { height: 6px; }
.carousel::-webkit-scrollbar-track { background: transparent; }
.carousel::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.35);
  border-radius: 999px;
}
.carousel::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.55); }

.carousel::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: linear-gradient(to right, currentColor 0 0) no-repeat #e5e5e5;
  border-radius: 999px;
  background-size: 0% 100%;
}
@supports (scroll-timeline-name: --x) {
  .carousel { scroll-timeline-name: --x; scroll-timeline-axis: horizontal; }
  @keyframes grow { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }
  .carousel::after { animation: grow 1s linear both; animation-timeline: --x; }
}

.project-meta {
  width: 100%;
  margin-top: 0.35rem;
  padding-top: 0.75rem;
  border-top: 1px solid #ccc;
  font-size: 0.95em;
}

article p:has(+ .project-meta) {
  margin-bottom: 0.35rem;
}

h3 + .project-meta,
h4 + .project-meta {
  margin-top: 0.25rem;
}

ul.cv { list-style: none; padding: 0; margin: 0; }
ul.cv li { display: flex; gap: 1.2rem; margin-bottom: 1.1rem; }
ul.cv .year {
  width: 4.5rem;
  font-weight: 600;
  flex-shrink: 0;
}
ul.cv .sub {
  display: block;
  margin-top: 0.15rem;
  color: #666;
  font-size: 0.9em;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
