* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  overflow-wrap: break-word;
}

:root {
  &[data-color-mode="light"] {
    --bg: lab(100% 0 0);
    --bg-subtle: #f9f9f9;
    --bg-pattern-color: #eef0f3;
    --subtle: #525252;
    --text: #212121;
    --border-color: #a7a5a5;
    --highlight: #d64933;
    --copied: #027769;
    --footer-bg: #cecdcd;
    --moon-display: none;
    --sun-display: block;
    --cursor-external-link: url("/static/images/cursors/light-mode/external-link.svg")
        10 10,
      pointer;
    --design-gradient: repeating-linear-gradient(
      90deg,
      #6366f1,
      #f59e0b,
      #ec4899,
      #6366f1
    );
    --logo-svg-filter: invert(30%);
    --logo-svg-filter-hover: invert(0%);
  }

  &[data-color-mode="dark"] {
    --bg: lab(2.51107% 0.242703 -0.886115);
    --bg-subtle: #111111;
    --bg-pattern-color: #1e1e1e;
    --subtle: #888888;
    --text: #ededed;
    --border-color: #474748;
    --highlight: #318ce7;
    --copied: #00a693;
    --footer-bg: #1e1c1c;
    --moon-display: block;
    --sun-display: none;
    --cursor-external-link: url("/static/images/cursors/dark-mode/external-link.svg")
        10 10,
      pointer;
    --design-gradient: repeating-linear-gradient(
      90deg,
      #b3acf2,
      #f2c2b3,
      #f2b3c2,
      #b3acf2
    );
    --logo-svg-filter: invert(70%);
    --logo-svg-filter-hover: invert(100%);
  }
}

html {
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-arabic: "Vazirmatn", Tahoma, sans-serif;
  --font-size: 1rem;
  --font-size-s: 0.8rem;
  --font-size-xxs: 0.7rem;
  --font-size-l: 1.1rem;
  --font-size-h1: 2.25em;
  --padding: 20px;
  --padding-small: 10px;
  --padding-xs: 5px;
  --padding-xxs: 2.5px;
  --margin: 20px;
  --margin-large: 40px;
  --margin-xl: 50px;
  --margin-small: 10px;
  --margin-xs: 7.5px;
  --border-radius: 0.3rem;
  --border-width: 0.03125rem;
  --body-width-max: 750px;
  font-family: var(--font-sans);
  font-size: var(--font-size);
  line-height: 1.5;
  color: var(--text);
  min-height: 100%;
  position: relative;
  background: var(--bg-subtle);
  letter-spacing: 0.04rem;
  max-width: 100%;
  height: auto;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 1000;
  padding: var(--padding-small) var(--padding);
  background: var(--bg);
  color: var(--text);
  border: var(--border-width) solid var(--border-color);
}

.skip-link:focus {
  top: 0;
}

body {
  height: auto;
  max-width: min(100svw, var(--body-width-max));
  box-sizing: border-box;
  padding: 0 1rem;
  margin: 0 auto;
  overflow-x: clip;
}

a {
  text-decoration: none;
  border-bottom: 1px solid var(--border-color);
  transition: border 0.3s ease-out;
  color: var(--text) !important;

  &[target="_blank"] {
    cursor: var(--cursor-external-link);
  }

  &:hover {
    border-bottom: 1px solid var(--text);
  }
}

a .svg-icon {
  filter: var(--logo-svg-filter);

  &:hover {
    filter: var(--logo-svg-filter-hover);
  }
}

s {
  text-decoration-color: var(--highlight);
}

mark {
  background-color: color-mix(in srgb, var(--highlight) 50%, transparent);
  padding: 0 var(--padding-xxs);
}

aside.aside-container {
  position: absolute;
  width: 10rem;
  left: calc(100% + var(--margin-small));
  top: 0;
  z-index: 1000;
  padding: var(--padding-small);
  background-color: var(--bg);
  border: var(--border-width) solid var(--border-color);
  padding: var(--padding-small);
}

::selection {
  background-color: color-mix(in srgb, var(--highlight) 40%, transparent);
  color: var(--text);
}

::-moz-selection {
  background-color: yellow;
  color: black;
}

.go-back-button {
  color: var(--subtle) !important;
  border: none !important;
  transition: color 0.3s ease-out;

  &:hover {
    color: var(--text) !important;
  }
}

@keyframes designTextAnimation {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 100%;
  }

  100% {
    background-position: 0% 50%;
  }
}

