/* ===== Hero Section ===== */
.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 0;
  position: relative;
  z-index: 1;
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: flex-start;
}

/* Profile image */
.profile-pic-wrapper {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background-color: var(--background-dark-grey);
  /* background-color: #b6b6b6; */
  overflow: visible;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Status Indicator - Clean Minimal Design */
.status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .status-indicator:hover {
    transform: scale(1.15);
  }
}

.status-indicator:active {
  transform: scale(0.97);
}

/* The green pulsing dot */
.status-dot {
  position: relative;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--status-online);
  box-shadow:
    0 0 0 2px var(--text-white),
    0 2px 6px rgba(0, 0, 0, 0.15);
  z-index: 1;
}

/* Pulsing ring animation */
.status-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background-color: var(--status-online);
  opacity: 0.4;
  animation: statusPulse 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes statusPulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot::after {
    animation: none;
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot::after {
    animation: none;
  }
}

/* Minimal Info Tooltip - Right Side */
.status-tooltip {
  position: absolute;
  bottom: 50%;
  left: 100%;
  transform: translateY(50%) translateX(8px);
  background: var(--status-online-bg);
  color: var(--status-online-text);
  font-family: "Switzer", sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s cubic-bezier(0.23, 1, 0.32, 1),
    transform 0.2s cubic-bezier(0.23, 1, 0.32, 1),
    visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 10;
}

/* Tooltip arrow - Left Side */
.status-tooltip::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--status-online-bg);
}

/* Show tooltip on hover (desktop) or tap (touch via .active) */
@media (hover: hover) and (pointer: fine) {
  .status-indicator:hover .status-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(50%) translateX(12px);
  }
}

.status-indicator.active .status-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(50%) translateX(12px);
}

/* Focus styles for accessibility */
.status-indicator:focus-visible {
  outline: 2px solid var(--status-online);
  outline-offset: 2px;
}

/* Hero text stack */
.hero-text {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}

.hero-heading {
  font-family: "Switzer", sans-serif;
  font-weight: 600;
  font-size: clamp(32px, 5vw, 42px);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0;
}

.hero-subheading {
  font-family: "Switzer", sans-serif;
  color: var(--text-secondary);
  text-align: justify;
  font-size: 17px;
  line-height: 1.5;
  margin: 0;
  max-width: 600px;
}

