/* ==========================================================================
   Abdullah Ewidah — Portfolio styles
   Sections: tokens, base, layout, header, hero, about, projects, contact,
   footer. Each component keeps its own responsive rules next to it.
   ========================================================================== */

/* ---------- Design tokens ---------- */

:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #eef2ed;
  --ink: #192b27;
  --muted: #55635e;
  --line: #d8dfd8;
  --line-strong: #b4c3b9;
  --accent: #0e7659;
  --accent-strong: #075840;
  --accent-soft: #e1efe8;
  --on-accent: #ffffff;
  --visual: #dcece3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --header-bg: rgba(245, 246, 243, 0.86);
  --shadow-sm: 0 1px 2px rgba(25, 43, 39, 0.06);
  --shadow: 0 18px 50px rgba(25, 43, 39, 0.07);
  --shadow-lg: 0 24px 60px rgba(25, 43, 39, 0.14);

  /* The contact band stays dark in both themes, so it has its own palette. */
  --contact-bg: #192b27;
  --contact-ink: #eff7f1;
  --contact-muted: #b7cac0;
  --contact-accent: #94ddb4;
  --contact-field: #22382f;
  --contact-line: #56736a;
  --contact-error: #ffb4a8;

  --radius: 0.75rem;
  --radius-sm: 0.45rem;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --header-height: 4.7rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101b19;
  --surface: #172523;
  --surface-2: #1d2d2a;
  --ink: #eff7f1;
  --muted: #a9bdb3;
  --line: #2c3d39;
  --line-strong: #45594f;
  --accent: #8ee0b1;
  --accent-strong: #b0eccb;
  --accent-soft: #1d3a2f;
  --on-accent: #0d1a16;
  --visual: #1c3b31;
  --danger: #ff9b8f;
  --danger-soft: #3a1f1c;
  --header-bg: rgba(16, 27, 25, 0.86);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.4);

  --contact-bg: #0b1513;
  --contact-field: #15231f;
  --contact-line: #3d554c;
}

/* ---------- Base ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

img,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.12;
  letter-spacing: -0.045em;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

/* Elements focused by script (like the heading after "Back to top") need no ring for mouse users. */
[tabindex="-1"]:focus:not(:focus-visible) {
  outline: none;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 50;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
}

.skip-link:focus {
  top: 1rem;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Layout ---------- */

.container {
  width: min(1120px, calc(100% - 3rem));
  margin-inline: auto;
}

.section {
  padding: 6.5rem 0;
}

.section-number,
.eyebrow,
.project-type {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.section-number {
  margin-bottom: 1.15rem;
}

h2 {
  max-width: 620px;
  margin-bottom: 0;
  font-size: clamp(2.3rem, 4vw, 3.55rem);
}

.split-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  margin-bottom: 2.4rem;
}

.split-heading > p {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.3rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.91rem;
  font-weight: 750;
  line-height: 1.3;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease), box-shadow 0.2s ease;
}

.button-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.button-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.text-link {
  font-size: 0.92rem;
  font-weight: 750;
  transition: color 0.2s ease;
}

.text-link:hover {
  color: var(--accent);
}

@media (max-width: 900px) {
  .section {
    padding: 5rem 0;
  }
}

@media (max-width: 680px) {
  .container {
    width: min(1120px, calc(100% - 2rem));
  }

  .section {
    padding: 4.5rem 0;
  }

  .split-heading {
    display: block;
  }

  .split-heading > p {
    margin-top: 1rem;
  }
}

/* ---------- Header and navigation ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  transition: box-shadow 0.25s ease, background-color 0.3s ease;
}

.nav-wrap {
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: var(--header-height);
}

.brand {
  font-size: 1.55rem;
  font-weight: 850;
  letter-spacing: -0.08em;
  line-height: 1;
}

.brand-dot {
  color: var(--accent);
}

.site-nav {
  margin-left: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-links a {
  position: relative;
  display: block;
  padding: 0.45rem 0.8rem;
  border-radius: 100px;
  color: var(--muted);
  font-size: 0.91rem;
  font-weight: 650;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-links a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-links a[aria-current="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.3s var(--ease);
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Show the icon for the theme the button switches to. */
.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

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

.theme-toggle:active {
  transform: rotate(25deg) scale(0.92);
}

.menu-toggle {
  display: none;
}

.menu-line {
  transition: transform 0.3s var(--ease);
  transform-origin: 12px 12px;
}

