:root {
  --bg: #f6fbf7;
  --card-bg: rgb(255 255 255 / 98%);
  --accent1: #667eea;
  --accent2: #764ba2;
  --text: #2d3748;
  --muted: #718096;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  padding: 8px 12px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgb(0 0 0 / 10%);
  z-index: 9999;
  color: var(--text);
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgb(255 255 255 / 86%);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgb(48 63 79 / 6%);
  margin-bottom: 22px;

  /* Fix for pages that set body to display:flex: make the header full-width */
  flex: 0 0 100%;
  width: 100%;
  align-self: flex-start;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(102 126 234 / 8%);
}

.brand h1 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand p {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

nav[role='navigation'] {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-list {
  list-style: none;
  display: flex;
  gap: 14px;
}

.nav-list a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.nav-list a:hover,
.nav-list a:focus {
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  color: white;
  outline: none;
}

/* Submenu styles */
.has-submenu {
  position: relative;
}
.has-submenu > .submenu-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 600;
  border-radius: 8px;
}
.has-submenu > .submenu-toggle:hover,
.has-submenu > .submenu-toggle:focus {
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  color: white;
  outline: none;
}
.submenu {
  display: none;
  position: absolute;
  /* reduce gap to avoid losing hover when moving pointer */
  top: calc(100% + 2px);
  left: 0;
  background: var(--card-bg);
  box-shadow: 0 8px 24px rgb(48 63 79 / 12%);
  padding: 8px;
  border-radius: 8px;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  z-index: 1000;
}
.submenu a {
  display: block;
  padding: 8px 10px;
  color: var(--text);
}
/* invisible bridge to prevent quick disappearance when moving mouse */
.has-submenu::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0px);
  height: 6px;
  background: transparent;
  z-index: 999;
}
.has-submenu:hover .submenu,
.has-submenu[aria-expanded="true"] .submenu {
  display: flex;
}
@media (width <= 700px) {
  .submenu {
    position: static;
    display: none;
    box-shadow: none;
    padding: 6px 0;
  }
  .has-submenu[aria-expanded="true"] .submenu {
    display: flex;
  }
}

.nav-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  font-size: 1.2rem;
  transition: background 0.2s;
  color: var(--text);
}

.icon-btn:hover {
  background: rgb(102 126 234 / 10%);
}

.icon-btn:focus {
  outline: 3px solid rgb(102 126 234 / 18%);
}

.nav-cta {
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--accent2), var(--accent1));
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
}

.hamburger {
  display: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}

.hamburger:focus {
  outline: 3px solid rgb(102 126 234 / 18%);
}

.hamburger .bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  margin: 4px 0;
  border-radius: 2px;
}

@media (max-width: 1000px) {
  .nav-list {
    gap: 10px;
  }
}

@media (max-width: 700px) {
  .nav-list {
    display: none;
  }

  .hamburger {
    display: block;
  }

  .topbar {
    padding: 12px;
  }

  nav[role='navigation'] {
    width: 100%;
  }
}

/* small focus styles */
.project-card:focus {
  outline: 3px solid rgb(118 75 162 / 12%);
  outline-offset: 2px;
}

/* Calculadora header defaults: make header look like the calculadora page across the site */
body .topbar {
  padding: 8px 14px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  align-items: center;
}

body .topbar .brand .logo {
  width: 48px;
  height: 48px;
}

body .topbar .brand h1 {
  font-size: 1rem;
  margin: 0;
}

body .topbar .brand p {
  font-size: 0.85rem;
  margin: 0;
}

body .topbar .nav-list a {
  font-size: 0.93rem;
  padding: 6px 8px;
}

body .topbar .nav-cta {
  padding: 6px 10px;
}

@media (width <= 700px) {
  body .topbar {
    padding: 10px 12px;
  }

  body .topbar .logo {
    width: 52px;
    height: 52px;
  }

  body .topbar .brand h1 {
    font-size: 1.05rem;
  }
}

/* remove invisible bridge on small screens to avoid layout quirks */
@media (max-width:700px) {
  .has-submenu::after { display: none; }
}