/* Hero actions */
.hero-actions {
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Enhanced Responsive Design */
@media (max-width: 1024px) {
  .hero-heading {
    font-size: 36px;
  }
}

@media (max-width: 768px) {
  .hero-heading {
    font-size: 28px;
    letter-spacing: -0.01em;
  }
  .hero-subheading {
    font-size: 15px;
    line-height: 1.6;
  }
  .hero-actions {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .btn-status {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .hero-heading {
    font-size: 24px;
  }
  .hero-subheading {
    font-size: 14px;
  }
  .profile-pic-wrapper {
    width: 80px;
    height: 80px;
  }

  /* Adjust status indicator for smaller screens */
  .status-indicator {
    width: 14px;
    height: 14px;
  }

  .status-dot {
    width: 10px;
    height: 10px;
  }

  /* Tooltip on top for mobile (less space on sides) */
  .status-tooltip {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    font-size: 10px;
    padding: 5px 8px;
    border-radius: 6px;
  }

  .status-tooltip::after {
    top: 100%;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-right-color: transparent;
    border-top-color: var(--status-online-bg);
  }

  .status-indicator.active .status-tooltip {
    transform: translateX(-50%) translateY(-10px);
  }

  @media (hover: hover) and (pointer: fine) {
    .status-indicator:hover .status-tooltip {
      transform: translateX(-50%) translateY(-10px);
    }
  }
}

/* CSS for section section:portfolio-marquee */
.portfolio-marquee-section {
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.marquee-wrapper {
  width: 100%;
  overflow: hidden;
  position: relative;
  padding: 20px 0;
  touch-action: pan-y pinch-zoom;
}

.marquee-content {
  display: flex;
  width: fit-content;
  animation: marquee 40s linear infinite;
}

/* Hover slowdown is now handled by JavaScript for smooth transition */

.marquee-item {
  flex-shrink: 0;
  width: 428px;
  height: 333px;
  background: var(--background-card);
  border: 1px solid var(--background-dark-grey);
  border-radius: 20px;
  padding: 24px;
  margin: 0 15px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.04),
    0 1px 4px rgba(0, 0, 0, 0.02);
  transition:
    transform var(--transition-slow) var(--ease-out-expo),
    box-shadow var(--transition-base) var(--ease-out-expo);
}

/* Staggered intro when section enters viewport (class set in global.js) */
@keyframes marquee-item-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* Avoid a flash of all cards before the stagger runs (requires html.js-enabled on index) */
  html.js-enabled #portfolio-marquee .marquee-content:not(.marquee-intro-active) .marquee-item {
    opacity: 0;
  }

  .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item {
    animation: marquee-item-in 0.56s cubic-bezier(0.2, 1, 0.3, 1) backwards;
  }

  /* Stagger ~80ms between cards; slightly slower than instant, still snappy */
  .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(1) {
    animation-delay: 0ms;
  }
  .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(2) {
    animation-delay: 80ms;
  }
  .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(3) {
    animation-delay: 160ms;
  }
  .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(4) {
    animation-delay: 240ms;
  }
  .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(5) {
    animation-delay: 320ms;
  }

  /* Loop duplicates: visible immediately, no second stagger */
  .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(n + 6) {
    animation: none;
    opacity: 1;
  }

  /*
   * RTL: reverse stagger for the five unique cards only.
   * Marquee scroll direction stays LTR (see global.css).
   */
  html[dir="rtl"] .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(1) {
    animation-delay: 320ms;
  }
  html[dir="rtl"] .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(2) {
    animation-delay: 240ms;
  }
  html[dir="rtl"] .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(3) {
    animation-delay: 160ms;
  }
  html[dir="rtl"] .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(4) {
    animation-delay: 80ms;
  }
  html[dir="rtl"] .marquee-wrapper .marquee-content.marquee-intro-active .marquee-item:nth-child(5) {
    animation-delay: 0ms;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-content {
    animation: none;
    transform: translateX(0);
  }
}

.marquee-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

@keyframes marquee {
  from {
    transform: translateX(0%);
  }
  to {
    transform: translateX(-50%);
  }
}

/* Responsive marquee */
@media (max-width: 768px) {
  .marquee-content {
    will-change: auto;
  }

  .marquee-item {
    /* Slightly larger cards on tablet/mobile */
    width: 372px;
    height: 290px;
    padding: 16px;
    margin: 0 10px;
  }
}

@media (max-width: 480px) {
  .marquee-item {
    width: 316px;
    height: 246px;
    padding: 14px;
    margin: 0 8px;
  }
}

/* CSS for section section:about */
.about-section {
  display: flex;
  justify-content: center;
  text-align: left;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.about-heading {
  font-family: "Switzer", sans-serif;
  font-weight: 600;
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: -0.72px;
  margin: 0;
}

.about-description {
  font-family: "Switzer", sans-serif;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  text-align: justify;
  letter-spacing: 0.16px;
  margin: 0;
}

/* CSS for section section:projects */
.projects-section {
  display: flex;
  justify-content: center;
}

.projects-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 44px;
}

.projects-title {
  font-family: "Switzer", sans-serif;
  font-weight: 600;
  font-size: 30.5px;
  line-height: 1.15;
  letter-spacing: -0.96px;
  margin: 0;
  text-align: left;
}

.projects-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

.project-card {
  background: var(--background-card);
  border: 1px solid var(--background-dark-grey);
  border-radius: 25px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.04),
    0 1px 4px rgba(0, 0, 0, 0.02);
  transition:
    transform var(--transition-base) var(--ease-out-expo),
    box-shadow var(--transition-base) var(--ease-out-expo);
}

.project-card:active {
  transform: scale(0.995);
  transition-duration: var(--transition-fast);
}

/* Magnetic effect for buttons on hover - removed for btn-secondary */
.project-card .btn:not(.btn-secondary) {
  position: relative;
  overflow: visible;
}

.project-card .btn:not(.btn-secondary)::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  background: transparent;
  transition: background-color var(--transition-base) var(--ease-out-expo);
}

@media (hover: hover) and (pointer: fine) {
  .project-card:hover .btn:not(.btn-secondary) {
    transform: translateX(4px);
  }

  .view-all-projects-link:hover {
    color: var(--text-primary);
  }

  .view-all-projects-link:hover::after {
    width: calc(100% - 20px);
  }
}

/* View all projects link */
.view-all-projects-link {
  font-family: "Switzer", sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition:
    color var(--transition-base) var(--ease-out-expo),
    transform var(--transition-fast) var(--ease-out-expo);
  position: relative;
  padding: 8px 0;
}