.menu-toggle[aria-expanded="true"] .menu-line-top {
  transform: translateY(5px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-line-bottom {
  transform: translateY(-5px) rotate(-45deg);
}

@media (max-width: 680px) {
  :root {
    --header-height: 4.2rem;
  }

  .nav-wrap {
    gap: 0.8rem;
  }

  .nav-links {
    gap: 0;
  }

  .nav-links a {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
  }

  .icon-button {
    width: 2.25rem;
    height: 2.25rem;
  }

  /* With JavaScript, the links collapse into a menu panel. */
  .js .menu-toggle {
    display: grid;
  }

  .js .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.5rem 1rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: opacity 0.2s ease, transform 0.25s var(--ease), visibility 0s linear 0.25s;
  }

  .js .site-nav.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.2s ease, transform 0.25s var(--ease), visibility 0s;
  }

  .js .site-nav .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
  }

  .js .site-nav .nav-links a {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
  }

  .js .header-actions {
    margin-left: auto;
  }
}

/* ---------- Hero ---------- */

.hero {
  padding-top: 7rem;
  padding-bottom: 7rem;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
  align-items: center;
  gap: 4rem;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0 0 1.45rem;
}

#greeting::after {
  content: "·";
  margin-left: 0.65rem;
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

h1 {
  max-width: 680px;
  margin-bottom: 1.55rem;
  font-size: clamp(3.4rem, 6vw, 5.65rem);
}

h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero-intro {
  max-width: 550px;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 1.18rem;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.75rem;
}

.local-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 2.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.local-time .icon {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--accent);
}

.local-time time {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hero-visual {
  position: relative;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 1;
  margin: auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: radial-gradient(circle at 45% 42%, var(--surface) 0 18%, var(--visual) 19% 100%);
}

.orbit {
  position: absolute;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0.4;
}

.orbit-one {
  inset: 12%;
  transform: rotate(-24deg) scaleX(1.13);
}

.orbit-two {
  inset: 22%;
  transform: rotate(33deg) scaleX(1.4);
}

.visual-core {
  position: absolute;
  inset: 31%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.visual-core span {
  font-size: clamp(2.7rem, 5vw, 4rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.08em;
}

.visual-core small {
  margin-top: 0.6rem;
  font-size: 0.48rem;
  letter-spacing: 0.09em;
  white-space: nowrap;
}

.floating-label {
  position: absolute;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--surface);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  box-shadow: var(--shadow);
}

.label-one {
  left: -4%;
  top: 26%;
}

.label-two {
  right: -3%;
  top: 31%;
}

.label-three {
  right: 9%;
  bottom: 12%;
}

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr 0.75fr;
    gap: 2rem;
  }
}

@media (max-width: 680px) {
  .hero {
    padding-top: 4.5rem;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  h1 {
    font-size: clamp(2.7rem, 11vw, 4.5rem);
  }

  .hero-intro {
    font-size: 1.05rem;
  }

  .hero-actions {
    gap: 1.25rem;
  }

  .hero-visual {
    max-width: 320px;
  }
}

@media (max-width: 380px) {
  .floating-label {
    font-size: 0.53rem;
  }
}

/* ---------- About ---------- */

.about-section {
  background: var(--surface);
  border-block: 1px solid var(--line);
}

.two-column {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 6rem;
}

.lead {
  margin-bottom: 1.8rem;
  color: var(--muted);
  font-size: 1.14rem;
}

.pill-list,
.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.pill-list li,
.project-tags li {
  display: inline-flex;
  padding: 0.4rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--bg);
  font-size: 0.78rem;
  font-weight: 650;
}

.about-note {
  margin: 1.8rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
}

/* Tabs: an accessible tablist with a sliding indicator behind the active tab. */
.tab-list {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  margin-bottom: 1.75rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--bg);
}

.tab {
  position: relative;
  z-index: 1;
  padding: 0.5rem 1.15rem;
  border: 0;
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"] {
  color: var(--on-accent);
}

.tab:focus-visible {
  outline-offset: 2px;
}

.tab-indicator {
  position: absolute;
  top: 0.3rem;
  bottom: 0.3rem;
  left: 0;
  width: 0;
  border-radius: 100px;
  background: var(--accent);
}

.tab-indicator.is-ready {
  transition: transform 0.35s var(--ease), width 0.35s var(--ease);
}