html[lang="fa"],
html[dir="rtl"] {
  font-family: var(--font-arabic);
  line-height: 1.75;
}

.design-text {
  position: relative;
  font-family: inherit;
  font-weight: 500;
  font-style: normal;
  border: none;
  cursor: none;

  &:hover {
    background-clip: text;
    background-image: var(--design-gradient);
    background-size: 50%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: designTextAnimation 4s linear infinite;
    border: none;
  }
}

p {
  line-height: 1.75;
  margin: 1em 0;

  img {
    max-width: 100%;
  }

  &:has(> img) {
    display: flex;
    width: 100%;
    justify-content: center;
  }
}

h1 {
  margin: 1em 0 2em 0;
}

h2,
h3,
h4 {
  margin: 1.2em 0;
}

ul li {
  margin-left: 1.2em;
}

hr {
  width: 100%;
  background-color: var(--highlight);
  border-color: var(--highlight);
}

mjx-container {
  padding: var(--padding) 0;
  height: min-content;
  overflow-x: scroll;
}

blockquote {
  font-size: 1.4em;
  margin: 2em auto;
  font-style: italic;
  padding: 1.2em 30px 1.2em 2.2em;
  border-left: 0.2em solid var(--highlight);
  line-height: 1.6;
  position: relative;

  &::before {
    content: "\201C";
    color: var(--highlight);
    font-size: 4em;
    position: absolute;
    left: 10px;
    top: -10px;
  }
}

.parent-container {
  min-height: auto;
  width: 100%;
  overflow-x: visible;
  border-left: var(--border-width) solid var(--border-color);
  border-right: var(--border-width) solid var(--border-color);
  position: relative;
}

main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: auto;
  overflow-x: visible;
  padding: 0 var(--margin);
  background-color: var(--bg);

  & > div {
    width: 100%;
  }
}

.theme-button--moon {
  display: var(--moon-display);
}

.theme-button--sun {
  display: var(--sun-display);
}

#logo-box {
  height: 100%;
  aspect-ratio: 1;
  padding: var(--padding-small) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: var(--margin-small);
  border: none;
  overflow: clip;
  border-radius: 50%;

  &:active {
    background-color: color-mix(in srgb, var(--highlight) 15%, transparent);
    transition: all 0s;
    transform: scale(0.95);
  }

  > img {
    width: 100%;
    height: 100%;
  }
}

.title {
  margin-top: var(--margin-xl);
  margin-bottom: var(--margin-xs);
  font-weight: 500;
  font-size: var(--font-size-h1);
  line-height: 1.1111111;
}

.category-info {
  margin: 0;
  color: var(--subtle);
}

.about-me-text,
.about-me-text a {
  margin: 0;
  font-size: var(--font-size);
  margin-top: var(--margin);
  color: var(--subtle) !important;
}

.about-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--padding-small);
  border-top: var(--border-width) dashed var(--border-color);
  border-bottom: var(--border-width) dashed var(--border-color);
  background-color: var(--bg-subtle);
  padding: var(--padding-small) 1rem;
  margin: 0 calc(var(--margin) * -1);
  margin-top: var(--margin-large);
}

.about-tag {
  font-size: var(--font-size-s);
  background-color: var(--bg);
  padding: var(--padding-xxs) var(--padding-small);
  border: var(--border-width) dotted var(--border-color);

  &:first-child,
  &.about-tag--role {
    border: var(--border-width) dotted var(--highlight);
    background-color: color-mix(in srgb, var(--highlight) 10%, transparent);
    color: var(--highlight);
  }
}

a.about-tag {
  border-bottom: var(--border-width) dotted var(--highlight) !important;
  transition: background-color 0.2s ease, color 0.2s ease;

  &:hover {
    background-color: color-mix(in srgb, var(--highlight) 18%, transparent);
    border-bottom: var(--border-width) dotted var(--highlight) !important;
    color: var(--highlight) !important;
  }
}

.section-projects {
  display: flex;
  overflow-x: scroll;
  -ms-overflow-style: none;
  scrollbar-width: none;
  gap: var(--margin);
  border-top: var(--border-width) dashed var(--border-color);
  border-bottom: var(--border-width) dashed var(--border-color);
  background-color: var(--bg-subtle);
  box-sizing: content-box;
  margin: 0 calc(var(--margin) * -1);

  &::-webkit-scrollbar {
    display: none;
  }
}

