:root {
  --cw-accent: var(--primary-color);
  --cw-muted: rgba(153, 160, 166, 0.85);
  --cw-bg: transparent;
  --cw-radius: 8px;
}
.contact-widget {
  display: block;
  font-family: inherit;
  --cw-gap: 1rem;
  --cw-scale: 2;
  text-align: center;
  margin-bottom: 2em;
}
.cw-hint {
  font-size: 0.95rem;
  color: var(--cw-muted);
  opacity: 0;
  transition: opacity 0.3s ease;
  min-height: 1.2rem;
  display: block;
}
.cw-hint.visible {
  opacity: 1;
}

/* Email line - use inline-flex so we control precise spacing */
.cw-email {
  font-size: calc(1.05rem * var(--cw-scale));
  font-weight: 700;
  display: inline-flex;
  gap: 0; /* join parts so email reads as one word */
  align-items: center;
  padding: 0.35rem 0;
  margin: 0;
  line-height: 1;
  transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}
.cw-part {
  display: inline-flex;
  align-items: center;
  transition: opacity 0.18s ease, color 0.18s ease, transform 0.18s ease;
  color: var(--cw-accent);
  opacity: 1;
  white-space: pre; /* prevent unexpected wrapping */
}

/* make the domain label a single inline-flex container so its parts have no gap */
.cw-domain-label {
  display: inline-flex;
  gap: 0;
  align-items: center;
}

/* dot morphing: replace . with 'dot' text when twitter/instagram active */
.cw-domain-dot {
  transition: opacity 0.3s ease;
}
.cw-mode-twitter .cw-domain-dot,
.cw-mode-instagram .cw-domain-dot {
  font-size: 0;
}
.cw-mode-twitter .cw-domain-dot::after,
.cw-mode-instagram .cw-domain-dot::after {
  content: "dot";
  font-size: calc(1.05rem * var(--cw-scale));
}
.cw-mode-twitter .cw-dot-char,
.cw-mode-instagram .cw-dot-char {
  opacity: 0;
}
.cw-mode-twitter .cw-dot-text,
.cw-mode-instagram .cw-dot-text {
  opacity: 1;
}

/* Controls */
.cw-controls {
  display: flex;
  gap: 0;
  margin: 1rem auto 0;
  justify-content: center;
  background: transparent;
  overflow: hidden;
  width: fit-content;
}
.cw-btn {
  background: transparent;
  border: none;
  border: 1px solid var(--cw-muted);
  color: var(--cw-muted);
  padding: 0.5rem 0.5rem;
  border-radius: 0;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 500;
  transition: background-color 0.18s ease, color 0.18s ease,
    box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 2.5rem;
}
.cw-btn i {
  font-size: 1.25rem;
  flex-shrink: 0;
}
.cw-btn span {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition: opacity 0.3s ease, max-width 0.3s ease, margin-left 0.3s ease;
  white-space: nowrap;
  margin-left: 0;
}
@media (hover: hover) and (pointer: fine) {
  .cw-btn:hover {
    color: var(--cw-accent);
    border-color: var(--cw-accent);
    background-color: transparent;
    border-radius: 12px;
  }
  .cw-btn:hover span {
    opacity: 1;
    max-width: 100px;
    margin-left: 0.5rem;
  }
  /* Next button - round its left corners */
  .cw-btn:hover + .cw-btn {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
  }
  /* Previous button - round its right corners */
  .cw-btn:has(+ .cw-btn:hover) {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
  }
  /* Leftmost button when hovered - ensure all corners are rounded */
  .cw-btn:first-child:hover {
    border-radius: 12px;
  }
  /* Rightmost button when hovered - ensure all corners are rounded */
  .cw-btn:last-child:hover {
    border-radius: 12px;
  }
}
.cw-btn:first-child {
  border-radius: 20px 0 0 20px;
}
.cw-btn:last-child {
  border-radius: 0 20px 20px 0;
}
.cw-btn:focus {
  outline: none;
  color: var(--cw-accent);
  border-color: var(--cw-accent);
}
.cw-btn.cw-selected {
  background: var(--cw-accent);
  color: var(--background-color-primary, white);
  border-color: var(--cw-accent);
}

/* Modes: default shows all (all parts highlighted) */
.cw-mode-all .cw-part {
  opacity: 1;
  color: var(--cw-accent);
}

/* Domain (website) - highlight domain label + tld */
/* Fade the local and the '@' while highlighting domain segments individually */
.cw-mode-domain .cw-local,
.cw-mode-domain .cw-at {
  opacity: 0.25;
  color: var(--cw-muted);
  transform: none;
}
.cw-mode-domain .cw-domain-first,
.cw-mode-domain .cw-domain-rest,
.cw-mode-domain .cw-domain-dot,
.cw-mode-domain .cw-tld {
  opacity: 1;
  color: var(--cw-accent);
  transform: translateY(-2px);
}