.view-all-projects-link::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text-primary);
  transition: width var(--transition-base) var(--ease-out-expo);
}

.view-all-projects-link:active {
  transform: scale(0.98);
}

/* Responsive projects */
@media (max-width: 768px) {
  .projects-title {
    font-size: 24px;
  }
  .project-card {
    padding: 20px;
    gap: 20px;
    border-radius: 20px;
  }
  .view-all-projects-link {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .projects-title {
    font-size: 22px;
  }
  .project-card {
    padding: 16px;
    gap: 16px;
  }
}

.project-image-wrapper {
  width: 100%;
  height: auto;
  aspect-ratio: 470 / 338;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--background-dark-grey);
}

.project-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 8px;
}

.project-info h3 {
  font-family: "Switzer", sans-serif;
  font-weight: 600;
  font-size: 22.5px;
  line-height: 1.17;
  letter-spacing: -0.72px;
  margin: 0;
}

.project-info p {
  font-family: "Switzer", sans-serif;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.16px;
  margin: 0;
}

.project-link {
  /* Styles inherited from .btn-secondary */
}

/* CSS for section section:quote — flat selectors (nested @keyframes broke highlight in some browsers) */
.quote-section {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 1;
}

@media (max-width: 768px) {
  .quote-section {
    padding: 24px 20px;
  }
}

@media (max-width: 480px) {
  .quote-section {
    padding: 20px 16px;
  }
}

.quote-section mark {
  margin: 0 -0.4em;
  padding: 0.1em 0.4em;
  border-radius: 0.8em 0.3em;
  background: transparent;
  position: relative;
  display: inline-block;
  isolation: isolate;
  z-index: 0;
}

.quote-section .slanted-highlight {
  background: transparent;
}