.section-header {
  margin-bottom: var(--margin-large);
}

.projects-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;

  .category-info {
    margin-bottom: 0;
  }
}

.card {
  border: var(--border-width) dashed var(--border-color);
  background-color: var(--bg);

  &:hover {
    background-color: rgba(243, 243, 243, 0.01);
  }
}

.project-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 21em;
  width: 13.5em;
  min-width: 13.5em;
  padding: var(--padding);
  scroll-snap-align: center;
  position: relative;
  overflow: clip;
  border-top: none;
  border-bottom: none;

  .title {
    font-size: var(--font-size-l);
    margin: 0;
  }

  .brief {
    margin-top: var(--margin-small);
    color: var(--subtle);
    font-size: 0.8rem;
  }

  img {
    position: absolute;
    bottom: -10%;
    left: var(--margin);
    height: 50%;
    width: auto;
    filter: drop-shadow(0 0 0.05rem var(--subtle));
    transition: bottom 0.3s ease-out, left 0.3s ease-out;
  }

  &:hover img {
    position: absolute;
    bottom: 0;
    left: 0;
  }

  &:last-child {
    margin-right: var(--margin);
  }

  &:first-child {
    margin-left: 1rem;
  }
}

nav {
  display: flex;
  align-items: center;
  width: fit-content;
  height: 100%;
}

.nav-icon {
  text-decoration: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background-color: transparent;
  margin: 2px;
  transition: all 0.2s ease, background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  padding: var(--padding-small);
  text-decoration: none !important;
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  color: inherit;
  font: inherit;

  > img {
    width: 1.25em;
    aspect-ratio: 1;
  }

  &:active {
    background-color: color-mix(in srgb, var(--highlight) 15%, transparent);
    transition: all 0s;
    transform: scale(0.95) !important;
  }

  &:hover {
    border: none;
  }
}

.parent-container > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 45px;
  width: 100%;
  margin: 1rem 0 0;
  border-top: var(--border-width) solid var(--border-color);
  border-bottom: var(--border-width) solid var(--border-color);
  background-color: var(--bg);
  position: sticky;
  top: -1px;
  z-index: 100;
  background-color: var(--bg);

  &.is-stuck {
    box-shadow: 1px 18px 30px -5px var(--bg);
    background-color: color-mix(
      in srgb,
      var(--bg-subtle) 55%,
      transparent
    ) !important;
    backdrop-filter: blur(8px) !important;
  }
}

footer {
  margin-top: -3em;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
  width: fit-content;
  padding: var(--padding);
  border-radius: var(--border-radius);
  height: 40px;
  background-color: color-mix(in srgb, var(--bg-subtle) 80%, transparent);
  backdrop-filter: blur(8px);
  overflow-y: visible;
  margin-bottom: var(--margin-small);

  * {
    color: var(--subtle);
  }

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

.writings-card {
  width: inherit;
  height: fit-content;
  margin: var(--margin) 0;
  padding: 0 0.5rem;
  border-left: none;
  border-right: none;
  position: relative;

  .date {
    position: absolute;
    top: -1rem;
    right: 0;
    color: var(--subtle);
    font-size: var(--font-size-s);
    margin: auto 0;
    padding: var(--padding-xs) var(--padding-small);
  }
}

.section-about .side-tag {
  position: absolute;
  left: -3.4rem;
  top: -6rem;
  font-size: var(--font-size-xxs);
  color: var(--highlight);
  writing-mode: sideways-lr;
  transform: translate(50%);
  letter-spacing: 0.08em;
}

.section-books,
.section-os,
.section-writings {
  border-top: var(--border-width) dashed var(--border-color);
  border-bottom: var(--border-width) dashed var(--border-color);
  background-color: var(--bg-subtle);
  margin: 0 calc(var(--margin) * -1);
}

.book-card,
.os-card {
  display: flex;
  flex-direction: column;
  position: relative;
  width: auto;
  height: fit-content;
  margin: var(--margin) 0;
  padding: 0 0.5rem;
  border-left: none;
  border-right: none;
}

a.book-card.card:hover,
a.os-card.card:hover {
  border-bottom: var(--border-width) dashed var(--border-color);
}

.languages {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: var(--padding-small);
  padding-top: var(--padding-xs);
}

.tags {
  font-size: var(--font-size-xxs);
  color: var(--highlight);
  background-color: color-mix(in srgb, var(--highlight) 10%, transparent);
  padding: var(--padding-xxs) var(--padding-small);
  border: var(--border-width) dotted var(--highlight);
  width: fit-content;
}

.description {
  margin: var(--margin-small);
  color: var(--text);
  font-weight: 500;
}

.contact-parent {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 80dvh;
  gap: 1rem;
  text-align: center;
  flex-wrap: wrap-reverse;

  .brief {
    color: var(--subtle);
  }

  .email {
    font-size: 2.5rem;
    word-break: break-word;
  }

  .social {
    display: flex;
    gap: var(--padding);
  }

  .social > p {
    font-size: var(--font-size-s);
    background-color: var(--border-color);
    padding: var(--padding-xs) var(--padding);
    border-radius: var(--border-radius);
  }
}

#copy-email-control {
  position: relative;
  min-width: 5.3rem;

  &::before {
    content: "";
    position: absolute;
    display: block;
    width: 20px;
    top: -100%;
    aspect-ratio: 1;
    background-image: url(/static/images/curly-arrow.png);
    background-size: contain;
    background-repeat: no-repeat;
    transform: rotate(180deg);
  }
}