/* Handle (github) - highlight the @ and domain label */
/* Fade unrelated small parts and highlight @ + full domain pieces */
.cw-mode-handle .cw-local,
.cw-mode-handle .cw-domain-dot,
.cw-mode-handle .cw-tld {
  opacity: 0.25;
  color: var(--cw-muted);
  transform: none;
}
.cw-mode-handle .cw-at,
.cw-mode-handle .cw-domain-first,
.cw-mode-handle .cw-domain-rest {
  opacity: 1;
  color: var(--cw-accent);
  transform: translateY(-2px);
}

/* LinkedIn - highlight @sameerasw (same as github) */
.cw-mode-linkedin .cw-local,
.cw-mode-linkedin .cw-domain-dot,
.cw-mode-linkedin .cw-tld {
  opacity: 0.25;
  color: var(--cw-muted);
  transform: none;
}
.cw-mode-linkedin .cw-at,
.cw-mode-linkedin .cw-domain-first,
.cw-mode-linkedin .cw-domain-rest {
  opacity: 1;
  color: var(--cw-accent);
  transform: translateY(-2px);
}

/* Telegram - highlight @sameerasw (same as github) */
.cw-mode-telegram .cw-local,
.cw-mode-telegram .cw-domain-dot,
.cw-mode-telegram .cw-tld {
  opacity: 0.25;
  color: var(--cw-muted);
  transform: none;
}
.cw-mode-telegram .cw-at,
.cw-mode-telegram .cw-domain-first,
.cw-mode-telegram .cw-domain-rest {
  opacity: 1;
  color: var(--cw-accent);
  transform: translateY(-2px);
}

/* Local (name) - highlight the name (first part of domain) */
/* Fade everything except the domain-first */
.cw-mode-local .cw-local,
.cw-mode-local .cw-at,
.cw-mode-local .cw-domain-rest,
.cw-mode-local .cw-domain-dot,
.cw-mode-local .cw-tld {
  opacity: 0.25;
  color: var(--cw-muted);
  transform: none;
}
.cw-mode-local .cw-domain-first {
  opacity: 1;
  color: var(--cw-accent);
  transform: translateY(-2px);
}

/* Twitter - highlight @sameeraswdotcom (at + domain + dot + tld) */
.cw-mode-twitter .cw-local {
  opacity: 0.25;
  color: var(--cw-muted);
  transform: none;
}
.cw-mode-twitter .cw-at,
.cw-mode-twitter .cw-domain-first,
.cw-mode-twitter .cw-domain-rest,
.cw-mode-twitter .cw-domain-dot,
.cw-mode-twitter .cw-tld {
  opacity: 1;
  color: var(--cw-accent);
  transform: translateY(-2px);
}

/* Instagram - highlight @sameeraswdotcom (at + domain + dot + tld) */
.cw-mode-instagram .cw-local {
  opacity: 0.25;
  color: var(--cw-muted);
  transform: none;
}
.cw-mode-instagram .cw-at,
.cw-mode-instagram .cw-domain-first,
.cw-mode-instagram .cw-domain-rest,
.cw-mode-instagram .cw-domain-dot,
.cw-mode-instagram .cw-tld {
  opacity: 1;
  color: var(--cw-accent);
  transform: translateY(-2px);
}

/* Small accessibility focus ring */
.cw-btn:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cw-accent) 18%, transparent);
  border-radius: 8px;
}
.cw-btn.cw-active {
  background: var(--cw-accent);
  color: var(--background-color-primary, white);
  border-color: var(--cw-accent);
}

.contact-widget-wrapper {
  margin: 4em 0;
  width: 100%;
  align-items: center;
  justify-content: center;
}

/* Mobile touch device styles */
@media (hover: none) and (pointer: coarse) {
  /* Make email widget interactive on mobile */
  .cw-email {
    cursor: pointer;
    padding: 0.35rem 0;
    transition: all 0.2s ease;
    font-size: calc(0.9rem * var(--cw-scale));
  }

  .cw-email:active {
    transform: scale(0.98);
    opacity: 0.9;
  }

  /* Scale down dot text to match the reduced email widget font size */
  .cw-mode-twitter .cw-domain-dot::after,
  .cw-mode-instagram .cw-domain-dot::after {
    font-size: calc(1.05rem * var(--cw-scale) * 0.9);
  }

  /* Style controls - no gaps, match web layout */
  .cw-controls {
    gap: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    width: fit-content;
  }

  .cw-btn {
    border-radius: 0;
    padding: 0.5rem 0.5rem;
    transition: all 0.2s ease;
    flex: initial;
  }

  /* Only edge buttons have rounded corners */
  .cw-btn:first-child {
    border-radius: 20px 0 0 20px;
  }

  .cw-btn:last-child {
    border-radius: 0 20px 20px 0;
  }

  /* Selected button and its neighbors get rounded corners */
  .cw-btn.cw-selected {
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  /* Next button after selected - round its left corners */
  .cw-btn.cw-selected + .cw-btn {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
  }

  /* Previous button before selected - round its right corners */
  .cw-btn:has(+ .cw-btn.cw-selected) {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
  }

  .cw-btn:active {
    transform: scale(0.98);
  }

  .cw-btn.cw-selected:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }
}