.quote-section .slanted-highlight::before {
  content: "";
  position: absolute;
  left: -0.15em;
  right: -0.15em;
  top: 52%;
  height: 60%;
  background: var(--highlight-color);
  transform: skew(-8deg) scaleX(0);
  transform-origin: left center;
  border-radius: 6px;
  z-index: -1;
  opacity: 0;
  transition:
    transform 0.85s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 0.5s ease,
    top 0.85s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.quote-section .slanted-highlight.is-highlighted::before {
  top: 30%;
  transform: skew(-8deg) scaleX(1);
  opacity: 0.45;
}

.quote-section .quote-text {
  font-family:
    "Kalam", "Comic Sans MS", "Brush Script MT", cursive, system-ui;
  font-weight: 400;
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.4;
  text-align: center;
  margin: 0;
  max-width: 600px;
  font-display: swap;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  -webkit-font-synthesis: none;
  text-rendering: optimizeLegibility;
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

@supports not (font-display: swap) {
  .quote-section .quote-text {
    opacity: 1;
  }
}

/* When fonts load, show quote (must not be nested under .quote-section — body is not a descendant) */
body.fonts-loaded .quote-text,
.fonts-loaded .quote-text {
  opacity: 1;
}

  /* CSS for section section:tools */
  .tools-section {
    display: flex;
    justify-content: center;
  }

  .tools-container {
    max-width: 582px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 52px;
  }

  .tools-heading {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 17px;
  }

  .tools-heading h2 {
    font-family: "Switzer", sans-serif;
    font-weight: 600;
    font-size: 30px;
    line-height: 1.16;
    letter-spacing: -0.96px;
    margin: 0;
  }

  .tools-heading p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0.16px;
    margin: 0;
  }

  .tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
  }

  .tool-item {
    background: var(--background-card);
    border: 1px solid var(--background-dark-grey);
    border-radius: 18px;
    padding: 36px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 44px;
    text-align: center;
    min-width: 180px;
    box-shadow:
      0 4px 16px rgba(0, 0, 0, 0.04),
      0 1px 4px rgba(0, 0, 0, 0.02);
    transition:
      transform var(--transition-base) var(--ease-out-expo),
      box-shadow var(--transition-base) var(--ease-out-expo);
  }

  .tool-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--background-white);
    border: 0.5px solid var(--background-grey);
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
      transform 0.4s ease,
      box-shadow 0.4s ease;
    cursor: pointer;
  }

  .tool-icon {
    width: 48px;
    height: auto;
    transition: transform 0.4s ease;
  }

  @media (hover: hover) and (pointer: fine) {
    .tool-item:hover {
      box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.06),
        0 2px 8px rgba(0, 0, 0, 0.03);
    }

    .tool-item:hover .tool-icon-wrapper {
      transform: rotate(6deg) scale(1.08);
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    }

    .tool-item:hover .tool-icon {
      transform: scale(1.1);
    }
  }

  .tool-item:active {
    transform: scale(0.98);
    transition-duration: var(--transition-fast);
  }

  .tool-icon {
    width: 44px;
    height: 44px;
    max-width: 44px;
    max-height: 44px;
    min-width: 0; /* PNGs with large intrinsic size must not expand the flex item */
    object-fit: contain;
    flex-shrink: 0;
  }

  .tool-name {
    font-family: "Inter", sans-serif;
    font-weight: 500;
    font-size: 15.25px;
  }

  @media (max-width: 768px) {
    .tools-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
    }
    .tool-item {
      padding: 28px 16px 20px;
      gap: 32px;
      min-width: 0;
    }
    .tool-icon-wrapper {
      width: 64px;
      height: 64px;
    }
    .tool-icon {
      width: 36px;
      height: 36px;
      max-width: 36px;
      max-height: 36px;
    }
    .tool-name {
      font-size: 14px;
    }
    .tools-heading h2 {
      font-size: 24px;
    }
    .tools-heading p {
      font-size: 14px;
    }
  }

  @media (max-width: 480px) {
    .tools-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }
    .tool-item {
      padding: 20px 12px 16px;
      gap: 24px;
    }
  }

  /* CSS for section section:contact */
  .contact-section {
    display: flex;
    justify-content: center;
  }

  .contact-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 32px;
  }

  .contact-heading {
    display: flex;
    flex-direction: column;
    gap: 9px;
    text-align: left;
  }

  .contact-heading h2 {
    font-family: "Switzer", sans-serif;
    font-weight: 600;
    font-size: 22px;
    line-height: 1.2;
    letter-spacing: -0.72px;
    text-align: left;
    margin: 0;
  }

  .contact-heading p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0.16px;
    text-align: justify;
    margin: 0;
  }

  .contact-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 20px;
  }

  /* Prevent auto-scroll on validation */
  .contact-form input,
  .contact-form textarea {
    scroll-margin: 0;
    scroll-snap-margin: 0;
  }

  .form-row {
    display: flex;
    gap: 20px;
  }

  .input-wrapper {
    position: relative;
    width: 100%;
  }

  .contact-form input,
  .contact-form textarea {
    width: 100%;
    padding: 15px 12px;
    border: 1px solid var(--background-grey);
    background-color: var(--background-dark-grey);
    /* background-color: rgba(187, 187, 187, 0.15); */
    border-radius: 14px;
    font-family: "Switzer", sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
  }

  .contact-form input::placeholder,
  .contact-form textarea::placeholder {
    color: var(--text-placeholder);
    font-weight: 500;
    transition: opacity 0.3s ease;
  }

  /* Hide placeholder when input has value */
  .contact-form input:not(:placeholder-shown)::placeholder,
  .contact-form textarea:not(:placeholder-shown)::placeholder {
    opacity: 0;
  }

  /* Keep error placeholder visible even on focus */
  .contact-form input.placeholder-error::placeholder,
  .contact-form textarea.placeholder-error::placeholder {
    opacity: 1 !important;
  }

  /* ============================================
   FUN HINT MESSAGES - Unique positions per field
   ============================================ */

  .field-error-message {
    position: absolute;
    font-family: "Switzer", sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0;
    pointer-events: none !important;
    z-index: 2;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  /* === NAME FIELD: Error above (start side), Success inside (end side) === */
  /* Uses logical properties so it flips automatically in RTL */
  .input-wrapper:has(input[name="name"]) .field-error-message {
    inset-inline-start: 4px;
    bottom: 100%;
    transform: translateY(8px);
    margin-bottom: 6px;
    white-space: nowrap;
  }

  .input-wrapper:has(input[name="name"]).has-error .field-error-message {
    transform: translateY(0);
    opacity: 1;
  }

  /* Success: inside field at the end side (opposite of typing direction) */
  .input-wrapper:has(input[name="name"]).has-success .field-error-message {
    inset-inline-start: auto;
    inset-inline-end: 14px;
    bottom: auto;
    top: 50%;
    margin-bottom: 0;
    transform: translateY(-50%);
    opacity: 1;
  }

  /* === EMAIL FIELD: Error inside at end side (flips for RTL) === */
  .input-wrapper:has(input[name="email"]) .field-error-message {
    inset-inline-start: auto;
    inset-inline-end: 14px;
    top: 50%;
    transform: translateY(-50%) translateX(-8px);
    width: auto;
    white-space: nowrap;
    line-height: 1.3;
    text-align: end;
  }

  /* Mirror the initial slide-in direction for RTL so the message animates
     from inside the field outward, same feel as LTR */
  html[dir="rtl"] .input-wrapper:has(input[name="email"]) .field-error-message {
    transform: translateY(-50%) translateX(8px);
  }

  .input-wrapper:has(input[name="email"]).has-error .field-error-message,
  html[dir="rtl"] .input-wrapper:has(input[name="email"]).has-error .field-error-message {
    transform: translateY(-50%);
    opacity: 1;
  }

  .input-wrapper:has(input[name="email"]).has-success .field-error-message,
  html[dir="rtl"] .input-wrapper:has(input[name="email"]).has-success .field-error-message {
    transform: translateY(-50%);
    opacity: 1;
  }

  /* === MESSAGE FIELD: Bottom corner at end side (flips for RTL) === */
  .input-wrapper:has(textarea[name="message"]) .field-error-message {
    inset-inline-end: 12px;
    bottom: 12px;
    transform: translateY(4px);
    white-space: nowrap;
  }

  .input-wrapper:has(textarea[name="message"]).has-error .field-error-message,
  .input-wrapper:has(textarea[name="message"]).has-success
    .field-error-message {
    transform: translateY(0);
    opacity: 1;
  }

  /* Success message styling */
  .input-wrapper.has-success .field-error-message {
    color: var(--text-secondary);
  }

  /* Subtle attention state for inputs */
  .contact-form input.needs-attention,
  .contact-form textarea.needs-attention {
    background-color: var(--background-light) !important;
  }

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

  @media (max-width: 768px) {
    .form-row {
      flex-direction: column;
      gap: 16px;
    }
    .contact-heading h2 {
      font-size: 20px;
    }
    .contact-heading p {
      font-size: 14px;
    }
    .contact-form input,
    .contact-form textarea {
      font-size: 16px;
    }

    /* Mobile: All messages (error and success) appear inside the field at the
       end side (opposite of typing direction). Uses logical properties to
       flip automatically in RTL. */
    /* NAME FIELD */
    .input-wrapper:has(input[name="name"]) .field-error-message {
      inset-inline-start: auto;
      inset-inline-end: 14px;
      bottom: auto;
      top: 50%;
      margin-bottom: 0;
      transform: translateY(-50%) translateX(8px);
      white-space: nowrap;
    }

    /* Mirror initial slide direction in RTL */
    html[dir="rtl"] .input-wrapper:has(input[name="name"]) .field-error-message {
      transform: translateY(-50%) translateX(-8px);
    }

    .input-wrapper:has(input[name="name"]).has-error .field-error-message,
    .input-wrapper:has(input[name="name"]).has-success .field-error-message,
    html[dir="rtl"] .input-wrapper:has(input[name="name"]).has-error .field-error-message,
    html[dir="rtl"] .input-wrapper:has(input[name="name"]).has-success .field-error-message {
      transform: translateY(-50%);
      opacity: 1;
    }

    /* EMAIL FIELD */
    .input-wrapper:has(input[name="email"]) .field-error-message {
      inset-inline-start: auto;
      inset-inline-end: 14px;
      top: 50%;
      bottom: auto;
      margin-bottom: 0;
      transform: translateY(-50%) translateX(8px);
      width: auto;
      white-space: nowrap;
    }

    /* Mirror initial slide direction in RTL */
    html[dir="rtl"] .input-wrapper:has(input[name="email"]) .field-error-message {
      transform: translateY(-50%) translateX(-8px);
    }

    .input-wrapper:has(input[name="email"]).has-error .field-error-message,
    .input-wrapper:has(input[name="email"]).has-success .field-error-message,
    html[dir="rtl"] .input-wrapper:has(input[name="email"]).has-error .field-error-message,
    html[dir="rtl"] .input-wrapper:has(input[name="email"]).has-success .field-error-message {
      transform: translateY(-50%);
      opacity: 1;
    }
  }

  @media (max-width: 480px) {
    .contact-container {
      gap: 24px;
    }
    .contact-heading h2 {
      font-size: 18px;
    }
  }