.section-divider-top-container {
  max-width: 750px;

  min-width: 280px;
  margin: 0 auto;
  background-color: var(--bg);

  > .section-divider {
    margin: 0;
    width: 100%;
  }
}

.section-divider {
  --mask-image: linear-gradient(to top, transparent 0%, var(--bg) 150%);

  width: calc(100% + var(--margin) * 2);
  height: 3rem;
  background-color: var(--bg-subtle);
  background-size: 0.6rem 0.6rem;
  background-image: repeating-linear-gradient(
    45deg,
    var(--border-color) 0,
    var(--border-color) var(--border-width),
    var(--bg) 0,
    var(--bg) 50%
  );
  -webkit-mask-image: var(--mask-image);
  mask-image: var(--mask-image);
  margin: 0 calc(var(--margin) * -1);
}

#section-divider-footer {
  width: 100%;
  margin: 0 auto;
  margin-bottom: 0;
}

@media print {
  .no-print {
    display: none !important;
  }
}

@media only screen and (max-width: 800px) {
  #side-tag {
    display: none;
  }
}

@keyframes slide-enter {
  0% {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 100;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html:not(.no-sliding) [slide-enter],
  html:not(.no-sliding) .slide-enter,
  html:not(.no-sliding)
    .slide-enter-content
    > *:not(:has(.table-of-contents)):not(#side-tag) {
    --enter-stage: 0;
    --enter-step: 90ms;
    --enter-initial: 0ms;
    animation: slide-enter 1s both 1;
    animation-delay: calc(
      var(--enter-initial) + var(--enter-stage) * var(--enter-step)
    );
  }

  .slide-enter-content {
    > *:nth-child(1) {
      --enter-stage: 1 !important;
    }

    > *:nth-child(2) {
      --enter-stage: 2 !important;
    }

    > *:nth-child(3) {
      --enter-stage: 3 !important;
    }

    > *:nth-child(4) {
      --enter-stage: 4 !important;
    }

    > *:nth-child(5) {
      --enter-stage: 5 !important;
    }

    > *:nth-child(6) {
      --enter-stage: 6 !important;
    }

    > *:nth-child(7) {
      --enter-stage: 7 !important;
    }

    > *:nth-child(8) {
      --enter-stage: 8 !important;
    }

    > *:nth-child(9) {
      --enter-stage: 9 !important;
    }

    > *:nth-child(10) {
      --enter-stage: 10 !important;
    }

    > *:nth-child(11) {
      --enter-stage: 11 !important;
    }

    > *:nth-child(12) {
      --enter-stage: 12 !important;
    }

    > *:nth-child(13) {
      --enter-stage: 13 !important;
    }

    > *:nth-child(14) {
      --enter-stage: 14 !important;
    }

    > *:nth-child(15) {
      --enter-stage: 15 !important;
    }

    > *:nth-child(16) {
      --enter-stage: 16 !important;
    }

    > *:nth-child(17) {
      --enter-stage: 17 !important;
    }

    > *:nth-child(18) {
      --enter-stage: 18 !important;
    }

    > *:nth-child(19) {
      --enter-stage: 19 !important;
    }

    > *:nth-child(20) {
      --enter-stage: 20 !important;
    }
  }
}

/* Tooltip styling */
[data-tooltip] {
  --arrow-size: 5px;
  position: relative;
  z-index: 10;

  /* Positioning and visibility settings of the tooltip */
  &:before,
  &:after {
    position: absolute;
    visibility: hidden;
    opacity: 0;
    left: 50%;
    bottom: calc(100% + var(--arrow-size));
    pointer-events: none;
    transition: 0.2s;
    will-change: transform;
  }

  /* The actual tooltip with a dynamic width */
  &:before {
    content: attr(data-tooltip);
    padding: 5px 10px;
    min-width: 50px;
    max-width: 300px;
    width: max-content;
    width: -moz-max-content;
    border-radius: var(--border-radius);
    font-size: 14px;
    background-color: rgba(59, 72, 80, 0.9);
    background-image: linear-gradient(
      30deg,
      rgba(59, 72, 80, 0.44),
      rgba(59, 68, 75, 0.44),
      rgba(60, 82, 88, 0.44)
    );
    box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.2);
    color: #fff;
    text-align: center;
    white-space: pre-wrap;
    transform: translate(-50%, calc(0px - var(--arrow-size))) scale(0.5);
  }

  /* Tooltip arrow */
  &:after {
    content: "";
    border-style: solid;
    border-width: var(--arrow-size) var(--arrow-size) 0px var(--arrow-size);
    /* CSS triangle */
    border-color: rgba(55, 64, 70, 0.9) transparent transparent transparent;
    transition-duration: 0s;
    /* If the mouse leaves the element, 
                                the transition effects for the 
                                tooltip arrow are "turned off" */
    transform-origin: top;
    /* Orientation setting for the
                                slide-down effect */
    transform: translateX(-50%) scaleY(0);
  }

  /* Tooltip becomes visible at hover */
  &:hover:before,
  &:hover:after {
    visibility: visible;
    opacity: 1;
  }

  /* Scales from 0.5 to 1 -> grow effect */
  &:hover:before {
    transition-delay: 0.3s;
    transform: translate(-50%, calc(0px - var(--arrow-size))) scale(1);
  }

  /* 
    Arrow slide down effect only on mouseenter (NOT on mouseleave)
  */
  &:hover:after {
    transition-delay: 0.5s;
    /* Starting after the grow effect */
    transition-duration: 0.2s;
    transform: translateX(-50%) scaleY(1);
  }
}