.tab-panel:focus-visible {
  outline-offset: 8px;
  border-radius: var(--radius-sm);
}

.tab-panel + .tab-panel {
  margin-top: 2.5rem;
}

.js .tab-panel + .tab-panel {
  margin-top: 0;
}

.panel-title {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

/* With tabs available, the tab names already label each panel. */
.js .panel-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tab-panel.is-entering {
  animation: panel-in 0.4s var(--ease) both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.skill-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0;
}

.skill-groups > div {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.skill-groups dt {
  margin-bottom: 0.3rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.skill-groups dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.timeline {
  margin: 0;
  padding: 0 0 0 1.5rem;
  border-left: 2px solid var(--line);
  list-style: none;
}

.timeline li {
  position: relative;
}

.timeline li + li {
  margin-top: 1.6rem;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-1.5rem - 7px);
  top: 0.3rem;
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}

.timeline-date {
  margin-bottom: 0.2rem;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.timeline h4 {
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.timeline p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 900px) {
  .two-column {
    gap: 3rem;
  }

  .skill-groups {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .two-column {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .tab {
    padding: 0.5rem 0.9rem;
  }
}

/* ---------- Projects ---------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 1.5rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-card img {
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  background: var(--visual);
}

:root[data-theme="dark"] .project-card img {
  filter: brightness(0.82) saturate(0.9);
}

.project-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.5rem;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.project-type {
  margin: 0;
  font-size: 0.66rem;
}

.status-badge {
  flex-shrink: 0;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.status-badge.status-active {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.project-body h3 {
  margin-bottom: 0.85rem;
  font-size: 1.5rem;
}

.project-summary {
  margin-bottom: 1.3rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.project-tags li {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
}

.project-note {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 680px) {
  .project-grid {
    grid-template-columns: 1fr;
  }

  .project-body {
    padding: 1.25rem;
  }
}

/* ---------- Project explorer (search, filters, sort, details) ---------- */

.project-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1rem;
  margin-bottom: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-field {
  position: relative;
  flex: 1 1 260px;
}

.search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  height: 2.75rem;
  padding: 0 2.75rem 0 2.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  background: var(--bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-field input:hover {
  border-color: var(--muted);
}

.search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-field input::placeholder {
  color: var(--muted);
}

.search-shortcut {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  display: grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.3rem;
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input:focus ~ .search-shortcut,
.search-field input:not(:placeholder-shown) ~ .search-shortcut {
  display: none;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  background: transparent;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 650;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.chip-count {
  min-width: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.chip[aria-pressed="true"] .chip-count {
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}

.chip-count:empty {
  display: none;
}

.select-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.select-field::after {
  content: "";
  position: absolute;
  right: 0.9rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select-field select {
  height: 2.5rem;
  padding: 0 2.3rem 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.86rem;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.select-field select:hover {
  border-color: var(--accent);
}

.result-count {
  min-height: 1.5rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.result-count strong {
  color: var(--ink);
}

.details-toggle {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.35rem;
  margin-top: 1.1rem;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 750;
}

.details-toggle:hover .details-label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.details-toggle .icon {
  width: 1.1rem;
  height: 1.1rem;
  transition: transform 0.3s var(--ease);
}

.details-toggle[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}

/* Spacing lives on the heading, inside the clipped wrapper, so a collapsed
   panel measures exactly 0px tall. */
.project-details h4 {
  margin: 1rem 0 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.project-details ul {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.project-details li {
  position: relative;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.project-details li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--accent);
}

/* Collapsing works by animating the row height from 0fr to 1fr.
   visibility removes hidden links from the tab order and screen readers. */
.js .project-details {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.35s var(--ease), visibility 0s linear 0.35s;
}

.js .project-details.is-open {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows 0.35s var(--ease), visibility 0s;
}

.js .project-details > .project-details-inner {
  min-height: 0;
  overflow: hidden;
}

.project-card.is-entering {
  animation: card-enter 0.4s var(--ease) both;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1.5rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  animation: card-enter 0.35s var(--ease) both;
}

.empty-icon {
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: 1rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.empty-state h3 {
  margin-bottom: 0.4rem;
  font-size: 1.35rem;
}

.empty-state p {
  max-width: 420px;
  margin-bottom: 1.4rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .select-field {
    margin-left: 0;
  }
}

@media (max-width: 680px) {
  .project-toolbar {
    padding: 0.75rem;
  }

  .search-field {
    flex-basis: 100%;
  }

  .search-shortcut {
    display: none;
  }

  .chip {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }

  .select-field,
  .select-field select {
    width: 100%;
  }

  .select-field select {
    flex: 1;
  }
}

/* ---------- GitHub repositories (public API) ---------- */

.github-section {
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.repo-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.repo-toolbar .select-field {
  margin-left: 0;
}

.repo-toolbar .select-field select {
  background: var(--bg);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 2.6rem;
  height: 1.5rem;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 100px;
  background: var(--line-strong);
  transition: background-color 0.25s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(1.1rem);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.repo-updated {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.2rem;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 750;
}

.text-button:hover span {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:disabled {
  color: var(--muted);
  cursor: progress;
}

.text-button .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.text-button.is-loading .icon {
  animation: spin 0.9s linear infinite;
}

.repo-status:empty {
  display: none;
}

.repo-status {
  margin-bottom: 1.25rem;
}

.loading-message {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line-strong);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.9rem;
  animation: notice-in 0.35s var(--ease) both;
}

.notice p {
  flex: 1 1 320px;
  margin: 0;
}

.notice-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.notice-info {
  border-color: var(--accent);
}

.notice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.notice .button {
  padding: 0.55rem 0.95rem;
  font-size: 0.84rem;
}

@keyframes notice-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.repo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.repo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 11rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.2s ease, transform 0.25s var(--ease), box-shadow 0.25s ease;
  animation: card-enter 0.4s var(--ease) both;
}

.repo-head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.repo-head .icon {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  color: var(--muted);
}

.repo-head h3 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

/* The link covers the whole card, so anywhere on it opens the repository. */
.repo-head a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.repo-head a:focus-visible {
  outline: none;
}

.repo-card:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.repo-badge {
  flex-shrink: 0;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.repo-desc {
  display: -webkit-box;
  margin-bottom: 1rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.repo-desc.is-placeholder {
  font-style: italic;
  opacity: 0.8;
}

.repo-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.repo-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
  font-weight: 650;
}

.lang-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--lang-color, var(--muted));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.repo-more {
  margin-top: 1.25rem;
}

.repo-profile {
  display: inline-block;
  margin-top: 1.5rem;
}

.repo-fallback {
  color: var(--muted);
}

.repo-fallback a {
  color: var(--accent);
  font-weight: 700;
}

/* Skeleton cards hold the layout steady while data loads. */
.repo-card.is-skeleton {
  gap: 0.75rem;
  animation: none;
}

.skeleton-line {
  display: block;
  height: 0.8rem;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-line.is-title {
  width: 55%;
  height: 1.05rem;
}

.skeleton-line.is-short {
  width: 40%;
  margin-top: auto;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }

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

@media (max-width: 900px) {
  .repo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .repo-grid {
    grid-template-columns: 1fr;
  }

  .repo-card {
    min-height: 0;
  }

  .repo-updated {
    flex-basis: 100%;
    order: 5;
    margin-left: 0;
  }
}

/* ---------- Contact ---------- */

.contact-section {
  background: var(--contact-bg);
  color: var(--contact-ink);
  border-top: 1px solid var(--line);
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6rem;
}

.contact-section .section-number {
  color: var(--contact-accent);
}

.contact-copy h2 {
  margin-bottom: 1.1rem;
}

.contact-copy > p:not(.section-number) {
  max-width: 380px;
  color: var(--contact-muted);
}

.contact-section :focus-visible {
  outline-color: var(--contact-accent);
}

.email-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 2.5rem;
}

.contact-email,
.social-link {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: color 0.2s ease;
}

.contact-email {
  padding-bottom: 0.35rem;
  border-bottom: 1px solid currentColor;
  font-weight: 750;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--contact-line);
  border-radius: 100px;
  background: transparent;
  color: var(--contact-ink);
  font-size: 0.78rem;
  font-weight: 700;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.copy-button .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.copy-button:hover {
  border-color: var(--contact-accent);
  color: var(--contact-accent);
}

.copy-button.is-copied {
  border-color: var(--contact-accent);
  background: rgba(148, 221, 180, 0.12);
  color: var(--contact-accent);
}

.social-links {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.social-link {
  color: var(--contact-muted);
  font-size: 0.9rem;
}

.contact-email:hover,
.social-link:hover {
  color: var(--contact-accent);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.86rem;
  font-weight: 700;
}

.optional {
  color: var(--contact-muted);
  font-weight: 500;
}

.contact-form input,
.contact-form select,
.contact-form textarea {
  width: 100%;
  padding: 0.82rem 0.9rem;
  border: 1px solid var(--contact-line);
  border-radius: 0.4rem;
  background: var(--contact-field);
  color: var(--contact-ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.contact-form select {
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--contact-muted) 50%), linear-gradient(135deg, var(--contact-muted) 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 50%, calc(100% - 0.8rem) 50%;
  background-size: 0.35rem 0.35rem;
  background-repeat: no-repeat;
  cursor: pointer;
}

.contact-form input:hover,
.contact-form select:hover,
.contact-form textarea:hover {
  border-color: var(--contact-muted);
}

.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--contact-accent);
  box-shadow: 0 0 0 3px rgba(148, 221, 180, 0.25);
}

.contact-form textarea {
  min-height: 140px;
  resize: vertical;
}

.contact-form ::placeholder {
  color: var(--contact-muted);
  opacity: 0.75;
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--contact-error);
}

.field.has-error input:focus,
.field.has-error textarea:focus {
  box-shadow: 0 0 0 3px rgba(255, 180, 168, 0.25);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0;
  color: var(--contact-error);
  font-size: 0.82rem;
  font-weight: 600;
  animation: notice-in 0.25s var(--ease) both;
}

.field-error::before {
  content: "!";
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  border-radius: 50%;
  background: var(--contact-error);
  color: var(--contact-bg);
  font-size: 0.7rem;
  font-weight: 900;
}

.field-error:empty {
  display: none;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.char-count {
  margin: 0 0 0 auto;
  color: var(--contact-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.char-count.is-near-limit {
  color: #ffd58a;
  font-weight: 700;
}

.contact-form .button-primary {
  align-self: flex-start;
  background: var(--contact-accent);
  color: #12291f;
}

.contact-form .button-primary:hover {
  background: #c1f3d3;
}

.form-help {
  margin: -0.3rem 0 0;
  color: var(--contact-muted);
  font-size: 0.8rem;
}

.draft-notice {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.7rem 1rem;
  border: 1px dashed var(--contact-accent);
  border-radius: var(--radius-sm);
  background: rgba(148, 221, 180, 0.08);
  font-size: 0.85rem;
  animation: notice-in 0.35s var(--ease) both;
}

.draft-notice p {
  margin: 0;
}

.contact-section .text-button {
  color: var(--contact-accent);
}

.form-status:empty {
  display: none;
}

.form-alert {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--contact-line);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  animation: alert-pop 0.4s var(--ease) both;
}

.form-alert.is-error {
  border-color: var(--contact-error);
  background: rgba(255, 180, 168, 0.08);
  animation: alert-pop 0.4s var(--ease) both, shake 0.4s ease 0.1s;
}

.form-alert.is-success {
  border-color: var(--contact-accent);
  background: rgba(148, 221, 180, 0.1);
}

.alert-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--contact-accent);
  color: #12291f;
}

.form-alert.is-error .alert-icon {
  background: var(--contact-error);
}

.alert-icon .icon {
  width: 1rem;
  height: 1rem;
  stroke-width: 3;
}

.form-alert.is-success .icon path {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: draw-check 0.45s ease 0.2s forwards;
}

.form-alert strong {
  display: block;
  margin-bottom: 0.15rem;
}

.form-alert p {
  margin: 0;
  color: var(--contact-muted);
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.5rem;
}

@keyframes alert-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes shake {
  25% {
    transform: translateX(-6px);
  }

  50% {
    transform: translateX(5px);
  }

  75% {
    transform: translateX(-3px);
  }
}

@keyframes draw-check {
  to {
    stroke-dashoffset: 0;
  }
}

@media (max-width: 900px) {
  .contact-grid {
    gap: 3rem;
  }
}

@media (max-width: 680px) {
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .contact-form .button-primary {
    align-self: stretch;
  }
}

/* ---------- Toast notifications ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: calc(100% - 2rem);
  padding: 0.75rem 1.2rem;
  border-radius: 100px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.88rem;
  font-weight: 650;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 1rem);
  transition: opacity 0.25s ease, transform 0.3s var(--ease), visibility 0s linear 0.3s;
  pointer-events: none;
}

.toast::before {
  content: "";
  flex-shrink: 0;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #8ee0b1;
}

/* The toast inverts the page colors, so its dot uses the opposite theme's tones. */
:root[data-theme="dark"] .toast::before {
  background: #0e7659;
}

.toast[data-type="error"]::before {
  background: #ff9b8f;
}

:root[data-theme="dark"] .toast[data-type="error"]::before {
  background: #b42318;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 0.25s ease, transform 0.3s var(--ease), visibility 0s;
}

.toast:empty {
  display: none;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer a {
  color: var(--ink);
  font-weight: 700;
  transition: color 0.2s ease;
}

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

@media (max-width: 680px) {
  .footer-inner {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.4rem 1.5rem;
    padding-block: 1.4rem;
  }

  .footer-built {
    display: none;
  }
}

/* ---------- Motion and polish ---------- */

/* Header gains a soft shadow once the page scrolls. */
.site-header.is-scrolled {
  box-shadow: 0 6px 24px rgba(25, 43, 39, 0.08);
}

:root[data-theme="dark"] .site-header.is-scrolled {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

/* Hero entrance: copy rises in line by line, the visual fades in after. */
.js .hero-copy > * {
  animation: rise-in 0.8s var(--ease) both;
}

.js .hero-copy > :nth-child(2) {
  animation-delay: 0.08s;
}

.js .hero-copy > :nth-child(3) {
  animation-delay: 0.16s;
}

.js .hero-copy > :nth-child(4) {
  animation-delay: 0.24s;
}

.js .hero-copy > :nth-child(5) {
  animation-delay: 0.32s;
}

.js .hero-visual {
  animation: fade-scale-in 1s var(--ease) 0.2s both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

@keyframes fade-scale-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

/* Slow, quiet motion in the decorative hero illustration. */
.orbit-one {
  animation: orbit-one 60s linear infinite;
}

.orbit-two {
  animation: orbit-two 80s linear infinite reverse;
}

@keyframes orbit-one {
  to {
    transform: rotate(336deg) scaleX(1.13);
  }
}

@keyframes orbit-two {
  to {
    transform: rotate(393deg) scaleX(1.4);
  }
}

.floating-label {
  animation: float 6s ease-in-out infinite alternate;
}

.label-two {
  animation-delay: -2s;
}

.label-three {
  animation-delay: -4s;
}

@keyframes float {
  to {
    transform: translateY(-8px);
  }
}

/* Scroll reveal: JavaScript adds .reveal and then .is-visible when in view. */
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: var(--reveal-delay, 0s);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Hover feedback on interactive cards and buttons. */
@media (hover: hover) {
  .project-card {
    transition: transform 0.35s var(--ease), box-shadow 0.35s ease, border-color 0.35s ease;
  }

  .project-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
  }

  .project-card img {
    transition: transform 0.6s var(--ease);
  }

  .project-card:hover img {
    transform: scale(1.03);
  }

  .repo-card:not(.is-skeleton):hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-3px);
  }

  .button-primary:hover {
    box-shadow: 0 8px 20px rgba(14, 118, 89, 0.25);
    transform: translateY(-1px);
  }

  .button:active {
    transform: translateY(0) scale(0.98);
  }
}

/* Floating back-to-top button (only with JavaScript, which controls it). */
.back-to-top {
  display: none;
}

.js .back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.75rem);
  transition: opacity 0.25s ease, transform 0.3s var(--ease), visibility 0s linear 0.3s, border-color 0.2s ease, color 0.2s ease;
}

.js .back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.25s ease, transform 0.3s var(--ease), visibility 0s, border-color 0.2s ease, color 0.2s ease;
}

.js .back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 680px) {
  .js .back-to-top {
    right: 1rem;
    bottom: 1rem;
  }
}

/* A short cross-fade when switching themes (View Transitions API). */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
}

/* ---------- Print ---------- */

@media print {
  .site-header,
  .back-to-top,
  .toast,
  .project-toolbar,
  .details-toggle,
  .repo-toolbar,
  .hero-visual,
  .contact-form {
    display: none !important;
  }

  .js .reveal,
  .js .project-details {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
    grid-template-rows: 1fr !important;
  }

  .contact-section {
    background: none;
    color: #000000;
  }
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }

  /* Keep the decorative orbits still instead of jumping to their end angle. */
  .orbit,
  .floating-label {
    animation: none !important;
  }
}