/*
    That's it for the basic tooltip.
    If you want some adjustability
    here are some orientation settings you can use:
  */

[data-tooltip-location="left"] {
  /* Tooltip + arrow */
  &:before,
  &:after {
    left: auto;
    right: calc(100% + var(--arrow-size));
    bottom: 50%;
  }

  /* Tooltip */
  &:before {
    transform: translate(calc(0px - var(--arrow-size)), 50%) scale(0.5);
  }

  &:hover:before {
    transform: translate(calc(0px - var(--arrow-size)), 50%) scale(1);
  }

  /* Arrow */
  &:after {
    border-width: var(--arrow-size) 0px var(--arrow-size) var(--arrow-size);
    border-color: transparent transparent transparent rgba(55, 64, 70, 0.9);
    transform-origin: left;
    transform: translateY(50%) scaleX(0);
  }

  &:hover:after {
    transform: translateY(50%) scaleX(1);
  }
}

[data-tooltip-location="right"] {
  &:before,
  &:after {
    left: calc(100% + var(--arrow-size));
    bottom: 50%;
  }

  &:before {
    transform: translate(var(--arrow-size), 50%) scale(0.5);
  }

  &:hover:before {
    transform: translate(var(--arrow-size), 50%) scale(1);
  }

  &:after {
    border-width: var(--arrow-size) var(--arrow-size) var(--arrow-size) 0px;
    border-color: transparent rgba(55, 64, 70, 0.9) transparent transparent;
    transform-origin: right;
    transform: translateY(50%) scaleX(0);
  }

  &:hover:after {
    transform: translateY(50%) scaleX(1);
  }
}

[data-tooltip-location="bottom"] {
  &:before,
  &:after {
    top: calc(100% + var(--arrow-size));
    bottom: auto;
  }

  &:before {
    transform: translate(-50%, var(--arrow-size)) scale(0.5);
  }

  &:hover:before {
    transform: translate(-50%, var(--arrow-size)) scale(1);
  }

  &:after {
    border-width: 0px var(--arrow-size) var(--arrow-size) var(--arrow-size);
    border-color: transparent transparent rgba(55, 64, 70, 0.9) transparent;
    transform-origin: bottom;
  }
}

/* View Transition */

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 9999;
}

:root[data-color-mode="dark"]::view-transition-old(root) {
  z-index: 9999;
}

:root[data-color-mode="dark"]::view-transition-new(root) {
  z-index: 1;
}

/* --- komeil.me polish ----------------------------------------------- */

html {
  letter-spacing: 0.015em;
}

html[lang="fa"],
html[dir="rtl"] {
  letter-spacing: 0;
}

body {
  padding: 0 1.25rem;
}

.parent-container > header {
  margin-top: 0.75rem;
}

main {
  padding-bottom: var(--margin);
}

#logo-box > img {
  width: 1.5rem;
  height: 1.5rem;
}

.nav-lang-code {
  font-family: var(--font-sans);
  font-size: var(--font-size-s);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
}

html[lang="fa"] .nav-lang-code,
html[dir="rtl"] .nav-lang-code {
  font-family: var(--font-arabic);
}

/* Home — tighter vertical rhythm */
.section-about .title {
  margin-top: 2.25rem;
  margin-bottom: 0.5rem;
}

.about-me-text {
  margin-top: 0.65rem !important;
  max-width: 38ch;
  line-height: 1.7;
}

.about-tags-container {
  margin-top: 1.35rem;
  padding: 0.85rem 1rem;
  gap: 0.65rem;
}

.section-header {
  margin-top: 0.35rem;
  margin-bottom: 1.1rem;
}

.section-header .title,
.projects-header .title {
  margin-top: 1.75rem;
  margin-bottom: 0.4rem;
}

.category-info {
  max-width: 50ch;
  line-height: 1.6;
  margin-top: 0.15rem;
}

.section-divider {
  height: 2.25rem;
}

.section-projects {
  gap: 0.85rem;
  padding: 0.65rem 0;
}

.project-card {
  padding: 0.9rem;
}

.project-card .brief {
  line-height: 1.55;
}

.writings-card,
.book-card,
.os-card {
  margin: 0.85rem 0;
  padding: 0.35rem 0.75rem;
}

.section-writings ul {
  padding: 0.25rem 0 0.65rem;
}

.section-books,
.section-os {
  padding-bottom: 0.35rem;
}

.book-card .description,
.os-card .description,
.writings-card .description {
  margin: 0.55rem 0.5rem;
  line-height: 1.55;
}

.languages {
  gap: 0.65rem;
  padding: 0.35rem 0.5rem 0.5rem;
}

footer {
  margin-bottom: 1.1rem;
}

/* Bilingual layout */
html[dir="rtl"] .writings-card .date {
  right: auto;
  left: 0;
}

html[dir="rtl"] .section-about .side-tag {
  left: auto;
  right: -3.4rem;
  writing-mode: sideways-rl;
}

html[dir="rtl"] .about-tags-container,
html[dir="rtl"] .section-projects,
html[dir="rtl"] .section-books,
html[dir="rtl"] .section-os,
html[dir="rtl"] .section-writings {
  direction: rtl;
}

html[dir="rtl"] .project-card:first-child {
  margin-left: 0;
  margin-right: 1rem;
}

html[dir="rtl"] .project-card:last-child {
  margin-right: 0;
  margin-left: var(--margin);
}

@media only screen and (max-width: 600px) {
  body {
    padding: 0 0.85rem;
  }

  .section-about .title {
    margin-top: 1.5rem;
  }

  .section-header .title,
  .projects-header .title {
    margin-top: 1.25rem;
  }

  main {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .section-projects {
    flex-direction: column;
    overflow-x: visible;
    gap: var(--margin-small);
  }

  .project-card,
  html[dir="rtl"] .project-card:first-child,
  html[dir="rtl"] .project-card:last-child {
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin-left: 0;
    margin-right: 0;
    border-top: var(--border-width) dashed var(--border-color);
    border-bottom: var(--border-width) dashed var(--border-color);
  }

  .project-card img,
  .project-card:hover img {
    position: static;
    width: 100%;
    height: auto;
    max-height: 11rem;
    object-fit: contain;
    margin-top: var(--margin-small);
  }
}

/* Gleam/Lustre runtime islands */

.page-header {
  position: static;
  z-index: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem 1rem;
  align-items: baseline;
  width: 100%;
  height: auto;
  margin: 2.5rem 0 1.5rem;
  padding: 0 0 1rem;
  border-top: 0;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
}

.page-header__index {
  grid-row: 1 / span 2;
  align-self: start;
  margin: 0.4rem 0 0;
  color: var(--highlight);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--font-size-s);
}

.page-header__title {
  margin: 0;
  font-size: var(--font-size-h1);
  line-height: 1.15;
}

.page-header__lead {
  grid-column: 2;
  margin: 0;
  max-width: 58ch;
  color: var(--subtle);
}

#theme-control {
  display: flex;
  height: 100%;
}

#theme-control > .nav-icon,
#theme-control > button {
  height: 100%;
}

.copy-email {
  appearance: none;
  color: var(--text);
  font: inherit;
  min-width: 8rem;
  cursor: pointer;
}

.copy-email[data-state="copied"] {
  color: var(--copied);
  border-color: var(--copied);
}

.copy-email[data-state="failed"] {
  color: var(--highlight);
  border-color: var(--highlight);
}

.contact-parent {
  padding: 3rem 0;
  min-height: auto;
}

#contact-control {
  width: min(100%, 34rem);
  margin-top: 1rem;
  text-align: start;
}

.contact-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.25rem;
  border: var(--border-width) solid var(--border-color);
  border-radius: calc(var(--border-radius) * 2);
  background: color-mix(in srgb, var(--bg-subtle) 82%, transparent);
}

.contact-form__field {
  display: grid;
  gap: 0.4rem;
  color: var(--subtle);
  font-size: var(--font-size-s);
}

.contact-form__field:has(textarea),
.contact-form__submit,
.contact-form__status {
  grid-column: 1 / -1;
}

.contact-form input,
.contact-form textarea,
.search__input {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 0.75rem 0.85rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.contact-form input:focus,
.contact-form textarea:focus,
.search__input:focus {
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--highlight) 18%, transparent);
}

.contact-form textarea {
  resize: vertical;
  min-height: 9rem;
}

.contact-form__honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.contact-form__submit {
  appearance: none;
  border: 1px solid var(--highlight);
  border-radius: var(--border-radius);
  background: color-mix(in srgb, var(--highlight) 14%, var(--bg));
  color: var(--text);
  font: inherit;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.contact-form__submit:hover {
  background: color-mix(in srgb, var(--highlight) 24%, var(--bg));
}

.contact-form__submit:active {
  transform: scale(0.985);
}

.contact-form__submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

.contact-form__status {
  min-height: 1.5rem;
  margin: 0;
  color: var(--subtle);
}

.contact-form__status[data-state="ok"] {
  color: var(--copied);
}

.contact-form__status[data-state="error"] {
  color: var(--highlight);
}

.search {
  margin: 1.5rem 0 2rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--border-radius) * 2);
  background: var(--bg-subtle);
}

.search__heading {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.search__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.search__results {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
  list-style: none;
}

.search__result {
  margin: 0;
  padding: 0.65rem 0;
  border-top: 1px dashed var(--border-color);
}

.search__result p {
  margin: 0.25rem 0 0;
  color: var(--subtle);
  font-size: var(--font-size-s);
}

.system-monitor {
  margin: 2.5rem 0;
}

.system-monitor__eyebrow {
  color: var(--highlight);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--font-size-xxs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

lustre-server-component {
  display: block;
  min-height: 15rem;
}

.system-monitor__fallback {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--border-radius) * 2);
  background:
    radial-gradient(
      circle at 100% 0,
      color-mix(in srgb, var(--highlight) 12%, transparent),
      transparent 42%
    ),
    var(--bg-subtle);
}

.system-monitor__fallback {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 8rem;
}

.system-monitor__fallback p {
  margin: 0;
}

.system-monitor__pulse {
  width: 0.65rem;
  height: 0.65rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--copied);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--copied) 55%, transparent);
  animation: beam-pulse 1.8s infinite;
}

@keyframes beam-pulse {
  70% {
    box-shadow: 0 0 0 0.55rem transparent;
  }
}

footer {
  margin-top: 1.5rem;
}

.section-projects {
  scroll-snap-type: x mandatory;
  overscroll-behavior-inline: contain;
}

.project-card {
  scroll-snap-align: start;
}

@media only screen and (max-width: 600px) {
  .contact-form {
    grid-template-columns: 1fr;
  }

  .contact-form__field,
  .contact-form__submit,
  .contact-form__status {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .system-monitor__pulse {
    animation: none;
  }
}
